YODA::WriterYODA1 Class Reference Persistency writer for YODA flat text format. More...
Inheritance diagram for YODA::WriterYODA1:
Detailed DescriptionPersistency writer for YODA flat text format. Definition at line 20 of file WriterYODA1.h. Member Function Documentation◆ create()
Singleton creation function. Definition at line 21 of file WriterYODA1.cc. 21 {
22 static WriterYODA1 _instance;
23 _instance.setPrecision(6);
24 return _instance;
25 }
References YODA::Writer::setPrecision(). ◆ writeAO()
Implements YODA::Writer. Definition at line 42 of file WriterYODA1.cc. 42 {
43 const string aotype = ao.type();
44 if (aotype == "Counter") {
46 } else if (aotype == "Histo1D") {
48 } else if (aotype == "Histo2D") {
50 } else if (aotype == "Profile1D") {
52 } else if (aotype == "Profile2D") {
54 } else if (aotype == "Scatter1D") {
56 } else if (aotype == "Scatter2D") {
58 } else if (aotype == "Scatter3D") {
60 } else {
61 stream << "# Type " << aotype << " not supported in the legacy writer.\n";
62 // Skip writing other AO types since they were not supported in YODA1.
63 }
64 }
void writeScatter1D(std::ostream &stream, const Scatter1D &s) Definition WriterYODA1.cc:231 void writeCounter(std::ostream &stream, const Counter &c) Definition WriterYODA1.cc:67 void writeScatter3D(std::ostream &stream, const Scatter3D &s) Definition WriterYODA1.cc:291 void writeScatter2D(std::ostream &stream, const Scatter2D &s) Definition WriterYODA1.cc:259 void writeHisto1D(std::ostream &stream, const Histo1D &h) Definition WriterYODA1.cc:81 void writeProfile1D(std::ostream &stream, const Profile1D &p) Definition WriterYODA1.cc:159 void writeProfile2D(std::ostream &stream, const Profile2D &p) Definition WriterYODA1.cc:195 void writeHisto2D(std::ostream &stream, const Histo2D &h) Definition WriterYODA1.cc:119 BinnedHisto< double > Histo1D User-friendly familiar names (continuous axes only) Definition Histo.h:354 BinnedProfile< double > Profile1D User-friendly familiar names (continuous axes only) Definition Profile.h:350 References YODA::AnalysisObject::type(), writeCounter(), writeHisto1D(), writeHisto2D(), writeProfile1D(), writeProfile2D(), writeScatter1D(), writeScatter2D(), and writeScatter3D(). ◆ writeCounter()
Definition at line 67 of file WriterYODA1.cc. 67 {
68 ios_base::fmtflags oldflags = os.flags();
69 os << scientific << showpoint << setprecision(_aoprecision);
70
71 os << "BEGIN YODA_" << Utils::toUpper("COUNTER") << "_V2 " << c.path() << "\n";
72 _writeAnnotations(os, c);
73 os << "# sumW\t sumW2\t numEntries\n";
74 os << c.sumW() << "\t" << c.sumW2() << "\t" << c.numEntries() << "\n";
75 os << "END YODA_" << Utils::toUpper("COUNTER") << "_V2\n\n";
76
77 os.flags(oldflags);
78 }
References YODA::Counter::numEntries(), YODA::AnalysisObject::path(), YODA::Counter::sumW(), and YODA::Counter::sumW2(). Referenced by writeAO(). ◆ writeHisto1D()
Definition at line 81 of file WriterYODA1.cc. 81 {
82 ios_base::fmtflags oldflags = os.flags();
83 os << scientific << showpoint << setprecision(_aoprecision);
84
85 os << "BEGIN YODA_" << Utils::toUpper("HISTO1D") << "_V2 " << h.path() << "\n";
86 _writeAnnotations(os, h);
87 try {
88 os << "# Mean: " << h.xMean() << "\n";
89 os << "# Area: " << h.integral() << "\n";
90 } catch (LowStatsError& e) {
91 //
92 }
93 os << "# ID\t ID\t sumw\t sumw2\t sumwx\t sumwx2\t numEntries\n";
94 os << "Total \tTotal \t";
95 os << h.sumW() << "\t" << h.sumW2() << "\t";
96 os << h.sumWA(0) << "\t" << h.sumWA2(0) << "\t";
97 os << h.numEntries() << "\n";
98 os << "Underflow\tUnderflow\t";
99 os << h.bin(0).sumW() << "\t" << h.bin(0).sumW2() << "\t";
100 os << h.bin(0).sumWX() << "\t" << h.bin(0).sumWX2() << "\t";
101 os << h.bin(0).numEntries() << "\n";
102 os << "Overflow\tOverflow\t";
103 os << h.bin(h.numBins()+1).sumW() << "\t" << h.bin(h.numBins()+1).sumW2() << "\t";
104 os << h.bin(h.numBins()+1).sumWX() << "\t" << h.bin(h.numBins()+1).sumWX2() << "\t";
105 os << h.bin(h.numBins()+1).numEntries() << "\n";
106 os << "# xlow\t xhigh\t sumw\t sumw2\t sumwx\t sumwx2\t numEntries\n";
107 for (const auto& b : h.bins()) {
108 os << b.xMin() << "\t" << b.xMax() << "\t";
109 os << b.sumW() << "\t" << b.sumW2() << "\t";
110 os << b.sumWX() << "\t" << b.sumWX2() << "\t";
111 os << b.numEntries() << "\n";
112 }
113 os << "END YODA_" << Utils::toUpper("HISTO1D") << "_V2\n\n";
114
115 os.flags(oldflags);
116 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), YODA::DbnStorage< DbnN, AxisT >::sumW(), YODA::DbnStorage< DbnN, AxisT >::sumW2(), YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2(). Referenced by writeAO(). ◆ writeHisto2D()
Definition at line 119 of file WriterYODA1.cc. 119 {
120 ios_base::fmtflags oldflags = os.flags();
121 os << scientific << showpoint << setprecision(_aoprecision);
122 os << "BEGIN YODA_" << Utils::toUpper("HISTO2D") << "_V2 " << h.path() << "\n";
123 _writeAnnotations(os, h);
124 try {
125 //if ( h.totalDbn().numEntries() > 0 )
126 os << "# Mean: (" << h.xMean() << ", " << h.yMean() << ")\n";
127 os << "# Volume: " << h.integral() << "\n";
128 } catch (LowStatsError& e) {
129 //
130 }
131 os << "# ID\t ID\t sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t sumwxy\t numEntries\n";
132 // Total distribution
133 os << "Total \tTotal \t";
134 os << h.sumW() << "\t" << h.sumW2() << "\t";
135 os << h.sumWA(0) << "\t" << h.sumWA2(0) << "\t";
136 os << h.sumWA(1) << "\t" << h.sumWA2(1) << "\t";
137 os << h.crossTerm(0,1) << "\t";
138 os << h.numEntries() << "\n";
139 // Outflows
141 os << "# 2D outflow persistency not currently supported until API is stable\n";
142 // Bins
143 os << "# xlow\t xhigh\t ylow\t yhigh\t sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t sumwxy\t numEntries\n";
144 for (const auto& b : h.bins()) {
145 os << b.xMin() << "\t" << b.xMax() << "\t";
146 os << b.yMin() << "\t" << b.yMax() << "\t";
147 os << b.sumW() << "\t" << b.sumW2() << "\t";
148 os << b.sumWX() << "\t" << b.sumWX2() << "\t";
149 os << b.sumWY() << "\t" << b.sumWY2() << "\t";
150 os << b.sumWXY() << "\t";
151 os << b.numEntries() << "\n";
152 }
153 os << "END YODA_" << Utils::toUpper("HISTO2D") << "_V2\n\n";
154
155 os.flags(oldflags);
156 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::crossTerm(), YODA::DbnStorage< DbnN, AxisT >::integral(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), YODA::DbnStorage< DbnN, AxisT >::sumW(), YODA::DbnStorage< DbnN, AxisT >::sumW2(), YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2(). Referenced by writeAO(). ◆ writeProfile1D()
Definition at line 159 of file WriterYODA1.cc. 159 {
160 ios_base::fmtflags oldflags = os.flags();
161 os << scientific << showpoint << setprecision(_aoprecision);
162
163 os << "BEGIN YODA_" << Utils::toUpper("PROFILE1D") << "_V2 " << p.path() << "\n";
164 _writeAnnotations(os, p);
165 os << "# ID\t ID\t sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t numEntries\n";
166 os << "Total \tTotal \t";
167 os << p.sumW() << "\t" << p.sumW2() << "\t";
168 os << p.sumWA(0) << "\t" << p.sumWA2(0) << "\t";
169 os << p.sumWA(1) << "\t" << p.sumWA2(1) << "\t";
170 os << p.numEntries() << "\n";
171 os << "Underflow\tUnderflow\t";
172 os << p.bin(0).sumW() << "\t" << p.bin(0).sumW2() << "\t";
173 os << p.bin(0).sumWX() << "\t" << p.bin(0).sumWX2() << "\t";
174 os << p.bin(0).sumWY() << "\t" << p.bin(0).sumWY2() << "\t";
175 os << p.bin(0).numEntries() << "\n";
176 os << "Overflow\tOverflow\t";
177 os << p.bin(p.numBins()+1).sumW() << "\t" << p.bin(p.numBins()+1).sumW2() << "\t";
178 os << p.bin(p.numBins()+1).sumWX() << "\t" << p.bin(p.numBins()+1).sumWX2() << "\t";
179 os << p.bin(p.numBins()+1).sumWY() << "\t" << p.bin(p.numBins()+1).sumWY2() << "\t";
180 os << p.bin(p.numBins()+1).numEntries() << "\n";
181 os << "# xlow\t xhigh\t sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t numEntries\n";
182 for (const auto& b : p.bins()) {
183 os << b.xMin() << "\t" << b.xMax() << "\t";
184 os << b.sumW() << "\t" << b.sumW2() << "\t";
185 os << b.sumWX() << "\t" << b.sumWX2() << "\t";
186 os << b.sumWY() << "\t" << b.sumWY2() << "\t";
187 os << b.numEntries() << "\n";
188 }
189 os << "END YODA_" << Utils::toUpper("PROFILE1D") << "_V2\n\n";
190
191 os.flags(oldflags);
192 }
References YODA::BinnedStorage< BinContentT, AxisT >::bin(), YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::BinnedStorage< BinContentT, AxisT >::numBins(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), YODA::DbnStorage< DbnN, AxisT >::sumW(), YODA::DbnStorage< DbnN, AxisT >::sumW2(), YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2(). Referenced by writeAO(). ◆ writeProfile2D()
Definition at line 195 of file WriterYODA1.cc. 195 {
196 ios_base::fmtflags oldflags = os.flags();
197 os << scientific << showpoint << setprecision(_aoprecision);
198
199 os << "BEGIN YODA_" << Utils::toUpper("PROFILE2D") << "_V2 " << p.path() << "\n";
200 _writeAnnotations(os, p);
201 os << "# sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t sumwz\t sumwz2\t sumwxy\t numEntries\n";
202 // Total distribution
203 os << "Total \tTotal \t";
204 os << p.sumW() << "\t" << p.sumW2() << "\t";
205 os << p.sumWA(0) << "\t" << p.sumWA2(0) << "\t";
206 os << p.sumWA(1) << "\t" << p.sumWA2(1) << "\t";
207 os << p.sumWA(2) << "\t" << p.sumWA2(2) << "\t";
208 os << p.crossTerm(0,1) << "\t"; // << td.sumWXZ() << "\t" << td.sumWYZ() << "\t";
209 os << p.numEntries() << "\n";
210 // Outflows
212 os << "# 2D outflow persistency not currently supported until API is stable\n";
213 // Bins
214 os << "# xlow\t xhigh\t ylow\t yhigh\t sumw\t sumw2\t sumwx\t sumwx2\t sumwy\t sumwy2\t sumwz\t sumwz2\t sumwxy\t numEntries\n";
215 for (const auto& b : p.bins()) {
216 os << b.xMin() << "\t" << b.xMax() << "\t";
217 os << b.yMin() << "\t" << b.yMax() << "\t";
218 os << b.sumW() << "\t" << b.sumW2() << "\t";
219 os << b.sumWX() << "\t" << b.sumWX2() << "\t";
220 os << b.sumWY() << "\t" << b.sumWY2() << "\t";
221 os << b.sumWZ() << "\t" << b.sumWZ2() << "\t";
222 os << b.sumWXY() << "\t"; // << b.sumWXZ() << "\t" << b.sumWYZ() << "\t";
223 os << b.numEntries() << "\n";
224 }
225 os << "END YODA_" << Utils::toUpper("PROFILE2D") << "_V2\n\n";
226
227 os.flags(oldflags);
228 }
References YODA::BinnedStorage< BinContentT, AxisT >::bins(), YODA::DbnStorage< DbnN, AxisT >::crossTerm(), YODA::DbnStorage< DbnN, AxisT >::numEntries(), YODA::AnalysisObject::path(), YODA::DbnStorage< DbnN, AxisT >::sumW(), YODA::DbnStorage< DbnN, AxisT >::sumW2(), YODA::DbnStorage< DbnN, AxisT >::sumWA(), and YODA::DbnStorage< DbnN, AxisT >::sumWA2(). Referenced by writeAO(). ◆ writeScatter1D()
Definition at line 231 of file WriterYODA1.cc. 231 {
232 ios_base::fmtflags oldflags = os.flags();
233 os << scientific << showpoint << setprecision(_aoprecision);
234
235 // we promised not to modify const s, but we want to add an annotation
236 // we did not promise to not modify the *clone* of s...
237 auto sclone = s.clone();
238
239 os << "BEGIN YODA_" << Utils::toUpper("SCATTER1D") << "_V2 " << s.path() << "\n";
240 _writeAnnotations(os, sclone);
241
242 //write headers
243 std::string headers="# xval\t xerr-\t xerr+\t";
244 os << headers << "\n";
245
246 //write points
248 // fill central value
249 os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrPlus() ;
250 os << "\n";
251 }
252 os << "END YODA_" << Utils::toUpper("SCATTER1D") << "_V2\n\n";
253
254 os << flush;
255 os.flags(oldflags);
256 }
References YODA::ScatterND< N >::clone(), YODA::AnalysisObject::path(), and YODA::ScatterND< N >::points(). Referenced by writeAO(). ◆ writeScatter2D()
Definition at line 259 of file WriterYODA1.cc. 259 {
260 ios_base::fmtflags oldflags = os.flags();
261 os << scientific << showpoint << setprecision(_aoprecision);
262 os << "BEGIN YODA_" << Utils::toUpper("SCATTER2D") << "_V2 " << s.path() << "\n";
263
264 // Write annotations.
265 // We promised not to modify const s, but we want to add an annotation;
266 // We did not promise to not modify the *clone* of s;
267 // Judge not, lest ye be judged
268 auto sclone = s.clone();
269 _writeAnnotations(os, sclone);
270
271 //write headers
273 std::string headers="# xval\t xerr-\t xerr+\t yval\t yerr-\t yerr+\t";
274 os << headers << "\n";
275
276 //write points
279 // fill central value
280 os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrPlus() << "\t";
281 os << pt.y() << "\t" << pt.yErrMinus() << "\t" << pt.yErrPlus() ;
282 os << "\n";
283 }
284 os << "END YODA_" << Utils::toUpper("SCATTER2D") << "_V2\n\n";
285
286 os << flush;
287 os.flags(oldflags);
288 }
References YODA::ScatterND< N >::clone(), YODA::AnalysisObject::path(), and YODA::ScatterND< N >::points(). Referenced by writeAO(). ◆ writeScatter3D()
Definition at line 291 of file WriterYODA1.cc. 291 {
292 ios_base::fmtflags oldflags = os.flags();
293 os << scientific << showpoint << setprecision(_aoprecision);
294 os << "BEGIN YODA_" << Utils::toUpper("SCATTER3D") << "_V2 " << s.path() << "\n";
295
296 // write annotations
297 // we promised not to modify const s, but we want to add an annotation
298 // we did not promise to not modify the *clone* of s...
299 auto sclone = s.clone();
300 _writeAnnotations(os, sclone);
301
302 //write headers
304 std::string headers="# xval\t xerr-\t xerr+\t yval\t yerr-\t yerr+\t zval\t zerr-\t zerr+\t";
305 os << headers << "\n";
306
307 //write points
310 // fill central value
311 os << pt.x() << "\t" << pt.xErrMinus() << "\t" << pt.xErrPlus() << "\t";
312 os << pt.y() << "\t" << pt.yErrMinus() << "\t" << pt.yErrPlus() << "\t";
313 os << pt.z() << "\t" << pt.zErrMinus() << "\t" << pt.zErrPlus() ;
314 os << "\n";
315 }
316 os << "END YODA_" << Utils::toUpper("SCATTER3D") << "_V2\n\n";
317
318 os << flush;
319 os.flags(oldflags);
320 }
References YODA::ScatterND< N >::clone(), YODA::AnalysisObject::path(), and YODA::ScatterND< N >::points(). Referenced by writeAO(). The documentation for this class was generated from the following files:
Generated on Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |