Rivet  3.1.3
Analysis.hh
1 // -*- C++ -*-
2 #ifndef RIVET_Analysis_HH
3 #define RIVET_Analysis_HH
4 
5 #include "Rivet/Config/RivetCommon.hh"
6 #include "Rivet/AnalysisInfo.hh"
7 #include "Rivet/Event.hh"
8 #include "Rivet/Projection.hh"
9 #include "Rivet/ProjectionApplier.hh"
10 #include "Rivet/ProjectionHandler.hh"
11 #include "Rivet/AnalysisLoader.hh"
12 #include "Rivet/Tools/Cuts.hh"
13 #include "Rivet/Tools/Logging.hh"
14 #include "Rivet/Tools/ParticleUtils.hh"
15 #include "Rivet/Tools/BinnedHistogram.hh"
16 #include "Rivet/Tools/RivetMT2.hh"
17 #include "Rivet/Tools/RivetYODA.hh"
18 #include "Rivet/Tools/Percentile.hh"
19 #include "Rivet/Projections/CentralityProjection.hh"
20 #include <tuple>
21 
22 
25 #define vetoEvent \
26  do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0)
27 
28 
29 namespace Rivet {
30 
31 
32  // Convenience for analysis writers
33  using std::cout;
34  using std::cerr;
35  using std::endl;
36  using std::tuple;
37  using std::stringstream;
38  using std::swap;
39  using std::numeric_limits;
40 
41 
42  // Forward declaration
43  class AnalysisHandler;
44 
45 
64  class Analysis : public ProjectionApplier {
65  public:
66 
68  friend class AnalysisHandler;
69 
70 
72  Analysis(const std::string& name);
73 
75  virtual ~Analysis() {}
76 
78  Analysis& operator=(const Analysis&) = delete;
79 
80 
81  public:
82 
85 
89  virtual void init() { }
90 
95  virtual void analyze(const Event& event) = 0;
96 
102  virtual void finalize() { }
103 
105 
106 
107  public:
108 
113 
115  const AnalysisInfo& info() const {
116  assert(_info && "No AnalysisInfo object :O");
117  return *_info;
118  }
119 
127  virtual std::string name() const {
128  return ( (info().name().empty()) ? _defaultname : info().name() ) + _optstring;
129  }
130 
132  virtual std::string getRefDataName() const {
133  return (info().getRefDataName().empty()) ? _defaultname : info().getRefDataName();
134  }
135 
137  virtual void setRefDataName(const std::string& ref_data="") {
138  info().setRefDataName(!ref_data.empty() ? ref_data : name());
139  }
140 
142  virtual std::string inspireId() const {
143  return info().inspireId();
144  }
145 
147  virtual std::string spiresId() const {
148  return info().spiresId();
149  }
150 
155  virtual std::vector<std::string> authors() const {
156  return info().authors();
157  }
158 
164  virtual std::string summary() const {
165  return info().summary();
166  }
167 
174  virtual std::string description() const {
175  return info().description();
176  }
177 
183  virtual std::string runInfo() const {
184  return info().runInfo();
185  }
186 
188  virtual std::string experiment() const {
189  return info().experiment();
190  }
191 
193  virtual std::string collider() const {
194  return info().collider();
195  }
196 
198  virtual std::string year() const {
199  return info().year();
200  }
201 
203  virtual double luminosityfb() const {
204  return info().luminosityfb();
205  }
207  virtual double luminosity() const {
208  return info().luminosity();
209  }
210 
212  virtual std::vector<std::string> references() const {
213  return info().references();
214  }
215 
217  virtual std::string bibKey() const {
218  return info().bibKey();
219  }
220 
222  virtual std::string bibTeX() const {
223  return info().bibTeX();
224  }
225 
227  virtual std::string status() const {
228  return (info().status().empty()) ? "UNVALIDATED" : info().status();
229  }
230 
232  virtual std::vector<std::string> todos() const {
233  return info().todos();
234  }
235 
237  virtual std::vector<std::string> validation() const {
238  return info().validation();
239  }
240 
242  virtual bool reentrant() const {
243  return info().reentrant();
244  }
245 
246 
248  virtual std::string refFile() const {
249  return info().refFile();
250  }
251 
252 
254  virtual const std::vector<PdgIdPair>& requiredBeams() const {
255  return info().beams();
256  }
258  virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
259  info().setBeams(requiredBeams);
260  return *this;
261  }
262 
264  virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
265  return info().energies();
266  }
267 
269  virtual const std::vector<std::string> & keywords() const {
270  return info().keywords();
271  }
272 
274  virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
276  return *this;
277  }
278 
279 
283  assert(_info && "No AnalysisInfo object :O");
284  return *_info;
285  }
286 
288 
289 
292 
294  const ParticlePair& beams() const;
295 
297  const PdgIdPair beamIds() const;
298 
300  double sqrtS() const;
301 
303  bool merging() const {
304  return sqrtS() <= 0.0;
305  }
306 
308 
309 
315 
317  bool isCompatible(const ParticlePair& beams) const;
318 
320  bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
321 
323  bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
324 
326 
328  AnalysisHandler& handler() const { return *_analysishandler; }
329 
330 
331  protected:
332 
334  Log& getLog() const;
335 
337  double crossSection() const;
338 
341  double crossSectionPerEvent() const;
342 
344  double crossSectionError() const;
345 
348  double crossSectionErrorPerEvent() const;
349 
353  size_t numEvents() const;
354 
358  double sumW() const;
360  double sumOfWeights() const { return sumW(); }
361 
365  double sumW2() const;
366 
367 
368  protected:
369 
372 
374  const std::string histoDir() const;
375 
377  const std::string histoPath(const std::string& hname) const;
378 
380  const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
381 
383  const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
384 
386 
387 
390 
392  const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
393  _cacheRefData();
394  return _refdata;
395  }
396 
397 
400  template <typename T=YODA::Scatter2D>
401  const T& refData(const string& hname) const {
402  _cacheRefData();
403  MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
404  if (!_refdata[hname]) {
405  MSG_ERROR("Can't find reference histogram " << hname);
406  throw Exception("Reference data " + hname + " not found.");
407  }
408  return dynamic_cast<T&>(*_refdata[hname]);
409  }
410 
411 
414  template <typename T=YODA::Scatter2D>
415  const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
416  const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
417  return refData<T>(hname);
418  }
419 
421 
422 
425 
427  CounterPtr& book(CounterPtr&, const std::string& name);
428 
432  CounterPtr& book(CounterPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
433 
435 
436 
439 
441  Histo1DPtr& book(Histo1DPtr&,const std::string& name, size_t nbins, double lower, double upper);
442 
444  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::vector<double>& binedges);
445 
447  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::initializer_list<double>& binedges);
448 
450  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const Scatter2D& refscatter);
451 
453  Histo1DPtr& book(Histo1DPtr&,const std::string& name);
454 
458  Histo1DPtr& book(Histo1DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
459 
461 
462 
465 
469  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
470  size_t nxbins, double xlower, double xupper,
471  size_t nybins, double ylower, double yupper);
472 
475  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
476  const std::vector<double>& xbinedges,
477  const std::vector<double>& ybinedges);
478 
481  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
482  const std::initializer_list<double>& xbinedges,
483  const std::initializer_list<double>& ybinedges);
484 
486  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
487  const Scatter3D& refscatter);
488 
490  Histo2DPtr& book(Histo2DPtr&,const std::string& name);
491 
495  Histo2DPtr& book(Histo2DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
496 
498 
499 
502 
504  Profile1DPtr& book(Profile1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
505 
507  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::vector<double>& binedges);
508 
510  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
511 
513  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const Scatter2D& refscatter);
514 
516  Profile1DPtr& book(Profile1DPtr&, const std::string& name);
517 
521  Profile1DPtr& book(Profile1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
522 
524 
525 
528 
532  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
533  size_t nxbins, double xlower, double xupper,
534  size_t nybins, double ylower, double yupper);
535 
538  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
539  const std::vector<double>& xbinedges,
540  const std::vector<double>& ybinedges);
541 
544  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
545  const std::initializer_list<double>& xbinedges,
546  const std::initializer_list<double>& ybinedges);
547 
549 
550  // /// Book a 2D profile histogram with binning from a reference scatter.
551  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name,
552  // const Scatter3D& refscatter);
553 
554  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
555  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name);
556 
557  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
558  // ///
559  // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
560  // Profile2DPtr& book(const Profile2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
561 
563 
564 
567 
578  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, bool copy_pts = false);
579 
590  Scatter2DPtr& book(Scatter2DPtr& s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
591 
595  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, size_t npts, double lower, double upper);
596 
600  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const std::vector<double>& binedges);
601 
603  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const Scatter2D& refscatter);
604 
606 
609 
620  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, bool copy_pts=false);
621 
632  Scatter3DPtr& book(Scatter3DPtr& s3d, unsigned int datasetId, unsigned int xAxisId,
633  unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
634 
638  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
639  size_t xnpts, double xlower, double xupper,
640  size_t ynpts, double ylower, double yupper);
641 
645  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
646  const std::vector<double>& xbinedges,
647  const std::vector<double>& ybinedges);
648 
650  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, const Scatter3D& refscatter);
651 
653 
654 
655  public:
656 
659  virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
660  (void) yao;
661  }
662 
665  virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
666  (void) raos;
667  (void) iW;
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  MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
819 
821  void _checkBookInit() const;
822 
824  bool _inInit() const;
825 
827  bool _inFinalize() const;
828 
829 
830  private:
831 
833  class CounterAdapter {
834  public:
835 
836  CounterAdapter(double x) : x_(x) {}
837 
838  CounterAdapter(const YODA::Counter & c) : x_(c.val()) {}
839 
840  CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
841  assert( s.numPoints() == 1 || "Can only scale by a single value.");
842  }
843 
844  operator double() const { return x_; }
845 
846  private:
847  double x_;
848 
849  };
850 
851 
852  public:
853 
854  double dbl(double x) { return x; }
855  double dbl(const YODA::Counter & c) { return c.val(); }
856  double dbl(const YODA::Scatter1D & s) {
857  assert( s.numPoints() == 1 );
858  return s.points()[0].x();
859  }
860 
861 
866 
868 
870  void scale(CounterPtr cnt, CounterAdapter factor);
871 
875  void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
876  for (auto& c : cnts) scale(c, factor);
877  }
878 
880  template<typename T>
881  void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
882  for (auto& m : maps) scale(m.second, factor);
883  }
884 
886  template <std::size_t array_size>
887  void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
888  // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
889  for (auto& c : cnts) scale(c, factor);
890  }
891 
892 
894  void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
895 
899  void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
900  for (auto& h : histos) normalize(h, norm, includeoverflows);
901  }
902 
904  template<typename T>
905  void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
906  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
907  }
908 
910  template <std::size_t array_size>
911  void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
912  for (auto& h : histos) normalize(h, norm, includeoverflows);
913  }
914 
916  void scale(Histo1DPtr histo, CounterAdapter factor);
917 
921  void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
922  for (auto& h : histos) scale(h, factor);
923  }
924 
926  template<typename T>
927  void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
928  for (auto& m : maps) scale(m.second, factor);
929  }
930 
932  template <std::size_t array_size>
933  void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
934  for (auto& h : histos) scale(h, factor);
935  }
936 
937 
939  void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
940 
944  void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
945  for (auto& h : histos) normalize(h, norm, includeoverflows);
946  }
947 
949  template<typename T>
950  void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
951  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
952  }
953 
955  template <std::size_t array_size>
956  void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
957  for (auto& h : histos) normalize(h, norm, includeoverflows);
958  }
959 
961  void scale(Histo2DPtr histo, CounterAdapter factor);
962 
966  void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
967  for (auto& h : histos) scale(h, factor);
968  }
969 
971  template<typename T>
972  void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
973  for (auto& m : maps) scale(m.second, factor);
974  }
975 
977  template <std::size_t array_size>
978  void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
979  for (auto& h : histos) scale(h, factor);
980  }
981 
982 
986  void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
987 
991  void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
992 
993 
997  void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
998 
1002  void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1003 
1004 
1008  void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1009 
1013  void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1014 
1015 
1019  void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1020 
1024  void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1025 
1026 
1030  void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1031 
1035  void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1036 
1037 
1041  void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1042 
1046  void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1047 
1048 
1052  void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1053 
1057  void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1058 
1059 
1063  void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1064 
1068  void integrate(const Histo1D& h, Scatter2DPtr s) const;
1069 
1071 
1072 
1073  public:
1074 
1076  const vector<MultiweightAOPtr>& analysisObjects() const {
1077  return _analysisobjects;
1078  }
1079 
1080 
1081  protected:
1082 
1085 
1087  size_t defaultWeightIndex() const;
1088 
1090  template <typename YODAT>
1091  shared_ptr<YODAT> getPreload(string path) const {
1092  return dynamic_pointer_cast<YODAT>(_getPreload(path));
1093  }
1094 
1095 
1097  template <typename YODAT>
1098  rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT& yao) {
1099  typedef Wrapper<YODAT> WrapperT;
1100  typedef shared_ptr<YODAT> YODAPtrT;
1101  typedef rivet_shared_ptr<WrapperT> RAOT;
1102 
1103  if ( !_inInit() && !_inFinalize() ) {
1104  MSG_ERROR("Can't book objects outside of init() or finalize()");
1105  throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1106  }
1107 
1108  // First check that we haven't booked this before.
1109  // This is allowed when booking in finalize: just warn in that case.
1110  // If in init(), throw an exception: it's 99.9% never going to be intentional.
1111  for (auto& waold : analysisObjects()) {
1112  if ( yao.path() == waold.get()->basePath() ) {
1113  const string msg = "Found double-booking of " + yao.path() + " in " + name();
1114  if ( _inInit() ) {
1115  MSG_ERROR(msg);
1116  throw LookupError(msg);
1117  } else {
1118  MSG_WARNING(msg + ". Keeping previous booking");
1119  }
1120  return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1121  }
1122  }
1123 
1124  shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1125  wao->_basePath = yao.path();
1126  YODAPtrT yaop = make_shared<YODAT>(yao);
1127 
1128  for (const string& weightname : _weightNames()) {
1129  // Create two YODA objects for each weight. Copy from
1130  // preloaded YODAs if present. First the finalized yoda:
1131  string finalpath = yao.path();
1132  if ( weightname != "" ) finalpath += "[" + weightname + "]";
1133  YODAPtrT preload = getPreload<YODAT>(finalpath);
1134  if ( preload ) {
1135  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 
1423  private:
1424 
1427 
1429  void _cacheRefData() const;
1430 
1432 
1433  };
1434 
1435 
1436  // // Template specialisation for literal character strings (which don't play well with stringstream)
1437  // template<>
1438  // inline std::string Analysis::getOption(std::string optname, const char* def) {
1439  // return getOption<std::string>(optname, def); //.c_str();
1440  // }
1441 
1442 
1443 }
1444 
1445 
1446 // Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1447 #include "Rivet/AnalysisBuilder.hh"
1448 
1449 
1452 
1455 #define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1456 
1459 #define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias )
1460 
1463 #define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {}
1464 
1465 
1466 
1471 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1472 
1477 // #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1478 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1479 
1484 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1485 
1490 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1491 
1493 
1494 
1495 #endif
double sumOfWeights() const
Alias.
Definition: Analysis.hh:360
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:1076
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:89
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:392
Holder of analysis metadata.
Definition: AnalysisInfo.hh:12
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
virtual std::string bibKey() const
BibTeX citation key for this article.
Definition: Analysis.hh:217
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition: Analysis.hh:227
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition: Analysis.hh:927
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition: Analysis.hh:142
const CentralityProjection & declareCentrality(const SingleValueProjection &proj, string calAnaName, string calHistName, const string projName, bool increasing=false)
Book a CentralityProjection.
const ParticlePair & beams() const
Incoming beams for this run.
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition: Analysis.hh:674
virtual double luminosity() const
The integrated luminosity in inverse picobarn.
Definition: Analysis.hh:207
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
Error specialisation for where the problem is between the chair and the computer. ...
Definition: Exceptions.hh:55
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:219
bool bookingCompatible(TPtr a, TPtr b)
Definition: RivetYODA.hh:835
size_t defaultWeightIndex() const
Get the default/nominal weight index.
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:193
void removeAnalysisObject(const std::string &path)
Unregister a data object from the histogram system (by name)
virtual std::string summary() const
Get a short description of the analysis.
Definition: Analysis.hh:164
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:956
virtual std::vector< std::string > authors() const
Names & emails of paper/analysis authors.
Definition: Analysis.hh:155
virtual std::vector< std::string > validation() const
make-style commands for validating this analysis.
Definition: Analysis.hh:237
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:232
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:950
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:102
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition: Analysis.hh:875
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:254
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition: Analysis.hh:415
virtual void setRefDataName(const std::string &ref_data="")
Set name of reference data file, which could be different from plugin name.
Definition: Analysis.hh:137
AnalysisInfo & info()
Definition: Analysis.hh:282
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
virtual std::string spiresId() const
Get the SPIRES ID code for this analysis (~deprecated).
Definition: Analysis.hh:147
bool merging() const
Check if we are running rivet-merge.
Definition: Analysis.hh:303
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition: Analysis.hh:274
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:269
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:1098
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition: Analysis.hh:222
double sqrtS() const
Centre of mass energy for this run.
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition: Analysis.hh:183
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:21
void scale(const std::map< T, CounterPtr > &maps, CounterAdapter factor)
Iteratively scale the counters in the map maps, by factor factor.
Definition: Analysis.hh:881
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:911
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:258
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:328
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:944
const T & refData(const string &hname) const
Definition: Analysis.hh:401
Error Exception
Rivet::Exception is a synonym for Rivet::Error.
Definition: Exceptions.hh:18
size_t numEvents() const
Get the number of events seen (via the analysis handler).
virtual std::string experiment() const
Experiment which performed and published this analysis.
Definition: Analysis.hh:188
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:899
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:132
virtual std::string description() const
Get a full description of the analysis.
Definition: Analysis.hh:174
#define MSG_ERROR(x)
Highest level messaging for serious problems, using MSG_LVL.
Definition: Logging.hh:202
const std::string histoDir() const
Get the canonical histogram "directory" path for this analysis.
Analysis & operator=(const Analysis &)=delete
The assignment operator is private and mustdeleted, so it can never be called.
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition: Analysis.hh:212
virtual std::string year() const
When the original experimental analysis was published.
Definition: Analysis.hh:198
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition: Analysis.hh: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:1091
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:115
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:887
Analysis(const std::string &name)
Constructor.
virtual std::string name() const
Get the name of the analysis.
Definition: Analysis.hh:127
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition: Analysis.hh:921
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition: Analysis.hh:264
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:242
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:75
virtual double luminosityfb() const
The integrated luminosity in inverse femtobarn.
Definition: Analysis.hh:203
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:248
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:905
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:933
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