yoda is hosted by Hepforge, IPPP Durham
YODA - Yet more Objects for Data Analysis  1.7.2

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...
 
template<typename T >
static std::enable_if< DerefableToAO< T >::value >::type write (std::ostream &stream, const T &ao)
 Write out pointer-like 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...
 
template<typename T >
static std::enable_if< DerefableToAO< T >::value >::type write (const std::string &filename, const T &ao)
 Write out pointer-like object ao to file filename. More...
 
Writing multiple analysis objects by collection.
template<typename RANGE >
static std::enable_if< CIterable< RANGE >::value >::type write (std::ostream &stream, const RANGE &aos)
 
template<typename RANGE >
static std::enable_if< CIterable< RANGE >::value >::type write (const std::string &filename, const RANGE &aos)
 
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 writeHead (std::ostream &stream)
 Write any opening boilerplate required by the format to stream. More...
 
void writeFoot (std::ostream &stream)
 Write any closing boilerplate required by the format to stream. More...
 
void writeCounter (std::ostream &stream, const Counter &c)
 
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)
 Write the body elements corresponding to AnalysisObject ao to stream. More...
 
virtual void writeBody (std::ostream &stream, const AnalysisObject &ao)
 Write the body elements corresponding to AnalysisObject pointer ao to stream. More...
 
template<typename T >
std::enable_if< DerefableToAO< T >::value >::type writeBody (std::ostream &stream, const T &ao)
 Write the body elements corresponding to AnalysisObject ao to stream. More...
 

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 useCompression (bool compress=true)
 Use libz compression? More...
 
void write (const std::string &filename, const AnalysisObject &ao)
 Write out object ao to file filename. More...
 
void write (std::ostream &stream, const AnalysisObject &ao)
 Write out object ao to output stream stream. More...
 
template<typename T >
std::enable_if< DerefableToAO< T >::value >::type write (std::ostream &stream, const T &ao)
 Write out pointer-like object ao to output stream stream. More...
 
template<typename T >
std::enable_if< DerefableToAO< T >::value >::type write (const std::string &filename, const T &ao)
 Write out pointer-like object ao to file filename. More...
 
void write (std::ostream &stream, const std::vector< const AnalysisObject *> &aos)
 
template<typename RANGE >
std::enable_if< CIterable< RANGE >::value >::type write (std::ostream &stream, const RANGE &aos)
 
template<typename RANGE >
std::enable_if< CIterable< RANGE >::value >::type 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 16 of file WriterAIDA.h.

Member Function Documentation

◆ create()

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

Singleton creation function.

Definition at line 17 of file WriterAIDA.cc.

References YODA::Writer::setPrecision().

17  {
18  static WriterAIDA _instance;
19  _instance.setPrecision(6);
20  return _instance;
21  }

◆ write() [1/8]

static void YODA::WriterAIDA::write ( std::ostream &  stream,
const AnalysisObject ao 
)
inlinestatic

Write out object ao to output stream stream.

Definition at line 11 of file WriterAIDA.h.

12  {
13 

◆ write() [2/8]

template<typename T >
static std::enable_if<DerefableToAO<T>::value>::type YODA::WriterAIDA::write ( std::ostream &  stream,
const T &  ao 
)
inlinestatic

Write out pointer-like object ao to output stream stream.

Definition at line 18 of file WriterAIDA.h.

26 :
27 

◆ write() [3/8]

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

Write out object ao to file filename.

Definition at line 21 of file WriterAIDA.h.

26  :
27 
28  void writeHead(std::ostream& stream);

◆ write() [4/8]

template<typename T >
static std::enable_if<DerefableToAO<T>::value>::type YODA::WriterAIDA::write ( const std::string &  filename,
const T &  ao 
)
inlinestatic

Write out pointer-like object ao to file filename.

Definition at line 33 of file WriterAIDA.h.

◆ write() [5/8]

template<typename RANGE >
static std::enable_if<CIterable<RANGE>::value>::type YODA::WriterAIDA::write ( std::ostream &  stream,
const RANGE &  aos 
)
inlinestatic

Definition at line 43 of file WriterAIDA.h.

44  { }
45 

◆ write() [6/8]

template<typename RANGE >
static std::enable_if<CIterable<RANGE>::value>::type YODA::WriterAIDA::write ( const std::string &  filename,
const RANGE &  aos 
)
inlinestatic

Definition at line 49 of file WriterAIDA.h.

◆ write() [7/8]

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.

Todo:
Add SFINAE trait checking for AOITER = DerefableToAO

Definition at line 69 of file WriterAIDA.h.

◆ write() [8/8]

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.

Todo:
Add SFINAE trait checking for AOITER = DerefableToAO

Definition at line 78 of file WriterAIDA.h.

◆ writeCounter()

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

Implements YODA::Writer.

Definition at line 37 of file WriterAIDA.cc.

37  {
38  os << endl << "<!-- COUNTER WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
39  }

◆ writeFoot()

void YODA::WriterAIDA::writeFoot ( std::ostream &  stream)
protectedvirtual

Write any closing boilerplate required by the format to stream.

Reimplemented from YODA::Writer.

Definition at line 32 of file WriterAIDA.cc.

32  {
33  stream << "</aida>\n" << flush;
34  }

◆ writeHead()

void YODA::WriterAIDA::writeHead ( std::ostream &  )
protectedvirtual

Write any opening boilerplate required by the format to stream.

Reimplemented from YODA::Writer.

Definition at line 24 of file WriterAIDA.cc.

24  {
25  stream << "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n";
26  stream << "<!DOCTYPE aida SYSTEM \"http://aida.freehep.org/schemas/3.0/aida.dtd\">\n";
27  stream << "<aida>\n";
28  stream << " <implementation version=\"1.0\" package=\"YODA\"/>\n";
29  }

◆ writeHisto1D()

void YODA::WriterAIDA::writeHisto1D ( std::ostream &  stream,
const Histo1D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 42 of file WriterAIDA.cc.

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

42  {
43  Scatter2D tmp = mkScatter(h);
44  tmp.setAnnotation("Type", "Histo1D");
45  writeScatter2D(os, tmp);
46  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:9
void writeScatter2D(std::ostream &stream, const Scatter2D &s)
Definition: WriterAIDA.cc:77

◆ writeHisto2D()

void YODA::WriterAIDA::writeHisto2D ( std::ostream &  stream,
const Histo2D h 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 49 of file WriterAIDA.cc.

49  {
50  os << endl << "<!-- HISTO2D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
51  // Scatter3D tmp = mkScatter(h);
52  // tmp.setAnnotation("Type", "Histo2D");
53  // writeScatter3D(os, tmp);
54  }

◆ writeProfile1D()

void YODA::WriterAIDA::writeProfile1D ( std::ostream &  stream,
const Profile1D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 57 of file WriterAIDA.cc.

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

57  {
58  Scatter2D tmp = mkScatter(p);
59  tmp.setAnnotation("Type", "Profile1D");
60  writeScatter2D(os, tmp);
61  }
Scatter1D mkScatter(const Counter &c)
Make a Scatter1D representation of a Histo1D.
Definition: Scatter1D.cc:9
void writeScatter2D(std::ostream &stream, const Scatter2D &s)
Definition: WriterAIDA.cc:77

◆ writeProfile2D()

void YODA::WriterAIDA::writeProfile2D ( std::ostream &  stream,
const Profile2D p 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 64 of file WriterAIDA.cc.

64  {
65  os << endl << "<!-- PROFILE2D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
66  // Scatter3D tmp = mkScatter(p);
67  // tmp.setAnnotation("Type", "Profile2D");
68  // writeScatter3D(os, tmp);
69  }

◆ writeScatter1D()

void YODA::WriterAIDA::writeScatter1D ( std::ostream &  stream,
const Scatter1D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 72 of file WriterAIDA.cc.

72  {
73  os << endl << "<!-- SCATTER1D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
74  }

◆ writeScatter2D()

void YODA::WriterAIDA::writeScatter2D ( std::ostream &  stream,
const Scatter2D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 77 of file WriterAIDA.cc.

References YODA::AnalysisObject::path().

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

◆ writeScatter3D()

void YODA::WriterAIDA::writeScatter3D ( std::ostream &  stream,
const Scatter3D s 
)
protectedvirtual

Implements YODA::Writer.

Definition at line 123 of file WriterAIDA.cc.

123  {
124  os << endl << "<!-- SCATTER3D WRITING TO AIDA IS CURRENTLY UNSUPPORTED! -->" << endl << endl;
125  }

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