YODA is hosted by Hepforge, IPPP Durham

Persistency writer for flat text format. More...

#include <WriterFLAT.h>

Inheritance diagram for YODA::WriterFLAT:
YODA::Writer

Static Public Member Functions

static Writercreate ()
 Singleton creation function. More...
 
Writing a single analysis object.
static void write (std::ostream &stream, const AnalysisObject &ao)
 Write out object ao to output stream stream. More...
 
static void write (const std::string &filename, const AnalysisObject &ao)
 Write out object ao to file filename. More...
 
Writing multiple analysis objects by collection.
static void write (std::ostream &stream, const std::vector< AnalysisObject * > &aos)
 Write out a collection of objects objs to output stream stream. More...
 
static void write (const std::string &filename, const std::vector< AnalysisObject * > &aos)
 Write out a collection of objects objs to file filename. More...
 
static void write (std::ostream &stream, const std::list< AnalysisObject * > &aos)
 Write out a collection of objects objs to output stream stream. More...
 
static void write (const std::string &filename, const std::list< AnalysisObject * > &aos)
 Write out a collection of objects objs to file filename. More...
 
static void write (std::ostream &stream, const std::set< AnalysisObject * > &aos)
 Write out a collection of objects objs to output stream stream. More...
 
static void write (const std::string &filename, const std::set< AnalysisObject * > &aos)
 Write out a collection of objects objs to file filename. More...
 
static void write (std::ostream &stream, const std::deque< AnalysisObject * > &aos)
 Write out a collection of objects objs to output stream stream. More...
 
static void write (const std::string &filename, const std::deque< AnalysisObject * > &aos)
 Write out a collection of objects objs to file filename. More...
 
Writing multiple analysis objects by iterator range.
template<typename AOITER >
static void write (std::ostream &stream, const AOITER &begin, const AOITER &end)
 
template<typename AOITER >
static void write (const std::string &filename, const AOITER &begin, const AOITER &end)
 

Protected Member Functions

void writeHeader (std::ostream &stream)
 Main writer elements. More...
 
void writeFooter (std::ostream &stream)
 
void writeCounter (std::ostream &stream, const Counter &c)
 Specific AO type writer implementations. More...
 
void writeHisto1D (std::ostream &stream, const Histo1D &h)
 
void writeHisto2D (std::ostream &stream, const Histo2D &h)
 
void writeProfile1D (std::ostream &stream, const Profile1D &p)
 
void writeProfile2D (std::ostream &stream, const Profile2D &p)
 
void writeScatter1D (std::ostream &stream, const Scatter1D &s)
 
void writeScatter2D (std::ostream &stream, const Scatter2D &s)
 
void writeScatter3D (std::ostream &stream, const Scatter3D &s)
 
- Protected Member Functions inherited from YODA::Writer
virtual void writeBody (std::ostream &stream, const AnalysisObject &ao)
 

Additional Inherited Members

- Public Member Functions inherited from YODA::Writer
virtual ~Writer ()
 Virtual destructor. More...
 
void setPrecision (int precision)
 Set precision of numerical quantities in this writer's output. More...
 
void write (std::ostream &stream, const AnalysisObject &ao)
 Write out object ao to output stream stream. More...
 
void write (const std::string &filename, const AnalysisObject &ao)
 Write out object ao to file filename. More...
 
template<typename RANGE >
void write (std::ostream &stream, const RANGE &aos)
 Write out a collection of objects objs to output stream stream. More...
 
template<typename RANGE >
void write (const std::string &filename, const RANGE &aos)
 Write out a collection of objects objs to file filename. More...
 
template<typename AOITER >
void write (std::ostream &stream, const AOITER &begin, const AOITER &end)
 
template<typename AOITER >
void write (const std::string &filename, const AOITER &begin, const AOITER &end)
 

Detailed Description

Persistency writer for flat text format.

Definition at line 21 of file WriterFLAT.h.

Member Function Documentation

static Writer& YODA::WriterFLAT::create ( )
inlinestatic

Singleton creation function.

Definition at line 25 of file WriterFLAT.h.

References YODA::Writer::setPrecision().

25  {
26  static WriterFLAT _instance;
27  _instance.setPrecision(6);
28  return _instance;
29  }
static void YODA::WriterFLAT::write ( std::ostream &  stream,
const AnalysisObject ao 
)
inlinestatic

Write out object ao to output stream stream.

Definition at line 12 of file WriterFLAT.h.

17  {
static void YODA::WriterFLAT::write ( const std::string &  filename,
const AnalysisObject ao 
)
inlinestatic

Write out object ao to file filename.

Definition at line 17 of file WriterFLAT.h.

17  {
18 
19 
static void YODA::WriterFLAT::write ( std::ostream &  stream,
const std::vector< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to output stream stream.

Definition at line 28 of file WriterFLAT.h.

36  :
37 
static void YODA::WriterFLAT::write ( const std::string &  filename,
const std::vector< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to file filename.

Definition at line 32 of file WriterFLAT.h.

36  :
37 
static void YODA::WriterFLAT::write ( std::ostream &  stream,
const std::list< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to output stream stream.

Definition at line 38 of file WriterFLAT.h.

static void YODA::WriterFLAT::write ( const std::string &  filename,
const std::list< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to file filename.

Definition at line 42 of file WriterFLAT.h.

static void YODA::WriterFLAT::write ( std::ostream &  stream,
const std::set< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to output stream stream.

Definition at line 48 of file WriterFLAT.h.

51  :
52 
static void YODA::WriterFLAT::write ( const std::string &  filename,
const std::set< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to file filename.

Definition at line 52 of file WriterFLAT.h.

56  { }
static void YODA::WriterFLAT::write ( std::ostream &  stream,
const std::deque< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to output stream stream.

Definition at line 58 of file WriterFLAT.h.

static void YODA::WriterFLAT::write ( const std::string &  filename,
const std::deque< AnalysisObject * > &  aos 
)
inlinestatic

Write out a collection of objects objs to file filename.

Definition at line 62 of file WriterFLAT.h.

template<typename AOITER >
static void YODA::WriterFLAT::write ( std::ostream &  stream,
const AOITER &  begin,
const AOITER &  end 
)
inlinestatic

Write out the objects specified by start iterator begin and end iterator end to output stream stream.

Definition at line 75 of file WriterFLAT.h.

template<typename AOITER >
static void YODA::WriterFLAT::write ( const std::string &  filename,
const AOITER &  begin,
const AOITER &  end 
)
inlinestatic

Write out the objects specified by start iterator begin and end iterator end to file filename.

Definition at line 83 of file WriterFLAT.h.

void YODA::WriterFLAT::writeCounter ( std::ostream &  stream,
const Counter c 
)
protectedvirtual

Specific AO type writer implementations.

Implements YODA::Writer.

Definition at line 46 of file WriterFLAT.cc.

References YODA::Counter::err(), YODA::AnalysisObject::path(), and YODA::Counter::val().

46  {
47  ios_base::fmtflags oldflags = os.flags();
48  os << scientific << showpoint << setprecision(_precision);
49 
50  os << "# BEGIN COUNTER " << c.path() << "\n";
51  _writeAnnotations(os, c);
52  os << "# value\t error\n";
53  os << c.val() << "\t" << c.err() << "\n";
54  os << "# END COUNTER\n\n";
55 
56  os << flush;
57  os.flags(oldflags);
58  }
void YODA::WriterFLAT::writeFooter ( std::ostream &  stream)
protectedvirtual

Implements YODA::Writer.

Definition at line 30 of file WriterFLAT.cc.

30  {
31  os << flush;
32  }
void YODA::WriterFLAT::writeHeader ( std::ostream &  stream)
protectedvirtual

Main writer elements.

Implements YODA::Writer.

Definition at line 25 of file WriterFLAT.cc.

25  {
26  os << flush;
27  }
void YODA::WriterFLAT::writeHisto1D ( std::ostream &  stream,
const Histo1D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 61 of file WriterFLAT.cc.

References YODA::mkScatter(), and YODA::AnalysisObject::setAnnotation().

61  {
62  Scatter2D tmp = mkScatter(h);
63  tmp.setAnnotation("Type", "Histo1D");
64  writeScatter2D(os, tmp);
65  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:8
void writeScatter2D(std::ostream &stream, const Scatter2D &s)
Definition: WriterFLAT.cc:108
void YODA::WriterFLAT::writeHisto2D ( std::ostream &  stream,
const Histo2D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 68 of file WriterFLAT.cc.

References YODA::mkScatter(), and YODA::AnalysisObject::setAnnotation().

68  {
69  Scatter3D tmp = mkScatter(h);
70  tmp.setAnnotation("Type", "Histo2D");
71  writeScatter3D(os, tmp);
72  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:8
void writeScatter3D(std::ostream &stream, const Scatter3D &s)
Definition: WriterFLAT.cc:128
void YODA::WriterFLAT::writeProfile1D ( std::ostream &  stream,
const Profile1D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 75 of file WriterFLAT.cc.

References YODA::mkScatter(), and YODA::AnalysisObject::setAnnotation().

75  {
76  Scatter2D tmp = mkScatter(p);
77  tmp.setAnnotation("Type", "Profile1D");
78  writeScatter2D(os, tmp);
79  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:8
void writeScatter2D(std::ostream &stream, const Scatter2D &s)
Definition: WriterFLAT.cc:108
void YODA::WriterFLAT::writeProfile2D ( std::ostream &  stream,
const Profile2D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 82 of file WriterFLAT.cc.

References YODA::mkScatter(), and YODA::AnalysisObject::setAnnotation().

82  {
83  Scatter3D tmp = mkScatter(h);
84  tmp.setAnnotation("Type", "Profile2D");
85  writeScatter3D(os, tmp);
86  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:8
void writeScatter3D(std::ostream &stream, const Scatter3D &s)
Definition: WriterFLAT.cc:128
void YODA::WriterFLAT::writeScatter1D ( std::ostream &  stream,
const Scatter1D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 91 of file WriterFLAT.cc.

References YODA::AnalysisObject::path(), YODA::Scatter1D::points(), YODA::Point1D::x(), YODA::Point1D::xErrMinus(), and YODA::Point1D::xErrPlus().

91  {
92  ios_base::fmtflags oldflags = os.flags();
93  os << scientific << showpoint << setprecision(_precision);
94 
95  os << "# BEGIN HISTOGRAM " << s.path() << "\n";
96  _writeAnnotations(os, s);
97  os << "# value\t errminus\t errplus\n";
98  BOOST_FOREACH (const Point1D& pt, s.points()) {
99  os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrPlus() << "\n";
100  }
101  os << "# END HISTOGRAM\n\n";
102 
103  os << flush;
104  os.flags(oldflags);
105  }
void YODA::WriterFLAT::writeScatter2D ( std::ostream &  stream,
const Scatter2D s 
)
protectedvirtual
Todo:
Write as HISTO1D in future
Todo:
Write as HISTO1D in future

Implements YODA::Writer.

Definition at line 108 of file WriterFLAT.cc.

References YODA::AnalysisObject::path(), YODA::Scatter2D::points(), YODA::Point2D::x(), YODA::Point2D::xErrMinus(), YODA::Point2D::xErrPlus(), YODA::Point2D::y(), YODA::Point2D::yErrMinus(), and YODA::Point2D::yErrPlus().

108  {
109  ios_base::fmtflags oldflags = os.flags();
110  os << scientific << showpoint << setprecision(_precision);
111 
113  os << "# BEGIN HISTOGRAM " << s.path() << "\n";
114  _writeAnnotations(os, s);
115  os << "# xlow\t xhigh\t val\t errminus\t errplus\n";
116  BOOST_FOREACH (const Point2D& pt, s.points()) {
117  os << pt.x()-pt.xErrMinus() << "\t" << pt.x()+pt.xErrPlus() << "\t";
118  os << pt.y() << "\t" << pt.yErrMinus() << "\t" << pt.yErrPlus() << "\n";
119  }
121  os << "# END HISTOGRAM\n\n";
122 
123  os << flush;
124  os.flags(oldflags);
125  }
void YODA::WriterFLAT::writeScatter3D ( std::ostream &  stream,
const Scatter3D s 
)
protectedvirtual
Todo:
Alternative format to allow writing as unbinned scatters? Need same for Scatter2D if so... I think better to use YODA format for that
Todo:
Write as HISTO2D in future
Todo:
Write as HISTO2D in future

Implements YODA::Writer.

Definition at line 128 of file WriterFLAT.cc.

References YODA::AnalysisObject::path(), YODA::Scatter3D::points(), YODA::Point3D::x(), YODA::Point3D::xErrMinus(), YODA::Point3D::xErrPlus(), YODA::Point3D::y(), YODA::Point3D::yErrMinus(), YODA::Point3D::yErrPlus(), YODA::Point3D::z(), YODA::Point3D::zErrMinus(), and YODA::Point3D::zErrPlus().

128  { // , bool asHist2D) {
129  ios_base::fmtflags oldflags = os.flags();
130  os << scientific << showpoint << setprecision(_precision);
131 
135  os << "# BEGIN HISTOGRAM " << s.path() << "\n";
136  _writeAnnotations(os, s);
137 
138  // if (asHist2D) { // Extension of what writeScatter2D does
139  os << "# xlow\t xhigh\t ylow\t yhigh\t val\t errminus\t errplus\n";
140  BOOST_FOREACH (const Point3D& pt, s.points()) {
141  os << pt.x()-pt.xErrMinus() << "\t" << pt.x()+pt.xErrPlus() << "\t";
142  os << pt.y()-pt.yErrMinus() << "\t" << pt.y()+pt.yErrPlus() << "\t";
143  os << pt.z() << "\t" << pt.zErrMinus() << "\t" << pt.zErrPlus() << "\n";
144  }
145 
146  // } else { // What writerYODA should do... let's just put this in there (generalised for multiple errs).
147  // os << "# xval\t xerr-\t xerr+\t yval\t yerr-\t yerr+\t zval\t zerr-\t zerr+\n";
148  // BOOST_FOREACH (const Point3D& pt, s.points()) {
149  // os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrMinus() << "\t";
150  // os << pt.y() << "\t" << pt.yErrMinus() << "\t" << pt.yErrMinus() << "\t";
151  // os << pt.z() << "\t" << pt.zErrMinus() << "\t" << pt.zErrMinus() << "\n";
152  // }
153  // }
154 
156  os << "# END HISTOGRAM\n\n";
157 
158  os << flush;
159  os.flags(oldflags);
160  }

The documentation for this class was generated from the following files: