Rivet: /Users/chrisg/software/rivet/include/Rivet/Analysis.hh Source File

| Rivet 3.1.9

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 "Rivet/Tools/RivetPaths.hh"
21#include <tuple>
22
23
26#define vetoEvent \
27 do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0)
28
29
30namespace Rivet {
31
32
33 // Convenience for analysis writers
34 using std::cout;
35 using std::cerr;
36 using std::endl;
37 using std::tuple;
38 using std::stringstream;
39 using std::swap;
40 using std::numeric_limits;
41
42
43 // Forward declaration
44 class AnalysisHandler;
45
46
65 class Analysis : public ProjectionApplier {
66 public:
67
69 friend class AnalysisHandler;
70
71
73 Analysis(const std::string& name);
74
76 virtual ~Analysis() {}
77
79 Analysis& operator=(const Analysis&) = delete;
80
81
82 public:
83
86
90 virtual void init() { }
91
96 virtual void analyze(const Event& event) = 0;
97
103 virtual void finalize() { }
104
106
107
108 public:
109
114
116 void loadInfo() { info().parseInfoFile(); }
117
119 const AnalysisInfo& info() const {
120 assert(_info && "No AnalysisInfo object :O");
121 return *_info;
122 }
123
131 virtual std::string name() const {
132 return ( (info().name().empty()) ? _defaultname : info().name() ) + _optstring;
133 }
134
136 virtual std::string getRefDataName() const {
137 return (info().getRefDataName().empty()) ? _defaultname : info().getRefDataName();
138 }
139
141 virtual void setRefDataName(const std::string& ref_data="") {
142 info().setRefDataName(!ref_data.empty() ? ref_data : name());
143 }
144
149 std::string analysisDataPath(const std::string& extn, const std::string& suffix="") {
150 string filename = name() + (suffix.empty() ? "" : "-") + suffix + "." + extn;
151 return findAnalysisDataFile(filename);
152 }
153
155 virtual std::string inspireId() const {
156 return info().inspireId();
157 }
158
160 virtual std::string spiresId() const {
161 return info().spiresId();
162 }
163
168 virtual std::vector<std::string> authors() const {
169 return info().authors();
170 }
171
177 virtual std::string summary() const {
178 return info().summary();
179 }
180
187 virtual std::string description() const {
188 return info().description();
189 }
190
196 virtual std::string runInfo() const {
197 return info().runInfo();
198 }
199
201 virtual std::string experiment() const {
202 return info().experiment();
203 }
204
206 virtual std::string collider() const {
207 return info().collider();
208 }
209
211 virtual std::string year() const {
212 return info().year();
213 }
214
216 virtual double luminosityfb() const {
217 return info().luminosityfb();
218 }
220 virtual double luminosity() const {
221 return info().luminosity();
222 }
223
225 virtual std::vector<std::string> references() const {
226 return info().references();
227 }
228
230 virtual std::string bibKey() const {
231 return info().bibKey();
232 }
233
235 virtual std::string bibTeX() const {
236 return info().bibTeX();
237 }
238
240 virtual std::string status() const {
241 return (info().status().empty()) ? "UNVALIDATED" : info().status();
242 }
243
245 virtual std::string warning() const {
246 return info().warning();
247 }
248
250 virtual std::vector<std::string> todos() const {
251 return info().todos();
252 }
253
255 virtual std::vector<std::string> validation() const {
256 return info().validation();
257 }
258
260 virtual bool reentrant() const {
261 return info().reentrant();
262 }
263
264
266 virtual std::string refFile() const {
267 return info().refFile();
268 }
269
271 virtual std::string refMatch() const {
272 return info().refMatch();
273 }
274
276 virtual std::string refUnmatch() const {
277 return info().refUnmatch();
278 }
279
281 virtual std::string writerDoublePrecision() const {
282 return info().writerDoublePrecision();
283 }
284
286 virtual const std::vector<PdgIdPair>& requiredBeams() const {
287 return info().beams();
288 }
290 virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
291 info().setBeams(requiredBeams);
292 return *this;
293 }
294
296 virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
297 return info().energies();
298 }
299
301 virtual const std::vector<std::string> & keywords() const {
302 return info().keywords();
303 }
304
306 virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
307 info().setEnergies(requiredEnergies);
308 return *this;
309 }
310
311
314 AnalysisInfo& info() {
315 assert(_info && "No AnalysisInfo object :O");
316 return *_info;
317 }
318
320
321
324
326 const ParticlePair& beams() const;
327
329 const PdgIdPair beamIds() const;
330
332 double sqrtS() const;
333
335 bool merging() const {
336 return sqrtS() <= 0.0;
337 }
338
340
341
347
349 bool isCompatible(const ParticlePair& beams) const;
350
352 bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
353
355 bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
356
358 bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const;
359
361
363 AnalysisHandler& handler() const { return *_analysishandler; }
364
365
366 protected:
367
369 Log& getLog() const;
370
372 double crossSection() const;
373
376 double crossSectionPerEvent() const;
377
379 double crossSectionError() const;
380
383 double crossSectionErrorPerEvent() const;
384
388 size_t numEvents() const;
389
393 double sumW() const;
395 double sumOfWeights() const { return sumW(); }
396
400 double sumW2() const;
401
402
403 protected:
404
410
412 const std::string histoDir() const;
413
415 const std::string histoPath(const std::string& hname) const;
416
418 const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
419
421 const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
422
424
425
428
430 const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
431 _cacheRefData();
432 return _refdata;
433 }
434
435
438 template <typename T=YODA::Scatter2D>
439 const T& refData(const string& hname) const {
440 _cacheRefData();
441 MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
442 if (!_refdata[hname]) {
443 MSG_ERROR("Can't find reference histogram " << hname);
444 throw Exception("Reference data " + hname + " not found.");
445 }
446 return dynamic_cast<T&>(*_refdata[hname]);
447 }
448
449
452 template <typename T=YODA::Scatter2D>
453 const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
454 const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
455 return refData<T>(hname);
456 }
457
459
460
466
468 CounterPtr& book(CounterPtr&, const std::string& name);
469
473 CounterPtr& book(CounterPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
474
476
477
480
482 Histo1DPtr& book(Histo1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
483
485 Histo1DPtr& book(Histo1DPtr&, const std::string& name, const std::vector<double>& binedges);
486
488 Histo1DPtr& book(Histo1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
489
491 Histo1DPtr& book(Histo1DPtr&, const std::string& name, const Scatter2D& refscatter);
492
494 Histo1DPtr& book(Histo1DPtr&, const std::string& name);
495
499 Histo1DPtr& book(Histo1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
500
502
503
506
510 Histo2DPtr& book(Histo2DPtr&, const std::string& name,
511 size_t nxbins, double xlower, double xupper,
512 size_t nybins, double ylower, double yupper);
513
516 Histo2DPtr& book(Histo2DPtr&, const std::string& name,
517 const std::vector<double>& xbinedges,
518 const std::vector<double>& ybinedges);
519
522 Histo2DPtr& book(Histo2DPtr&, const std::string& name,
523 const std::initializer_list<double>& xbinedges,
524 const std::initializer_list<double>& ybinedges);
525
527 Histo2DPtr& book(Histo2DPtr&, const std::string& name,
528 const Scatter3D& refscatter);
529
531 Histo2DPtr& book(Histo2DPtr&, const std::string& name);
532
536 Histo2DPtr& book(Histo2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
537
539
540
543
545 Profile1DPtr& book(Profile1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
546
548 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::vector<double>& binedges);
549
551 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
552
554 Profile1DPtr& book(Profile1DPtr&, const std::string& name, const Scatter2D& refscatter);
555
557 Profile1DPtr& book(Profile1DPtr&, const std::string& name);
558
562 Profile1DPtr& book(Profile1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
563
565
566
569
573 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
574 size_t nxbins, double xlower, double xupper,
575 size_t nybins, double ylower, double yupper);
576
579 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
580 const std::vector<double>& xbinedges,
581 const std::vector<double>& ybinedges);
582
585 Profile2DPtr& book(Profile2DPtr&, const std::string& name,
586 const std::initializer_list<double>& xbinedges,
587 const std::initializer_list<double>& ybinedges);
588
590
591 // /// Book a 2D profile histogram with binning from a reference scatter.
592 // Profile2DPtr& book(const Profile2DPtr&, const std::string& name,
593 // const Scatter3D& refscatter);
594
595 // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
596 // Profile2DPtr& book(const Profile2DPtr&, const std::string& name);
597
598 // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
599 // ///
600 // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
601 // Profile2DPtr& book(const Profile2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
602
604
605
608
615 Scatter1DPtr& book(Scatter1DPtr& s1d, const string& hname);
616
625 Scatter1DPtr& book(Scatter1DPtr& s1d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
626
628 Scatter1DPtr& book(Scatter1DPtr& s1d, const string& hname, const Scatter1D& refscatter);
629
631
632
635
646 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, bool copy_pts=false);
647
658 Scatter2DPtr& book(Scatter2DPtr& s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts=false);
659
663 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, size_t npts, double lower, double upper);
664
668 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const std::vector<double>& binedges);
669
671 Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const Scatter2D& refscatter);
672
674
675
678
689 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, bool copy_pts=false);
690
701 Scatter3DPtr& book(Scatter3DPtr& s3d, unsigned int datasetId, unsigned int xAxisId,
702 unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
703
707 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
708 size_t xnpts, double xlower, double xupper,
709 size_t ynpts, double ylower, double yupper);
710
714 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
715 const std::vector<double>& xbinedges,
716 const std::vector<double>& ybinedges);
717
719 Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, const Scatter3D& refscatter);
720
722
723
724 public:
725
729 virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
730 (void) yao;
731 }
732
737 virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
738 (void) raos;
739 (void) iW;
740 }
741
743
744
746 const std::map<std::string,std::string>& options() const {
747 return _options;
748 }
749
751 std::string getOption(std::string optname, string def="") const {
752 if ( _options.find(optname) != _options.end() )
753 return _options.find(optname)->second;
754 return def;
755 }
756
761 std::string getOption(std::string optname, const char* def) {
762 return getOption<std::string>(optname, def);
763 }
764
772 template<typename T>
773 T getOption(std::string optname, T def) const {
774 if (_options.find(optname) == _options.end()) return def;
775 std::stringstream ss;
776 ss.exceptions(std::ios::failbit);
777 T ret;
778 ss << _options.find(optname)->second;
779 try {
780 ss >> ret;
781 } catch (...) {
782 throw ReadError("Could not read user-provided option into requested type");
783 }
784 return ret;
785 }
786
797 // template<>
798 // bool getOption<bool>(std::string optname, bool def) const {
799 bool getOption(std::string optname, bool def) const {
800 if (_options.find(optname) == _options.end()) return def;
801 const std::string val = getOption(optname);
802 const std::string lval = toLower(val);
803 if (lval.empty()) return false;
804 if (lval == "true" || lval == "yes" || lval == "on") return true;
805 if (lval == "false" || lval == "no" || lval == "off") return false;
806 return bool(getOption<int>(optname, 0));
807 }
808
810
811
814
831 const CentralityProjection&
832 declareCentrality(const SingleValueProjection &proj,
833 string calAnaName, string calHistName,
834 const string projName, bool increasing=false);
835
836
845 template <class T>
846 Percentile<T> bookPercentile(string projName,
847 vector<pair<float, float> > centralityBins,
848 vector<tuple<int, int, int> > ref) {
849
850 typedef typename ReferenceTraits<T>::RefT RefT;
851 typedef rivet_shared_ptr<Wrapper<T>> WrapT;
852
853 Percentile<T> pctl(this, projName);
854
855 const int nCent = centralityBins.size();
856 for (int iCent = 0; iCent < nCent; ++iCent) {
857 const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
858 std::get<1>(ref[iCent]),
859 std::get<2>(ref[iCent]));
860 const RefT & refscatter = refData<RefT>(axisCode);
861
862 WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
863 wtf = addAnalysisObject(wtf);
864
865 CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
866 cnt = addAnalysisObject(cnt);
867
868 pctl.add(wtf, cnt, centralityBins[iCent]);
869 }
870 return pctl;
871 }
872
873
874 // /// @brief Book Percentile wrappers around AnalysisObjects.
875 // ///
876 // /// Based on a previously registered CentralityProjection named @a
877 // /// projName book one (or several) AnalysisObject(s) named
878 // /// according to @a ref where the x-axis will be filled according
879 // /// to the percentile output(s) of the @projName.
880 // ///
881 // /// @todo Convert to just be called book() cf. others
882 // template <class T>
883 // PercentileXaxis<T> bookPercentileXaxis(string projName,
884 // tuple<int, int, int> ref) {
885
886 // typedef typename ReferenceTraits<T>::RefT RefT;
887 // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
888
889 // PercentileXaxis<T> pctl(this, projName);
890
891 // const string axisCode = mkAxisCode(std::get<0>(ref),
892 // std::get<1>(ref),
893 // std::get<2>(ref));
894 // const RefT & refscatter = refData<RefT>(axisCode);
895
896 // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
897 // wtf = addAnalysisObject(wtf);
898
899 // CounterPtr cnt(_weightNames(), Counter());
900 // cnt = addAnalysisObject(cnt);
901
902 // pctl.add(wtf, cnt);
903 // return pctl;
904 // }
905
907
908
909 private:
910
911 // Functions that have to be defined in the .cc file to avoid circular #includes
912
914 vector<string> _weightNames() const;
915
917 YODA::AnalysisObjectPtr _getPreload(string name) const;
918
920 MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
921
923 void _checkBookInit() const;
924
926 bool _inInit() const;
927
929 bool _inFinalize() const;
930
932 template <typename YODAT>
933 void _setWriterPrecision(const string& path, YODAT& yao);
934
935
936 private:
937
939 class CounterAdapter {
940 public:
941
942 CounterAdapter(double x) : x_(x) {}
943
944 CounterAdapter(const YODA::Counter & c) : x_(c.val()) {}
945
946 CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
947 assert( s.numPoints() == 1 || "Can only scale by a single value.");
948 }
949
950 operator double() const { return x_; }
951
952 private:
953 double x_;
954
955 };
956
957
958 public:
959
960 double dbl(double x) { return x; }
961 double dbl(const YODA::Counter & c) { return c.val(); }
962 double dbl(const YODA::Scatter1D & s) {
963 assert( s.numPoints() == 1 );
964 return s.points()[0].x();
965 }
966
967
972
974 void scale(CounterPtr cnt, CounterAdapter factor);
975
979 void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
980 for (auto& c : cnts) scale(c, factor);
981 }
982
984 template<typename T>
985 void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
986 for (auto& m : maps) scale(m.second, factor);
987 }
988
990 template <std::size_t array_size>
991 void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
992 // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
993 for (auto& c : cnts) scale(c, factor);
994 }
995
996
998 void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
999
1003 void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
1004 for (auto& h : histos) normalize(h, norm, includeoverflows);
1005 }
1006
1008 template<typename T>
1009 void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
1010 for (auto& m : maps) normalize(m.second, norm, includeoverflows);
1011 }
1012
1014 template <std::size_t array_size>
1015 void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
1016 for (auto& h : histos) normalize(h, norm, includeoverflows);
1017 }
1018
1020 void scale(Histo1DPtr histo, CounterAdapter factor);
1021
1025 void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
1026 for (auto& h : histos) scale(h, factor);
1027 }
1028
1030 template<typename T>
1031 void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
1032 for (auto& m : maps) scale(m.second, factor);
1033 }
1034
1036 template <std::size_t array_size>
1037 void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
1038 for (auto& h : histos) scale(h, factor);
1039 }
1040
1041
1043 void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
1044
1048 void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
1049 for (auto& h : histos) normalize(h, norm, includeoverflows);
1050 }
1051
1053 template<typename T>
1054 void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
1055 for (auto& m : maps) normalize(m.second, norm, includeoverflows);
1056 }
1057
1059 template <std::size_t array_size>
1060 void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
1061 for (auto& h : histos) normalize(h, norm, includeoverflows);
1062 }
1063
1065 void scale(Histo2DPtr histo, CounterAdapter factor);
1066
1070 void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
1071 for (auto& h : histos) scale(h, factor);
1072 }
1073
1075 template<typename T>
1076 void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
1077 for (auto& m : maps) scale(m.second, factor);
1078 }
1079
1081 template <std::size_t array_size>
1082 void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
1083 for (auto& h : histos) scale(h, factor);
1084 }
1085
1086
1088
1089
1093 void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const;
1094
1098 void barchart(Histo2DPtr h, Scatter3DPtr s, bool usefocus=false) const;
1099
1100
1104 void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
1105
1109 void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
1110
1111
1115 void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1116
1120 void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1121
1122
1126 void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1127
1131 void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1132
1133
1137 void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1138
1142 void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1143
1144
1148 void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1149
1153 void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1154
1155
1159 void efficiency(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
1160
1164 void efficiency(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
1165
1166
1170 void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1171
1175 void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1176
1177
1181 void efficiency(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1182
1186 void efficiency(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1187
1188
1192 void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1193
1197 void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1198
1199
1203 void asymm(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1204
1208 void asymm(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1209
1210
1214 void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1215
1219 void integrate(const Histo1D& h, Scatter2DPtr s) const;
1220
1222
1223
1224 public:
1225
1227 const vector<MultiweightAOPtr>& analysisObjects() const {
1228 return _analysisobjects;
1229 }
1230
1231
1232 protected:
1233
1236
1238 size_t defaultWeightIndex() const;
1239
1241 template <typename YODAT>
1242 shared_ptr<YODAT> getPreload(string path) const {
1243 return dynamic_pointer_cast<YODAT>(_getPreload(path));
1244 }
1245
1246
1248 template <typename YODAT>
1249 rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT& yao) {
1250 typedef Wrapper<YODAT> WrapperT;
1251 typedef shared_ptr<YODAT> YODAPtrT;
1252 typedef rivet_shared_ptr<WrapperT> RAOT;
1253
1254 if ( !_inInit() && !_inFinalize() ) {
1255 MSG_ERROR("Can't book objects outside of init() or finalize()");
1256 throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1257 }
1258
1259 // First check that we haven't booked this before.
1260 // This is allowed when booking in finalize: just warn in that case.
1261 // If in init(), throw an exception: it's 99.9% never going to be intentional.
1262 for (auto& waold : analysisObjects()) {
1263 if ( yao.path() == waold.get()->basePath() ) {
1264 const string msg = "Found double-booking of " + yao.path() + " in " + name();
1265 if ( _inInit() ) {
1266 MSG_ERROR(msg);
1267 throw LookupError(msg);
1268 } else {
1269 MSG_WARNING(msg + ". Keeping previous booking");
1270 }
1271 return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1272 }
1273 }
1274
1275 shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1276 wao->_basePath = yao.path();
1277 YODAPtrT yaop = make_shared<YODAT>(yao);
1278
1279 for (const string& weightname : _weightNames()) {
1280 // Create two YODA objects for each weight. Copy from
1281 // preloaded YODAs if present. First the finalized yoda:
1282 string finalpath = yao.path();
1283 if ( weightname != "" ) finalpath += "[" + weightname + "]";
1284 YODAPtrT preload = getPreload<YODAT>(finalpath);
1285 if ( preload ) {
1286 if ( !bookingCompatible(preload, yaop) ) {
1288 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1289 << finalpath << " for " << name());
1290 preload = nullptr;
1291 } else {
1292 MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1293 wao->_final.push_back(make_shared<YODAT>(*preload));
1294 }
1295 }
1296 if ( !preload ) {
1297 wao->_final.push_back(make_shared<YODAT>(yao));
1298 wao->_final.back()->setPath(finalpath);
1299 }
1300
1301 // Then the raw filling yodas.
1302 string rawpath = "/RAW" + finalpath;
1303 preload = getPreload<YODAT>(rawpath);
1304 if ( preload ) {
1305 if ( !bookingCompatible(preload, yaop) ) {
1306 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1307 << rawpath << " for " << name());
1308 preload = nullptr;
1309 } else {
1310 MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1311 wao->_persistent.push_back(make_shared<YODAT>(*preload));
1312 }
1313 }
1314 if ( !preload ) {
1315 wao->_persistent.push_back(make_shared<YODAT>(yao));
1316 wao->_persistent.back()->setPath(rawpath);
1317 }
1318 }
1319 rivet_shared_ptr<WrapperT> ret(wao);
1320
1321 ret.get()->unsetActiveWeight();
1322 if ( _inFinalize() ) {
1323 // If booked in finalize() we assume it is the first time
1324 // finalize is run.
1325 ret.get()->pushToFinal();
1326 ret.get()->setActiveFinalWeightIdx(0);
1327 }
1328 _analysisobjects.push_back(ret);
1329
1330 return ret;
1331 }
1332
1333
1335 template <typename AO=MultiweightAOPtr>
1336 AO addAnalysisObject(const AO& aonew) {
1337 _checkBookInit();
1338
1339 for (const MultiweightAOPtr& ao : analysisObjects()) {
1340
1341 // Check AO base-name first
1342 ao.get()->setActiveWeightIdx(defaultWeightIndex());
1343 aonew.get()->setActiveWeightIdx(defaultWeightIndex());
1344 if (ao->path() != aonew->path()) continue;
1345
1346 // If base-name matches, check compatibility
1347 // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1348 AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1349 if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1350 MSG_WARNING("Found incompatible pre-existing data object with same base path "
1351 << aonew->path() << " for " << name());
1352 throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1353 }
1354
1355 // Finally, check all weight variations
1356 for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1357 aoold.get()->setActiveWeightIdx(weightIdx);
1358 aonew.get()->setActiveWeightIdx(weightIdx);
1359 if (aoold->path() != aonew->path()) {
1360 MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1361 << aonew->path() << " for " << name());
1362 throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1363 }
1364 }
1365
1366 // They're fully compatible: bind and return
1367 aoold.get()->unsetActiveWeight();
1368 MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1369 return aoold;
1370 }
1371
1372 // No equivalent found
1373 MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1374 aonew.get()->unsetActiveWeight();
1375
1376 _analysisobjects.push_back(aonew);
1377 return aonew;
1378 }
1379
1381 void removeAnalysisObject(const std::string& path);
1382
1384 void removeAnalysisObject(const MultiweightAOPtr& ao);
1385
1386 // /// Get all data objects, for all analyses, from the AnalysisHandler
1387 // /// @todo Can we remove this? Why not call handler().getData()?
1388 // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1389
1390
1392 template <typename AO=MultiweightAOPtr>
1393 const AO getAnalysisObject(const std::string& aoname) const {
1394 for (const MultiweightAOPtr& ao : analysisObjects()) {
1395 ao.get()->setActiveWeightIdx(defaultWeightIndex());
1396 if (ao->path() == histoPath(aoname)) {
1397 // return dynamic_pointer_cast<AO>(ao);
1398 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1399 }
1400 }
1401 throw LookupError("Data object " + histoPath(aoname) + " not found");
1402 }
1403
1404
1405 // /// Get a data object from the histogram system
1406 // template <typename AO=YODA::AnalysisObject>
1407 // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
1408 // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1409 // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1410 // }
1411 // throw LookupError("Data object " + histoPath(name) + " not found");
1412 // }
1413
1414 // /// Get a data object from the histogram system (non-const)
1415 // template <typename AO=YODA::AnalysisObject>
1416 // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1417 // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1418 // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1419 // }
1420 // throw LookupError("Data object " + histoPath(name) + " not found");
1421 // }
1422
1423
1426 template <typename AO=MultiweightAOPtr>
1427 AO getAnalysisObject(const std::string& ananame,
1428 const std::string& aoname) {
1429 MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1430 // return dynamic_pointer_cast<AO>(ao);
1431 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1432 }
1433
1434
1435 // /// Get a named Histo1D object from the histogram system
1436 // const Histo1DPtr getHisto1D(const std::string& name) const {
1437 // return getAnalysisObject<Histo1D>(name);
1438 // }
1439
1440 // /// Get a named Histo1D object from the histogram system (non-const)
1441 // Histo1DPtr getHisto1D(const std::string& name) {
1442 // return getAnalysisObject<Histo1D>(name);
1443 // }
1444
1445 // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1446 // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1447 // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1448 // }
1449
1450 // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1451 // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1452 // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1453 // }
1454
1455
1456 // /// Get a named Histo2D object from the histogram system
1457 // const Histo2DPtr getHisto2D(const std::string& name) const {
1458 // return getAnalysisObject<Histo2D>(name);
1459 // }
1460
1461 // /// Get a named Histo2D object from the histogram system (non-const)
1462 // Histo2DPtr getHisto2D(const std::string& name) {
1463 // return getAnalysisObject<Histo2D>(name);
1464 // }
1465
1466 // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1467 // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1468 // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1469 // }
1470
1471 // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1472 // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1473 // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1474 // }
1475
1476
1477 // /// Get a named Profile1D object from the histogram system
1478 // const Profile1DPtr getProfile1D(const std::string& name) const {
1479 // return getAnalysisObject<Profile1D>(name);
1480 // }
1481
1482 // /// Get a named Profile1D object from the histogram system (non-const)
1483 // Profile1DPtr getProfile1D(const std::string& name) {
1484 // return getAnalysisObject<Profile1D>(name);
1485 // }
1486
1487 // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1488 // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1489 // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1490 // }
1491
1492 // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1493 // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1494 // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1495 // }
1496
1497
1498 // /// Get a named Profile2D object from the histogram system
1499 // const Profile2DPtr getProfile2D(const std::string& name) const {
1500 // return getAnalysisObject<Profile2D>(name);
1501 // }
1502
1503 // /// Get a named Profile2D object from the histogram system (non-const)
1504 // Profile2DPtr getProfile2D(const std::string& name) {
1505 // return getAnalysisObject<Profile2D>(name);
1506 // }
1507
1508 // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1509 // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1510 // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1511 // }
1512
1513 // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1514 // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1515 // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1516 // }
1517
1518
1519 // /// Get a named Scatter2D object from the histogram system
1520 // const Scatter2DPtr getScatter2D(const std::string& name) const {
1521 // return getAnalysisObject<Scatter2D>(name);
1522 // }
1523
1524 // /// Get a named Scatter2D object from the histogram system (non-const)
1525 // Scatter2DPtr getScatter2D(const std::string& name) {
1526 // return getAnalysisObject<Scatter2D>(name);
1527 // }
1528
1529 // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1530 // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1531 // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1532 // }
1533
1534 // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1535 // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1536 // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1537 // }
1538
1540
1541
1542 private:
1543
1545 string _defaultname;
1546
1548 unique_ptr<AnalysisInfo> _info;
1549
1552 vector<MultiweightAOPtr> _analysisobjects;
1553
1556 double _crossSection;
1557 bool _gotCrossSection;
1559
1561 AnalysisHandler* _analysishandler;
1562
1565 mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1566
1568 map<string, string> _options;
1569
1571 string _optstring;
1572
1573
1574 private:
1575
1578
1580 void _cacheRefData() const;
1581
1583
1584 };
1585
1586
1587 // // Template specialisation for literal character strings (which don't play well with stringstream)
1588 // template<>
1589 // inline std::string Analysis::getOption(std::string optname, const char* def) {
1590 // return getOption<std::string>(optname, def); //.c_str();
1591 // }
1592
1593
1594}
1595
1596
1597// Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1598#include "Rivet/AnalysisBuilder.hh"
1599
1600
1603
1606#define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1607
1610#define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias )
1611
1614#define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {}
1615
1616
1617
1622#define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1623
1628// #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1629#define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1630
1635#define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1636
1641#define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1642
1644
1645
1646#endif
Rivet::AnalysisHandler
The key class for coordination of Analysis objects and the event loop.
Definition AnalysisHandler.hh:23
Rivet::AnalysisInfo
Holder of analysis metadata.
Definition AnalysisInfo.hh:12
Rivet::AnalysisInfo::refFile
std::string refFile() const
Find the path to the reference-data file for this analysis.
Rivet::AnalysisInfo::validation
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition AnalysisInfo.hh:276
Rivet::Analysis
This is the base class of all analysis classes in Rivet.
Definition Analysis.hh:65
Rivet::Analysis::getOption
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:761
Rivet::Analysis::~Analysis
virtual ~Analysis()
The destructor.
Definition Analysis.hh:76
Rivet::Analysis::getOption
T getOption(std::string optname, T def) const
Get an option for this analysis instance converted to a specific type.
Definition Analysis.hh:773
Rivet::Analysis::crossSection
double crossSection() const
Get the process cross-section in pb. Throws if this hasn't been set.
Rivet::Analysis::crossSectionPerEvent
double crossSectionPerEvent() const
Rivet::Analysis::crossSectionErrorPerEvent
double crossSectionErrorPerEvent() const
Rivet::Analysis::getOption
std::string getOption(std::string optname, string def="") const
Get an option for this analysis instance as a string.
Definition Analysis.hh:751
Rivet::Analysis::sumW2
double sumW2() const
Get the sum of squared event weights seen (via the analysis handler).
Rivet::Analysis::options
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition Analysis.hh:746
Rivet::Analysis::getOption
bool getOption(std::string optname, bool def) const
Get an option for this analysis instance converted to a bool.
Definition Analysis.hh:799
Rivet::Analysis::analysisObjects
const vector< MultiweightAOPtr > & analysisObjects() const
List of registered analysis data objects.
Definition Analysis.hh:1227
Rivet::Analysis::sumW
double sumW() const
Get the sum of event weights seen (via the analysis handler).
Rivet::Analysis::handler
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition Analysis.hh:363
Rivet::Analysis::sumOfWeights
double sumOfWeights() const
Alias.
Definition Analysis.hh:395
Rivet::Analysis::numEvents
size_t numEvents() const
Get the number of events seen (via the analysis handler).
Rivet::Analysis::Analysis
Analysis(const std::string &name)
Constructor.
Rivet::Analysis::operator=
Analysis & operator=(const Analysis &)=delete
The assignment operator is private and mustdeleted, so it can never be called.
Rivet::Analysis::getLog
Log & getLog() const
Get a Log object based on the name() property of the calling analysis object.
Rivet::Analysis::crossSectionError
double crossSectionError() const
Get the process cross-section error in pb. Throws if this hasn't been set.
Rivet::Analysis::efficiency
void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
Rivet::Analysis::asymm
void asymm(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const
Rivet::Analysis::scale
void scale(const Histo1DPtr(&histos)[array_size], CounterAdapter factor)
Definition Analysis.hh:1037
Rivet::Analysis::scale
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition Analysis.hh:1025
Rivet::Analysis::scale
void scale(Histo1DPtr histo, CounterAdapter factor)
Multiplicatively scale the given histogram, histo, by factor factor.
Rivet::Analysis::divide
void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
Rivet::Analysis::normalize
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:1054
Rivet::Analysis::normalize
void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the given histogram, histo, to area = norm.
Rivet::Analysis::barchart
void barchart(Histo2DPtr h, Scatter3DPtr s, bool usefocus=false) const
Rivet::Analysis::normalize
void normalize(const std::vector< Histo2DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition Analysis.hh:1048
Rivet::Analysis::normalize
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition Analysis.hh:1060
Rivet::Analysis::scale
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition Analysis.hh:1031
Rivet::CentralityProjection
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition CentralityProjection.hh:27
Rivet::Event
Representation of a HepMC event, and enabler of Projection caching.
Definition Event.hh:22
Rivet::Log
Logging system for controlled & formatted writing to stdout.
Definition Logging.hh:10
Rivet::PercentileTBase::add
void add(TPtr ao, CounterPtr cnt, pair< float, float > cent={0.0, 100.0})
Add a new percentile bin.
Definition Percentile.hh:122
Rivet::Percentile
The Percentile class for centrality binning.
Definition Percentile.hh:203
Rivet::ProjectionApplier
Common base class for Projection and Analysis, used for internal polymorphism.
Definition ProjectionApplier.hh:21
Rivet::SingleValueProjection
Base class for projections returning a single floating point value.
Definition SingleValueProjection.hh:17
Rivet::AnalysisInfo::refUnmatch
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:160
Rivet::AnalysisInfo::description
const std::string & description() const
Get a full description of the analysis.
Definition AnalysisInfo.hh:93
Rivet::AnalysisInfo::warning
const std::string & warning() const
Any warning message.
Definition AnalysisInfo.hh:152
Rivet::AnalysisInfo::bibKey
const std::string & bibKey() const
BibTeX citation key for this article.
Definition AnalysisInfo.hh:168
Rivet::AnalysisInfo::setRefDataName
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:54
Rivet::AnalysisInfo::todos
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition AnalysisInfo.hh:178
Rivet::AnalysisInfo::collider
const std::string & collider() const
Collider on which the experiment ran.
Definition AnalysisInfo.hh:122
Rivet::AnalysisInfo::bibTeX
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition AnalysisInfo.hh:173
Rivet::AnalysisInfo::references
const std::vector< std::string > & references() const
Journal and preprint references.
Definition AnalysisInfo.hh:143
Rivet::AnalysisInfo::inspireId
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition AnalysisInfo.hh:57
Rivet::AnalysisInfo::summary
const std::string & summary() const
Get a short description of the analysis.
Definition AnalysisInfo.hh:83
Rivet::AnalysisInfo::energies
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition AnalysisInfo.hh:112
Rivet::AnalysisInfo::refMatch
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition AnalysisInfo.hh:156
Rivet::AnalysisInfo::setEnergies
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition AnalysisInfo.hh:114
Rivet::AnalysisInfo::setBeams
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition AnalysisInfo.hh:109
Rivet::AnalysisInfo::luminosity
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition AnalysisInfo.hh:137
Rivet::AnalysisInfo::keywords
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition AnalysisInfo.hh:148
Rivet::AnalysisInfo::runInfo
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition AnalysisInfo.hh:102
Rivet::AnalysisInfo::authors
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition AnalysisInfo.hh:74
Rivet::AnalysisInfo::name
std::string name() const
Definition AnalysisInfo.hh:34
Rivet::AnalysisInfo::getRefDataName
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition AnalysisInfo.hh:49
Rivet::AnalysisInfo::spiresId
const std::string & spiresId() const
Definition AnalysisInfo.hh:64
Rivet::AnalysisInfo::year
const std::string & year() const
When the original experimental analysis was published.
Definition AnalysisInfo.hh:129
Rivet::AnalysisInfo::beams
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition AnalysisInfo.hh:107
Rivet::AnalysisInfo::writerDoublePrecision
const std::string & writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition AnalysisInfo.hh:164
Rivet::AnalysisInfo::luminosityfb
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition AnalysisInfo.hh:135
Rivet::AnalysisInfo::experiment
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition AnalysisInfo.hh:117
Rivet::AnalysisInfo::status
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition AnalysisInfo.hh:210
Rivet::AnalysisInfo::reentrant
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition AnalysisInfo.hh:215
Rivet::Analysis::removeAnalysisObject
void removeAnalysisObject(const std::string &path)
Unregister a data object from the histogram system (by name)
Rivet::Analysis::getAnalysisObject
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition Analysis.hh:1427
Rivet::Analysis::registerAO
rivet_shared_ptr< Wrapper< YODAT > > registerAO(const YODAT &yao)
Register a new data object, optionally read in preloaded data.
Definition Analysis.hh:1249
Rivet::Analysis::defaultWeightIndex
size_t defaultWeightIndex() const
Get the default/nominal weight index.
Rivet::Analysis::getPreload
shared_ptr< YODAT > getPreload(string path) const
Get a preloaded YODA object.
Definition Analysis.hh:1242
Rivet::Analysis::getAnalysisObject
const AO getAnalysisObject(const std::string &aoname) const
Get a Rivet data object from the histogram system.
Definition Analysis.hh:1393
Rivet::Analysis::removeAnalysisObject
void removeAnalysisObject(const MultiweightAOPtr &ao)
Unregister a data object from the histogram system (by pointer)
Rivet::Analysis::addAnalysisObject
AO addAnalysisObject(const AO &aonew)
Register a data object in the histogram system.
Definition Analysis.hh:1336
Rivet::Analysis::isCompatible
bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const
Check if analysis is compatible with the provided beam particle IDs and energies.
Rivet::Analysis::isCompatible
bool isCompatible(const ParticlePair &beams) const
Check if analysis is compatible with the provided beam particle IDs and energies.
Rivet::Analysis::isCompatibleWithSqrtS
bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const
Check if sqrtS is compatible with provided value.
Rivet::Analysis::isCompatible
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.
Rivet::Analysis::bookPercentile
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:846
Rivet::Analysis::declareCentrality
const CentralityProjection & declareCentrality(const SingleValueProjection &proj, string calAnaName, string calHistName, const string projName, bool increasing=false)
Book a CentralityProjection.
Rivet::Analysis::book
CounterPtr & book(CounterPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Rivet::Analysis::book
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
Rivet::Analysis::book
Histo1DPtr & book(Histo1DPtr &, const std::string &name)
Book a 1D histogram, using the binnings in the reference data histogram.
Rivet::Analysis::book
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 .
Rivet::Analysis::book
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 .
Rivet::Analysis::book
Histo1DPtr & book(Histo1DPtr &, const std::string &name, const Scatter2D &refscatter)
Book a 1D histogram with binning from a reference scatter.
Rivet::Analysis::book
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 .
Rivet::Analysis::book
Histo1DPtr & book(Histo1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, const std::string &name)
Book a 2D histogram, using the binnings in the reference data histogram.
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const std::vector< double > &xbinedges, const std::vector< double > &ybinedges)
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const Scatter3D &refscatter)
Book a 2D histogram with binning from a reference scatter.
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, const std::string &name, const std::initializer_list< double > &xbinedges, const std::initializer_list< double > &ybinedges)
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Rivet::Analysis::book
Histo2DPtr & book(Histo2DPtr &, const std::string &name, size_t nxbins, double xlower, double xupper, size_t nybins, double ylower, double yupper)
Rivet::Analysis::mkAxisCode
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)
Rivet::Analysis::histoDir
const std::string histoDir() const
Get the canonical histogram "directory" path for this analysis.
Rivet::Analysis::histoPath
const std::string histoPath(const std::string &hname) const
Get the canonical histogram path for the named histogram in this analysis.
Rivet::Analysis::histoPath
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.
Rivet::Analysis::finalize
virtual void finalize()
Definition Analysis.hh:103
Rivet::Analysis::analyze
virtual void analyze(const Event &event)=0
Rivet::Analysis::init
virtual void init()
Definition Analysis.hh:90
Rivet::Analysis::integrate
void integrate(Histo1DPtr h, Scatter2DPtr s) const
Rivet::Analysis::efficiency
void efficiency(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
Rivet::Analysis::efficiency
void efficiency(const YODA::Counter &c1, const YODA::Counter &c2, Scatter1DPtr s) const
Rivet::Analysis::divide
void divide(const YODA::Histo2D &h1, const YODA::Histo2D &h2, Scatter3DPtr s) const
Rivet::Analysis::asymm
void asymm(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
Rivet::Analysis::asymm
void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
Rivet::Analysis::asymm
void asymm(const YODA::Histo2D &h1, const YODA::Histo2D &h2, Scatter3DPtr s) const
Rivet::Analysis::scale
void scale(const CounterPtr(&cnts)[array_size], CounterAdapter factor)
Definition Analysis.hh:991
Rivet::Analysis::scale
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition Analysis.hh:979
Rivet::Analysis::scale
void scale(CounterPtr cnt, CounterAdapter factor)
Multiplicatively scale the given counter, cnt, by factor factor.
Rivet::Analysis::divide
void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
Rivet::Analysis::normalize
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:1009
Rivet::Analysis::divide
void divide(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
Rivet::Analysis::normalize
void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the given histogram, histo, to area = norm.
Rivet::Analysis::barchart
void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const
Rivet::Analysis::integrate
void integrate(const Histo1D &h, Scatter2DPtr s) const
Rivet::Analysis::normalize
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition Analysis.hh:1003
Rivet::Analysis::efficiency
void efficiency(const YODA::Histo2D &h1, const YODA::Histo2D &h2, Scatter3DPtr s) const
Rivet::Analysis::divide
void divide(const YODA::Profile1D &p1, const YODA::Profile1D &p2, Scatter2DPtr s) const
Rivet::Analysis::normalize
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition Analysis.hh:1015
Rivet::Analysis::divide
void divide(const YODA::Profile2D &p1, const YODA::Profile2D &p2, Scatter3DPtr s) const
Rivet::Analysis::efficiency
void efficiency(const YODA::Histo1D &h1, const YODA::Histo1D &h2, Scatter2DPtr s) const
Rivet::Analysis::scale
void scale(const std::map< T, CounterPtr > &maps, CounterAdapter factor)
Iteratively scale the counters in the map maps, by factor factor.
Definition Analysis.hh:985
Rivet::Analysis::divide
void divide(const YODA::Counter &c1, const YODA::Counter &c2, Scatter1DPtr s) const
Rivet::Analysis::status
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition Analysis.hh:240
Rivet::Analysis::reentrant
virtual bool reentrant() const
Does this analysis have a reentrant finalize()?
Definition Analysis.hh:260
Rivet::Analysis::analysisDataPath
std::string analysisDataPath(const std::string &extn, const std::string &suffix="")
Get the path to a data file associated with this analysis.
Definition Analysis.hh:149
Rivet::Analysis::collider
virtual std::string collider() const
Collider on which the experiment ran.
Definition Analysis.hh:206
Rivet::Analysis::luminosityfb
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition Analysis.hh:216
Rivet::Analysis::loadInfo
void loadInfo()
Get the AnalysisInfo object to parse its info file in which the metadata is stored.
Definition Analysis.hh:116
Rivet::Analysis::info
const AnalysisInfo & info() const
Get the actual AnalysisInfo object in which all this metadata is stored.
Definition Analysis.hh:119
Rivet::Analysis::inspireId
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition Analysis.hh:155
Rivet::Analysis::requiredEnergies
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition Analysis.hh:296
Rivet::Analysis::keywords
virtual const std::vector< std::string > & keywords() const
Get vector of analysis keywords.
Definition Analysis.hh:301
Rivet::Analysis::luminosity
virtual double luminosity() const
The integrated luminosity in inverse picobarn.
Definition Analysis.hh:220
Rivet::Analysis::writerDoublePrecision
virtual std::string writerDoublePrecision() const
Positive filtering regex for setting double precision in Writer.
Definition Analysis.hh:281
Rivet::Analysis::info
AnalysisInfo & info()
Definition Analysis.hh:314
Rivet::Analysis::runInfo
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition Analysis.hh:196
Rivet::Analysis::year
virtual std::string year() const
When the original experimental analysis was published.
Definition Analysis.hh:211
Rivet::Analysis::setRefDataName
virtual void setRefDataName(const std::string &ref_data="")
Set name of reference data file, which could be different from plugin name.
Definition Analysis.hh:141
Rivet::Analysis::summary
virtual std::string summary() const
Get a short description of the analysis.
Definition Analysis.hh:177
Rivet::Analysis::description
virtual std::string description() const
Get a full description of the analysis.
Definition Analysis.hh:187
Rivet::Analysis::validation
virtual std::vector< std::string > validation() const
make-style commands for validating this analysis.
Definition Analysis.hh:255
Rivet::Analysis::authors
virtual std::vector< std::string > authors() const
Names & emails of paper/analysis authors.
Definition Analysis.hh:168
Rivet::Analysis::refFile
virtual std::string refFile() const
Location of reference data YODA file.
Definition Analysis.hh:266
Rivet::Analysis::requiredBeams
virtual const std::vector< PdgIdPair > & requiredBeams() const
Return the allowed pairs of incoming beams required by this analysis.
Definition Analysis.hh:286
Rivet::Analysis::setRequiredEnergies
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition Analysis.hh:306
Rivet::Analysis::references
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition Analysis.hh:225
Rivet::Analysis::todos
virtual std::vector< std::string > todos() const
Any work to be done on this analysis.
Definition Analysis.hh:250
Rivet::Analysis::refUnmatch
virtual std::string refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition Analysis.hh:276
Rivet::Analysis::spiresId
virtual std::string spiresId() const
Get the SPIRES ID code for this analysis (~deprecated).
Definition Analysis.hh:160
Rivet::Analysis::refMatch
virtual std::string refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition Analysis.hh:271
Rivet::Analysis::warning
virtual std::string warning() const
A warning message from the info file, if there is one.
Definition Analysis.hh:245
Rivet::Analysis::setRequiredBeams
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition Analysis.hh:290
Rivet::Analysis::bibKey
virtual std::string bibKey() const
BibTeX citation key for this article.
Definition Analysis.hh:230
Rivet::Analysis::bibTeX
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition Analysis.hh:235
Rivet::Analysis::name
virtual std::string name() const
Get the name of the analysis.
Definition Analysis.hh:131
Rivet::Analysis::getRefDataName
virtual std::string getRefDataName() const
Get name of reference data file, which could be different from plugin name.
Definition Analysis.hh:136
Rivet::Analysis::experiment
virtual std::string experiment() const
Experiment which performed and published this analysis.
Definition Analysis.hh:201
Rivet::Analysis::book
Profile1DPtr & book(Profile1DPtr &, const std::string &name)
Book a 1D profile histogram, using the binnings in the reference data histogram.
Rivet::Analysis::book
Profile1DPtr & book(Profile1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Rivet::Analysis::book
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 .
Rivet::Analysis::book
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 .
Rivet::Analysis::book
Profile1DPtr & book(Profile1DPtr &, const std::string &name, const Scatter2D &refscatter)
Book a 1D profile histogram with binning from a reference scatter.
Rivet::Analysis::book
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 .
Rivet::Analysis::book
Profile2DPtr & book(Profile2DPtr &, const std::string &name, const std::vector< double > &xbinedges, const std::vector< double > &ybinedges)
Rivet::Analysis::book
Profile2DPtr & book(Profile2DPtr &, const std::string &name, const std::initializer_list< double > &xbinedges, const std::initializer_list< double > &ybinedges)
Rivet::Analysis::book
Profile2DPtr & book(Profile2DPtr &, const std::string &name, size_t nxbins, double xlower, double xupper, size_t nybins, double ylower, double yupper)
Rivet::Analysis::refData
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition Analysis.hh:453
Rivet::Analysis::refData
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition Analysis.hh:430
Rivet::Analysis::refData
const T & refData(const string &hname) const
Definition Analysis.hh:439
Rivet::Analysis::beamIds
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
Rivet::Analysis::merging
bool merging() const
Check if we are running rivet-merge.
Definition Analysis.hh:335
Rivet::Analysis::sqrtS
double sqrtS() const
Centre of mass energy for this run.
Rivet::Analysis::beams
const ParticlePair & beams() const
Incoming beams for this run.
Rivet::Analysis::book
Scatter2DPtr & book(Scatter2DPtr &s2d, const string &hname, bool copy_pts=false)
Book a 2-dimensional data point set with the given name.
Rivet::Analysis::book
Scatter1DPtr & book(Scatter1DPtr &s1d, const string &hname, const Scatter1D &refscatter)
Book a 1-dimensional data point set from an existing scatter and a new path.
Rivet::Analysis::book
Scatter1DPtr & book(Scatter1DPtr &s1d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId)
Book a 1-dimensional data point set, using the reference-data histogram indices.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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".
Rivet::Analysis::book
Scatter1DPtr & book(Scatter1DPtr &s1d, const string &hname)
Book a 1-dimensional data point set with the given name.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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.
Rivet::Analysis::book
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".
Rivet::Analysis::book
Scatter3DPtr & book(Scatter3DPtr &s3d, const std::string &hname, bool copy_pts=false)
Book a 3-dimensional data point set with the given name.
Rivet::bookingCompatible
bool bookingCompatible(TPtr a, TPtr b)
Definition RivetYODA.hh:877
MSG_TRACE
#define MSG_TRACE(x)
Lowest-level, most verbose messaging, using MSG_LVL.
Definition Logging.hh:193
MSG_WARNING
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition Logging.hh:200
MSG_ERROR
#define MSG_ERROR(x)
Highest level messaging for serious problems, using MSG_LVL.
Definition Logging.hh:202
Rivet::findAnalysisDataFile
std::string findAnalysisDataFile(const std::string &filename, const std::vector< std::string > &pathprepend=std::vector< std::string >(), const std::vector< std::string > &pathappend=std::vector< std::string >())
Find the first file of the given name in the general data file search dirs.
Rivet::toLower
string toLower(const string &s)
Convert a string to lower-case.
Definition Utils.hh:128
Rivet
Definition MC_Cent_pPb.hh:10
Rivet::ParticlePair
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition Particle.hh:42
Rivet::Exception
Error Exception
Rivet::Exception is a synonym for Rivet::Error.
Definition Exceptions.hh:18
Rivet::LookupError
Error relating to looking up analysis objects in the register.
Definition Exceptions.hh:61
Rivet::ReadError
Error for read failures.
Definition Exceptions.hh:72
Rivet::UserError
Error specialisation for where the problem is between the chair and the computer.
Definition Exceptions.hh:55