Rivet  3.1.5
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 
29 namespace 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 
267 
269  virtual const std::vector<PdgIdPair>& requiredBeams() const {
270  return info().beams();
271  }
273  virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
274  info().setBeams(requiredBeams);
275  return *this;
276  }
277 
279  virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
280  return info().energies();
281  }
282 
284  virtual const std::vector<std::string> & keywords() const {
285  return info().keywords();
286  }
287 
289  virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
291  return *this;
292  }
293 
294 
298  assert(_info && "No AnalysisInfo object :O");
299  return *_info;
300  }
301 
303 
304 
307 
309  const ParticlePair& beams() const;
310 
312  const PdgIdPair beamIds() const;
313 
315  double sqrtS() const;
316 
318  bool merging() const {
319  return sqrtS() <= 0.0;
320  }
321 
323 
324 
330 
332  bool isCompatible(const ParticlePair& beams) const;
333 
335  bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
336 
338  bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
339 
341  bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const;
342 
344 
346  AnalysisHandler& handler() const { return *_analysishandler; }
347 
348 
349  protected:
350 
352  Log& getLog() const;
353 
355  double crossSection() const;
356 
359  double crossSectionPerEvent() const;
360 
362  double crossSectionError() const;
363 
366  double crossSectionErrorPerEvent() const;
367 
371  size_t numEvents() const;
372 
376  double sumW() const;
378  double sumOfWeights() const { return sumW(); }
379 
383  double sumW2() const;
384 
385 
386  protected:
387 
393 
395  const std::string histoDir() const;
396 
398  const std::string histoPath(const std::string& hname) const;
399 
401  const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
402 
404  const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
405 
407 
408 
411 
413  const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
414  _cacheRefData();
415  return _refdata;
416  }
417 
418 
421  template <typename T=YODA::Scatter2D>
422  const T& refData(const string& hname) const {
423  _cacheRefData();
424  MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
425  if (!_refdata[hname]) {
426  MSG_ERROR("Can't find reference histogram " << hname);
427  throw Exception("Reference data " + hname + " not found.");
428  }
429  return dynamic_cast<T&>(*_refdata[hname]);
430  }
431 
432 
435  template <typename T=YODA::Scatter2D>
436  const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
437  const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
438  return refData<T>(hname);
439  }
440 
442 
443 
449 
451  CounterPtr& book(CounterPtr&, const std::string& name);
452 
456  CounterPtr& book(CounterPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
457 
459 
460 
463 
465  Histo1DPtr& book(Histo1DPtr&,const std::string& name, size_t nbins, double lower, double upper);
466 
468  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::vector<double>& binedges);
469 
471  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::initializer_list<double>& binedges);
472 
474  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const Scatter2D& refscatter);
475 
477  Histo1DPtr& book(Histo1DPtr&,const std::string& name);
478 
482  Histo1DPtr& book(Histo1DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
483 
485 
486 
489 
493  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
494  size_t nxbins, double xlower, double xupper,
495  size_t nybins, double ylower, double yupper);
496 
499  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
500  const std::vector<double>& xbinedges,
501  const std::vector<double>& ybinedges);
502 
505  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
506  const std::initializer_list<double>& xbinedges,
507  const std::initializer_list<double>& ybinedges);
508 
510  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
511  const Scatter3D& refscatter);
512 
514  Histo2DPtr& book(Histo2DPtr&,const std::string& name);
515 
519  Histo2DPtr& book(Histo2DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
520 
522 
523 
526 
528  Profile1DPtr& book(Profile1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
529 
531  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::vector<double>& binedges);
532 
534  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
535 
537  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const Scatter2D& refscatter);
538 
540  Profile1DPtr& book(Profile1DPtr&, const std::string& name);
541 
545  Profile1DPtr& book(Profile1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
546 
548 
549 
552 
556  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
557  size_t nxbins, double xlower, double xupper,
558  size_t nybins, double ylower, double yupper);
559 
562  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
563  const std::vector<double>& xbinedges,
564  const std::vector<double>& ybinedges);
565 
568  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
569  const std::initializer_list<double>& xbinedges,
570  const std::initializer_list<double>& ybinedges);
571 
573 
574  // /// Book a 2D profile histogram with binning from a reference scatter.
575  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name,
576  // const Scatter3D& refscatter);
577 
578  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
579  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name);
580 
581  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
582  // ///
583  // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
584  // Profile2DPtr& book(const Profile2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
585 
587 
588 
591 
602  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, bool copy_pts = false);
603 
614  Scatter2DPtr& book(Scatter2DPtr& s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
615 
619  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, size_t npts, double lower, double upper);
620 
624  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const std::vector<double>& binedges);
625 
627  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const Scatter2D& refscatter);
628 
630 
633 
644  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, bool copy_pts=false);
645 
656  Scatter3DPtr& book(Scatter3DPtr& s3d, unsigned int datasetId, unsigned int xAxisId,
657  unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
658 
662  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
663  size_t xnpts, double xlower, double xupper,
664  size_t ynpts, double ylower, double yupper);
665 
669  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
670  const std::vector<double>& xbinedges,
671  const std::vector<double>& ybinedges);
672 
674  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, const Scatter3D& refscatter);
675 
677 
678 
679  public:
680 
684  virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
685  (void) yao;
686  }
687 
692  virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
693  (void) raos;
694  (void) iW;
695  }
696 
698 
699 
701  const std::map<std::string,std::string>& options() const {
702  return _options;
703  }
704 
706  std::string getOption(std::string optname, string def="") const {
707  if ( _options.find(optname) != _options.end() )
708  return _options.find(optname)->second;
709  return def;
710  }
711 
716  std::string getOption(std::string optname, const char* def) {
717  return getOption<std::string>(optname, def);
718  }
719 
727  template<typename T>
728  T getOption(std::string optname, T def) const {
729  if (_options.find(optname) == _options.end()) return def;
730  std::stringstream ss;
731  ss.exceptions(std::ios::failbit);
732  T ret;
733  ss << _options.find(optname)->second;
734  try {
735  ss >> ret;
736  } catch (...) {
737  throw ReadError("Could not read user-provided option into requested type");
738  }
739  return ret;
740  }
741 
752  // template<>
753  // bool getOption<bool>(std::string optname, bool def) const {
754  bool getOption(std::string optname, bool def) const {
755  if (_options.find(optname) == _options.end()) return def;
756  const std::string val = getOption(optname);
757  const std::string lval = toLower(val);
758  if (lval.empty()) return false;
759  if (lval == "true" || lval == "yes" || lval == "on") return true;
760  if (lval == "false" || lval == "no" || lval == "off") return false;
761  return bool(getOption<int>(optname, 0));
762  }
763 
765 
766 
769 
786  const CentralityProjection&
788  string calAnaName, string calHistName,
789  const string projName, bool increasing=false);
790 
791 
800  template <class T>
801  Percentile<T> bookPercentile(string projName,
802  vector<pair<float, float> > centralityBins,
803  vector<tuple<int, int, int> > ref) {
804 
805  typedef typename ReferenceTraits<T>::RefT RefT;
806  typedef rivet_shared_ptr<Wrapper<T>> WrapT;
807 
808  Percentile<T> pctl(this, projName);
809 
810  const int nCent = centralityBins.size();
811  for (int iCent = 0; iCent < nCent; ++iCent) {
812  const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
813  std::get<1>(ref[iCent]),
814  std::get<2>(ref[iCent]));
815  const RefT & refscatter = refData<RefT>(axisCode);
816 
817  WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
818  wtf = addAnalysisObject(wtf);
819 
820  CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
821  cnt = addAnalysisObject(cnt);
822 
823  pctl.add(wtf, cnt, centralityBins[iCent]);
824  }
825  return pctl;
826  }
827 
828 
829  // /// @brief Book Percentile wrappers around AnalysisObjects.
830  // ///
831  // /// Based on a previously registered CentralityProjection named @a
832  // /// projName book one (or several) AnalysisObject(s) named
833  // /// according to @a ref where the x-axis will be filled according
834  // /// to the percentile output(s) of the @projName.
835  // ///
836  // /// @todo Convert to just be called book() cf. others
837  // template <class T>
838  // PercentileXaxis<T> bookPercentileXaxis(string projName,
839  // tuple<int, int, int> ref) {
840 
841  // typedef typename ReferenceTraits<T>::RefT RefT;
842  // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
843 
844  // PercentileXaxis<T> pctl(this, projName);
845 
846  // const string axisCode = mkAxisCode(std::get<0>(ref),
847  // std::get<1>(ref),
848  // std::get<2>(ref));
849  // const RefT & refscatter = refData<RefT>(axisCode);
850 
851  // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
852  // wtf = addAnalysisObject(wtf);
853 
854  // CounterPtr cnt(_weightNames(), Counter());
855  // cnt = addAnalysisObject(cnt);
856 
857  // pctl.add(wtf, cnt);
858  // return pctl;
859  // }
860 
862 
863 
864  private:
865 
866  // Functions that have to be defined in the .cc file to avoid circular #includes
867 
869  vector<string> _weightNames() const;
870 
872  YODA::AnalysisObjectPtr _getPreload(string name) const;
873 
875  MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
876 
878  void _checkBookInit() const;
879 
881  bool _inInit() const;
882 
884  bool _inFinalize() const;
885 
886 
887  private:
888 
890  class CounterAdapter {
891  public:
892 
893  CounterAdapter(double x) : x_(x) {}
894 
895  CounterAdapter(const YODA::Counter & c) : x_(c.val()) {}
896 
897  CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
898  assert( s.numPoints() == 1 || "Can only scale by a single value.");
899  }
900 
901  operator double() const { return x_; }
902 
903  private:
904  double x_;
905 
906  };
907 
908 
909  public:
910 
911  double dbl(double x) { return x; }
912  double dbl(const YODA::Counter & c) { return c.val(); }
913  double dbl(const YODA::Scatter1D & s) {
914  assert( s.numPoints() == 1 );
915  return s.points()[0].x();
916  }
917 
918 
923 
925  void scale(CounterPtr cnt, CounterAdapter factor);
926 
930  void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
931  for (auto& c : cnts) scale(c, factor);
932  }
933 
935  template<typename T>
936  void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
937  for (auto& m : maps) scale(m.second, factor);
938  }
939 
941  template <std::size_t array_size>
942  void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
943  // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
944  for (auto& c : cnts) scale(c, factor);
945  }
946 
947 
949  void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
950 
954  void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
955  for (auto& h : histos) normalize(h, norm, includeoverflows);
956  }
957 
959  template<typename T>
960  void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
961  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
962  }
963 
965  template <std::size_t array_size>
966  void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
967  for (auto& h : histos) normalize(h, norm, includeoverflows);
968  }
969 
971  void scale(Histo1DPtr histo, CounterAdapter factor);
972 
976  void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
977  for (auto& h : histos) scale(h, factor);
978  }
979 
981  template<typename T>
982  void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
983  for (auto& m : maps) scale(m.second, factor);
984  }
985 
987  template <std::size_t array_size>
988  void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
989  for (auto& h : histos) scale(h, factor);
990  }
991 
992 
994  void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
995 
999  void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
1000  for (auto& h : histos) normalize(h, norm, includeoverflows);
1001  }
1002 
1004  template<typename T>
1005  void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
1006  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
1007  }
1008 
1010  template <std::size_t array_size>
1011  void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
1012  for (auto& h : histos) normalize(h, norm, includeoverflows);
1013  }
1014 
1016  void scale(Histo2DPtr histo, CounterAdapter factor);
1017 
1021  void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
1022  for (auto& h : histos) scale(h, factor);
1023  }
1024 
1026  template<typename T>
1027  void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
1028  for (auto& m : maps) scale(m.second, factor);
1029  }
1030 
1032  template <std::size_t array_size>
1033  void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
1034  for (auto& h : histos) scale(h, factor);
1035  }
1036 
1037 
1039 
1040 
1044  void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const;
1045 
1049  void barchart(Histo2DPtr h, Scatter3DPtr s, bool usefocus=false) const;
1050 
1051 
1055  void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
1056 
1060  void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
1061 
1062 
1066  void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1067 
1071  void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1072 
1073 
1077  void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1078 
1082  void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1083 
1084 
1088  void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1089 
1093  void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1094 
1095 
1099  void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1100 
1104  void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1105 
1106 
1110  void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1111 
1115  void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1116 
1117 
1121  void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1122 
1126  void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1127 
1128 
1132  void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1133 
1137  void integrate(const Histo1D& h, Scatter2DPtr s) const;
1138 
1140 
1141 
1142  public:
1143 
1145  const vector<MultiweightAOPtr>& analysisObjects() const {
1146  return _analysisobjects;
1147  }
1148 
1149 
1150  protected:
1151 
1154 
1156  size_t defaultWeightIndex() const;
1157 
1159  template <typename YODAT>
1160  shared_ptr<YODAT> getPreload(string path) const {
1161  return dynamic_pointer_cast<YODAT>(_getPreload(path));
1162  }
1163 
1164 
1166  template <typename YODAT>
1167  rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT& yao) {
1168  typedef Wrapper<YODAT> WrapperT;
1169  typedef shared_ptr<YODAT> YODAPtrT;
1170  typedef rivet_shared_ptr<WrapperT> RAOT;
1171 
1172  if ( !_inInit() && !_inFinalize() ) {
1173  MSG_ERROR("Can't book objects outside of init() or finalize()");
1174  throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1175  }
1176 
1177  // First check that we haven't booked this before.
1178  // This is allowed when booking in finalize: just warn in that case.
1179  // If in init(), throw an exception: it's 99.9% never going to be intentional.
1180  for (auto& waold : analysisObjects()) {
1181  if ( yao.path() == waold.get()->basePath() ) {
1182  const string msg = "Found double-booking of " + yao.path() + " in " + name();
1183  if ( _inInit() ) {
1184  MSG_ERROR(msg);
1185  throw LookupError(msg);
1186  } else {
1187  MSG_WARNING(msg + ". Keeping previous booking");
1188  }
1189  return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1190  }
1191  }
1192 
1193  shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1194  wao->_basePath = yao.path();
1195  YODAPtrT yaop = make_shared<YODAT>(yao);
1196 
1197  for (const string& weightname : _weightNames()) {
1198  // Create two YODA objects for each weight. Copy from
1199  // preloaded YODAs if present. First the finalized yoda:
1200  string finalpath = yao.path();
1201  if ( weightname != "" ) finalpath += "[" + weightname + "]";
1202  YODAPtrT preload = getPreload<YODAT>(finalpath);
1203  if ( preload ) {
1204  if ( !bookingCompatible(preload, yaop) ) {
1206  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1207  << finalpath << " for " << name());
1208  preload = nullptr;
1209  } else {
1210  MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1211  wao->_final.push_back(make_shared<YODAT>(*preload));
1212  }
1213  }
1214  if ( !preload ) {
1215  wao->_final.push_back(make_shared<YODAT>(yao));
1216  wao->_final.back()->setPath(finalpath);
1217  }
1218 
1219  // Then the raw filling yodas.
1220  string rawpath = "/RAW" + finalpath;
1221  preload = getPreload<YODAT>(rawpath);
1222  if ( preload ) {
1223  if ( !bookingCompatible(preload, yaop) ) {
1224  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1225  << rawpath << " for " << name());
1226  preload = nullptr;
1227  } else {
1228  MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1229  wao->_persistent.push_back(make_shared<YODAT>(*preload));
1230  }
1231  }
1232  if ( !preload ) {
1233  wao->_persistent.push_back(make_shared<YODAT>(yao));
1234  wao->_persistent.back()->setPath(rawpath);
1235  }
1236  }
1237  rivet_shared_ptr<WrapperT> ret(wao);
1238 
1239  ret.get()->unsetActiveWeight();
1240  if ( _inFinalize() ) {
1241  // If booked in finalize() we assume it is the first time
1242  // finalize is run.
1243  ret.get()->pushToFinal();
1244  ret.get()->setActiveFinalWeightIdx(0);
1245  }
1246  _analysisobjects.push_back(ret);
1247 
1248  return ret;
1249  }
1250 
1251 
1253  template <typename AO=MultiweightAOPtr>
1254  AO addAnalysisObject(const AO& aonew) {
1255  _checkBookInit();
1256 
1257  for (const MultiweightAOPtr& ao : analysisObjects()) {
1258 
1259  // Check AO base-name first
1260  ao.get()->setActiveWeightIdx(defaultWeightIndex());
1261  aonew.get()->setActiveWeightIdx(defaultWeightIndex());
1262  if (ao->path() != aonew->path()) continue;
1263 
1264  // If base-name matches, check compatibility
1265  // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1266  AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1267  if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1268  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1269  << aonew->path() << " for " << name());
1270  throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1271  }
1272 
1273  // Finally, check all weight variations
1274  for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1275  aoold.get()->setActiveWeightIdx(weightIdx);
1276  aonew.get()->setActiveWeightIdx(weightIdx);
1277  if (aoold->path() != aonew->path()) {
1278  MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1279  << aonew->path() << " for " << name());
1280  throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1281  }
1282  }
1283 
1284  // They're fully compatible: bind and return
1285  aoold.get()->unsetActiveWeight();
1286  MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1287  return aoold;
1288  }
1289 
1290  // No equivalent found
1291  MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1292  aonew.get()->unsetActiveWeight();
1293 
1294  _analysisobjects.push_back(aonew);
1295  return aonew;
1296  }
1297 
1299  void removeAnalysisObject(const std::string& path);
1300 
1302  void removeAnalysisObject(const MultiweightAOPtr& ao);
1303 
1304  // /// Get all data objects, for all analyses, from the AnalysisHandler
1305  // /// @todo Can we remove this? Why not call handler().getData()?
1306  // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1307 
1308 
1310  template <typename AO=MultiweightAOPtr>
1311  const AO getAnalysisObject(const std::string& aoname) const {
1312  for (const MultiweightAOPtr& ao : analysisObjects()) {
1313  ao.get()->setActiveWeightIdx(defaultWeightIndex());
1314  if (ao->path() == histoPath(aoname)) {
1315  // return dynamic_pointer_cast<AO>(ao);
1316  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1317  }
1318  }
1319  throw LookupError("Data object " + histoPath(aoname) + " not found");
1320  }
1321 
1322 
1323  // /// Get a data object from the histogram system
1324  // template <typename AO=YODA::AnalysisObject>
1325  // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
1326  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1327  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1328  // }
1329  // throw LookupError("Data object " + histoPath(name) + " not found");
1330  // }
1331 
1332  // /// Get a data object from the histogram system (non-const)
1333  // template <typename AO=YODA::AnalysisObject>
1334  // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1335  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1336  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1337  // }
1338  // throw LookupError("Data object " + histoPath(name) + " not found");
1339  // }
1340 
1341 
1344  template <typename AO=MultiweightAOPtr>
1345  AO getAnalysisObject(const std::string& ananame,
1346  const std::string& aoname) {
1347  MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1348  // return dynamic_pointer_cast<AO>(ao);
1349  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1350  }
1351 
1352 
1353  // /// Get a named Histo1D object from the histogram system
1354  // const Histo1DPtr getHisto1D(const std::string& name) const {
1355  // return getAnalysisObject<Histo1D>(name);
1356  // }
1357 
1358  // /// Get a named Histo1D object from the histogram system (non-const)
1359  // Histo1DPtr getHisto1D(const std::string& name) {
1360  // return getAnalysisObject<Histo1D>(name);
1361  // }
1362 
1363  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1364  // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1365  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1366  // }
1367 
1368  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1369  // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1370  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1371  // }
1372 
1373 
1374  // /// Get a named Histo2D object from the histogram system
1375  // const Histo2DPtr getHisto2D(const std::string& name) const {
1376  // return getAnalysisObject<Histo2D>(name);
1377  // }
1378 
1379  // /// Get a named Histo2D object from the histogram system (non-const)
1380  // Histo2DPtr getHisto2D(const std::string& name) {
1381  // return getAnalysisObject<Histo2D>(name);
1382  // }
1383 
1384  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1385  // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1386  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1387  // }
1388 
1389  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1390  // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1391  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1392  // }
1393 
1394 
1395  // /// Get a named Profile1D object from the histogram system
1396  // const Profile1DPtr getProfile1D(const std::string& name) const {
1397  // return getAnalysisObject<Profile1D>(name);
1398  // }
1399 
1400  // /// Get a named Profile1D object from the histogram system (non-const)
1401  // Profile1DPtr getProfile1D(const std::string& name) {
1402  // return getAnalysisObject<Profile1D>(name);
1403  // }
1404 
1405  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1406  // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1407  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1408  // }
1409 
1410  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1411  // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1412  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1413  // }
1414 
1415 
1416  // /// Get a named Profile2D object from the histogram system
1417  // const Profile2DPtr getProfile2D(const std::string& name) const {
1418  // return getAnalysisObject<Profile2D>(name);
1419  // }
1420 
1421  // /// Get a named Profile2D object from the histogram system (non-const)
1422  // Profile2DPtr getProfile2D(const std::string& name) {
1423  // return getAnalysisObject<Profile2D>(name);
1424  // }
1425 
1426  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1427  // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1428  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1429  // }
1430 
1431  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1432  // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1433  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1434  // }
1435 
1436 
1437  // /// Get a named Scatter2D object from the histogram system
1438  // const Scatter2DPtr getScatter2D(const std::string& name) const {
1439  // return getAnalysisObject<Scatter2D>(name);
1440  // }
1441 
1442  // /// Get a named Scatter2D object from the histogram system (non-const)
1443  // Scatter2DPtr getScatter2D(const std::string& name) {
1444  // return getAnalysisObject<Scatter2D>(name);
1445  // }
1446 
1447  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1448  // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1449  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1450  // }
1451 
1452  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1453  // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1454  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1455  // }
1456 
1458 
1459 
1460  private:
1461 
1463  string _defaultname;
1464 
1466  unique_ptr<AnalysisInfo> _info;
1467 
1470  vector<MultiweightAOPtr> _analysisobjects;
1471 
1474  double _crossSection;
1475  bool _gotCrossSection;
1477 
1479  AnalysisHandler* _analysishandler;
1480 
1483  mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1484 
1486  map<string, string> _options;
1487 
1489  string _optstring;
1490 
1491 
1492  private:
1493 
1496 
1498  void _cacheRefData() const;
1499 
1501 
1502  };
1503 
1504 
1505  // // Template specialisation for literal character strings (which don't play well with stringstream)
1506  // template<>
1507  // inline std::string Analysis::getOption(std::string optname, const char* def) {
1508  // return getOption<std::string>(optname, def); //.c_str();
1509  // }
1510 
1511 
1512 }
1513 
1514 
1515 // Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1516 #include "Rivet/AnalysisBuilder.hh"
1517 
1518 
1521 
1524 #define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1525 
1528 #define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias )
1529 
1532 #define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {}
1533 
1534 
1535 
1540 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1541 
1546 // #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1547 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1548 
1553 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1554 
1559 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1560 
1562 
1563 
1564 #endif
double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition: AnalysisInfo.hh:133
double sumOfWeights() const
Alias.
Definition: Analysis.hh:378
Definition: MC_Cent_pPb.hh:10
const AO getAnalysisObject(const std::string &aoname) const
Get a Rivet data object from the histogram system.
Definition: Analysis.hh:1311
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition: AnalysisInfo.hh:112
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition: AnalysisInfo.hh:107
const vector< MultiweightAOPtr > & analysisObjects() const
List of registered analysis data objects.
Definition: Analysis.hh:1145
double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition: AnalysisInfo.hh:135
const std::string & refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition: AnalysisInfo.hh:154
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:141
void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
double crossSectionErrorPerEvent() const
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition: CentralityProjection.hh:26
virtual void init()
Definition: Analysis.hh:89
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:413
Holder of analysis metadata.
Definition: AnalysisInfo.hh:12
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
virtual std::string bibKey() const
BibTeX citation key for this article.
Definition: Analysis.hh:217
bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const
Check if sqrtS is compatible with provided value.
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition: Analysis.hh:227
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition: Analysis.hh:982
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition: Analysis.hh:142
const CentralityProjection & declareCentrality(const SingleValueProjection &proj, string calAnaName, string calHistName, const string projName, bool increasing=false)
Book a CentralityProjection.
const ParticlePair & beams() const
Incoming beams for this run.
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition: Analysis.hh:701
virtual double luminosity() const
The integrated luminosity in inverse picobarn.
Definition: Analysis.hh:207
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
Error specialisation for where the problem is between the chair and the computer. ...
Definition: Exceptions.hh:55
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:204
bool bookingCompatible(TPtr a, TPtr b)
Definition: RivetYODA.hh:849
size_t defaultWeightIndex() const
Get the default/nominal weight index.
const std::string & spiresId() const
Definition: AnalysisInfo.hh:62
const std::vector< std::string > & keywords() const
Analysis keywords, for grouping etc.
Definition: AnalysisInfo.hh:146
virtual void analyze(const Event &event)=0
virtual std::string collider() const
Collider on which the experiment ran.
Definition: Analysis.hh:193
void removeAnalysisObject(const std::string &path)
Unregister a data object from the histogram system (by name)
virtual std::string summary() const
Get a short description of the analysis.
Definition: Analysis.hh:164
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:1011
void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const
virtual std::vector< std::string > authors() const
Names & emails of paper/analysis authors.
Definition: Analysis.hh:155
virtual std::vector< std::string > validation() const
make-style commands for validating this analysis.
Definition: Analysis.hh:242
void add(TPtr ao, CounterPtr cnt, pair< float, float > cent={0.0, 100.0})
Add a new percentile bin.
Definition: Percentile.hh:122
virtual std::vector< std::string > todos() const
Any work to be done on this analysis.
Definition: Analysis.hh:237
virtual std::string warning() const
A warning message from the info file, if there is one.
Definition: Analysis.hh:232
const std::string & description() const
Get a full description of the analysis.
Definition: AnalysisInfo.hh:91
Error for read failures.
Definition: Exceptions.hh:72
The Percentile class for centrality binning.
Definition: Percentile.hh:203
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:1005
const std::string & bibKey() const
BibTeX citation key for this article.
Definition: AnalysisInfo.hh:162
void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the given histogram, histo, to area = norm.
double crossSection() const
Get the process cross-section in pb. Throws if this hasn&#39;t been set.
Logging system for controlled & formatted writing to stdout.
Definition: Logging.hh:10
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition: AnalysisInfo.hh:270
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:52
void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
virtual void finalize()
Definition: Analysis.hh:102
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition: Analysis.hh:930
const std::string & year() const
When the original experimental analysis was published.
Definition: AnalysisInfo.hh:127
const std::string & runInfo() const
Information about the events needed as input for this analysis.
Definition: AnalysisInfo.hh:100
virtual const std::vector< PdgIdPair > & requiredBeams() const
Return the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:269
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition: Analysis.hh:436
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
AnalysisInfo & info()
Definition: Analysis.hh:297
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
virtual std::string spiresId() const
Get the SPIRES ID code for this analysis (~deprecated).
Definition: Analysis.hh:147
bool merging() const
Check if we are running rivet-merge.
Definition: Analysis.hh:318
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition: Analysis.hh:289
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
virtual const std::vector< std::string > & keywords() const
Get vector of analysis keywords.
Definition: Analysis.hh:284
string toLower(const string &s)
Convert a string to lower-case.
Definition: Utils.hh:137
double sumW() const
Get the sum of event weights seen (via the analysis handler).
rivet_shared_ptr< Wrapper< YODAT > > registerAO(const YODAT &yao)
Register a new data object, optionally read in preloaded data.
Definition: Analysis.hh:1167
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition: Analysis.hh:222
double sqrtS() const
Centre of mass energy for this run.
const std::string & warning() const
Any warning message.
Definition: AnalysisInfo.hh:150
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition: Analysis.hh:183
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:21
void scale(const std::map< T, CounterPtr > &maps, CounterAdapter factor)
Iteratively scale the counters in the map maps, by factor factor.
Definition: Analysis.hh:936
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:966
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:273
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:346
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:55
double crossSectionError() const
Get the process cross-section error in pb. Throws if this hasn&#39;t been set.
#define MSG_TRACE(x)
Lowest-level, most verbose messaging, using MSG_LVL.
Definition: Logging.hh:193
virtual std::string refMatch() const
Positive filtering regex for ref-data HepData sync.
Definition: Analysis.hh:258
Error relating to looking up analysis objects in the register.
Definition: Exceptions.hh:61
void normalize(const std::vector< Histo2DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:999
const T & refData(const string &hname) const
Definition: Analysis.hh:422
Error Exception
Rivet::Exception is a synonym for Rivet::Error.
Definition: Exceptions.hh:18
size_t numEvents() const
Get the number of events seen (via the analysis handler).
virtual std::string experiment() const
Experiment which performed and published this analysis.
Definition: Analysis.hh:188
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:954
The key class for coordination of Analysis objects and the event loop.
Definition: AnalysisHandler.hh:23
std::string getOption(std::string optname, string def="") const
Get an option for this analysis instance as a string.
Definition: Analysis.hh:706
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 description() const
Get a full description of the analysis.
Definition: Analysis.hh:174
#define MSG_ERROR(x)
Highest level messaging for serious problems, using MSG_LVL.
Definition: Logging.hh:202
const std::string histoDir() const
Get the canonical histogram "directory" path for this analysis.
Analysis & operator=(const Analysis &)=delete
The assignment operator is private and mustdeleted, so it can never be called.
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition: Analysis.hh:212
virtual std::string year() const
When the original experimental analysis was published.
Definition: Analysis.hh:198
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition: Analysis.hh:1345
double sumW2() const
Get the sum of squared event weights seen (via the analysis handler).
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::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition: AnalysisInfo.hh:172
void scale(CounterPtr cnt, CounterAdapter factor)
Multiplicatively scale the given counter, cnt, by factor factor.
T getOption(std::string optname, T def) const
Get an option for this analysis instance converted to a specific type.
Definition: Analysis.hh:728
void integrate(Histo1DPtr h, Scatter2DPtr s) const
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition: AnalysisInfo.hh:209
shared_ptr< YODAT > getPreload(string path) const
Get a preloaded YODA object.
Definition: Analysis.hh:1160
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:115
const AnalysisInfo & info() const
Get the actual AnalysisInfo object in which all this metadata is stored.
Definition: Analysis.hh:115
const std::string & collider() const
Collider on which the experiment ran.
Definition: AnalysisInfo.hh:120
void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
bool getOption(std::string optname, bool def) const
Get an option for this analysis instance converted to a bool.
Definition: Analysis.hh:754
void scale(const CounterPtr(&cnts)[array_size], CounterAdapter factor)
Definition: Analysis.hh:942
Analysis(const std::string &name)
Constructor.
virtual std::string name() const
Get the name of the analysis.
Definition: Analysis.hh:127
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition: Analysis.hh:976
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition: Analysis.hh:279
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors.
Definition: AnalysisInfo.hh:72
Log & getLog() const
Get a Log object based on the name() property of the calling analysis object.
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition: AnalysisInfo.hh:110
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:105
#define MSG_WARNING(x)
Warning messages for non-fatal bad things, using MSG_LVL.
Definition: Logging.hh:200
const std::string histoPath(const std::string &hname) const
Get the canonical histogram path for the named histogram in this analysis.
double crossSectionPerEvent() const
virtual bool reentrant() const
Does this analysis have a reentrant finalize()?
Definition: Analysis.hh:247
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:75
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition: Analysis.hh:203
virtual std::string refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition: Analysis.hh:263
std::string getOption(std::string optname, const char *def)
Sane overload for literal character strings (which don&#39;t play well with stringstream) ...
Definition: Analysis.hh:716
virtual std::string refFile() const
Location of reference data YODA file.
Definition: Analysis.hh:253
const std::string & summary() const
Get a short description of the analysis.
Definition: AnalysisInfo.hh:81
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:960
std::string refFile() const
Find the path to the reference-data file for this analysis.
const std::string & refUnmatch() const
Negative filtering regex for ref-data HepData sync.
Definition: AnalysisInfo.hh:158
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:47
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:167
void scale(const Histo1DPtr(&histos)[array_size], CounterAdapter factor)
Definition: Analysis.hh:988
bool isCompatible(const ParticlePair &beams) const
Check if analysis is compatible with the provided beam particle IDs and energies. ...
AO addAnalysisObject(const AO &aonew)
Register a data object in the histogram system.
Definition: Analysis.hh:1254
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:801