rivet is hosted by Hepforge, IPPP Durham
Rivet 3.1.6
Analysis.hh
1// -*- C++ -*-
2#ifndef RIVET_Analysis_HH
3#define RIVET_Analysis_HH
4
5#include "Rivet/Config/RivetCommon.hh"
6#include "Rivet/AnalysisInfo.hh"
7#include "Rivet/Event.hh"
8#include "Rivet/Projection.hh"
9#include "Rivet/ProjectionApplier.hh"
10#include "Rivet/ProjectionHandler.hh"
11#include "Rivet/AnalysisLoader.hh"
12#include "Rivet/Tools/Cuts.hh"
13#include "Rivet/Tools/Logging.hh"
14#include "Rivet/Tools/ParticleUtils.hh"
15#include "Rivet/Tools/BinnedHistogram.hh"
16#include "Rivet/Tools/RivetMT2.hh"
17#include "Rivet/Tools/RivetYODA.hh"
18#include "Rivet/Tools/Percentile.hh"
19#include "Rivet/Projections/CentralityProjection.hh"
20#include <tuple>
21
22
25#define vetoEvent \
26 do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0)
27
28
29namespace Rivet {
30
31
32 // Convenience for analysis writers
33 using std::cout;
34 using std::cerr;
35 using std::endl;
36 using std::tuple;
37 using std::stringstream;
38 using std::swap;
39 using std::numeric_limits;
40
41
42 // Forward declaration
43 class AnalysisHandler;
44
45
64 class Analysis : public ProjectionApplier {
65 public:
66
68 friend class AnalysisHandler;
69
70
72 Analysis(const std::string& name);
73
75 virtual ~Analysis() {}
76
78 Analysis& operator=(const Analysis&) = delete;
79
80
81 public:
82
85
89 virtual void init() { }
90
95 virtual void analyze(const Event& event) = 0;
96
102 virtual void finalize() { }
103
105
106
107 public:
108
113
115 const AnalysisInfo& info() const {
116 assert(_info && "No AnalysisInfo object :O");
117 return *_info;
118 }
119
127 virtual std::string name() const {
128 return ( (info().name().empty()) ? _defaultname : info().name() ) + _optstring;
129 }
130
132 virtual std::string getRefDataName() const {
133 return (info().getRefDataName().empty()) ? _defaultname : info().getRefDataName();
134 }
135
137 virtual void setRefDataName(const std::string& ref_data="") {
138 info().setRefDataName(!ref_data.empty() ? ref_data : name());
139 }
140
142 virtual std::string inspireId() const {
143 return info().inspireId();
144 }
145
147 virtual std::string spiresId() const {
148 return info().spiresId();
149 }
150
155 virtual std::vector<std::string> authors() const {
156 return info().authors();
157 }
158
164 virtual std::string summary() const {
165 return info().summary();
166 }
167
174 virtual std::string description() const {
175 return info().description();
176 }
177
183 virtual std::string runInfo() const {
184 return info().runInfo();
185 }
186
188 virtual std::string experiment() const {
189 return info().experiment();
190 }
191
193 virtual std::string collider() const {
194 return info().collider();
195 }
196
198 virtual std::string year() const {
199 return info().year();
200 }
201
203 virtual double luminosityfb() const {
204 return info().luminosityfb();
205 }
207 virtual double luminosity() const {
208 return info().luminosity();
209 }
210
212 virtual std::vector<std::string> references() const {
213 return info().references();
214 }
215
217 virtual std::string bibKey() const {
218 return info().bibKey();
219 }
220
222 virtual std::string bibTeX() const {
223 return info().bibTeX();
224 }
225
227 virtual std::string status() const {
228 return (info().status().empty()) ? "UNVALIDATED" : info().status();
229 }
230
232 virtual std::string warning() const {
233 return info().warning();
234 }
235
237 virtual std::vector<std::string> todos() const {
238 return info().todos();
239 }
240
242 virtual std::vector<std::string> validation() const {
243 return info().validation();
244 }
245
247 virtual bool reentrant() const {
248 return info().reentrant();
249 }
250
251
253 virtual std::string refFile() const {
254 return info().refFile();
255 }
256
258 virtual std::string refMatch() const {
259 return info().refMatch();
260 }
261
263 virtual std::string refUnmatch() const {
264 return info().refUnmatch();
265 }
266
268 virtual std::string writerDoublePrecision() const {
269 return info().writerDoublePrecision();
270 }
271
273 virtual const std::vector<PdgIdPair>& requiredBeams() const {
274 return info().beams();
275 }
277 virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
279 return *this;
280 }
281
283 virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
284 return info().energies();
285 }
286
288 virtual const std::vector<std::string> & keywords() const {
289 return info().keywords();
290 }
291
293 virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
295 return *this;
296 }
297
298
302 assert(_info && "No AnalysisInfo object :O");
303 return *_info;
304 }
305
307
308
311
313 const ParticlePair& beams() const;
314
316 const PdgIdPair beamIds() const;
317
319 double sqrtS() const;
320
322 bool merging() const {
323 return sqrtS() <= 0.0;
324 }
325
327
328
334
336 bool isCompatible(const ParticlePair& beams) const;
337
339 bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
340
342 bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
343
345 bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const;
346
348
350 AnalysisHandler& handler() const { return *_analysishandler; }
351
352
353 protected:
354
356 Log& getLog() const;
357
359 double crossSection() const;
360
363 double crossSectionPerEvent() const;
364
366 double crossSectionError() const;
367
371
375 size_t numEvents() const;
376
380 double sumW() const;
382 double sumOfWeights() const { return sumW(); }
383
387 double sumW2() const;
388
389
390 protected:
391
397
399 const std::string histoDir() const;
400
402 const std::string histoPath(const std::string& hname) const;
403
405 const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
406
408 const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
409
411
412
415
417 const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
418 _cacheRefData();
419 return _refdata;
420 }
421
422
425 template <typename T=YODA::Scatter2D>
426 const T& refData(const string& hname) const {
427 _cacheRefData();
428 MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
429 if (!_refdata[hname]) {
430 MSG_ERROR("Can't find reference histogram " << hname);
431 throw Exception("Reference data " + hname + " not found.");
432 }
433 return dynamic_cast<T&>(*_refdata[hname]);
434 }
435
436
439 template <typename T=YODA::Scatter2D>
440 const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
441 const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
442 return refData<T>(hname);
443 }
444
446
447
453
455 CounterPtr& book(CounterPtr&, const std::string& name);
456
460 CounterPtr& book(CounterPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
461
463
464
467
469 Histo1DPtr& book(Histo1DPtr&,const std::string& name, size_t nbins, double lower, double upper);
470
472 Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::vector<double>& binedges);
473
475 Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::initializer_list<double>& binedges);
476
478 Histo1DPtr& book(Histo1DPtr&,const std::string& name, const Scatter2D& refscatter);
479
481 Histo1DPtr& book(Histo1DPtr&,const std::string& name);
482
486 Histo1DPtr& book(Histo1DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
487
489
490
493
497 Histo2DPtr& book(Histo2DPtr&,const std::string& name,
498 size_t nxbins, double xlower, double xupper,
499 size_t nybins, double ylower, double yupper);
500
503 Histo2DPtr& book(Histo2DPtr&,const std::string& name,
504 const std::vector<double>& xbinedges,
505 const std::vector<double>& ybinedges);
506
509 Histo2DPtr& book(Histo2DPtr&,const std::string& name,
510 const std::initializer_list<double>& xbinedges,
511 const std::initializer_list<double>& ybinedges);
512
514 Histo2DPtr& book(Histo2DPtr&,const std::string& name,
515 const Scatter3D& refscatter);
516
518 Histo2DPtr& book(Histo2DPtr&,const std::string& name);
519
523 Histo2DPtr& book(Histo2DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
524
526
527
530
532 Profile1DPtr& book(Profile1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
533
535 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::vector<double>& binedges);
536
538 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
539
541 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const Scatter2D& refscatter);
542
544 Profile1DPtr& book(Profile1DPtr&, const std::string& name);
545
549 Profile1DPtr& book(Profile1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
550
552
553
556
560 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
561 size_t nxbins, double xlower, double xupper,
562 size_t nybins, double ylower, double yupper);
563
566 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
567 const std::vector<double>& xbinedges,
568 const std::vector<double>& ybinedges);
569
572 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
573 const std::initializer_list<double>& xbinedges,
574 const std::initializer_list<double>& ybinedges);
575
577
578 // /// Book a 2D profile histogram with binning from a reference scatter.
579 // Profile2DPtr& book(const Profile2DPtr&, const std::string& name,
580 // const Scatter3D& refscatter);
581
582 // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
583 // Profile2DPtr& book(const Profile2DPtr&, const std::string& name);
584
585 // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
586 // ///
587 // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
588 // Profile2DPtr& book(const Profile2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
589
591
592
595
606 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, bool copy_pts = false);
607
618 Scatter2DPtr& book(Scatter2DPtr& s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
619
623 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, size_t npts, double lower, double upper);
624
628 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const std::vector<double>& binedges);
629
631 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const Scatter2D& refscatter);
632
634
637
648 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, bool copy_pts=false);
649
660 Scatter3DPtr& book(Scatter3DPtr& s3d, unsigned int datasetId, unsigned int xAxisId,
661 unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
662
666 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
667 size_t xnpts, double xlower, double xupper,
668 size_t ynpts, double ylower, double yupper);
669
673 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
674 const std::vector<double>& xbinedges,
675 const std::vector<double>& ybinedges);
676
678 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, const Scatter3D& refscatter);
679
681
682
683 public:
684
688 virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
689 (void) yao;
690 }
691
696 virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
697 (void) raos;
698 (void) iW;
699 }
700
702
703
705 const std::map<std::string,std::string>& options() const {
706 return _options;
707 }
708
710 std::string getOption(std::string optname, string def="") const {
711 if ( _options.find(optname) != _options.end() )
712 return _options.find(optname)->second;
713 return def;
714 }
715
720 std::string getOption(std::string optname, const char* def) {
721 return getOption<std::string>(optname, def);
722 }
723
731 template<typename T>
732 T getOption(std::string optname, T def) const {
733 if (_options.find(optname) == _options.end()) return def;
734 std::stringstream ss;
735 ss.exceptions(std::ios::failbit);
736 T ret;
737 ss << _options.find(optname)->second;
738 try {
739 ss >> ret;
740 } catch (...) {
741 throw ReadError("Could not read user-provided option into requested type");
742 }
743 return ret;
744 }
745
756 // template<>
757 // bool getOption<bool>(std::string optname, bool def) const {
758 bool getOption(std::string optname, bool def) const {
759 if (_options.find(optname) == _options.end()) return def;
760 const std::string val = getOption(optname);
761 const std::string lval = toLower(val);
762 if (lval.empty()) return false;
763 if (lval == "true" || lval == "yes" || lval == "on") return true;
764 if (lval == "false" || lval == "no" || lval == "off") return false;
765 return bool(getOption<int>(optname, 0));
766 }
767
769
770
773
792 string calAnaName, string calHistName,
793 const string projName, bool increasing=false);
794
795
804 template <class T>
806 vector<pair<float, float> > centralityBins,
807 vector<tuple<int, int, int> > ref) {
808
809 typedef typename ReferenceTraits<T>::RefT RefT;
810 typedef rivet_shared_ptr<Wrapper<T>> WrapT;
811
812 Percentile<T> pctl(this, projName);
813
814 const int nCent = centralityBins.size();
815 for (int iCent = 0; iCent < nCent; ++iCent) {
816 const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
817 std::get<1>(ref[iCent]),
818 std::get<2>(ref[iCent]));
819 const RefT & refscatter = refData<RefT>(axisCode);
820
821 WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
822 wtf = addAnalysisObject(wtf);
823
824 CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
825 cnt = addAnalysisObject(cnt);
826
827 pctl.add(wtf, cnt, centralityBins[iCent]);
828 }
829 return pctl;
830 }
831
832
833 // /// @brief Book Percentile wrappers around AnalysisObjects.
834 // ///
835 // /// Based on a previously registered CentralityProjection named @a
836 // /// projName book one (or several) AnalysisObject(s) named
837 // /// according to @a ref where the x-axis will be filled according
838 // /// to the percentile output(s) of the @projName.
839 // ///
840 // /// @todo Convert to just be called book() cf. others
841 // template <class T>
842 // PercentileXaxis<T> bookPercentileXaxis(string projName,
843 // tuple<int, int, int> ref) {
844
845 // typedef typename ReferenceTraits<T>::RefT RefT;
846 // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
847
848 // PercentileXaxis<T> pctl(this, projName);
849
850 // const string axisCode = mkAxisCode(std::get<0>(ref),
851 // std::get<1>(ref),
852 // std::get<2>(ref));
853 // const RefT & refscatter = refData<RefT>(axisCode);
854
855 // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
856 // wtf = addAnalysisObject(wtf);
857
858 // CounterPtr cnt(_weightNames(), Counter());
859 // cnt = addAnalysisObject(cnt);
860
861 // pctl.add(wtf, cnt);
862 // return pctl;
863 // }
864
866
867
868 private:
869
870 // Functions that have to be defined in the .cc file to avoid circular #includes
871
873 vector<string> _weightNames() const;
874
876 YODA::AnalysisObjectPtr _getPreload(string name) const;
877
879 MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
880
882 void _checkBookInit() const;
883
885 bool _inInit() const;
886
888 bool _inFinalize() const;
889
891 template <typename YODAT>
892 void _setWriterPrecision(const string& path, YODAT& yao);
893
894
895 private:
896
898 class CounterAdapter {
899 public:
900
901 CounterAdapter(double x) : x_(x) {}
902
903 CounterAdapter(const YODA::Counter & c) : x_(c.val()) {}
904
905 CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
906 assert( s.numPoints() == 1 || "Can only scale by a single value.");
907 }
908
909 operator double() const { return x_; }
910
911 private:
912 double x_;
913
914 };
915
916
917 public:
918
919 double dbl(double x) { return x; }
920 double dbl(const YODA::Counter & c) { return c.val(); }
921 double dbl(const YODA::Scatter1D & s) {
922 assert( s.numPoints() == 1 );
923 return s.points()[0].x();
924 }
925
926
931
933 void scale(CounterPtr cnt, CounterAdapter factor);
934
938 void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
939 for (auto& c : cnts) scale(c, factor);
940 }
941
943 template<typename T>
944 void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
945 for (auto& m : maps) scale(m.second, factor);
946 }
947
949 template <std::size_t array_size>
950 void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
951 // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
952 for (auto& c : cnts) scale(c, factor);
953 }
954
955
957 void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
958
962 void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
963 for (auto& h : histos) normalize(h, norm, includeoverflows);
964 }
965
967 template<typename T>
968 void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
969 for (auto& m : maps) normalize(m.second, norm, includeoverflows);
970 }
971
973 template <std::size_t array_size>
974 void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
975 for (auto& h : histos) normalize(h, norm, includeoverflows);
976 }
977
979 void scale(Histo1DPtr histo, CounterAdapter factor);
980
984 void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
985 for (auto& h : histos) scale(h, factor);
986 }
987
989 template<typename T>
990 void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
991 for (auto& m : maps) scale(m.second, factor);
992 }
993
995 template <std::size_t array_size>
996 void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
997 for (auto& h : histos) scale(h, factor);
998 }
999
1000
1002 void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
1003
1007 void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
1008 for (auto& h : histos) normalize(h, norm, includeoverflows);
1009 }
1010
1012 template<typename T>
1013 void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
1014 for (auto& m : maps) normalize(m.second, norm, includeoverflows);
1015 }
1016
1018 template <std::size_t array_size>
1019 void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
1020 for (auto& h : histos) normalize(h, norm, includeoverflows);
1021 }
1022
1024 void scale(Histo2DPtr histo, CounterAdapter factor);
1025
1029 void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
1030 for (auto& h : histos) scale(h, factor);
1031 }
1032
1034 template<typename T>
1035 void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
1036 for (auto& m : maps) scale(m.second, factor);
1037 }
1038
1040 template <std::size_t array_size>
1041 void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
1042 for (auto& h : histos) scale(h, factor);
1043 }
1044
1045
1047
1048
1052 void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const;
1053
1057 void barchart(Histo2DPtr h, Scatter3DPtr s, bool usefocus=false) const;
1058
1059
1063 void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
1064
1068 void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
1069
1070
1074 void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1075
1079 void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1080
1081
1085 void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1086
1090 void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1091
1092
1096 void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1097
1101 void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1102
1103
1107 void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1108
1112 void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1113
1114
1118 void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1119
1123 void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1124
1125
1129 void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1130
1134 void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1135
1136
1140 void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1141
1145 void integrate(const Histo1D& h, Scatter2DPtr s) const;
1146
1148
1149
1150 public:
1151
1153 const vector<MultiweightAOPtr>& analysisObjects() const {
1154 return _analysisobjects;
1155 }
1156
1157
1158 protected:
1159
1162
1164 size_t defaultWeightIndex() const;
1165
1167 template <typename YODAT>
1168 shared_ptr<YODAT> getPreload(string path) const {
1169 return dynamic_pointer_cast<YODAT>(_getPreload(path));
1170 }
1171
1172
1174 template <typename YODAT>
1175 rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT& yao) {
1176 typedef Wrapper<YODAT> WrapperT;
1177 typedef shared_ptr<YODAT> YODAPtrT;
1178 typedef rivet_shared_ptr<WrapperT> RAOT;
1179
1180 if ( !_inInit() && !_inFinalize() ) {
1181 MSG_ERROR("Can't book objects outside of init() or finalize()");
1182 throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1183 }
1184
1185 // First check that we haven't booked this before.
1186 // This is allowed when booking in finalize: just warn in that case.
1187 // If in init(), throw an exception: it's 99.9% never going to be intentional.
1188 for (auto& waold : analysisObjects()) {
1189 if ( yao.path() == waold.get()->basePath() ) {
1190 const string msg = "Found double-booking of " + yao.path() + " in " + name();
1191 if ( _inInit() ) {
1192 MSG_ERROR(msg);
1193 throw LookupError(msg);
1194 } else {
1195 MSG_WARNING(msg + ". Keeping previous booking");
1196 }
1197 return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1198 }
1199 }
1200
1201 shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1202 wao->_basePath = yao.path();
1203 YODAPtrT yaop = make_shared<YODAT>(yao);
1204
1205 for (const string& weightname : _weightNames()) {
1206 // Create two YODA objects for each weight. Copy from
1207 // preloaded YODAs if present. First the finalized yoda:
1208 string finalpath = yao.path();
1209 if ( weightname != "" ) finalpath += "[" + weightname + "]";
1210 YODAPtrT preload = getPreload<YODAT>(finalpath);
1211 if ( preload ) {
1212 if ( !bookingCompatible(preload, yaop) ) {
1214 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1215 << finalpath << " for " << name());
1216 preload = nullptr;
1217 } else {
1218 MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1219 wao->_final.push_back(make_shared<YODAT>(*preload));
1220 }
1221 }
1222 if ( !preload ) {
1223 wao->_final.push_back(make_shared<YODAT>(yao));
1224 wao->_final.back()->setPath(finalpath);
1225 }
1226
1227 // Then the raw filling yodas.
1228 string rawpath = "/RAW" + finalpath;
1229 preload = getPreload<YODAT>(rawpath);
1230 if ( preload ) {
1231 if ( !bookingCompatible(preload, yaop) ) {
1232 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1233 << rawpath << " for " << name());
1234 preload = nullptr;
1235 } else {
1236 MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1237 wao->_persistent.push_back(make_shared<YODAT>(*preload));
1238 }
1239 }
1240 if ( !preload ) {
1241 wao->_persistent.push_back(make_shared<YODAT>(yao));
1242 wao->_persistent.back()->setPath(rawpath);
1243 }
1244 }
1245 rivet_shared_ptr<WrapperT> ret(wao);
1246
1247 ret.get()->unsetActiveWeight();
1248 if ( _inFinalize() ) {
1249 // If booked in finalize() we assume it is the first time
1250 // finalize is run.
1251 ret.get()->pushToFinal();
1252 ret.get()->setActiveFinalWeightIdx(0);
1253 }
1254 _analysisobjects.push_back(ret);
1255
1256 return ret;
1257 }
1258
1259
1261 template <typename AO=MultiweightAOPtr>
1262 AO addAnalysisObject(const AO& aonew) {
1263 _checkBookInit();
1264
1265 for (const MultiweightAOPtr& ao : analysisObjects()) {
1266
1267 // Check AO base-name first
1268 ao.get()->setActiveWeightIdx(defaultWeightIndex());
1269 aonew.get()->setActiveWeightIdx(defaultWeightIndex());
1270 if (ao->path() != aonew->path()) continue;
1271
1272 // If base-name matches, check compatibility
1273 // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1274 AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1275 if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1276 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1277 << aonew->path() << " for " << name());
1278 throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1279 }
1280
1281 // Finally, check all weight variations
1282 for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1283 aoold.get()->setActiveWeightIdx(weightIdx);
1284 aonew.get()->setActiveWeightIdx(weightIdx);
1285 if (aoold->path() != aonew->path()) {
1286 MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1287 << aonew->path() << " for " << name());
1288 throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1289 }
1290 }
1291
1292 // They're fully compatible: bind and return
1293 aoold.get()->unsetActiveWeight();
1294 MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1295 return aoold;
1296 }
1297
1298 // No equivalent found
1299 MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1300 aonew.get()->unsetActiveWeight();
1301
1302 _analysisobjects.push_back(aonew);
1303 return aonew;
1304 }
1305
1307 void removeAnalysisObject(const std::string& path);
1308
1310 void removeAnalysisObject(const MultiweightAOPtr& ao);
1311
1312 // /// Get all data objects, for all analyses, from the AnalysisHandler
1313 // /// @todo Can we remove this? Why not call handler().getData()?
1314 // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1315
1316
1318 template <typename AO=MultiweightAOPtr>
1319 const AO getAnalysisObject(const std::string& aoname) const {
1320 for (const MultiweightAOPtr& ao : analysisObjects()) {
1321 ao.get()->setActiveWeightIdx(defaultWeightIndex());
1322 if (ao->path() == histoPath(aoname)) {
1323 // return dynamic_pointer_cast<AO>(ao);
1324 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1325 }
1326 }
1327 throw LookupError("Data object " + histoPath(aoname) + " not found");
1328 }
1329
1330
1331 // /// Get a data object from the histogram system
1332 // template <typename AO=YODA::AnalysisObject>
1333 // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
1334 // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1335 // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1336 // }
1337 // throw LookupError("Data object " + histoPath(name) + " not found");
1338 // }
1339
1340 // /// Get a data object from the histogram system (non-const)
1341 // template <typename AO=YODA::AnalysisObject>
1342 // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1343 // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1344 // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1345 // }
1346 // throw LookupError("Data object " + histoPath(name) + " not found");
1347 // }
1348
1349
1352 template <typename AO=MultiweightAOPtr>
1353 AO getAnalysisObject(const std::string& ananame,
1354 const std::string& aoname) {
1355 MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1356 // return dynamic_pointer_cast<AO>(ao);
1357 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1358 }
1359
1360
1361 // /// Get a named Histo1D object from the histogram system
1362 // const Histo1DPtr getHisto1D(const std::string& name) const {
1363 // return getAnalysisObject<Histo1D>(name);
1364 // }
1365
1366 // /// Get a named Histo1D object from the histogram system (non-const)
1367 // Histo1DPtr getHisto1D(const std::string& name) {
1368 // return getAnalysisObject<Histo1D>(name);
1369 // }
1370
1371 // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1372 // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1373 // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1374 // }
1375
1376 // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1377 // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1378 // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1379 // }
1380
1381
1382 // /// Get a named Histo2D object from the histogram system
1383 // const Histo2DPtr getHisto2D(const std::string& name) const {
1384 // return getAnalysisObject<Histo2D>(name);
1385 // }
1386
1387 // /// Get a named Histo2D object from the histogram system (non-const)
1388 // Histo2DPtr getHisto2D(const std::string& name) {
1389 // return getAnalysisObject<Histo2D>(name);
1390 // }
1391
1392 // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1393 // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1394 // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1395 // }
1396
1397 // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1398 // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1399 // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1400 // }
1401
1402
1403 // /// Get a named Profile1D object from the histogram system
1404 // const Profile1DPtr getProfile1D(const std::string& name) const {
1405 // return getAnalysisObject<Profile1D>(name);
1406 // }
1407
1408 // /// Get a named Profile1D object from the histogram system (non-const)
1409 // Profile1DPtr getProfile1D(const std::string& name) {
1410 // return getAnalysisObject<Profile1D>(name);
1411 // }
1412
1413 // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1414 // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1415 // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1416 // }
1417
1418 // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1419 // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1420 // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1421 // }
1422
1423
1424 // /// Get a named Profile2D object from the histogram system
1425 // const Profile2DPtr getProfile2D(const std::string& name) const {
1426 // return getAnalysisObject<Profile2D>(name);
1427 // }
1428
1429 // /// Get a named Profile2D object from the histogram system (non-const)
1430 // Profile2DPtr getProfile2D(const std::string& name) {
1431 // return getAnalysisObject<Profile2D>(name);
1432 // }
1433
1434 // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1435 // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1436 // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1437 // }
1438
1439 // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1440 // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1441 // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1442 // }
1443
1444
1445 // /// Get a named Scatter2D object from the histogram system
1446 // const Scatter2DPtr getScatter2D(const std::string& name) const {
1447 // return getAnalysisObject<Scatter2D>(name);
1448 // }
1449
1450 // /// Get a named Scatter2D object from the histogram system (non-const)
1451 // Scatter2DPtr getScatter2D(const std::string& name) {
1452 // return getAnalysisObject<Scatter2D>(name);
1453 // }
1454
1455 // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1456 // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1457 // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1458 // }
1459
1460 // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1461 // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1462 // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1463 // }
1464
1466
1467
1468 private:
1469
1471 string _defaultname;
1472
1474 unique_ptr<AnalysisInfo> _info;
1475
1478 vector<MultiweightAOPtr> _analysisobjects;
1479
1482 double _crossSection;
1483 bool _gotCrossSection;
1485
1487 AnalysisHandler* _analysishandler;
1488
1491 mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1492
1494 map<string, string> _options;
1495
1497 string _optstring;
1498
1499
1500 private:
1501
1504
1506 void _cacheRefData() const;
1507
1509
1510 };
1511
1512
1513 // // Template specialisation for literal character strings (which don't play well with stringstream)
1514 // template<>
1515 // inline std::string Analysis::getOption(std::string optname, const char* def) {
1516 // return getOption<std::string>(optname, def); //.c_str();
1517 // }
1518
1519
1520}
1521
1522
1523// Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1524#include "Rivet/AnalysisBuilder.hh"
1525
1526
1529
1532#define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1533
1536#define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias )
1537
1540#define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {}
1541
1542
1543
1548#define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1549
1554// #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1555#define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1556
1561#define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1562
1567#define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1568
1570
1571
1572#endif
The key class for coordination of Analysis objects and the event loop.
Definition: AnalysisHandler.hh:23
Holder of analysis metadata.
Definition: AnalysisInfo.hh:12
std::string refFile() const
Find the path to the reference-data file for this analysis.
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition: AnalysisInfo.hh:274
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
std::string getOption(std::string optname, const char *def)
Sane overload for literal character strings (which don't play well with stringstream)
Definition: Analysis.hh:720
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:75
T getOption(std::string optname, T def) const
Get an option for this analysis instance converted to a specific type.
Definition: Analysis.hh:732
double crossSection() const
Get the process cross-section in pb. Throws if this hasn't been set.
double crossSectionPerEvent() const
double crossSectionErrorPerEvent() const
std::string getOption(std::string optname, string def="") const
Get an option for this analysis instance as a string.
Definition: Analysis.hh:710
double sumW2() const
Get the sum of squared event weights seen (via the analysis handler).
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition: Analysis.hh:705
bool getOption(std::string optname, bool def) const
Get an option for this analysis instance converted to a bool.
Definition: Analysis.hh:758
const vector< MultiweightAOPtr > & analysisObjects() const
List of registered analysis data objects.
Definition: Analysis.hh:1153
double sumW() const
Get the sum of event weights seen (via the analysis handler).
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:350
double sumOfWeights() const
Alias.
Definition: Analysis.hh:382
size_t numEvents() const
Get the number of events seen (via the analysis handler).
Analysis(const std::string &name)
Constructor.
Analysis & operator=(const Analysis &)=delete
The assignment operator is private and mustdeleted, so it can never be called.
Log & getLog() const
Get a Log object based on the name() property of the calling analysis object.
double crossSectionError() const
Get the process cross-section error in pb. Throws if this hasn't been set.
void scale(const Histo1DPtr(&histos)[array_size], CounterAdapter factor)
Definition: Analysis.hh:996
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition: Analysis.hh:984
void scale(Histo1DPtr histo, CounterAdapter factor)
Multiplicatively scale the given histogram, histo, by factor factor.
void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
void normalize(const std::map< T, Histo2DPtr > &maps, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the histograms in map, maps, to area = norm.
Definition: Analysis.hh:1013
void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the given histogram, histo, to area = norm.
void barchart(Histo2DPtr h, Scatter3DPtr s, bool usefocus=false) const
void normalize(const std::vector< Histo2DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:1007
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:1019
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition: Analysis.hh:990
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition: CentralityProjection.hh:26
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
Logging system for controlled & formatted writing to stdout.
Definition: Logging.hh:10
void add(TPtr ao, CounterPtr cnt, pair< float, float > cent={0.0, 100.0})
Add a new percentile bin.
Definition: Percentile.hh:122
The Percentile class for centrality binning.
Definition: Percentile.hh:203
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:21
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition: AnalysisInfo.hh:158
const std::string & description() const
Get a full description of the analysis.
Definition: AnalysisInfo.hh:91
const std::string & warning() const
Any warning message.
Definition: AnalysisInfo.hh:150
const std::string & bibKey() const
BibTeX citation key for this article.
Definition: AnalysisInfo.hh:166
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:52
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition: AnalysisInfo.hh:176
const std::string & collider() const
Collider on which the experiment ran.
Definition: AnalysisInfo.hh:120
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:171
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:141
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:55
const std::string & summary() const
Get a short description of the analysis.
Definition: AnalysisInfo.hh:81
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition: AnalysisInfo.hh:110
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition: AnalysisInfo.hh:154
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition: AnalysisInfo.hh:112
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition: AnalysisInfo.hh:107
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition: AnalysisInfo.hh:135
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition: AnalysisInfo.hh:146
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition: AnalysisInfo.hh:100
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition: AnalysisInfo.hh:72
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:47
const std::string & spiresId() const
Definition: AnalysisInfo.hh:62
const std::string & year() const
When the original experimental analysis was published.
Definition: AnalysisInfo.hh:127
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:105
const std::string & writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition: AnalysisInfo.hh:162
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition: AnalysisInfo.hh:133
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:115
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:208
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition: AnalysisInfo.hh:213
void removeAnalysisObject(const std::string &path)
Unregister a data object from the histogram system (by name)
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition: Analysis.hh:1353
rivet_shared_ptr< Wrapper< YODAT > > registerAO(const YODAT &yao)
Register a new data object, optionally read in preloaded data.
Definition: Analysis.hh:1175
size_t defaultWeightIndex() const
Get the default/nominal weight index.
shared_ptr< YODAT > getPreload(string path) const
Get a preloaded YODA object.
Definition: Analysis.hh:1168
const AO getAnalysisObject(const std::string &aoname) const
Get a Rivet data object from the histogram system.
Definition: Analysis.hh:1319
void removeAnalysisObject(const MultiweightAOPtr &ao)
Unregister a data object from the histogram system (by pointer)
AO addAnalysisObject(const AO &aonew)
Register a data object in the histogram system.
Definition: Analysis.hh:1262
bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const
Check if analysis is compatible with the provided beam particle IDs and energies.
bool isCompatible(const ParticlePair &beams) const
Check if analysis is compatible with the provided beam particle IDs and energies.
bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const
Check if sqrtS is compatible with provided value.
bool isCompatible(const PdgIdPair &beams, const std::pair< double, double > &energies) const
Check if analysis is compatible with the provided beam particle IDs and energies.
Percentile< T > bookPercentile(string projName, vector< pair< float, float > > centralityBins, vector< tuple< int, int, int > > ref)
Book a Percentile wrapper around AnalysisObjects.
Definition: Analysis.hh:805
const CentralityProjection & declareCentrality(const SingleValueProjection &proj, string calAnaName, string calHistName, const string projName, bool increasing=false)
Book a CentralityProjection.
CounterPtr & book(CounterPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
Histo1DPtr & book(Histo1DPtr &, const std::string &name)
Book a 1D histogram, using the binnings in the reference data histogram.
Histo1DPtr & book(Histo1DPtr &, const std::string &name, const std::vector< double > &binedges)
Book a 1D histogram with non-uniform bins defined by the vector of bin edges binedges .
Histo1DPtr & book(Histo1DPtr &, const std::string &name, size_t nbins, double lower, double upper)
Book a 1D histogram with nbins uniformly distributed across the range lower - upper .
Histo1DPtr & book(Histo1DPtr &, const std::string &name, const Scatter2D &refscatter)
Book a 1D histogram with binning from a reference scatter.
Histo1DPtr & book(Histo1DPtr &, const std::string &name, const std::initializer_list< double > &binedges)
Book a 1D histogram with non-uniform bins defined by the vector of bin edges binedges .
Histo1DPtr & book(Histo1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Histo2DPtr & book(Histo2DPtr &, const std::string &name)
Book a 2D histogram, using the binnings in the reference data histogram.
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const std::vector< double > &xbinedges, const std::vector< double > &ybinedges)
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const Scatter3D &refscatter)
Book a 2D histogram with binning from a reference scatter.
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const std::initializer_list< double > &xbinedges, const std::initializer_list< double > &ybinedges)
Histo2DPtr & book(Histo2DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Histo2DPtr & book(Histo2DPtr &, const std::string &name, size_t nxbins, double xlower, double xupper, size_t nybins, double ylower, double yupper)
const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Get the internal histogram name for given d, x and y (cf. HepData)
const std::string histoDir() const
Get the canonical histogram "directory" path for this analysis.
const std::string histoPath(const std::string &hname) const
Get the canonical histogram path for the named histogram in this analysis.
const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Get the canonical histogram path for the numbered histogram in this analysis.
virtual void finalize()
Definition: Analysis.hh:102
virtual void analyze(const Event &event)=0
virtual void init()
Definition: Analysis.hh:89
void integrate(Histo1DPtr h, Scatter2DPtr s) const
void divide(const YODA::Histo2D &h1, const YODA::Histo2D &h2, Scatter3DPtr s) const
void asymm(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
void scale(const CounterPtr(&cnts)[array_size], CounterAdapter factor)
Definition: Analysis.hh:950
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition: Analysis.hh:938
void scale(CounterPtr cnt, CounterAdapter factor)
Multiplicatively scale the given counter, cnt, by factor factor.
void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
void normalize(const std::map< T, Histo1DPtr > &maps, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the histograms in map, maps, to area = norm.
Definition: Analysis.hh:968
void divide(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the given histogram, histo, to area = norm.
void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const
void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
void integrate(const Histo1D &h, Scatter2DPtr s) const
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:962
void divide(const YODA::Profile1D &p1, const YODA::Profile1D &p2, Scatter2DPtr s) const
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:974
void divide(const YODA::Profile2D &p1, const YODA::Profile2D &p2, Scatter3DPtr s) const
void efficiency(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
void scale(const std::map< T, CounterPtr > &maps, CounterAdapter factor)
Iteratively scale the counters in the map maps, by factor factor.
Definition: Analysis.hh:944
void divide(const YODA::Counter &c1, const YODA::Counter &c2, Scatter1DPtr s) const
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition: Analysis.hh:227
virtual bool reentrant() const
Does this analysis have a reentrant finalize()?
Definition: Analysis.hh:247
virtual std::string collider() const
Collider on which the experiment ran.
Definition: Analysis.hh:193
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition: Analysis.hh:203
const AnalysisInfo & info() const
Get the actual AnalysisInfo object in which all this metadata is stored.
Definition: Analysis.hh:115
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition: Analysis.hh:142
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition: Analysis.hh:283
virtual const std::vector< std::string > & keywords() const
Get vector of analysis keywords.
Definition: Analysis.hh:288
virtual double luminosity() const
The integrated luminosity in inverse picobarn.
Definition: Analysis.hh:207
virtual std::string writerDoublePrecision() const
Positive filterin regex for setting double precision in Writer.
Definition: Analysis.hh:268
AnalysisInfo & info()
Definition: Analysis.hh:301
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition: Analysis.hh:183
virtual std::string year() const
When the original experimental analysis was published.
Definition: Analysis.hh:198
virtual void setRefDataName(const std::string &ref_data="")
Set name of reference data file, which could be different from plugin name.
Definition: Analysis.hh:137
virtual std::string summary() const
Get a short description of the analysis.
Definition: Analysis.hh:164
virtual std::string description() const
Get a full description of the analysis.
Definition: Analysis.hh:174
virtual std::vector< std::string > validation() const
make-style commands for validating this analysis.
Definition: Analysis.hh:242
virtual std::vector< std::string > authors() const
Names & emails of paper/analysis authors.
Definition: Analysis.hh:155
virtual std::string refFile() const
Location of reference data YODA file.
Definition: Analysis.hh:253
virtual const std::vector< PdgIdPair > & requiredBeams() const
Return the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:273
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition: Analysis.hh:293
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition: Analysis.hh:212
virtual std::vector< std::string > todos() const
Any work to be done on this analysis.
Definition: Analysis.hh:237
virtual std::string refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition: Analysis.hh:263
virtual std::string spiresId() const
Get the SPIRES ID code for this analysis (~deprecated).
Definition: Analysis.hh:147
virtual std::string refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition: Analysis.hh:258
virtual std::string warning() const
A warning message from the info file, if there is one.
Definition: Analysis.hh:232
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:277
virtual std::string bibKey() const
BibTeX citation key for this article.
Definition: Analysis.hh:217
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition: Analysis.hh:222
virtual std::string name() const
Get the name of the analysis.
Definition: Analysis.hh:127
virtual std::string getRefDataName() const
Get name of reference data file, which could be different from plugin name.
Definition: Analysis.hh:132
virtual std::string experiment() const
Experiment which performed and published this analysis.
Definition: Analysis.hh:188
Profile1DPtr & book(Profile1DPtr &, const std::string &name)
Book a 1D profile histogram, using the binnings in the reference data histogram.
Profile1DPtr & book(Profile1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Profile1DPtr & book(Profile1DPtr &, const std::string &name, const std::vector< double > &binedges)
Book a 1D profile histogram with non-uniform bins defined by the vector of bin edges binedges .
Profile1DPtr & book(Profile1DPtr &, const std::string &name, const std::initializer_list< double > &binedges)
Book a 1D profile histogram with non-uniform bins defined by the vector of bin edges binedges .
Profile1DPtr & book(Profile1DPtr &, const std::string &name, const Scatter2D &refscatter)
Book a 1D profile histogram with binning from a reference scatter.
Profile1DPtr & book(Profile1DPtr &, const std::string &name, size_t nbins, double lower, double upper)
Book a 1D profile histogram with nbins uniformly distributed across the range lower - upper .
Profile2DPtr & book(Profile2DPtr &, const std::string &name, const std::vector< double > &xbinedges, const std::vector< double > &ybinedges)
Profile2DPtr & book(Profile2DPtr &, const std::string &name, const std::initializer_list< double > &xbinedges, const std::initializer_list< double > &ybinedges)
Profile2DPtr & book(Profile2DPtr &, const std::string &name, size_t nxbins, double xlower, double xupper, size_t nybins, double ylower, double yupper)
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition: Analysis.hh:440
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:417
const T & refData(const string &hname) const
Definition: Analysis.hh:426
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
bool merging() const
Check if we are running rivet-merge.
Definition: Analysis.hh:322
double sqrtS() const
Centre of mass energy for this run.
const ParticlePair & beams() const
Incoming beams for this run.
Scatter2DPtr & book(Scatter2DPtr &s2d, const string &hname, bool copy_pts=false)
Book a 2-dimensional data point set with the given name.
Scatter2DPtr & book(Scatter2DPtr &s2d, const string &hname, const Scatter2D &refscatter)
Book a 2-dimensional data point set with x-points from an existing scatter and a new path.
Scatter2DPtr & book(Scatter2DPtr &s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts=false)
Book a 2-dimensional data point set, using the binnings in the reference data histogram.
Scatter2DPtr & book(Scatter2DPtr &s2d, const string &hname, size_t npts, double lower, double upper)
Book a 2-dimensional data point set with equally spaced x-points in a range.
Scatter2DPtr & book(Scatter2DPtr &s2d, const string &hname, const std::vector< double > &binedges)
Book a 2-dimensional data point set based on provided contiguous "bin edges".
Scatter3DPtr & book(Scatter3DPtr &s3d, const std::string &hname, size_t xnpts, double xlower, double xupper, size_t ynpts, double ylower, double yupper)
Book a 3-dimensional data point set with equally spaced x-points in a range.
Scatter3DPtr & book(Scatter3DPtr &s3d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false)
Book a 3-dimensional data point set, using the binnings in the reference data histogram.
Scatter3DPtr & book(Scatter3DPtr &s3d, const std::string &hname, const Scatter3D &refscatter)
Book a 3-dimensional data point set with x-points from an existing scatter and a new path.
Scatter3DPtr & book(Scatter3DPtr &s3d, const std::string &hname, const std::vector< double > &xbinedges, const std::vector< double > &ybinedges)
Book a 3-dimensional data point set based on provided contiguous "bin edges".
Scatter3DPtr & book(Scatter3DPtr &s3d, const std::string &hname, bool copy_pts=false)
Book a 3-dimensional data point set with the given name.
bool bookingCompatible(TPtr a, TPtr b)
Definition: RivetYODA.hh:849
#define MSG_TRACE(x)
Lowest-level, most verbose messaging, using MSG_LVL.
Definition: Logging.hh:193
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition: Logging.hh:200
#define MSG_ERROR(x)
Highest level messaging for serious problems, using MSG_LVL.
Definition: Logging.hh:202
string toLower(const string &s)
Convert a string to lower-case.
Definition: Utils.hh:137
Definition: MC_Cent_pPb.hh:10
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition: Particle.hh:42
Error Exception
Rivet::Exception is a synonym for Rivet::Error.
Definition: Exceptions.hh:18
Error relating to looking up analysis objects in the register.
Definition: Exceptions.hh:61
Error for read failures.
Definition: Exceptions.hh:72
Error specialisation for where the problem is between the chair and the computer.
Definition: Exceptions.hh:55