YODA is hosted by Hepforge, IPPP Durham

Persistency writer for AIDA XML format. More...

#include <WriterAIDA.h>

Inheritance diagram for YODA::WriterAIDA:
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 AIDA XML format.

Definition at line 21 of file WriterAIDA.h.

Member Function Documentation

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

Singleton creation function.

Definition at line 25 of file WriterAIDA.h.

References YODA::Writer::setPrecision().

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

Write out object ao to output stream stream.

Definition at line 12 of file WriterAIDA.h.

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

Write out object ao to file filename.

Definition at line 17 of file WriterAIDA.h.

17  {
18 
19 
static void YODA::WriterAIDA::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 WriterAIDA.h.

36  :
37 
static void YODA::WriterAIDA::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 WriterAIDA.h.

36  :
37 
static void YODA::WriterAIDA::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 WriterAIDA.h.

static void YODA::WriterAIDA::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 WriterAIDA.h.

static void YODA::WriterAIDA::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 WriterAIDA.h.

51  :
52 
static void YODA::WriterAIDA::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 WriterAIDA.h.

54  { }
static void YODA::WriterAIDA::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 WriterAIDA.h.

static void YODA::WriterAIDA::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 WriterAIDA.h.

template<typename AOITER >
static void YODA::WriterAIDA::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 WriterAIDA.h.

template<typename AOITER >
static void YODA::WriterAIDA::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 WriterAIDA.h.

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

Specific AO type writer implementations.

Implements YODA::Writer.

Definition at line 30 of file WriterAIDA.cc.

30  {
31  os << endl << "<!-- COUNTER WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
32  }
void YODA::WriterAIDA::writeFooter ( std::ostream &  stream)
protectedvirtual

Implements YODA::Writer.

Definition at line 25 of file WriterAIDA.cc.

25  {
26  stream << "</aida>\n";
27  }
void YODA::WriterAIDA::writeHeader ( std::ostream &  stream)
protectedvirtual

Main writer elements.

Implements YODA::Writer.

Definition at line 17 of file WriterAIDA.cc.

17  {
18  stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
19  stream << "<!DOCTYPE aida SYSTEM \"http://aida.freehep.org/schemas/3.0/aida.dtd\">\n";
20  stream << "<aida>\n";
21  stream << " <implementation version=\"1.0\" package=\"YODA\"/>\n";
22  }
void YODA::WriterAIDA::writeHisto1D ( std::ostream &  stream,
const Histo1D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 35 of file WriterAIDA.cc.

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

35  {
36  Scatter2D tmp = mkScatter(h);
37  tmp.setAnnotation("Type", "Histo1D");
38  writeScatter2D(os, tmp);
39  }
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: WriterAIDA.cc:70
void YODA::WriterAIDA::writeHisto2D ( std::ostream &  stream,
const Histo2D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 42 of file WriterAIDA.cc.

42  {
43  os << endl << "<!-- HISTO2D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
44  // Scatter3D tmp = mkScatter(h);
45  // tmp.setAnnotation("Type", "Histo2D");
46  // writeScatter3D(os, tmp);
47  }
void YODA::WriterAIDA::writeProfile1D ( std::ostream &  stream,
const Profile1D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 50 of file WriterAIDA.cc.

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

50  {
51  Scatter2D tmp = mkScatter(p);
52  tmp.setAnnotation("Type", "Profile1D");
53  writeScatter2D(os, tmp);
54  }
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: WriterAIDA.cc:70
void YODA::WriterAIDA::writeProfile2D ( std::ostream &  stream,
const Profile2D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 57 of file WriterAIDA.cc.

57  {
58  os << endl << "<!-- PROFILE2D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
59  // Scatter3D tmp = mkScatter(p);
60  // tmp.setAnnotation("Type", "Profile2D");
61  // writeScatter3D(os, tmp);
62  }
void YODA::WriterAIDA::writeScatter1D ( std::ostream &  stream,
const Scatter1D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 65 of file WriterAIDA.cc.

65  {
66  os << endl << "<!-- SCATTER1D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
67  }
void YODA::WriterAIDA::writeScatter2D ( std::ostream &  stream,
const Scatter2D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 70 of file WriterAIDA.cc.

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

70  {
71  ios_base::fmtflags oldflags = os.flags();
72  // const int precision = 8;
73  os << scientific << showpoint << setprecision(_precision);
74 
75  string name = "";
76  string path = "/";
77  const size_t slashpos = s.path().rfind("/");
78  if (slashpos != string::npos) {
79  name = s.path().substr(slashpos+1, s.path().length() - slashpos - 1);
80  if (slashpos > 0) path = s.path().substr(0, slashpos);
81  }
82  os << " <dataPointSet name=\"" << Utils::encodeForXML(name) << "\"\n"
83  << " title=\"" << Utils::encodeForXML(s.title()) << "\""
84  << " path=\"" << Utils::encodeForXML(path) << "\" dimension=\"2\">\n";
85  os << " <dimension dim=\"0\" title=\"\" />\n";
86  os << " <dimension dim=\"1\" title=\"\" />\n";
87  os << " <annotation>\n";
88  BOOST_FOREACH (const string& a, s.annotations()) {
89  if (a.empty()) continue;
90  os << " <item key=\"" << Utils::encodeForXML(a)
91  << "\" value=\"" << Utils::encodeForXML(s.annotation(a)) << "\" />\n";
92  }
93  if (!s.hasAnnotation("Type")) {
94  os << " <item key=\"Type\" value=\"Scatter2D\" />\n";
95  }
96  os << " </annotation>\n";
97  BOOST_FOREACH (const Point2D& pt, s.points()) {
98  os << " <dataPoint>\n";
99  os << " <measurement value=\"" << pt.x()
100  << "\" errorPlus=\"" << pt.xErrPlus()
101  << "\" errorMinus=\"" << pt.xErrMinus()
102  << "\"/>\n";
103  os << " <measurement value=\"" << pt.y()
104  << "\" errorPlus=\"" << pt.yErrPlus()
105  << "\" errorMinus=\"" << pt.yErrMinus()
106  << "\"/>\n";
107  os << " </dataPoint>\n";
108  }
109  os << " </dataPointSet>\n";
110  os << flush;
111 
112  os.flags(oldflags);
113  }
void YODA::WriterAIDA::writeScatter3D ( std::ostream &  stream,
const Scatter3D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 116 of file WriterAIDA.cc.

116  {
117  os << endl << "<!-- SCATTER3D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
118  }

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