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 26 of file AnalysisObject.h. Member Typedef Documentation◆ Annotations
Collection type for annotations, as a string-string map. Definition at line 31 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 41 of file AnalysisObject.h. 41 {
45 }
virtual std::string type() const Get name of the analysis object type. Definition AnalysisObject.h:284 void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:182 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 48 of file AnalysisObject.h. 49 {
50 AnalysisObject::operator = (ao);
54 }
virtual AnalysisObject & operator=(const AnalysisObject &ao) noexcept Default copy assignment operator. Definition AnalysisObject.h:66 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 208 of file AnalysisObject.h. 208 {
210 }
References name(), and setAnnotation(). ◆ annotation() [1/4]
Get an annotation by name (as a string) Definition at line 138 of file AnalysisObject.h. 138 {
139 Annotations::const_iterator v = _annotations.find(name);
140 // If not found... written this way round on purpose
141 if (v == _annotations.end()) {
143 throw AnnotationError(missing);
144 }
145 return v->second;
146 }
References name(). Referenced by 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::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 161 of file AnalysisObject.h. 161 {
163 return Utils::lexical_cast<T>(s);
164 }
const std::string & annotation(const std::string &name) const Get an annotation by name (as a string) Definition AnalysisObject.h:138 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 150 of file AnalysisObject.h. 150 {
151 Annotations::const_iterator v = _annotations.find(name);
152 if (v != _annotations.end()) return v->second;
153 return defaultreturn;
154 }
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 171 of file AnalysisObject.h. 171 {
172 Annotations::const_iterator v = _annotations.find(name);
173 if (v != _annotations.end()) return Utils::lexical_cast<T>(v->second);
174 return defaultreturn;
175 }
References name(). ◆ annotations()
Get all the annotation names
Definition at line 123 of file AnalysisObject.h. 123 {
124 std::vector<std::string> rtn;
125 rtn.reserve(_annotations.size());
126 for (const Annotations::value_type& kv : _annotations) rtn.push_back(kv.first);
127 return rtn;
128 }
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::Counter::mkScatter(), YODA::Estimate0D::mkScatter(), and YODA::EstimateStorage< AxisT >::mkScatter(). ◆ clearAnnotations()
Delete an annotation by name. Definition at line 220 of file AnalysisObject.h. 220 {
221 _annotations.clear();
222 }
◆ 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 341 of file AnalysisObject.h. 342 {
343
344 if (data.empty()) return;
345 if (data.size() % 2)
346 throw UserError("Expected even number of annotation elements (key-value pairs)!");
347
351 _annotations.clear();
355
356 auto itr = data.cbegin();
357 const auto itrEnd = data.cend();
358 while (itr != itrEnd) {
359 const std::string key = *itr; ++itr;
360 const std::string val = *itr; ++itr;
361 _annotations[key] = val;
362 }
363 }
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 132 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 318 of file AnalysisObject.h. 319 {
320 return 2*(_annotations.size() - skipPath - skipTitle);
321 }
◆ 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 295 of file AnalysisObject.h. 296 {
297 (void)source;
299 rtn->setPath(path);
300 return rtn;
301 }
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 268 of file AnalysisObject.h. 268 {
270 const size_t lastslash = p.rfind("/");
271 if (lastslash == std::string::npos) return p;
272 return p.substr(lastslash+1);
273 }
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 66 of file AnalysisObject.h. 66 {
68 if (a == "Type") continue;
69 if (a == "Path" && !ao.path().length()) continue;
70 if (a == "Title" && !ao.title().length()) continue;
71 setAnnotation(a, ao.annotation(a));
72 }
73 return *this;
74 }
std::vector< std::string > annotations() const Definition AnalysisObject.h:123 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 246 of file AnalysisObject.h. 246 {
248 // If not set at all, return an empty string
249 if (p.empty()) return p;
250 // If missing a leading slash, one will be prepended
251 return p.find("/") == 0 ? p : ("/"+p);
252 }
References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), YODA::divide(), YODA::divide(), YODA::divide(), YODA::divide(), YODA::efficiency(), YODA::DbnStorage< DbnN, AxisT >::mkBinnedEffNumEntries(), 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::DbnStorage< DbnN, AxisT >::mkScatter(), YODA::Estimate0D::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 214 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()
Meta-data serialisation for MPI reduce operations. Definition at line 324 of file AnalysisObject.h. 325 {
326
327 // Assemble annotations
328 std::vector<std::string> rtn;
329 rtn.reserve(2*(_annotations.size() - skipPath - skipTitle));
330 for (const auto& item : _annotations) {
331 if (item.first == "Type") continue;
332 if (skipPath && item.first == "Path") continue;
333 if (skipTitle && item.first == "Title") continue;
334 rtn.push_back(item.first);
335 rtn.push_back(item.second);
336 }
337 return rtn;
338 }
◆ setAnnotation()
template<typename T >
Add or set an annotation by name (templated for remaining types)
Definition at line 182 of file AnalysisObject.h. 182 {
183 if constexpr( std::is_floating_point<T>::value ) {
184 // Recipe from Boost docs
185 std::stringstream ss;
186 ss << std::setprecision(std::numeric_limits<double>::max_digits10) << std::scientific << value;
188 }
189 else if constexpr( std::is_same<T, std::string>::value ) {
190 _annotations[name] = value;
191 }
192 else {
193 _annotations[name] = Utils::lexical_cast<std::string>(value);
194 }
195 }
References name(), and setAnnotation(). Referenced by addAnnotation(), AnalysisObject(), AnalysisObject(), YODA::Counter::mkEstimate(), 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(), setTitle(), and YODA::zipProfiles(). ◆ setAnnotations()
Set all annotations at once. Definition at line 199 of file AnalysisObject.h. 199 {
200 _annotations = anns;
201 }
◆ setPath()
Set the AO path
Definition at line 257 of file AnalysisObject.h. 257 {
259 // if (path.length() > 0 && path.find("/") != 0) {
260 // throw AnnotationError("Histo paths must start with a slash (/) character.");
261 // }
263 }
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 238 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 233 of file AnalysisObject.h. References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), and setTitle(). ◆ type()
Get name of the analysis object type. Definition at line 284 of file AnalysisObject.h. References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), YODA::WriterYODA::writeAO(), YODA::WriterYODA1::writeAO(), and YODA::Writer::writeBody(). The documentation for this class was generated from the following file:
Generated on Fri Mar 7 2025 09:06:40 for YODA - Yet more Objects for Data Analysis by |