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:268 void setAnnotation(const std::string &name, const T &value) Add or set an annotation by name (templated for remaining types) Definition AnalysisObject.h:166 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 192 of file AnalysisObject.h. 192 {
194 }
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(), 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 Annotations::const_iterator v = _annotations.find(name);
157 if (v != _annotations.end()) return Utils::lexical_cast<T>(v->second);
158 return defaultreturn;
159 }
References 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 204 of file AnalysisObject.h. 204 {
205 _annotations.clear();
206 }
◆ 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 325 of file AnalysisObject.h. 326 {
327
328 if (data.empty()) return;
329 if (data.size() % 2)
330 throw UserError("Expected even number of annotation elements (key-value pairs)!");
331
335 _annotations.clear();
339
340 auto itr = data.cbegin();
341 const auto itrEnd = data.cend();
342 while (itr != itrEnd) {
343 const std::string key = *itr; ++itr;
344 const std::string val = *itr; ++itr;
345 _annotations[key] = val;
346 }
347 }
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 302 of file AnalysisObject.h. 303 {
304 return 2*(_annotations.size() - skipPath - skipTitle);
305 }
◆ 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 279 of file AnalysisObject.h. 280 {
281 (void)source;
283 rtn->setPath(path);
284 return rtn;
285 }
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 252 of file AnalysisObject.h. 252 {
254 const size_t lastslash = p.rfind("/");
255 if (lastslash == std::string::npos) return p;
256 return p.substr(lastslash+1);
257 }
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 230 of file AnalysisObject.h. 230 {
232 // If not set at all, return an empty string
233 if (p.empty()) return p;
234 // If missing a leading slash, one will be prepended
235 return p.find("/") == 0 ? p : ("/"+p);
236 }
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::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 198 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 308 of file AnalysisObject.h. 309 {
310
311 // Assemble annotations
312 std::vector<std::string> rtn;
313 rtn.reserve(2*(_annotations.size() - skipPath - skipTitle));
314 for (const auto& item : _annotations) {
315 if (item.first == "Type") continue;
316 if (skipPath && item.first == "Path") continue;
317 if (skipTitle && item.first == "Title") continue;
318 rtn.push_back(item.first);
319 rtn.push_back(item.second);
320 }
321 return rtn;
322 }
◆ setAnnotation()
template<typename T >
Add or set an annotation by name (templated for remaining types)
Definition at line 166 of file AnalysisObject.h. 166 {
167 if constexpr( std::is_floating_point<T>::value ) {
168 // Recipe from Boost docs
169 std::stringstream ss;
170 ss << std::setprecision(std::numeric_limits<double>::max_digits10) << std::scientific << value;
172 }
173 else if constexpr( std::is_same<T, std::string>::value ) {
174 _annotations[name] = value;
175 }
176 else {
177 _annotations[name] = Utils::lexical_cast<std::string>(value);
178 }
179 }
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(), setTitle(), and YODA::zipProfiles(). ◆ setAnnotations()
Set all annotations at once. Definition at line 183 of file AnalysisObject.h. 183 {
184 _annotations = anns;
185 }
◆ setPath()
Set the AO path
Definition at line 241 of file AnalysisObject.h. 241 {
243 // if (path.length() > 0 && path.find("/") != 0) {
244 // throw AnnotationError("Histo paths must start with a slash (/) character.");
245 // }
247 }
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 222 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 217 of file AnalysisObject.h. References annotation(). Referenced by AnalysisObject(), AnalysisObject(), deserializeMeta(), and setTitle(). ◆ type()
Get name of the analysis object type. Definition at line 268 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 Mon Oct 28 2024 13:47:24 for YODA - Yet more Objects for Data Analysis by 1.9.8 |