YODA::AnalysisObject Class Referenceabstract AnalysisObject is the base class for histograms and scatters. More...
Inheritance diagram for YODA::AnalysisObject:
Detailed DescriptionAnalysisObject is the base class for histograms and scatters. Definition at line 21 of file AnalysisObject.h. Member Typedef Documentation◆ Annotations
Collection type for annotations, as a string-string map. Definition at line 26 of file AnalysisObject.h. Constructor & Destructor Documentation◆ AnalysisObject() [1/3]
◆ AnalysisObject() [2/3]
Constructor giving a type, a path and an optional title. Definition at line 36 of file AnalysisObject.h. 36 {
40 }
virtual std::string type() const Get name of the analysis object type. Definition AnalysisObject.h:271 void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:169 References path(), setAnnotation(), setPath(), setTitle(), title(), and type(). ◆ AnalysisObject() [3/3]
Constructor giving a type, a path, another AO to copy annotation from, and an optional title. Definition at line 43 of file AnalysisObject.h. 44 {
45 AnalysisObject::operator = (ao);
49 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept Default copy assignment operator. Definition AnalysisObject.h:61 References operator=(), path(), setAnnotation(), setPath(), setTitle(), title(), and type(). ◆ ~AnalysisObject()
Member Function Documentation◆ addAnnotation()
template<typename T >
Add or set an annotation by name. Note: Templated on arg type, but stored as a string. This is just a synonym for setAnnotation. Definition at line 195 of file AnalysisObject.h. 195 {
197 }
References name(), and setAnnotation(). ◆ annotation() [1/4]
Get an annotation by name (as a string) Definition at line 122 of file AnalysisObject.h. 122 {
123 Annotations::const_iterator v = _annotations.find(name);
124 // If not found... written this way round on purpose
125 if (v == _annotations.end()) {
127 throw AnnotationError(missing);
128 }
129 return v->second;
130 }
References name(). Referenced by annotation(), annotation(), deserializeMeta(), YODA::Counter::mkEstimate(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::EstimateStorage< AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::DbnStorage< DbnN, AxisT >::mkHistos(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalProfile(), YODA::DbnStorage< DbnN, AxisT >::mkProfiles(), YODA::mkScatter(), YODA::Counter::mkScatter(), YODA::Estimate0D::mkScatter(), YODA::EstimateStorage< AxisT >::mkScatter(), path(), title(), and type(). ◆ annotation() [2/4]
template<typename T >
Get an annotation by name (copied to another type)
Definition at line 145 of file AnalysisObject.h. 145 {
147 return Utils::lexical_cast<T>(s);
148 }
const std::string & annotation(const std::string &name) const Get an annotation by name (as a string) Definition AnalysisObject.h:122 References annotation(), and name(). ◆ annotation() [3/4]
Get an annotation by name (as a string) with a default in case the annotation is not found. Definition at line 134 of file AnalysisObject.h. 134 {
135 Annotations::const_iterator v = _annotations.find(name);
136 if (v != _annotations.end()) return v->second;
137 return defaultreturn;
138 }
References name(). ◆ annotation() [4/4]
template<typename T >
Get an annotation by name (copied to another type) with a default in case the annotation is not found.
Definition at line 155 of file AnalysisObject.h. 155 {
156 try {
158 return Utils::lexical_cast<T>(s);
159 } catch (const AnnotationError& ae) {
160 return defaultreturn;
161 }
162 }
References annotation(), and name(). ◆ annotations()
Get all the annotation names
Definition at line 107 of file AnalysisObject.h. 107 {
108 std::vector<std::string> rtn;
109 rtn.reserve(_annotations.size());
110 for (const Annotations::value_type& kv : _annotations) rtn.push_back(kv.first);
111 return rtn;
112 }
Referenced by YODA::Counter::mkEstimate(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::EstimateStorage< AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::DbnStorage< DbnN, AxisT >::mkHistos(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalProfile(), YODA::DbnStorage< DbnN, AxisT >::mkProfiles(), YODA::mkScatter(), YODA::Counter::mkScatter(), YODA::Estimate0D::mkScatter(), and YODA::EstimateStorage< AxisT >::mkScatter(). ◆ clearAnnotations()
Delete an annotation by name. Definition at line 207 of file AnalysisObject.h. 207 {
208 _annotations.clear();
209 }
◆ deserializeContent()
Content deserialisation for MPI reduce operations. Implemented in YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::Counter, YODA::Estimate0D, and YODA::ScatterND< N >. ◆ deserializeMeta()
Mate-data deserialisation for MPI reduce operations. Definition at line 328 of file AnalysisObject.h. 329 {
330
331 if (data.empty()) return;
332 if (data.size() % 2)
333 throw UserError("Expected even number of annotation elements (key-value pairs)!");
334
338 _annotations.clear();
342
343 auto itr = data.cbegin();
344 const auto itrEnd = data.cend();
345 while (itr != itrEnd) {
346 const std::string key = *itr; ++itr;
347 const std::string val = *itr; ++itr;
348 _annotations[key] = val;
349 }
350 }
References annotation(), path(), title(), and type(). ◆ dim()
Get the dimension of the analysis object type.
Implemented in YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::Counter, YODA::Estimate0D, and YODA::ScatterND< N >. Referenced by YODA::WriterFLAT::writeAO(). ◆ hasAnnotation()
Check if an annotation is defined. Definition at line 116 of file AnalysisObject.h. References name(). Referenced by YODA::Estimate0D::add(), YODA::EstimateStorage< AxisT >::add(), YODA::Estimate0D::add(), YODA::EstimateStorage< AxisT >::add(), YODA::divide(), YODA::divide(), YODA::efficiency(), YODA::Counter::operator*=(), YODA::Counter::operator++(), YODA::Counter::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::Counter::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::Counter::operator--(), YODA::Counter::operator-=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::Counter::operator-=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::Counter::operator/=(), YODA::Estimate0D::subtract(), YODA::EstimateStorage< AxisT >::subtract(), YODA::Estimate0D::subtract(), and YODA::EstimateStorage< AxisT >::subtract(). ◆ lengthContent()
Length of serialized content vector for MPI reduce operations. Implemented in YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::Estimate0D, YODA::ScatterND< N >, YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, and YODA::Counter. ◆ lengthMeta()
Length of serialized meta-data vector for MPI reduce operations. Definition at line 305 of file AnalysisObject.h. 306 {
307 return 2*(_annotations.size() - skipPath - skipTitle);
308 }
◆ mkInert()
Return an inert version of the analysis object (e.g. scatter, estimate) Reimplemented in YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::Counter, and YODA::Estimate0D. Definition at line 282 of file AnalysisObject.h. 283 {
284 (void)source;
286 rtn->setPath(path);
287 return rtn;
288 }
virtual AnalysisObject * newclone() const =0 Make a copy on the heap, via 'new'. References newclone(), path(), and setPath(). ◆ name()
Get the AO name – the last part of the path. Returns a null string if path is undefined Definition at line 255 of file AnalysisObject.h. 255 {
257 const size_t lastslash = p.rfind("/");
258 if (lastslash == std::string::npos) return p;
259 return p.substr(lastslash+1);
260 }
References path(). Referenced by addAnnotation(), annotation(), annotation(), annotation(), hasAnnotation(), rmAnnotation(), and setAnnotation(). ◆ newclone()
Make a copy on the heap, via 'new'. Implemented in YODA::Counter, YODA::ScatterND< N >, YODA::BinnedDbn< DbnN, AxisT >, YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::BinnedEstimate< AxisT >, YODA::BinnedEstimate< AxisT1, AxisT2 >, YODA::BinnedEstimate< AxisT1, AxisT2, AxisT3 >, YODA::Estimate0D, YODA::BinnedDbn< 1, AxisT >, YODA::BinnedDbn< 2, AxisT1, AxisT2 >, YODA::BinnedDbn< 3, AxisT1, AxisT2, AxisT3 >, YODA::BinnedDbn< 2, AxisT >, YODA::BinnedDbn< 3, AxisT1, AxisT2 >, and YODA::BinnedDbn< 4, AxisT1, AxisT2, AxisT3 >. Referenced by mkInert(), and YODA::DbnStorage< DbnN, AxisT >::mkInert(). ◆ operator=()
Default copy assignment operator. Definition at line 61 of file AnalysisObject.h. 61 {
63 if (a == "Type") continue;
64 if (a == "Path" && !ao.path().length()) continue;
65 if (a == "Title" && !ao.title().length()) continue;
66 setAnnotation(a, ao.annotation(a));
67 }
68 return *this;
69 }
std::vector< std::string > annotations() const Definition AnalysisObject.h:107 References setAnnotation(). Referenced by AnalysisObject(), YODA::Counter::operator=(), YODA::DbnStorage< DbnN, AxisT >::operator=(), YODA::Estimate0D::operator=(), YODA::EstimateStorage< AxisT >::operator=(), YODA::ScatterND< N >::operator=(), YODA::Counter::operator=(), YODA::DbnStorage< DbnN, AxisT >::operator=(), YODA::Estimate0D::operator=(), YODA::EstimateStorage< AxisT >::operator=(), and YODA::ScatterND< N >::operator=(). ◆ path()
Get the AO path. Returns a null string if undefined, rather than throwing an exception cf. annotation("Path").
Definition at line 233 of file AnalysisObject.h. 233 {
235 // If not set at all, return an empty string
236 if (p.empty()) return p;
237 // If missing a leading slash, one will be prepended
238 return p.find("/") == 0 ? p : ("/"+p);
239 }
References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), YODA::divide(), YODA::divide(), YODA::divide(), YODA::divide(), YODA::efficiency(), YODA::Counter::mkEstimate(), YODA::DbnStorage< DbnN, AxisT >::mkEstimate(), YODA::EstimateStorage< AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkEstimates(), YODA::DbnStorage< DbnN, AxisT >::mkHisto(), YODA::DbnStorage< DbnN, AxisT >::mkHistos(), mkInert(), YODA::DbnStorage< DbnN, AxisT >::mkInert(), YODA::EstimateStorage< AxisT >::mkInert(), YODA::Counter::mkInert(), YODA::Estimate0D::mkInert(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalHisto(), YODA::DbnStorage< DbnN, AxisT >::mkMarginalProfile(), YODA::DbnStorage< DbnN, AxisT >::mkProfiles(), YODA::Counter::mkScatter(), YODA::Estimate0D::mkScatter(), YODA::DbnStorage< DbnN, AxisT >::mkScatter(), YODA::EstimateStorage< AxisT >::mkScatter(), name(), setPath(), YODA::WriterFLAT::writeAO(), YODA::WriterYODA::writeAO(), YODA::WriterYODA1::writeCounter(), YODA::WriterYODA1::writeHisto1D(), YODA::WriterYODA1::writeHisto2D(), YODA::WriterYODA1::writeProfile1D(), YODA::WriterYODA1::writeProfile2D(), YODA::WriterYODA1::writeScatter1D(), YODA::WriterYODA1::writeScatter2D(), and YODA::WriterYODA1::writeScatter3D(). ◆ reset()
Reset this analysis object. Implemented in YODA::Counter, YODA::ScatterND< N >, YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, and YODA::Estimate0D. ◆ rmAnnotation()
Delete an annotation by name. Definition at line 201 of file AnalysisObject.h. References name(). Referenced by YODA::Estimate0D::add(), YODA::EstimateStorage< AxisT >::add(), YODA::Estimate0D::add(), YODA::EstimateStorage< AxisT >::add(), YODA::divide(), YODA::divide(), YODA::efficiency(), YODA::Counter::operator*=(), YODA::Counter::operator++(), YODA::Counter::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::Counter::operator+=(), YODA::DbnStorage< DbnN, AxisT >::operator+=(), YODA::Counter::operator--(), YODA::Counter::operator-=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::Counter::operator-=(), YODA::DbnStorage< DbnN, AxisT >::operator-=(), YODA::Counter::operator/=(), YODA::Estimate0D::subtract(), YODA::EstimateStorage< AxisT >::subtract(), YODA::Estimate0D::subtract(), and YODA::EstimateStorage< AxisT >::subtract(). ◆ serializeContent()
Content serialisation for MPI reduce operations. Implemented in YODA::EstimateStorage< AxisT >, YODA::EstimateStorage< AxisT... >, YODA::EstimateStorage< AxisT1, AxisT2 >, YODA::EstimateStorage< AxisT1, AxisT2, AxisT3 >, YODA::Estimate0D, YODA::ScatterND< N >, YODA::DbnStorage< DbnN, AxisT >, YODA::DbnStorage< 1, AxisT >, YODA::DbnStorage< 2, AxisT >, YODA::DbnStorage< 2, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2 >, YODA::DbnStorage< 3, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< 4, AxisT1, AxisT2, AxisT3 >, YODA::DbnStorage< DbnN, AxisT... >, and YODA::Counter. ◆ serializeMeta()
Mate-data serialisation for MPI reduce operations. Definition at line 311 of file AnalysisObject.h. 312 {
313
314 // Assemble annotations
315 std::vector<std::string> rtn;
316 rtn.reserve(2*(_annotations.size() - skipPath - skipTitle));
317 for (const auto& item : _annotations) {
318 if (item.first == "Type") continue;
319 if (skipPath && item.first == "Path") continue;
320 if (skipTitle && item.first == "Title") continue;
321 rtn.push_back(item.first);
322 rtn.push_back(item.second);
323 }
324 return rtn;
325 }
◆ setAnnotation()
template<typename T >
Add or set an annotation by name (templated for remaining types)
Definition at line 169 of file AnalysisObject.h. 169 {
170 if constexpr( std::is_floating_point<T>::value ) {
171 // Recipe from Boost docs
172 std::stringstream ss;
173 ss << std::setprecision(std::numeric_limits<double>::max_digits10) << std::scientific << value;
175 }
176 else if constexpr( std::is_same<T, std::string>::value ) {
177 _annotations[name] = value;
178 }
179 else {
180 _annotations[name] = Utils::lexical_cast<std::string>(value);
181 }
182 }
References name(), and setAnnotation(). Referenced by addAnnotation(), AnalysisObject(), AnalysisObject(), YODA::Counter::mkEstimate(), YODA::mkScatter(), YODA::Counter::mkScatter(), YODA::Estimate0D::mkScatter(), YODA::EstimateStorage< AxisT >::mkScatter(), operator=(), YODA::EstimateStorage< AxisT >::scale(), YODA::DbnStorage< DbnN, AxisT >::scale(), YODA::DbnStorage< DbnN, AxisT >::scaleW(), YODA::Counter::scaleW(), setAnnotation(), setPath(), and setTitle(). ◆ setAnnotations()
Set all annotations at once. Definition at line 186 of file AnalysisObject.h. 186 {
187 _annotations = anns;
188 }
◆ setPath()
Set the AO path
Definition at line 244 of file AnalysisObject.h. 244 {
246 // if (path.length() > 0 && path.find("/") != 0) {
247 // throw AnnotationError("Histo paths must start with a slash (/) character.");
248 // }
250 }
References path(), and setAnnotation(). Referenced by AnalysisObject(), AnalysisObject(), YODA::divide(), YODA::divide(), YODA::efficiency(), mkInert(), YODA::EstimateStorage< AxisT >::mkInert(), and YODA::Estimate0D::mkInert(). ◆ setTitle()
Set the AO title. Definition at line 225 of file AnalysisObject.h. References setAnnotation(), and title(). Referenced by AnalysisObject(), and AnalysisObject(). ◆ title()
Get the AO title. Returns a null string if undefined, rather than throwing an exception cf. the annotation("Title"). Definition at line 220 of file AnalysisObject.h. References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), and setTitle(). ◆ type()
Get name of the analysis object type. Definition at line 271 of file AnalysisObject.h. References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), YODA::mkScatter(), YODA::WriterYODA::writeAO(), YODA::WriterYODA1::writeAO(), and YODA::Writer::writeBody(). The documentation for this class was generated from the following file:
Generated on Thu Feb 29 2024 12:47:15 for YODA - Yet more Objects for Data Analysis by 1.9.8 |