Rivet  3.1.4
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 
375 
377  const std::string histoDir() const;
378 
380  const std::string histoPath(const std::string& hname) const;
381 
383  const std::string histoPath(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
384 
386  const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const;
387 
389 
390 
393 
395  const std::map<std::string, YODA::AnalysisObjectPtr>& refData() const {
396  _cacheRefData();
397  return _refdata;
398  }
399 
400 
403  template <typename T=YODA::Scatter2D>
404  const T& refData(const string& hname) const {
405  _cacheRefData();
406  MSG_TRACE("Using histo bin edges for " << name() << ":" << hname);
407  if (!_refdata[hname]) {
408  MSG_ERROR("Can't find reference histogram " << hname);
409  throw Exception("Reference data " + hname + " not found.");
410  }
411  return dynamic_cast<T&>(*_refdata[hname]);
412  }
413 
414 
417  template <typename T=YODA::Scatter2D>
418  const T& refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
419  const string hname = mkAxisCode(datasetId, xAxisId, yAxisId);
420  return refData<T>(hname);
421  }
422 
424 
425 
431 
433  CounterPtr& book(CounterPtr&, const std::string& name);
434 
438  CounterPtr& book(CounterPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
439 
441 
442 
445 
447  Histo1DPtr& book(Histo1DPtr&,const std::string& name, size_t nbins, double lower, double upper);
448 
450  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::vector<double>& binedges);
451 
453  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const std::initializer_list<double>& binedges);
454 
456  Histo1DPtr& book(Histo1DPtr&,const std::string& name, const Scatter2D& refscatter);
457 
459  Histo1DPtr& book(Histo1DPtr&,const std::string& name);
460 
464  Histo1DPtr& book(Histo1DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
465 
467 
468 
471 
475  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
476  size_t nxbins, double xlower, double xupper,
477  size_t nybins, double ylower, double yupper);
478 
481  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
482  const std::vector<double>& xbinedges,
483  const std::vector<double>& ybinedges);
484 
487  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
488  const std::initializer_list<double>& xbinedges,
489  const std::initializer_list<double>& ybinedges);
490 
492  Histo2DPtr& book(Histo2DPtr&,const std::string& name,
493  const Scatter3D& refscatter);
494 
496  Histo2DPtr& book(Histo2DPtr&,const std::string& name);
497 
501  Histo2DPtr& book(Histo2DPtr&,unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
502 
504 
505 
508 
510  Profile1DPtr& book(Profile1DPtr&, const std::string& name, size_t nbins, double lower, double upper);
511 
513  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::vector<double>& binedges);
514 
516  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const std::initializer_list<double>& binedges);
517 
519  Profile1DPtr& book(Profile1DPtr&, const std::string& name, const Scatter2D& refscatter);
520 
522  Profile1DPtr& book(Profile1DPtr&, const std::string& name);
523 
527  Profile1DPtr& book(Profile1DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
528 
530 
531 
534 
538  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
539  size_t nxbins, double xlower, double xupper,
540  size_t nybins, double ylower, double yupper);
541 
544  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
545  const std::vector<double>& xbinedges,
546  const std::vector<double>& ybinedges);
547 
550  Profile2DPtr& book(Profile2DPtr&, const std::string& name,
551  const std::initializer_list<double>& xbinedges,
552  const std::initializer_list<double>& ybinedges);
553 
555 
556  // /// Book a 2D profile histogram with binning from a reference scatter.
557  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name,
558  // const Scatter3D& refscatter);
559 
560  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
561  // Profile2DPtr& book(const Profile2DPtr&, const std::string& name);
562 
563  // /// Book a 2D profile histogram, using the binnings in the reference data histogram.
564  // ///
565  // /// The paper, dataset and x/y-axis IDs will be used to build the histo name in the HepData standard way.
566  // Profile2DPtr& book(const Profile2DPtr&, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId);
567 
569 
570 
573 
584  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, bool copy_pts = false);
585 
596  Scatter2DPtr& book(Scatter2DPtr& s2d, unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId, bool copy_pts = false);
597 
601  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, size_t npts, double lower, double upper);
602 
606  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const std::vector<double>& binedges);
607 
609  Scatter2DPtr& book(Scatter2DPtr& s2d, const string& hname, const Scatter2D& refscatter);
610 
612 
615 
626  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, bool copy_pts=false);
627 
638  Scatter3DPtr& book(Scatter3DPtr& s3d, unsigned int datasetId, unsigned int xAxisId,
639  unsigned int yAxisId, unsigned int zAxisId, bool copy_pts=false);
640 
644  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
645  size_t xnpts, double xlower, double xupper,
646  size_t ynpts, double ylower, double yupper);
647 
651  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname,
652  const std::vector<double>& xbinedges,
653  const std::vector<double>& ybinedges);
654 
656  Scatter3DPtr& book(Scatter3DPtr& s3d, const std::string& hname, const Scatter3D& refscatter);
657 
659 
660 
661  public:
662 
666  virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
667  (void) yao;
668  }
669 
674  virtual void rawHookOut(vector<MultiweightAOPtr> raos, size_t iW) {
675  (void) raos;
676  (void) iW;
677  }
678 
680 
681 
683  const std::map<std::string,std::string>& options() const {
684  return _options;
685  }
686 
688  std::string getOption(std::string optname) const {
689  if ( _options.find(optname) != _options.end() )
690  return _options.find(optname)->second;
691  return "";
692  }
693 
698  template<typename T>
699  T getOption(std::string optname, T def) const {
700  if (_options.find(optname) == _options.end()) return def;
701  std::stringstream ss;
702  ss << _options.find(optname)->second;
703  T ret;
704  ss >> ret;
705  return ret;
706  }
707 
712  std::string getOption(std::string optname, const char* def) {
713  return getOption<std::string>(optname, def);
714  }
715 
717 
718 
721 
738  const CentralityProjection&
740  string calAnaName, string calHistName,
741  const string projName, bool increasing=false);
742 
743 
752  template <class T>
753  Percentile<T> bookPercentile(string projName,
754  vector<pair<float, float> > centralityBins,
755  vector<tuple<int, int, int> > ref) {
756 
757  typedef typename ReferenceTraits<T>::RefT RefT;
758  typedef rivet_shared_ptr<Wrapper<T>> WrapT;
759 
760  Percentile<T> pctl(this, projName);
761 
762  const int nCent = centralityBins.size();
763  for (int iCent = 0; iCent < nCent; ++iCent) {
764  const string axisCode = mkAxisCode(std::get<0>(ref[iCent]),
765  std::get<1>(ref[iCent]),
766  std::get<2>(ref[iCent]));
767  const RefT & refscatter = refData<RefT>(axisCode);
768 
769  WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
770  wtf = addAnalysisObject(wtf);
771 
772  CounterPtr cnt(_weightNames(), Counter(histoPath("TMP/COUNTER/" + axisCode)));
773  cnt = addAnalysisObject(cnt);
774 
775  pctl.add(wtf, cnt, centralityBins[iCent]);
776  }
777  return pctl;
778  }
779 
780 
781  // /// @brief Book Percentile wrappers around AnalysisObjects.
782  // ///
783  // /// Based on a previously registered CentralityProjection named @a
784  // /// projName book one (or several) AnalysisObject(s) named
785  // /// according to @a ref where the x-axis will be filled according
786  // /// to the percentile output(s) of the @projName.
787  // ///
788  // /// @todo Convert to just be called book() cf. others
789  // template <class T>
790  // PercentileXaxis<T> bookPercentileXaxis(string projName,
791  // tuple<int, int, int> ref) {
792 
793  // typedef typename ReferenceTraits<T>::RefT RefT;
794  // typedef rivet_shared_ptr<Wrapper<T>> WrapT;
795 
796  // PercentileXaxis<T> pctl(this, projName);
797 
798  // const string axisCode = mkAxisCode(std::get<0>(ref),
799  // std::get<1>(ref),
800  // std::get<2>(ref));
801  // const RefT & refscatter = refData<RefT>(axisCode);
802 
803  // WrapT wtf(_weightNames(), T(refscatter, histoPath(axisCode)));
804  // wtf = addAnalysisObject(wtf);
805 
806  // CounterPtr cnt(_weightNames(), Counter());
807  // cnt = addAnalysisObject(cnt);
808 
809  // pctl.add(wtf, cnt);
810  // return pctl;
811  // }
812 
814 
815 
816  private:
817 
818  // Functions that have to be defined in the .cc file to avoid circular #includes
819 
821  vector<string> _weightNames() const;
822 
824  YODA::AnalysisObjectPtr _getPreload(string name) const;
825 
827  MultiweightAOPtr _getOtherAnalysisObject(const std::string & ananame, const std::string& name);
828 
830  void _checkBookInit() const;
831 
833  bool _inInit() const;
834 
836  bool _inFinalize() const;
837 
838 
839  private:
840 
842  class CounterAdapter {
843  public:
844 
845  CounterAdapter(double x) : x_(x) {}
846 
847  CounterAdapter(const YODA::Counter & c) : x_(c.val()) {}
848 
849  CounterAdapter(const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
850  assert( s.numPoints() == 1 || "Can only scale by a single value.");
851  }
852 
853  operator double() const { return x_; }
854 
855  private:
856  double x_;
857 
858  };
859 
860 
861  public:
862 
863  double dbl(double x) { return x; }
864  double dbl(const YODA::Counter & c) { return c.val(); }
865  double dbl(const YODA::Scatter1D & s) {
866  assert( s.numPoints() == 1 );
867  return s.points()[0].x();
868  }
869 
870 
875 
877 
879  void scale(CounterPtr cnt, CounterAdapter factor);
880 
884  void scale(const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
885  for (auto& c : cnts) scale(c, factor);
886  }
887 
889  template<typename T>
890  void scale(const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
891  for (auto& m : maps) scale(m.second, factor);
892  }
893 
895  template <std::size_t array_size>
896  void scale(const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
897  // for (size_t i = 0; i < std::extent<decltype(cnts)>::value; ++i) scale(cnts[i], factor);
898  for (auto& c : cnts) scale(c, factor);
899  }
900 
901 
903  void normalize(Histo1DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
904 
908  void normalize(const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
909  for (auto& h : histos) normalize(h, norm, includeoverflows);
910  }
911 
913  template<typename T>
914  void normalize(const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
915  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
916  }
917 
919  template <std::size_t array_size>
920  void normalize(const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
921  for (auto& h : histos) normalize(h, norm, includeoverflows);
922  }
923 
925  void scale(Histo1DPtr histo, CounterAdapter factor);
926 
930  void scale(const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
931  for (auto& h : histos) scale(h, factor);
932  }
933 
935  template<typename T>
936  void scale(const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
937  for (auto& m : maps) scale(m.second, factor);
938  }
939 
941  template <std::size_t array_size>
942  void scale(const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
943  for (auto& h : histos) scale(h, factor);
944  }
945 
946 
948  void normalize(Histo2DPtr histo, CounterAdapter norm=1.0, bool includeoverflows=true);
949 
953  void normalize(const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0, bool includeoverflows=true) {
954  for (auto& h : histos) normalize(h, norm, includeoverflows);
955  }
956 
958  template<typename T>
959  void normalize(const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0, bool includeoverflows=true) {
960  for (auto& m : maps) normalize(m.second, norm, includeoverflows);
961  }
962 
964  template <std::size_t array_size>
965  void normalize(const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true) {
966  for (auto& h : histos) normalize(h, norm, includeoverflows);
967  }
968 
970  void scale(Histo2DPtr histo, CounterAdapter factor);
971 
975  void scale(const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
976  for (auto& h : histos) scale(h, factor);
977  }
978 
980  template<typename T>
981  void scale(const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
982  for (auto& m : maps) scale(m.second, factor);
983  }
984 
986  template <std::size_t array_size>
987  void scale(const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
988  for (auto& h : histos) scale(h, factor);
989  }
990 
991 
995  void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const;
996 
1000  void divide(const YODA::Counter& c1, const YODA::Counter& c2, Scatter1DPtr s) const;
1001 
1002 
1006  void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1007 
1011  void divide(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1012 
1013 
1017  void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s) const;
1018 
1022  void divide(const YODA::Profile1D& p1, const YODA::Profile1D& p2, Scatter2DPtr s) const;
1023 
1024 
1028  void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s) const;
1029 
1033  void divide(const YODA::Histo2D& h1, const YODA::Histo2D& h2, Scatter3DPtr s) const;
1034 
1035 
1039  void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s) const;
1040 
1044  void divide(const YODA::Profile2D& p1, const YODA::Profile2D& p2, Scatter3DPtr s) const;
1045 
1046 
1050  void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1051 
1055  void efficiency(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1056 
1057 
1061  void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const;
1062 
1066  void asymm(const YODA::Histo1D& h1, const YODA::Histo1D& h2, Scatter2DPtr s) const;
1067 
1068 
1072  void integrate(Histo1DPtr h, Scatter2DPtr s) const;
1073 
1077  void integrate(const Histo1D& h, Scatter2DPtr s) const;
1078 
1080 
1081 
1082  public:
1083 
1085  const vector<MultiweightAOPtr>& analysisObjects() const {
1086  return _analysisobjects;
1087  }
1088 
1089 
1090  protected:
1091 
1094 
1096  size_t defaultWeightIndex() const;
1097 
1099  template <typename YODAT>
1100  shared_ptr<YODAT> getPreload(string path) const {
1101  return dynamic_pointer_cast<YODAT>(_getPreload(path));
1102  }
1103 
1104 
1106  template <typename YODAT>
1107  rivet_shared_ptr< Wrapper<YODAT> > registerAO(const YODAT& yao) {
1108  typedef Wrapper<YODAT> WrapperT;
1109  typedef shared_ptr<YODAT> YODAPtrT;
1110  typedef rivet_shared_ptr<WrapperT> RAOT;
1111 
1112  if ( !_inInit() && !_inFinalize() ) {
1113  MSG_ERROR("Can't book objects outside of init() or finalize()");
1114  throw UserError(name() + ": Can't book objects outside of init() or finalize().");
1115  }
1116 
1117  // First check that we haven't booked this before.
1118  // This is allowed when booking in finalize: just warn in that case.
1119  // If in init(), throw an exception: it's 99.9% never going to be intentional.
1120  for (auto& waold : analysisObjects()) {
1121  if ( yao.path() == waold.get()->basePath() ) {
1122  const string msg = "Found double-booking of " + yao.path() + " in " + name();
1123  if ( _inInit() ) {
1124  MSG_ERROR(msg);
1125  throw LookupError(msg);
1126  } else {
1127  MSG_WARNING(msg + ". Keeping previous booking");
1128  }
1129  return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1130  }
1131  }
1132 
1133  shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1134  wao->_basePath = yao.path();
1135  YODAPtrT yaop = make_shared<YODAT>(yao);
1136 
1137  for (const string& weightname : _weightNames()) {
1138  // Create two YODA objects for each weight. Copy from
1139  // preloaded YODAs if present. First the finalized yoda:
1140  string finalpath = yao.path();
1141  if ( weightname != "" ) finalpath += "[" + weightname + "]";
1142  YODAPtrT preload = getPreload<YODAT>(finalpath);
1143  if ( preload ) {
1144  if ( !bookingCompatible(preload, yaop) ) {
1146  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1147  << finalpath << " for " << name());
1148  preload = nullptr;
1149  } else {
1150  MSG_TRACE("Using preloaded " << finalpath << " in " <<name());
1151  wao->_final.push_back(make_shared<YODAT>(*preload));
1152  }
1153  }
1154  if ( !preload ) {
1155  wao->_final.push_back(make_shared<YODAT>(yao));
1156  wao->_final.back()->setPath(finalpath);
1157  }
1158 
1159  // Then the raw filling yodas.
1160  string rawpath = "/RAW" + finalpath;
1161  preload = getPreload<YODAT>(rawpath);
1162  if ( preload ) {
1163  if ( !bookingCompatible(preload, yaop) ) {
1164  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1165  << rawpath << " for " << name());
1166  preload = nullptr;
1167  } else {
1168  MSG_TRACE("Using preloaded " << rawpath << " in " <<name());
1169  wao->_persistent.push_back(make_shared<YODAT>(*preload));
1170  }
1171  }
1172  if ( !preload ) {
1173  wao->_persistent.push_back(make_shared<YODAT>(yao));
1174  wao->_persistent.back()->setPath(rawpath);
1175  }
1176  }
1177  rivet_shared_ptr<WrapperT> ret(wao);
1178 
1179  ret.get()->unsetActiveWeight();
1180  if ( _inFinalize() ) {
1181  // If booked in finalize() we assume it is the first time
1182  // finalize is run.
1183  ret.get()->pushToFinal();
1184  ret.get()->setActiveFinalWeightIdx(0);
1185  }
1186  _analysisobjects.push_back(ret);
1187 
1188  return ret;
1189  }
1190 
1191 
1193  template <typename AO=MultiweightAOPtr>
1194  AO addAnalysisObject(const AO& aonew) {
1195  _checkBookInit();
1196 
1197  for (const MultiweightAOPtr& ao : analysisObjects()) {
1198 
1199  // Check AO base-name first
1200  ao.get()->setActiveWeightIdx(defaultWeightIndex());
1201  aonew.get()->setActiveWeightIdx(defaultWeightIndex());
1202  if (ao->path() != aonew->path()) continue;
1203 
1204  // If base-name matches, check compatibility
1205  // NB. This evil is because dynamic_ptr_cast can't work on rivet_shared_ptr directly
1206  AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get())); //< OMG
1207  if ( !aoold || !bookingCompatible(aonew, aoold) ) {
1208  MSG_WARNING("Found incompatible pre-existing data object with same base path "
1209  << aonew->path() << " for " << name());
1210  throw LookupError("Found incompatible pre-existing data object with same base path during AO booking");
1211  }
1212 
1213  // Finally, check all weight variations
1214  for (size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1215  aoold.get()->setActiveWeightIdx(weightIdx);
1216  aonew.get()->setActiveWeightIdx(weightIdx);
1217  if (aoold->path() != aonew->path()) {
1218  MSG_WARNING("Found incompatible pre-existing data object with different weight-path "
1219  << aonew->path() << " for " << name());
1220  throw LookupError("Found incompatible pre-existing data object with same weight-path during AO booking");
1221  }
1222  }
1223 
1224  // They're fully compatible: bind and return
1225  aoold.get()->unsetActiveWeight();
1226  MSG_TRACE("Bound pre-existing data object " << aoold->path() << " for " << name());
1227  return aoold;
1228  }
1229 
1230  // No equivalent found
1231  MSG_TRACE("Registered " << aonew->annotation("Type") << " " << aonew->path() << " for " << name());
1232  aonew.get()->unsetActiveWeight();
1233 
1234  _analysisobjects.push_back(aonew);
1235  return aonew;
1236  }
1237 
1239  void removeAnalysisObject(const std::string& path);
1240 
1242  void removeAnalysisObject(const MultiweightAOPtr& ao);
1243 
1244  // /// Get all data objects, for all analyses, from the AnalysisHandler
1245  // /// @todo Can we remove this? Why not call handler().getData()?
1246  // vector<YODA::AnalysisObjectPtr> getAllData(bool includeorphans) const;
1247 
1248 
1250  template <typename AO=MultiweightAOPtr>
1251  const AO getAnalysisObject(const std::string& aoname) const {
1252  for (const MultiweightAOPtr& ao : analysisObjects()) {
1253  ao.get()->setActiveWeightIdx(defaultWeightIndex());
1254  if (ao->path() == histoPath(aoname)) {
1255  // return dynamic_pointer_cast<AO>(ao);
1256  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1257  }
1258  }
1259  throw LookupError("Data object " + histoPath(aoname) + " not found");
1260  }
1261 
1262 
1263  // /// Get a data object from the histogram system
1264  // template <typename AO=YODA::AnalysisObject>
1265  // const std::shared_ptr<AO> getAnalysisObject(const std::string& name) const {
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  // /// Get a data object from the histogram system (non-const)
1273  // template <typename AO=YODA::AnalysisObject>
1274  // std::shared_ptr<AO> getAnalysisObject(const std::string& name) {
1275  // foreach (const AnalysisObjectPtr& ao, analysisObjects()) {
1276  // if (ao->path() == histoPath(name)) return dynamic_pointer_cast<AO>(ao);
1277  // }
1278  // throw LookupError("Data object " + histoPath(name) + " not found");
1279  // }
1280 
1281 
1284  template <typename AO=MultiweightAOPtr>
1285  AO getAnalysisObject(const std::string& ananame,
1286  const std::string& aoname) {
1287  MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1288  // return dynamic_pointer_cast<AO>(ao);
1289  return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1290  }
1291 
1292 
1293  // /// Get a named Histo1D object from the histogram system
1294  // const Histo1DPtr getHisto1D(const std::string& name) const {
1295  // return getAnalysisObject<Histo1D>(name);
1296  // }
1297 
1298  // /// Get a named Histo1D object from the histogram system (non-const)
1299  // Histo1DPtr getHisto1D(const std::string& name) {
1300  // return getAnalysisObject<Histo1D>(name);
1301  // }
1302 
1303  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1304  // const Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1305  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1306  // }
1307 
1308  // /// Get a Histo1D object from the histogram system by axis ID codes (non-const)
1309  // Histo1DPtr getHisto1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1310  // return getAnalysisObject<Histo1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1311  // }
1312 
1313 
1314  // /// Get a named Histo2D object from the histogram system
1315  // const Histo2DPtr getHisto2D(const std::string& name) const {
1316  // return getAnalysisObject<Histo2D>(name);
1317  // }
1318 
1319  // /// Get a named Histo2D object from the histogram system (non-const)
1320  // Histo2DPtr getHisto2D(const std::string& name) {
1321  // return getAnalysisObject<Histo2D>(name);
1322  // }
1323 
1324  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1325  // const Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1326  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1327  // }
1328 
1329  // /// Get a Histo2D object from the histogram system by axis ID codes (non-const)
1330  // Histo2DPtr getHisto2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1331  // return getAnalysisObject<Histo2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1332  // }
1333 
1334 
1335  // /// Get a named Profile1D object from the histogram system
1336  // const Profile1DPtr getProfile1D(const std::string& name) const {
1337  // return getAnalysisObject<Profile1D>(name);
1338  // }
1339 
1340  // /// Get a named Profile1D object from the histogram system (non-const)
1341  // Profile1DPtr getProfile1D(const std::string& name) {
1342  // return getAnalysisObject<Profile1D>(name);
1343  // }
1344 
1345  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1346  // const Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1347  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1348  // }
1349 
1350  // /// Get a Profile1D object from the histogram system by axis ID codes (non-const)
1351  // Profile1DPtr getProfile1D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1352  // return getAnalysisObject<Profile1D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1353  // }
1354 
1355 
1356  // /// Get a named Profile2D object from the histogram system
1357  // const Profile2DPtr getProfile2D(const std::string& name) const {
1358  // return getAnalysisObject<Profile2D>(name);
1359  // }
1360 
1361  // /// Get a named Profile2D object from the histogram system (non-const)
1362  // Profile2DPtr getProfile2D(const std::string& name) {
1363  // return getAnalysisObject<Profile2D>(name);
1364  // }
1365 
1366  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1367  // const Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1368  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1369  // }
1370 
1371  // /// Get a Profile2D object from the histogram system by axis ID codes (non-const)
1372  // Profile2DPtr getProfile2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1373  // return getAnalysisObject<Profile2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1374  // }
1375 
1376 
1377  // /// Get a named Scatter2D object from the histogram system
1378  // const Scatter2DPtr getScatter2D(const std::string& name) const {
1379  // return getAnalysisObject<Scatter2D>(name);
1380  // }
1381 
1382  // /// Get a named Scatter2D object from the histogram system (non-const)
1383  // Scatter2DPtr getScatter2D(const std::string& name) {
1384  // return getAnalysisObject<Scatter2D>(name);
1385  // }
1386 
1387  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1388  // const Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const {
1389  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1390  // }
1391 
1392  // /// Get a Scatter2D object from the histogram system by axis ID codes (non-const)
1393  // Scatter2DPtr getScatter2D(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) {
1394  // return getAnalysisObject<Scatter2D>(makeAxisCode(datasetId, xAxisId, yAxisId));
1395  // }
1396 
1398 
1399 
1400  private:
1401 
1403  string _defaultname;
1404 
1406  unique_ptr<AnalysisInfo> _info;
1407 
1410  vector<MultiweightAOPtr> _analysisobjects;
1411 
1414  double _crossSection;
1415  bool _gotCrossSection;
1417 
1419  AnalysisHandler* _analysishandler;
1420 
1423  mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1424 
1426  map<string, string> _options;
1427 
1429  string _optstring;
1430 
1431 
1432  private:
1433 
1436 
1438  void _cacheRefData() const;
1439 
1441 
1442  };
1443 
1444 
1445  // // Template specialisation for literal character strings (which don't play well with stringstream)
1446  // template<>
1447  // inline std::string Analysis::getOption(std::string optname, const char* def) {
1448  // return getOption<std::string>(optname, def); //.c_str();
1449  // }
1450 
1451 
1452 }
1453 
1454 
1455 // Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
1456 #include "Rivet/AnalysisBuilder.hh"
1457 
1458 
1461 
1464 #define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1465 
1468 #define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias )
1469 
1472 #define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {}
1473 
1474 
1475 
1480 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
1481 
1486 // #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname ## ( ## #alias ## )
1487 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias )
1488 
1493 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {}
1494 
1499 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
1500 
1502 
1503 
1504 #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:1251
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:1085
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:395
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:936
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:683
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:849
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:965
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:959
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:884
std::string getOption(std::string optname) const
Get an option for this analysis instance as a string.
Definition: Analysis.hh:688
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:418
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:1107
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:890
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:920
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:953
const T & refData(const string &hname) const
Definition: Analysis.hh:404
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:908
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:1285
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:699
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:1100
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:896
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:930
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:712
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:914
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:942
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:1194
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:753