Rivet  3.1.1
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 
67  friend class AnalysisHandler;
68 
69 
70  public:
71 
73  Analysis(const std::string& name);
74 
76  virtual ~Analysis() {}
77 
78 
79  public:
80 
83 
87  virtual void init() { }
88 
93  virtual void analyze(const Event& event) = 0;
94 
100  virtual void finalize() { }
101 
103 
104 
105  public:
106 
111 
113  const AnalysisInfo& info() const {
114  assert(_info && "No AnalysisInfo object :O");
115  return *_info;
116  }
117 
125  virtual std::string name() const {
126  return ( (info().name().empty()) ? _defaultname : info().name() ) + _optstring;
127  }
128 
130  virtual std::string getRefDataName() const {
131  return (info().getRefDataName().empty()) ? _defaultname : info().getRefDataName();
132  }
133 
135  virtual void setRefDataName(const std::string& ref_data="") {
136  info().setRefDataName(!ref_data.empty() ? ref_data : name());
137  }
138 
140  virtual std::string inspireId() const {
141  return info().inspireId();
142  }
143 
145  virtual std::string spiresId() const {
146  return info().spiresId();
147  }
148 
153  virtual std::vector<std::string> authors() const {
154  return info().authors();
155  }
156 
162  virtual std::string summary() const {
163  return info().summary();
164  }
165 
172  virtual std::string description() const {
173  return info().description();
174  }
175 
181  virtual std::string runInfo() const {
182  return info().runInfo();
183  }
184 
186  virtual std::string experiment() const {
187  return info().experiment();
188  }
189 
191  virtual std::string collider() const {
192  return info().collider();
193  }
194 
196  virtual std::string year() const {
197  return info().year();
198  }
199 
201  virtual double luminosityfb() const {
202  return info().luminosityfb();
203  }
205  virtual double luminosity() const {
206  return info().luminosity();
207  }
208 
210  virtual std::vector<std::string> references() const {
211  return info().references();
212  }
213 
215  virtual std::string bibKey() const {
216  return info().bibKey();
217  }
218 
220  virtual std::string bibTeX() const {
221  return info().bibTeX();
222  }
223 
225  virtual std::string status() const {
226  return (info().status().empty()) ? "UNVALIDATED" : info().status();
227  }
228 
230  virtual std::vector<std::string> todos() const {
231  return info().todos();
232  }
233 
235  virtual std::vector<std::string> validation() const {
236  return info().validation();
237  }
238 
240  virtual bool reentrant() const {
241  return info().reentrant();
242  }
243 
244 
246  virtual std::string refFile() const {
247  return info().refFile();
248  }
249 
250 
252  virtual const std::vector<PdgIdPair>& requiredBeams() const {
253  return info().beams();
254  }
256  virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
257  info().setBeams(requiredBeams);
258  return *this;
259  }
260 
262  virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
263  return info().energies();
264  }
265 
267  virtual const std::vector<std::string> & keywords() const {
268  return info().keywords();
269  }
270 
272  virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
274  return *this;
275  }
276 
277 
281  assert(_info && "No AnalysisInfo object :O");
282  return *_info;
283  }
284 
286 
287 
290 
292  const ParticlePair& beams() const;
293 
295  const PdgIdPair beamIds() const;
296 
298  double sqrtS() const;
299 
301  bool merging() const {
302  return sqrtS() <= 0.0;
303  }
304 
306 
307 
313 
315  bool isCompatible(const ParticlePair& beams) const;
316 
318  bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
319 
321  bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
322 
324 
326  AnalysisHandler& handler() const { return *_analysishandler; }
327 
328 
329  protected:
330 
332  Log& getLog() const;
333 
335  double crossSection() const;
336 
339  double crossSectionPerEvent() const;
340 
344  size_t numEvents() const;
345 
349  double sumW() const;
351  double sumOfWeights() const { return sumW(); }
352 
356  double sumW2() const;
357 
358 
359  protected:
360 
363 
365  const std::string histoDir() const;
366 
368  const std::string histoPath(const std::string& hname) const;
369 
371  const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
372 
374  const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
375 
377 
378 
381 
383  const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
384  _cacheRefData();
385  return _refdata;
386  }
387 
388 
391  template <typename T=YODA::Scatter2D>
392  const T& refData(const string& hname) const {
393  _cacheRefData();
394  MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
395  if (!_refdata[hname]) {
396  MSG_ERROR("Can't find reference histogram " << hname);
397  throw Exception("Reference data " + hname + " not found.");
398  }
399  return dynamic_cast<T&>(*_refdata[hname]);
400  }
401 
402 
405  template <typename T=YODA::Scatter2D>
406  const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
407  const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
408  return refData(hname);
409  }
410 
412 
413 
416 
418  CounterPtr & book(CounterPtr &, const std::string& name);
419 
423  CounterPtr & book(CounterPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
424 
426 
427 
430 
432  Histo1DPtr & book(Histo1DPtr &,const std::string& name, size_t nbins, double lower, double upper);
433 
435  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const std::vector<double>& binedges);
436 
438  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const std::initializer_list<double>& binedges);
439 
441  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const Scatter2D& refscatter);
442 
444  Histo1DPtr & book(Histo1DPtr &,const std::string& name);
445 
449  Histo1DPtr & book(Histo1DPtr &,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
450 
452 
453 
456 
460  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
461  size_t nxbins, double xlower, double xupper,
462  size_t nybins, double ylower, double yupper);
463 
466  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
467  const std::vector<double>& xbinedges,
468  const std::vector<double>& ybinedges);
469 
472  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
473  const std::initializer_list<double>& xbinedges,
474  const std::initializer_list<double>& ybinedges);
475 
477  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
478  const Scatter3D& refscatter);
479 
481  Histo2DPtr & book(Histo2DPtr &,const std::string& name);
482 
486  Histo2DPtr & book(Histo2DPtr &,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
487 
489 
490 
493 
495  Profile1DPtr & book(Profile1DPtr &, const std::string& name, size_t nbins, double lower, double upper);
496 
498  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const std::vector<double>& binedges);
499 
501  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const std::initializer_list<double>& binedges);
502 
504  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const Scatter2D& refscatter);
505 
507  Profile1DPtr & book(Profile1DPtr &, const std::string& name);
508 
512  Profile1DPtr & book(Profile1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
513 
515 
516 
519 
523  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
524  size_t nxbins, double xlower, double xupper,
525  size_t nybins, double ylower, double yupper);
526 
529  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
530  const std::vector<double>& xbinedges,
531  const std::vector<double>& ybinedges);
532 
535  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
536  const std::initializer_list<double>& xbinedges,
537  const std::initializer_list<double>& ybinedges);
538 
540 
541  // /// Book a 2D profile histogram with binning from a reference scatter.
542  // Profile2DPtr & book(const Profile2DPtr &, const std::string& name,
543  // const Scatter3D& refscatter);
544 
545  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
546  // Profile2DPtr & book(const Profile2DPtr &, const std::string& name);
547 
548  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
549  // ///
550  // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
551  // Profile2DPtr & book(const Profile2DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
552 
554 
555 
558 
569  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, bool copy_pts = false);
570 
581  Scatter2DPtr & book(Scatter2DPtr & s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
582 
586  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, size_t npts, double lower, double upper);
587 
591  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, const std::vector<double>& binedges);
592 
594  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, const Scatter2D& refscatter);
595 
597 
600 
611  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname, bool copy_pts=false);
612 
623  Scatter3DPtr & book(Scatter3DPtr & s3d, unsigned int datasetId, unsigned int xAxisId,
624  unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
625 
629  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname,
630  size_t xnpts, double xlower, double xupper,
631  size_t ynpts, double ylower, double yupper);
632 
636  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname,
637  const std::vector<double>& xbinedges,
638  const std::vector<double>& ybinedges);
639 
641  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname, const Scatter3D& refscatter);
642 
644 
645 
646  public:
647 
649  virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
650  (void) yao;
651  }
652 
654  virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
655  (void) raos;
656  (void) iW;
657  }
658 
660  size_t _globalDefaultWeightIndex() const;
661 
662 
664 
665 
667  const std::map<std::string,std::string> & options() {
668  return _options;
669  }
670 
672  std::string getOption(std::string optname) {
673  if ( _options.find(optname) != _options.end() )
674  return _options.find(optname)->second;
675  return "";
676  }
677 
682  template<typename T>
683  T getOption(std::string optname, T def) {
684  if (_options.find(optname) == _options.end()) return def;
685  std::stringstream ss;
686  ss << _options.find(optname)->second;
687  T ret;
688  ss >> ret;
689  return ret;
690  }
691 
693 
694 
697 
714  const CentralityProjection&
716  string calAnaName, string calHistName,
717  const string projName, bool increasing=false);
718 
719 
728  template <class T>
729  Percentile<T> bookPercentile(string projName,
730  vector<pair<float, float> > centralityBins,
731  vector<tuple<int, int, int> > ref) {
732 
733  typedef typename ReferenceTraits<T>::RefT RefT;
734  typedef rivet_shared_ptr<Wrapper<T>> WrapT;
735 
736  Percentile<T> pctl(this, projName);
737 
738  const int nCent = centralityBins.size();
739  for (int iCent = 0; iCent < nCent; ++iCent) {
740  const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
741  std::get<1>(ref[iCent]),
742  std::get<2>(ref[iCent]));
743  const RefT & refscatter = refData<RefT>(axisCode);
744 
745  WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
746  wtf = addAnalysisObject(wtf);
747 
748  CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
749  cnt = addAnalysisObject(cnt);
750 
751  pctl.add(wtf, cnt, centralityBins[iCent]);
752  }
753  return pctl;
754  }
755 
756 
757  // /// @brief Book Percentile wrappers around AnalysisObjects.
758  // ///
759  // /// Based on a previously registered CentralityProjection named @a
760  // /// projName book one (or several) AnalysisObject(s) named
761  // /// according to @a ref where the x-axis will be filled according
762  // /// to the percentile output(s) of the @projName.
763  // ///
764  // /// @todo Convert to just be called book() cf. others
765  // template <class T>
766  // PercentileXaxis<T> bookPercentileXaxis(string projName,
767  // tuple<int, int, int> ref) {
768 
769  // typedef typename ReferenceTraits<T>::RefT RefT;
770  // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
771 
772  // PercentileXaxis<T> pctl(this, projName);
773 
774  // const string axisCode = mkAxisCode(std::get<0>(ref),
775  // std::get<1>(ref),
776  // std::get<2>(ref));
777  // const RefT & refscatter = refData<RefT>(axisCode);
778 
779  // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
780  // wtf = addAnalysisObject(wtf);
781 
782  // CounterPtr cnt(_weightNames(), Counter());
783  // cnt = addAnalysisObject(cnt);
784 
785  // pctl.add(wtf, cnt);
786  // return pctl;
787  // }
788 
790 
791 
792  private:
793 
794  // Functions that have to be defined in the .cc file to avoid circular #includes
795 
797  vector<string> _weightNames() const;
798 
800  YODA::AnalysisObjectPtr _getPreload(string name) const;
801 
803  size_t _defaultWeightIndex() const;
804 
806  MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
807 
809  void _checkBookInit() const;
810 
812  bool inInit() const;
813 
815  bool inFinalize() const;
816 
817  private:
818 
820  class CounterAdapter {
821  public:
822  CounterAdapter(double x) : x_(x ) {}
823 
824  CounterAdapter(const YODA::Counter & c) : x_(c.val() ) {}
825 
826  // CounterAdapter(CounterPtr cp) : x_(cp->val() ) {}
827 
828  CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
829  assert( s.numPoints() == 1 || "Can only scale by a single value.");
830  }
831 
832  // CounterAdapter(Scatter1DPtr sp) : x_(sp->points()[0].x()) {
833  // assert( sp->numPoints() == 1 || "Can only scale by a single value.");
834  // }
835 
836  operator double() const { return x_; }
837 
838  private:
839  double x_;
840 
841  };
842 
843 
844  public:
845 
846  double dbl(double x) { return x; }
847  double dbl(const YODA::Counter & c) { return c.val(); }
848  double dbl(const YODA::Scatter1D & s) {
849  assert( s.numPoints() == 1 );
850  return s.points()[0].x();
851  }
852 
857 
859  void scale(CounterPtr cnt, CounterAdapter factor);
860 
864  void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
865  for (auto& c : cnts) scale(c, factor);
866  }
867 
869  template<typename T>
870  void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
871  for (auto& m : maps) scale(m.second, factor);
872  }
873 
875  template <std::size_t array_size>
876  void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
877  // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
878  for (auto& c : cnts) scale(c, factor);
879  }
880 
881 
883  void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
884 
888  void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
889  for (auto& h : histos) normalize(h, norm, includeoverflows);
890  }
891 
893  template<typename T>
894  void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
895  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
896  }
897 
899  template <std::size_t array_size>
900  void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
901  for (auto& h : histos) normalize(h, norm, includeoverflows);
902  }
903 
905  void scale(Histo1DPtr histo, CounterAdapter factor);
906 
910  void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
911  for (auto& h : histos) scale(h, factor);
912  }
913 
915  template<typename T>
916  void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
917  for (auto& m : maps) scale(m.second, factor);
918  }
919 
921  template <std::size_t array_size>
922  void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
923  for (auto& h : histos) scale(h, factor);
924  }
925 
926 
928  void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
929 
933  void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
934  for (auto& h : histos) normalize(h, norm, includeoverflows);
935  }
936 
938  template<typename T>
939  void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
940  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
941  }
942 
944  template <std::size_t array_size>
945  void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
946  for (auto& h : histos) normalize(h, norm, includeoverflows);
947  }
948 
950  void scale(Histo2DPtr histo, CounterAdapter factor);
951 
955  void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
956  for (auto& h : histos) scale(h, factor);
957  }
958 
960  template<typename T>
961  void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
962  for (auto& m : maps) scale(m.second, factor);
963  }
964 
966  template <std::size_t array_size>
967  void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
968  for (auto& h : histos) scale(h, factor);
969  }
970 
971 
975  void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
976 
980  void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
981 
982 
986  void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
987 
991  void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
992 
993 
997  void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
998 
1002  void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1003 
1004 
1008  void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1009 
1013  void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1014 
1015 
1019  void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1020 
1024  void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1025 
1026 
1030  void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1031 
1035  void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1036 
1037 
1041  void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1042 
1046  void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1047 
1048 
1052  void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1053 
1057  void integrate(const Histo1D& h, Scatter2DPtr s) const;
1058 
1060 
1061 
1062  public:
1063 
1065  const vector<MultiweightAOPtr>& analysisObjects() const {
1066  return _analysisobjects;
1067  }
1068 
1069 
1070  protected:
1071 
1074 
1076  template <typename YODAT>
1077  shared_ptr<YODAT> getPreload(string path) const {
1078  return dynamic_pointer_cast<YODAT>(_getPreload(path));
1079  }
1080 
1081 
1083  template <typename YODAT>
1084  rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT & yao) {
1085  typedef Wrapper<YODAT> WrapperT;
1086  typedef shared_ptr<YODAT> YODAPtrT;
1087  typedef rivet_shared_ptr<WrapperT> RAOT;
1088 
1089  if ( !inInit() && !inFinalize() ) {
1090  MSG_ERROR("Can't book objects outside of init()");
1091  throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1092  }
1093 
1094  // First check that we haven't booked this before.
1095  // This is allowed when booking in finalize: just warn in that case.
1096  // If in init(), throw an exception: it's 99.9% never going to be intentional.
1097  for (auto & waold : analysisObjects()) {
1098  if ( yao.path() == waold.get()->basePath() ) {
1099  const string msg = "Found double-booking of " + yao.path() + " in " + name();
1100  if ( inInit() ) {
1101  MSG_ERROR(msg);
1102  throw LookupError(msg);
1103  } else {
1104  MSG_WARNING(msg + ". Keeping previous booking");
1105  }
1106  return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1107  }
1108  }
1109 
1110  shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1111  wao->_basePath = yao.path();
1112  YODAPtrT yaop = make_shared<YODAT>(yao);
1113 
1114  for (const string& weightname : _weightNames()) {
1115  // Create two YODA objects for each weight. Copy from
1116  // preloaded YODAs if present. First the finalized yoda:
1117  string finalpath = yao.path();
1118  if ( weightname != "" ) finalpath += "[" + weightname + "]";
1119  YODAPtrT preload = getPreload<YODAT>(finalpath);
1120  if ( preload ) {
1121  if ( !bookingCompatible(preload, yaop) ) {
1122  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1123  << finalpath << " for " << name());
1124  preload = nullptr;
1125  } else {
1126  MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1127  wao->_final.push_back(make_shared<YODAT>(*preload));
1128  }
1129  }
1130  if ( !preload ) {
1131  wao->_final.push_back(make_shared<YODAT>(yao));
1132  wao->_final.back()->setPath(finalpath);
1133  }
1134 
1135  // Then the raw filling yodas.
1136  string rawpath = "/RAW" + finalpath;
1137  preload = getPreload<YODAT>(rawpath);
1138  if ( preload ) {
1139  if ( !bookingCompatible(preload, yaop) ) {
1140  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1141  << rawpath << " for " << name());
1142  preload = nullptr;
1143  } else {
1144  MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1145  wao->_persistent.push_back(make_shared<YODAT>(*preload));
1146  }
1147  }
1148  if ( !preload ) {
1149  wao->_persistent.push_back(make_shared<YODAT>(yao));
1150  wao->_persistent.back()->setPath(rawpath);
1151  }
1152  }
1153  rivet_shared_ptr<WrapperT> ret(wao);
1154 
1155  ret.get()->unsetActiveWeight();
1156  if ( inFinalize() ) {
1157  // If booked in finalize() we assume it is the first time
1158  // finalize is run.
1159  ret.get()->pushToFinal();
1160  ret.get()->setActiveFinalWeightIdx(0);
1161  }
1162  _analysisobjects.push_back(ret);
1163 
1164  return ret;
1165  }
1166 
1167 
1169  template <typename AO=MultiweightAOPtr>
1170  AO addAnalysisObject(const AO & aonew) {
1171  _checkBookInit();
1172 
1173  for (const MultiweightAOPtr& ao : analysisObjects()) {
1174 
1175  // Check AO base-name first
1176  ao.get()->setActiveWeightIdx(_defaultWeightIndex());
1177  aonew.get()->setActiveWeightIdx(_defaultWeightIndex());
1178  if (ao->path() != aonew->path()) continue;
1179 
1180  // If base-name matches, check compatibility
1181  // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1182  AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1183  if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1184  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1185  << aonew->path() << " for " << name());
1186  throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1187  }
1188 
1189  // Finally, check all weight variations
1190  for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1191  aoold.get()->setActiveWeightIdx(weightIdx);
1192  aonew.get()->setActiveWeightIdx(weightIdx);
1193  if (aoold->path() != aonew->path()) {
1194  MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1195  << aonew->path() << " for " << name());
1196  throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1197  }
1198  }
1199 
1200  // They're fully compatible: bind and return
1201  aoold.get()->unsetActiveWeight();
1202  MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1203  return aoold;
1204  }
1205 
1206  // No equivalent found
1207  MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1208  aonew.get()->unsetActiveWeight();
1209 
1210  _analysisobjects.push_back(aonew);
1211  return aonew;
1212  }
1213 
1215  void removeAnalysisObject(const std::string& path);
1216 
1218  void removeAnalysisObject(const MultiweightAOPtr & ao);
1219 
1220  // /// Get all data objects, for all analyses, from the AnalysisHandler
1221  // /// @todo Can we remove this? Why not call handler().getData()?
1222  // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1223 
1224 
1226  template <typename AO=MultiweightAOPtr>
1227  const AO getAnalysisObject(const std::string& aoname) const {
1228  for (const MultiweightAOPtr& ao : analysisObjects()) {
1229  ao.get()->setActiveWeightIdx(_defaultWeightIndex());
1230  if (ao->path() == histoPath(aoname)) {
1231  // return dynamic_pointer_cast<AO>(ao);
1232  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1233  }
1234  }
1235  throw LookupError("Data object " + histoPath(aoname) + " not found");
1236  }
1237 
1238 
1239  // /// Get a data object from the histogram system
1240  // template <typename AO=YODA::AnalysisObject>
1241  // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
1242  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1243  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1244  // }
1245  // throw LookupError("Data object " + histoPath(name) + " not found");
1246  // }
1247 
1248  // /// Get a data object from the histogram system (non-const)
1249  // template <typename AO=YODA::AnalysisObject>
1250  // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1251  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1252  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1253  // }
1254  // throw LookupError("Data object " + histoPath(name) + " not found");
1255  // }
1256 
1257 
1260  template <typename AO=MultiweightAOPtr>
1261  AO getAnalysisObject(const std::string& ananame,
1262  const std::string& aoname) {
1263  MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1264  // return dynamic_pointer_cast<AO>(ao);
1265  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1266  }
1267 
1268 
1269  // /// Get a named Histo1D object from the histogram system
1270  // const Histo1DPtr getHisto1D(const std::string& name) const {
1271  // return getAnalysisObject<Histo1D>(name);
1272  // }
1273 
1274  // /// Get a named Histo1D object from the histogram system (non-const)
1275  // Histo1DPtr getHisto1D(const std::string& name) {
1276  // return getAnalysisObject<Histo1D>(name);
1277  // }
1278 
1279  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1280  // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1281  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1282  // }
1283 
1284  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1285  // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1286  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1287  // }
1288 
1289 
1290  // /// Get a named Histo2D object from the histogram system
1291  // const Histo2DPtr getHisto2D(const std::string& name) const {
1292  // return getAnalysisObject<Histo2D>(name);
1293  // }
1294 
1295  // /// Get a named Histo2D object from the histogram system (non-const)
1296  // Histo2DPtr getHisto2D(const std::string& name) {
1297  // return getAnalysisObject<Histo2D>(name);
1298  // }
1299 
1300  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1301  // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1302  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1303  // }
1304 
1305  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1306  // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1307  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1308  // }
1309 
1310 
1311  // /// Get a named Profile1D object from the histogram system
1312  // const Profile1DPtr getProfile1D(const std::string& name) const {
1313  // return getAnalysisObject<Profile1D>(name);
1314  // }
1315 
1316  // /// Get a named Profile1D object from the histogram system (non-const)
1317  // Profile1DPtr getProfile1D(const std::string& name) {
1318  // return getAnalysisObject<Profile1D>(name);
1319  // }
1320 
1321  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1322  // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1323  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1324  // }
1325 
1326  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1327  // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1328  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1329  // }
1330 
1331 
1332  // /// Get a named Profile2D object from the histogram system
1333  // const Profile2DPtr getProfile2D(const std::string& name) const {
1334  // return getAnalysisObject<Profile2D>(name);
1335  // }
1336 
1337  // /// Get a named Profile2D object from the histogram system (non-const)
1338  // Profile2DPtr getProfile2D(const std::string& name) {
1339  // return getAnalysisObject<Profile2D>(name);
1340  // }
1341 
1342  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1343  // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1344  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1345  // }
1346 
1347  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1348  // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1349  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1350  // }
1351 
1352 
1353  // /// Get a named Scatter2D object from the histogram system
1354  // const Scatter2DPtr getScatter2D(const std::string& name) const {
1355  // return getAnalysisObject<Scatter2D>(name);
1356  // }
1357 
1358  // /// Get a named Scatter2D object from the histogram system (non-const)
1359  // Scatter2DPtr getScatter2D(const std::string& name) {
1360  // return getAnalysisObject<Scatter2D>(name);
1361  // }
1362 
1363  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1364  // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1365  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1366  // }
1367 
1368  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1369  // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1370  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1371  // }
1372 
1374 
1375 
1376  private:
1377 
1379  string _defaultname;
1380 
1382  unique_ptr<AnalysisInfo> _info;
1383 
1386  vector<MultiweightAOPtr> _analysisobjects;
1387 
1390  double _crossSection;
1391  bool _gotCrossSection;
1393 
1395  AnalysisHandler* _analysishandler;
1396 
1399  mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1400 
1402  map<string, string> _options;
1403 
1405  string _optstring;
1406 
1407  private:
1408 
1411 
1413  void _cacheRefData() const;
1414 
1416 
1417 
1420  Analysis& operator=(const Analysis&);
1421 
1422  };
1423 
1424 
1425  // Template specialisation for literal character strings (which don't play well with stringstream)
1426  template<>
1427  inline const char* Analysis::getOption(std::string optname, const char* def) {
1428  return getOption<std::string>(optname, def).c_str();
1429  }
1430 
1431 
1432 }
1433 
1434 
1435 // Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1436 #include "Rivet/AnalysisBuilder.hh"
1437 
1440 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1441 
1444 // #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1445 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1446 
1449 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1450 
1453 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1454 
1455 
1456 
1457 #endif
double sumOfWeights() const
Alias.
Definition: Analysis.hh:351
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:1227
const double luminosityfb() const
The integrated data luminosity of the data set in 1/fb.
Definition: AnalysisInfo.hh:155
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition: AnalysisInfo.hh:129
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition: AnalysisInfo.hh:122
const vector< MultiweightAOPtr > & analysisObjects() const
List of registered analysis data objects.
Definition: Analysis.hh:1065
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:163
void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition: CentralityProjection.hh:26
virtual void init()
Definition: Analysis.hh:87
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:383
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:215
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition: Analysis.hh:225
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition: Analysis.hh:916
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition: Analysis.hh:140
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.
virtual double luminosity() const
The integrated luminosity in inverse picobarn.
Definition: Analysis.hh:205
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:219
const std::string & spiresId() const
Get the SPIRES ID code for this analysis.
Definition: AnalysisInfo.hh:72
const std::vector< std::string > & keywords() const
Analysis Keywords for grouping etc.
Definition: AnalysisInfo.hh:169
virtual void analyze(const Event &event)=0
virtual std::string collider() const
Collider on which the experiment ran.
Definition: Analysis.hh:191
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:162
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:945
bool bookingCompatible(TPtr a, TPtr b)
Definition: RivetYODA.hh:607
virtual std::vector< std::string > authors() const
Names & emails of paper/analysis authors.
Definition: Analysis.hh:153
virtual std::vector< std::string > validation() const
make-style commands for validating this analysis.
Definition: Analysis.hh:235
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:230
const std::string & description() const
Get a full description of the analysis. Full textual description of this analysis, what it is useful for, what experimental techniques are applied, etc. Should be treated as a chunk of restructuredText (http://docutils.sourceforge.net/rst.html), with equations to be rendered as LaTeX with amsmath operators.
Definition: AnalysisInfo.hh:102
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:939
const std::string & bibKey() const
BibTeX citation key for this article.
Definition: AnalysisInfo.hh:172
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 double luminosity() const
The integrated data luminosity of the data set in 1/pb.
Definition: AnalysisInfo.hh:157
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition: AnalysisInfo.hh:288
void setRefDataName(const std::string &name)
Set the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:62
void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
virtual void finalize()
Definition: Analysis.hh:100
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition: Analysis.hh:864
const std::string & year() const
When the original experimental analysis was published. When the refereed paper on which this is based...
Definition: AnalysisInfo.hh:149
const std::string & runInfo() const
Information about the events needed as input for this analysis. Event types, energies, kinematic cuts, particles to be considered stable, etc. etc. Should be treated as a restructuredText bullet list (http://docutils.sourceforge.net/rst.html)
Definition: AnalysisInfo.hh:112
virtual const std::vector< PdgIdPair > & requiredBeams() const
Return the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:252
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition: Analysis.hh:406
std::string getOption(std::string optname)
Get an option for this analysis instance as a string.
Definition: Analysis.hh:672
virtual void setRefDataName(const std::string &ref_data="")
Set name of reference data file, which could be different from plugin name.
Definition: Analysis.hh:135
AnalysisInfo & info()
Definition: Analysis.hh:280
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:145
bool merging() const
Check if we are running rivet-merge.
Definition: Analysis.hh:301
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition: Analysis.hh:272
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:267
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:1084
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition: Analysis.hh:220
double sqrtS() const
Centre of mass energy for this run.
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition: Analysis.hh:181
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:870
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:900
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:256
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:326
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:65
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:933
const T & refData(const string &hname) const
Definition: Analysis.hh:392
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:186
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:888
The key class for coordination of Analysis objects and the event loop.
Definition: AnalysisHandler.hh:23
virtual std::string getRefDataName() const
Get name of reference data file, which could be different from plugin name.
Definition: Analysis.hh:130
virtual std::string description() const
Get a full description of the analysis.
Definition: Analysis.hh:172
const std::map< std::string, std::string > & options()
Return the map of all options given to this analysis.
Definition: Analysis.hh:667
const std::string histoDir() const
Get the canonical histogram "directory" path for this analysis.
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition: Analysis.hh:210
virtual std::string year() const
When the original experimental analysis was published.
Definition: Analysis.hh:196
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition: Analysis.hh:1261
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:186
void scale(CounterPtr cnt, CounterAdapter factor)
Multiplicatively scale the given counter, cnt, by factor factor.
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:225
shared_ptr< YODAT > getPreload(string path) const
Get a preloaded YODA object.
Definition: Analysis.hh:1077
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:133
const AnalysisInfo & info() const
Get the actual AnalysisInfo object in which all this metadata is stored.
Definition: Analysis.hh:113
const std::string & collider() const
Collider on which the experiment ran.
Definition: AnalysisInfo.hh:140
void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
void scale(const CounterPtr(&cnts)[array_size], CounterAdapter factor)
Definition: Analysis.hh:876
Analysis(const std::string &name)
Constructor.
virtual std::string name() const
Get the name of the analysis.
Definition: Analysis.hh:125
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition: Analysis.hh:910
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition: Analysis.hh:262
const std::vector< std::string > & authors() const
Names & emails of paper/analysis authors. Names and email of authors in &#39;NAME <EMAIL>&#39; format...
Definition: AnalysisInfo.hh:81
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:126
T getOption(std::string optname, T def)
Get an option for this analysis instance converted to a specific type.
Definition: Analysis.hh:683
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:119
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:240
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:76
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition: Analysis.hh:201
virtual std::string refFile() const
Location of reference data YODA file.
Definition: Analysis.hh:246
const std::string & summary() const
Get a short description of the analysis. Short (one sentence) description used as an index entry...
Definition: AnalysisInfo.hh:91
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:894
std::string refFile() const
Find the path to the reference-data file for this analysis.
std::string getRefDataName() const
Get the reference data name of the analysis (if different from plugin name).
Definition: AnalysisInfo.hh:56
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:179
void scale(const Histo1DPtr(&histos)[array_size], CounterAdapter factor)
Definition: Analysis.hh:922
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:1170
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:729