Rivet  3.1.2
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 
342  double crossSectionError() const;
343 
346  double crossSectionErrorPerEvent() const;
347 
351  size_t numEvents() const;
352 
356  double sumW() const;
358  double sumOfWeights() const { return sumW(); }
359 
363  double sumW2() const;
364 
365 
366  protected:
367 
370 
372  const std::string histoDir() const;
373 
375  const std::string histoPath(const std::string& hname) const;
376 
378  const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
379 
381  const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
382 
384 
385 
388 
390  const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
391  _cacheRefData();
392  return _refdata;
393  }
394 
395 
398  template <typename T=YODA::Scatter2D>
399  const T& refData(const string& hname) const {
400  _cacheRefData();
401  MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
402  if (!_refdata[hname]) {
403  MSG_ERROR("Can't find reference histogram " << hname);
404  throw Exception("Reference data " + hname + " not found.");
405  }
406  return dynamic_cast<T&>(*_refdata[hname]);
407  }
408 
409 
412  template <typename T=YODA::Scatter2D>
413  const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
414  const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
415  return refData(hname);
416  }
417 
419 
420 
423 
425  CounterPtr & book(CounterPtr &, const std::string& name);
426 
430  CounterPtr & book(CounterPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
431 
433 
434 
437 
439  Histo1DPtr & book(Histo1DPtr &,const std::string& name, size_t nbins, double lower, double upper);
440 
442  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const std::vector<double>& binedges);
443 
445  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const std::initializer_list<double>& binedges);
446 
448  Histo1DPtr & book(Histo1DPtr &,const std::string& name, const Scatter2D& refscatter);
449 
451  Histo1DPtr & book(Histo1DPtr &,const std::string& name);
452 
456  Histo1DPtr & book(Histo1DPtr &,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
457 
459 
460 
463 
467  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
468  size_t nxbins, double xlower, double xupper,
469  size_t nybins, double ylower, double yupper);
470 
473  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
474  const std::vector<double>& xbinedges,
475  const std::vector<double>& ybinedges);
476 
479  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
480  const std::initializer_list<double>& xbinedges,
481  const std::initializer_list<double>& ybinedges);
482 
484  Histo2DPtr & book(Histo2DPtr &,const std::string& name,
485  const Scatter3D& refscatter);
486 
488  Histo2DPtr & book(Histo2DPtr &,const std::string& name);
489 
493  Histo2DPtr & book(Histo2DPtr &,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
494 
496 
497 
500 
502  Profile1DPtr & book(Profile1DPtr &, const std::string& name, size_t nbins, double lower, double upper);
503 
505  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const std::vector<double>& binedges);
506 
508  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const std::initializer_list<double>& binedges);
509 
511  Profile1DPtr & book(Profile1DPtr &, const std::string& name, const Scatter2D& refscatter);
512 
514  Profile1DPtr & book(Profile1DPtr &, const std::string& name);
515 
519  Profile1DPtr & book(Profile1DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
520 
522 
523 
526 
530  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
531  size_t nxbins, double xlower, double xupper,
532  size_t nybins, double ylower, double yupper);
533 
536  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
537  const std::vector<double>& xbinedges,
538  const std::vector<double>& ybinedges);
539 
542  Profile2DPtr & book(Profile2DPtr &, const std::string& name,
543  const std::initializer_list<double>& xbinedges,
544  const std::initializer_list<double>& ybinedges);
545 
547 
548  // /// Book a 2D profile histogram with binning from a reference scatter.
549  // Profile2DPtr & book(const Profile2DPtr &, const std::string& name,
550  // const Scatter3D& refscatter);
551 
552  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
553  // Profile2DPtr & book(const Profile2DPtr &, const std::string& name);
554 
555  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
556  // ///
557  // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
558  // Profile2DPtr & book(const Profile2DPtr &, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
559 
561 
562 
565 
576  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, bool copy_pts = false);
577 
588  Scatter2DPtr & book(Scatter2DPtr & s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
589 
593  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, size_t npts, double lower, double upper);
594 
598  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, const std::vector<double>& binedges);
599 
601  Scatter2DPtr & book(Scatter2DPtr & s2d, const string& hname, const Scatter2D& refscatter);
602 
604 
607 
618  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname, bool copy_pts=false);
619 
630  Scatter3DPtr & book(Scatter3DPtr & s3d, unsigned int datasetId, unsigned int xAxisId,
631  unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
632 
636  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname,
637  size_t xnpts, double xlower, double xupper,
638  size_t ynpts, double ylower, double yupper);
639 
643  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname,
644  const std::vector<double>& xbinedges,
645  const std::vector<double>& ybinedges);
646 
648  Scatter3DPtr & book(Scatter3DPtr & s3d, const std::string& hname, const Scatter3D& refscatter);
649 
651 
652 
653  public:
654 
656  virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
657  (void) yao;
658  }
659 
661  virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
662  (void) raos;
663  (void) iW;
664  }
665 
667  size_t _globalDefaultWeightIndex() const;
668 
669 
671 
672 
674  const std::map<std::string,std::string>& options() const {
675  return _options;
676  }
677 
679  std::string getOption(std::string optname) const {
680  if ( _options.find(optname) != _options.end() )
681  return _options.find(optname)->second;
682  return "";
683  }
684 
689  template<typename T>
690  T getOption(std::string optname, T def) const {
691  if (_options.find(optname) == _options.end()) return def;
692  std::stringstream ss;
693  ss << _options.find(optname)->second;
694  T ret;
695  ss >> ret;
696  return ret;
697  }
698 
703  std::string getOption(std::string optname, const char* def) {
704  return getOption<std::string>(optname, def);
705  }
706 
708 
709 
712 
729  const CentralityProjection&
731  string calAnaName, string calHistName,
732  const string projName, bool increasing=false);
733 
734 
743  template <class T>
744  Percentile<T> bookPercentile(string projName,
745  vector<pair<float, float> > centralityBins,
746  vector<tuple<int, int, int> > ref) {
747 
748  typedef typename ReferenceTraits<T>::RefT RefT;
749  typedef rivet_shared_ptr<Wrapper<T>> WrapT;
750 
751  Percentile<T> pctl(this, projName);
752 
753  const int nCent = centralityBins.size();
754  for (int iCent = 0; iCent < nCent; ++iCent) {
755  const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
756  std::get<1>(ref[iCent]),
757  std::get<2>(ref[iCent]));
758  const RefT & refscatter = refData<RefT>(axisCode);
759 
760  WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
761  wtf = addAnalysisObject(wtf);
762 
763  CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
764  cnt = addAnalysisObject(cnt);
765 
766  pctl.add(wtf, cnt, centralityBins[iCent]);
767  }
768  return pctl;
769  }
770 
771 
772  // /// @brief Book Percentile wrappers around AnalysisObjects.
773  // ///
774  // /// Based on a previously registered CentralityProjection named @a
775  // /// projName book one (or several) AnalysisObject(s) named
776  // /// according to @a ref where the x-axis will be filled according
777  // /// to the percentile output(s) of the @projName.
778  // ///
779  // /// @todo Convert to just be called book() cf. others
780  // template <class T>
781  // PercentileXaxis<T> bookPercentileXaxis(string projName,
782  // tuple<int, int, int> ref) {
783 
784  // typedef typename ReferenceTraits<T>::RefT RefT;
785  // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
786 
787  // PercentileXaxis<T> pctl(this, projName);
788 
789  // const string axisCode = mkAxisCode(std::get<0>(ref),
790  // std::get<1>(ref),
791  // std::get<2>(ref));
792  // const RefT & refscatter = refData<RefT>(axisCode);
793 
794  // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
795  // wtf = addAnalysisObject(wtf);
796 
797  // CounterPtr cnt(_weightNames(), Counter());
798  // cnt = addAnalysisObject(cnt);
799 
800  // pctl.add(wtf, cnt);
801  // return pctl;
802  // }
803 
805 
806 
807  private:
808 
809  // Functions that have to be defined in the .cc file to avoid circular #includes
810 
812  vector<string> _weightNames() const;
813 
815  YODA::AnalysisObjectPtr _getPreload(string name) const;
816 
818  size_t _defaultWeightIndex() const;
819 
821  MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
822 
824  void _checkBookInit() const;
825 
827  bool inInit() const;
828 
830  bool inFinalize() const;
831 
832  private:
833 
835  class CounterAdapter {
836  public:
837  CounterAdapter(double x) : x_(x ) {}
838 
839  CounterAdapter(const YODA::Counter & c) : x_(c.val() ) {}
840 
841  // CounterAdapter(CounterPtr cp) : x_(cp->val() ) {}
842 
843  CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
844  assert( s.numPoints() == 1 || "Can only scale by a single value.");
845  }
846 
847  // CounterAdapter(Scatter1DPtr sp) : x_(sp->points()[0].x()) {
848  // assert( sp->numPoints() == 1 || "Can only scale by a single value.");
849  // }
850 
851  operator double() const { return x_; }
852 
853  private:
854  double x_;
855 
856  };
857 
858 
859  public:
860 
861  double dbl(double x) { return x; }
862  double dbl(const YODA::Counter & c) { return c.val(); }
863  double dbl(const YODA::Scatter1D & s) {
864  assert( s.numPoints() == 1 );
865  return s.points()[0].x();
866  }
867 
872 
874  void scale(CounterPtr cnt, CounterAdapter factor);
875 
879  void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
880  for (auto& c : cnts) scale(c, factor);
881  }
882 
884  template<typename T>
885  void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
886  for (auto& m : maps) scale(m.second, factor);
887  }
888 
890  template <std::size_t array_size>
891  void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
892  // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
893  for (auto& c : cnts) scale(c, factor);
894  }
895 
896 
898  void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
899 
903  void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
904  for (auto& h : histos) normalize(h, norm, includeoverflows);
905  }
906 
908  template<typename T>
909  void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
910  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
911  }
912 
914  template <std::size_t array_size>
915  void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
916  for (auto& h : histos) normalize(h, norm, includeoverflows);
917  }
918 
920  void scale(Histo1DPtr histo, CounterAdapter factor);
921 
925  void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
926  for (auto& h : histos) scale(h, factor);
927  }
928 
930  template<typename T>
931  void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
932  for (auto& m : maps) scale(m.second, factor);
933  }
934 
936  template <std::size_t array_size>
937  void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
938  for (auto& h : histos) scale(h, factor);
939  }
940 
941 
943  void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
944 
948  void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
949  for (auto& h : histos) normalize(h, norm, includeoverflows);
950  }
951 
953  template<typename T>
954  void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
955  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
956  }
957 
959  template <std::size_t array_size>
960  void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
961  for (auto& h : histos) normalize(h, norm, includeoverflows);
962  }
963 
965  void scale(Histo2DPtr histo, CounterAdapter factor);
966 
970  void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
971  for (auto& h : histos) scale(h, factor);
972  }
973 
975  template<typename T>
976  void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
977  for (auto& m : maps) scale(m.second, factor);
978  }
979 
981  template <std::size_t array_size>
982  void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
983  for (auto& h : histos) scale(h, factor);
984  }
985 
986 
990  void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
991 
995  void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
996 
997 
1001  void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1002 
1006  void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1007 
1008 
1012  void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1013 
1017  void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1018 
1019 
1023  void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1024 
1028  void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1029 
1030 
1034  void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1035 
1039  void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1040 
1041 
1045  void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1046 
1050  void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1051 
1052 
1056  void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1057 
1061  void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1062 
1063 
1067  void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1068 
1072  void integrate(const Histo1D& h, Scatter2DPtr s) const;
1073 
1075 
1076 
1077  public:
1078 
1080  const vector<MultiweightAOPtr>& analysisObjects() const {
1081  return _analysisobjects;
1082  }
1083 
1084 
1085  protected:
1086 
1089 
1091  template <typename YODAT>
1092  shared_ptr<YODAT> getPreload(string path) const {
1093  return dynamic_pointer_cast<YODAT>(_getPreload(path));
1094  }
1095 
1096 
1098  template <typename YODAT>
1099  rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT & yao) {
1100  typedef Wrapper<YODAT> WrapperT;
1101  typedef shared_ptr<YODAT> YODAPtrT;
1102  typedef rivet_shared_ptr<WrapperT> RAOT;
1103 
1104  if ( !inInit() && !inFinalize() ) {
1105  MSG_ERROR("Can't book objects outside of init()");
1106  throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1107  }
1108 
1109  // First check that we haven't booked this before.
1110  // This is allowed when booking in finalize: just warn in that case.
1111  // If in init(), throw an exception: it's 99.9% never going to be intentional.
1112  for (auto & waold : analysisObjects()) {
1113  if ( yao.path() == waold.get()->basePath() ) {
1114  const string msg = "Found double-booking of " + yao.path() + " in " + name();
1115  if ( inInit() ) {
1116  MSG_ERROR(msg);
1117  throw LookupError(msg);
1118  } else {
1119  MSG_WARNING(msg + ". Keeping previous booking");
1120  }
1121  return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1122  }
1123  }
1124 
1125  shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1126  wao->_basePath = yao.path();
1127  YODAPtrT yaop = make_shared<YODAT>(yao);
1128 
1129  for (const string& weightname : _weightNames()) {
1130  // Create two YODA objects for each weight. Copy from
1131  // preloaded YODAs if present. First the finalized yoda:
1132  string finalpath = yao.path();
1133  if ( weightname != "" ) finalpath += "[" + weightname + "]";
1134  YODAPtrT preload = getPreload<YODAT>(finalpath);
1135  if ( preload ) {
1136  if ( !bookingCompatible(preload, yaop) ) {
1137  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1138  << finalpath << " for " << name());
1139  preload = nullptr;
1140  } else {
1141  MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1142  wao->_final.push_back(make_shared<YODAT>(*preload));
1143  }
1144  }
1145  if ( !preload ) {
1146  wao->_final.push_back(make_shared<YODAT>(yao));
1147  wao->_final.back()->setPath(finalpath);
1148  }
1149 
1150  // Then the raw filling yodas.
1151  string rawpath = "/RAW" + finalpath;
1152  preload = getPreload<YODAT>(rawpath);
1153  if ( preload ) {
1154  if ( !bookingCompatible(preload, yaop) ) {
1155  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1156  << rawpath << " for " << name());
1157  preload = nullptr;
1158  } else {
1159  MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1160  wao->_persistent.push_back(make_shared<YODAT>(*preload));
1161  }
1162  }
1163  if ( !preload ) {
1164  wao->_persistent.push_back(make_shared<YODAT>(yao));
1165  wao->_persistent.back()->setPath(rawpath);
1166  }
1167  }
1168  rivet_shared_ptr<WrapperT> ret(wao);
1169 
1170  ret.get()->unsetActiveWeight();
1171  if ( inFinalize() ) {
1172  // If booked in finalize() we assume it is the first time
1173  // finalize is run.
1174  ret.get()->pushToFinal();
1175  ret.get()->setActiveFinalWeightIdx(0);
1176  }
1177  _analysisobjects.push_back(ret);
1178 
1179  return ret;
1180  }
1181 
1182 
1184  template <typename AO=MultiweightAOPtr>
1185  AO addAnalysisObject(const AO & aonew) {
1186  _checkBookInit();
1187 
1188  for (const MultiweightAOPtr& ao : analysisObjects()) {
1189 
1190  // Check AO base-name first
1191  ao.get()->setActiveWeightIdx(_defaultWeightIndex());
1192  aonew.get()->setActiveWeightIdx(_defaultWeightIndex());
1193  if (ao->path() != aonew->path()) continue;
1194 
1195  // If base-name matches, check compatibility
1196  // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1197  AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1198  if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1199  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1200  << aonew->path() << " for " << name());
1201  throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1202  }
1203 
1204  // Finally, check all weight variations
1205  for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1206  aoold.get()->setActiveWeightIdx(weightIdx);
1207  aonew.get()->setActiveWeightIdx(weightIdx);
1208  if (aoold->path() != aonew->path()) {
1209  MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1210  << aonew->path() << " for " << name());
1211  throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1212  }
1213  }
1214 
1215  // They're fully compatible: bind and return
1216  aoold.get()->unsetActiveWeight();
1217  MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1218  return aoold;
1219  }
1220 
1221  // No equivalent found
1222  MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1223  aonew.get()->unsetActiveWeight();
1224 
1225  _analysisobjects.push_back(aonew);
1226  return aonew;
1227  }
1228 
1230  void removeAnalysisObject(const std::string& path);
1231 
1233  void removeAnalysisObject(const MultiweightAOPtr & ao);
1234 
1235  // /// Get all data objects, for all analyses, from the AnalysisHandler
1236  // /// @todo Can we remove this? Why not call handler().getData()?
1237  // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1238 
1239 
1241  template <typename AO=MultiweightAOPtr>
1242  const AO getAnalysisObject(const std::string& aoname) const {
1243  for (const MultiweightAOPtr& ao : analysisObjects()) {
1244  ao.get()->setActiveWeightIdx(_defaultWeightIndex());
1245  if (ao->path() == histoPath(aoname)) {
1246  // return dynamic_pointer_cast<AO>(ao);
1247  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1248  }
1249  }
1250  throw LookupError("Data object " + histoPath(aoname) + " not found");
1251  }
1252 
1253 
1254  // /// Get a data object from the histogram system
1255  // template <typename AO=YODA::AnalysisObject>
1256  // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
1257  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1258  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1259  // }
1260  // throw LookupError("Data object " + histoPath(name) + " not found");
1261  // }
1262 
1263  // /// Get a data object from the histogram system (non-const)
1264  // template <typename AO=YODA::AnalysisObject>
1265  // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1266  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1267  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1268  // }
1269  // throw LookupError("Data object " + histoPath(name) + " not found");
1270  // }
1271 
1272 
1275  template <typename AO=MultiweightAOPtr>
1276  AO getAnalysisObject(const std::string& ananame,
1277  const std::string& aoname) {
1278  MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1279  // return dynamic_pointer_cast<AO>(ao);
1280  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1281  }
1282 
1283 
1284  // /// Get a named Histo1D object from the histogram system
1285  // const Histo1DPtr getHisto1D(const std::string& name) const {
1286  // return getAnalysisObject<Histo1D>(name);
1287  // }
1288 
1289  // /// Get a named Histo1D object from the histogram system (non-const)
1290  // Histo1DPtr getHisto1D(const std::string& name) {
1291  // return getAnalysisObject<Histo1D>(name);
1292  // }
1293 
1294  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1295  // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1296  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1297  // }
1298 
1299  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1300  // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1301  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1302  // }
1303 
1304 
1305  // /// Get a named Histo2D object from the histogram system
1306  // const Histo2DPtr getHisto2D(const std::string& name) const {
1307  // return getAnalysisObject<Histo2D>(name);
1308  // }
1309 
1310  // /// Get a named Histo2D object from the histogram system (non-const)
1311  // Histo2DPtr getHisto2D(const std::string& name) {
1312  // return getAnalysisObject<Histo2D>(name);
1313  // }
1314 
1315  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1316  // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1317  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1318  // }
1319 
1320  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1321  // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1322  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1323  // }
1324 
1325 
1326  // /// Get a named Profile1D object from the histogram system
1327  // const Profile1DPtr getProfile1D(const std::string& name) const {
1328  // return getAnalysisObject<Profile1D>(name);
1329  // }
1330 
1331  // /// Get a named Profile1D object from the histogram system (non-const)
1332  // Profile1DPtr getProfile1D(const std::string& name) {
1333  // return getAnalysisObject<Profile1D>(name);
1334  // }
1335 
1336  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1337  // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1338  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1339  // }
1340 
1341  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1342  // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1343  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1344  // }
1345 
1346 
1347  // /// Get a named Profile2D object from the histogram system
1348  // const Profile2DPtr getProfile2D(const std::string& name) const {
1349  // return getAnalysisObject<Profile2D>(name);
1350  // }
1351 
1352  // /// Get a named Profile2D object from the histogram system (non-const)
1353  // Profile2DPtr getProfile2D(const std::string& name) {
1354  // return getAnalysisObject<Profile2D>(name);
1355  // }
1356 
1357  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1358  // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1359  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1360  // }
1361 
1362  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1363  // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1364  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1365  // }
1366 
1367 
1368  // /// Get a named Scatter2D object from the histogram system
1369  // const Scatter2DPtr getScatter2D(const std::string& name) const {
1370  // return getAnalysisObject<Scatter2D>(name);
1371  // }
1372 
1373  // /// Get a named Scatter2D object from the histogram system (non-const)
1374  // Scatter2DPtr getScatter2D(const std::string& name) {
1375  // return getAnalysisObject<Scatter2D>(name);
1376  // }
1377 
1378  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1379  // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1380  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1381  // }
1382 
1383  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1384  // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1385  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1386  // }
1387 
1389 
1390 
1391  private:
1392 
1394  string _defaultname;
1395 
1397  unique_ptr<AnalysisInfo> _info;
1398 
1401  vector<MultiweightAOPtr> _analysisobjects;
1402 
1405  double _crossSection;
1406  bool _gotCrossSection;
1408 
1410  AnalysisHandler* _analysishandler;
1411 
1414  mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1415 
1417  map<string, string> _options;
1418 
1420  string _optstring;
1421 
1422  private:
1423 
1426 
1428  void _cacheRefData() const;
1429 
1431 
1432 
1435  Analysis& operator=(const Analysis&);
1436 
1437  };
1438 
1439 
1440  // // Template specialisation for literal character strings (which don't play well with stringstream)
1441  // template<>
1442  // inline std::string Analysis::getOption(std::string optname, const char* def) {
1443  // return getOption<std::string>(optname, def); //.c_str();
1444  // }
1445 
1446 
1447 }
1448 
1449 
1450 // Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1451 #include "Rivet/AnalysisBuilder.hh"
1452 
1453 
1456 
1459 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1460 
1463 // #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1464 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1465 
1468 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1469 
1472 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1473 
1475 
1476 
1477 #endif
double sumOfWeights() const
Alias.
Definition: Analysis.hh:358
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:1242
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:1080
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:163
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:87
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:390
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:931
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.
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition: Analysis.hh:674
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:960
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:954
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:879
std::string getOption(std::string optname) const
Get an option for this analysis instance as a string.
Definition: Analysis.hh:679
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:413
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:1099
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:885
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:915
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
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
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:948
const T & refData(const string &hname) const
Definition: Analysis.hh:399
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:903
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
#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.
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:1276
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.
T getOption(std::string optname, T def) const
Get an option for this analysis instance converted to a specific type.
Definition: Analysis.hh:690
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:1092
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:891
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:925
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
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:119
#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:240
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:76
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition: Analysis.hh:201
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:703
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:909
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:937
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:1185
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:744