2 #ifndef RIVET_Analysis_HH 3 #define RIVET_Analysis_HH 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" 26 do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0) 37 using std::stringstream;
39 using std::numeric_limits;
43 class AnalysisHandler;
116 assert(_info &&
"No AnalysisInfo object :O");
127 virtual std::string
name()
const {
128 return ( (
info().
name().empty()) ? _defaultname :
info().
name() ) + _optstring;
155 virtual std::vector<std::string>
authors()
const {
198 virtual std::string
year()
const {
237 virtual std::vector<std::string>
todos()
const {
284 virtual const std::vector<std::string> &
keywords()
const {
298 assert(_info &&
"No AnalysisInfo object :O");
309 const ParticlePair&
beams()
const;
312 const PdgIdPair
beamIds()
const;
315 double sqrtS()
const;
319 return sqrtS() <= 0.0;
335 bool isCompatible(PdgId beam1, PdgId beam2,
double e1,
double e2)
const;
338 bool isCompatible(
const PdgIdPair& beams,
const std::pair<double,double>& energies)
const;
383 double sumW2()
const;
398 const std::string
histoPath(
const std::string& hname)
const;
401 const std::string
histoPath(
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId)
const;
404 const std::string
mkAxisCode(
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId)
const;
413 const std::map<std::string, YODA::AnalysisObjectPtr>&
refData()
const {
421 template <
typename T=YODA::Scatter2D>
424 MSG_TRACE(
"Using histo bin edges for " <<
name() <<
":" << hname);
425 if (!_refdata[hname]) {
426 MSG_ERROR(
"Can't find reference histogram " << hname);
427 throw Exception(
"Reference data " + hname +
" not found.");
429 return dynamic_cast<T&
>(*_refdata[hname]);
435 template <
typename T=YODA::Scatter2D>
436 const T&
refData(
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId)
const {
437 const string hname =
mkAxisCode(datasetId, xAxisId, yAxisId);
438 return refData<T>(hname);
451 CounterPtr&
book(CounterPtr&,
const std::string&
name);
456 CounterPtr&
book(CounterPtr&,
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId);
465 Histo1DPtr&
book(Histo1DPtr&,
const std::string& name,
size_t nbins,
double lower,
double upper);
468 Histo1DPtr&
book(Histo1DPtr&,
const std::string& name,
const std::vector<double>& binedges);
471 Histo1DPtr&
book(Histo1DPtr&,
const std::string& name,
const std::initializer_list<double>& binedges);
474 Histo1DPtr&
book(Histo1DPtr&,
const std::string& name,
const Scatter2D& refscatter);
477 Histo1DPtr&
book(Histo1DPtr&,
const std::string& name);
482 Histo1DPtr&
book(Histo1DPtr&,
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId);
493 Histo2DPtr&
book(Histo2DPtr&,
const std::string& name,
494 size_t nxbins,
double xlower,
double xupper,
495 size_t nybins,
double ylower,
double yupper);
499 Histo2DPtr&
book(Histo2DPtr&,
const std::string& name,
500 const std::vector<double>& xbinedges,
501 const std::vector<double>& ybinedges);
505 Histo2DPtr&
book(Histo2DPtr&,
const std::string& name,
506 const std::initializer_list<double>& xbinedges,
507 const std::initializer_list<double>& ybinedges);
510 Histo2DPtr&
book(Histo2DPtr&,
const std::string& name,
511 const Scatter3D& refscatter);
514 Histo2DPtr&
book(Histo2DPtr&,
const std::string& name);
519 Histo2DPtr&
book(Histo2DPtr&,
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId);
528 Profile1DPtr&
book(Profile1DPtr&,
const std::string& name,
size_t nbins,
double lower,
double upper);
531 Profile1DPtr&
book(Profile1DPtr&,
const std::string& name,
const std::vector<double>& binedges);
534 Profile1DPtr&
book(Profile1DPtr&,
const std::string& name,
const std::initializer_list<double>& binedges);
537 Profile1DPtr&
book(Profile1DPtr&,
const std::string& name,
const Scatter2D& refscatter);
540 Profile1DPtr&
book(Profile1DPtr&,
const std::string& name);
545 Profile1DPtr&
book(Profile1DPtr&,
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId);
556 Profile2DPtr&
book(Profile2DPtr&,
const std::string& name,
557 size_t nxbins,
double xlower,
double xupper,
558 size_t nybins,
double ylower,
double yupper);
562 Profile2DPtr&
book(Profile2DPtr&,
const std::string& name,
563 const std::vector<double>& xbinedges,
564 const std::vector<double>& ybinedges);
568 Profile2DPtr&
book(Profile2DPtr&,
const std::string& name,
569 const std::initializer_list<double>& xbinedges,
570 const std::initializer_list<double>& ybinedges);
602 Scatter2DPtr&
book(Scatter2DPtr& s2d,
const string& hname,
bool copy_pts =
false);
614 Scatter2DPtr&
book(Scatter2DPtr& s2d,
unsigned int datasetId,
unsigned int xAxisId,
unsigned int yAxisId,
bool copy_pts =
false);
619 Scatter2DPtr&
book(Scatter2DPtr& s2d,
const string& hname,
size_t npts,
double lower,
double upper);
624 Scatter2DPtr&
book(Scatter2DPtr& s2d,
const string& hname,
const std::vector<double>& binedges);
627 Scatter2DPtr&
book(Scatter2DPtr& s2d,
const string& hname,
const Scatter2D& refscatter);
644 Scatter3DPtr&
book(Scatter3DPtr& s3d,
const std::string& hname,
bool copy_pts=
false);
656 Scatter3DPtr&
book(Scatter3DPtr& s3d,
unsigned int datasetId,
unsigned int xAxisId,
657 unsigned int yAxisId,
unsigned int zAxisId,
bool copy_pts=
false);
662 Scatter3DPtr&
book(Scatter3DPtr& s3d,
const std::string& hname,
663 size_t xnpts,
double xlower,
double xupper,
664 size_t ynpts,
double ylower,
double yupper);
669 Scatter3DPtr&
book(Scatter3DPtr& s3d,
const std::string& hname,
670 const std::vector<double>& xbinedges,
671 const std::vector<double>& ybinedges);
674 Scatter3DPtr&
book(Scatter3DPtr& s3d,
const std::string& hname,
const Scatter3D& refscatter);
684 virtual void rawHookIn(YODA::AnalysisObjectPtr yao) {
692 virtual void rawHookOut(vector<MultiweightAOPtr> raos,
size_t iW) {
701 const std::map<std::string,std::string>&
options()
const {
706 std::string
getOption(std::string optname,
string def=
"")
const {
707 if ( _options.find(optname) != _options.end() )
708 return _options.find(optname)->second;
716 std::string
getOption(std::string optname,
const char* def) {
717 return getOption<std::string>(optname, def);
729 if (_options.find(optname) == _options.end())
return def;
730 std::stringstream ss;
731 ss.exceptions(std::ios::failbit);
733 ss << _options.find(optname)->second;
737 throw ReadError(
"Could not read user-provided option into requested type");
755 if (_options.find(optname) == _options.end())
return def;
756 const std::string val =
getOption(optname);
757 const std::string lval =
toLower(val);
758 if (lval.empty())
return false;
759 if (lval ==
"true" || lval ==
"yes" || lval ==
"on")
return true;
760 if (lval ==
"false" || lval ==
"no" || lval ==
"off")
return false;
761 return bool(getOption<int>(optname, 0));
788 string calAnaName,
string calHistName,
789 const string projName,
bool increasing=
false);
802 vector<pair<float, float> > centralityBins,
803 vector<tuple<int, int, int> > ref) {
805 typedef typename ReferenceTraits<T>::RefT RefT;
806 typedef rivet_shared_ptr<Wrapper<T>> WrapT;
810 const int nCent = centralityBins.size();
811 for (
int iCent = 0; iCent < nCent; ++iCent) {
812 const string axisCode =
mkAxisCode(std::get<0>(ref[iCent]),
813 std::get<1>(ref[iCent]),
814 std::get<2>(ref[iCent]));
815 const RefT & refscatter = refData<RefT>(axisCode);
817 WrapT wtf(_weightNames(), T(refscatter,
histoPath(axisCode)));
820 CounterPtr cnt(_weightNames(), Counter(
histoPath(
"TMP/COUNTER/" + axisCode)));
823 pctl.
add(wtf, cnt, centralityBins[iCent]);
869 vector<string> _weightNames()
const;
872 YODA::AnalysisObjectPtr _getPreload(
string name)
const;
875 MultiweightAOPtr _getOtherAnalysisObject(
const std::string & ananame,
const std::string& name);
878 void _checkBookInit()
const;
881 bool _inInit()
const;
884 bool _inFinalize()
const;
890 class CounterAdapter {
893 CounterAdapter(
double x) : x_(x) {}
895 CounterAdapter(
const YODA::Counter & c) : x_(c.val()) {}
897 CounterAdapter(
const YODA::Scatter1D & s) : x_(s.points()[0].x()) {
898 assert( s.numPoints() == 1 ||
"Can only scale by a single value.");
901 operator double()
const {
return x_; }
911 double dbl(
double x) {
return x; }
912 double dbl(
const YODA::Counter & c) {
return c.val(); }
913 double dbl(
const YODA::Scatter1D & s) {
914 assert( s.numPoints() == 1 );
915 return s.points()[0].x();
925 void scale(CounterPtr cnt, CounterAdapter factor);
930 void scale(
const std::vector<CounterPtr>& cnts, CounterAdapter factor) {
931 for (
auto& c : cnts)
scale(c, factor);
936 void scale(
const std::map<T, CounterPtr>& maps, CounterAdapter factor) {
937 for (
auto& m : maps)
scale(m.second, factor);
941 template <std::
size_t array_size>
942 void scale(
const CounterPtr (&cnts)[array_size], CounterAdapter factor) {
944 for (
auto& c : cnts)
scale(c, factor);
949 void normalize(Histo1DPtr histo, CounterAdapter norm=1.0,
bool includeoverflows=
true);
954 void normalize(
const std::vector<Histo1DPtr>& histos, CounterAdapter norm=1.0,
bool includeoverflows=
true) {
955 for (
auto& h : histos)
normalize(h, norm, includeoverflows);
960 void normalize(
const std::map<T, Histo1DPtr>& maps, CounterAdapter norm=1.0,
bool includeoverflows=
true) {
961 for (
auto& m : maps)
normalize(m.second, norm, includeoverflows);
965 template <std::
size_t array_size>
966 void normalize(
const Histo1DPtr (&histos)[array_size], CounterAdapter norm=1.0,
bool includeoverflows=
true) {
967 for (
auto& h : histos)
normalize(h, norm, includeoverflows);
971 void scale(Histo1DPtr histo, CounterAdapter factor);
976 void scale(
const std::vector<Histo1DPtr>& histos, CounterAdapter factor) {
977 for (
auto& h : histos)
scale(h, factor);
982 void scale(
const std::map<T, Histo1DPtr>& maps, CounterAdapter factor) {
983 for (
auto& m : maps)
scale(m.second, factor);
987 template <std::
size_t array_size>
988 void scale(
const Histo1DPtr (&histos)[array_size], CounterAdapter factor) {
989 for (
auto& h : histos)
scale(h, factor);
994 void normalize(Histo2DPtr histo, CounterAdapter norm=1.0,
bool includeoverflows=
true);
999 void normalize(
const std::vector<Histo2DPtr>& histos, CounterAdapter norm=1.0,
bool includeoverflows=
true) {
1000 for (
auto& h : histos)
normalize(h, norm, includeoverflows);
1004 template<
typename T>
1005 void normalize(
const std::map<T, Histo2DPtr>& maps, CounterAdapter norm=1.0,
bool includeoverflows=
true) {
1006 for (
auto& m : maps)
normalize(m.second, norm, includeoverflows);
1010 template <std::
size_t array_size>
1011 void normalize(
const Histo2DPtr (&histos)[array_size], CounterAdapter norm=1.0,
bool includeoverflows=
true) {
1012 for (
auto& h : histos)
normalize(h, norm, includeoverflows);
1016 void scale(Histo2DPtr histo, CounterAdapter factor);
1021 void scale(
const std::vector<Histo2DPtr>& histos, CounterAdapter factor) {
1022 for (
auto& h : histos)
scale(h, factor);
1026 template<
typename T>
1027 void scale(
const std::map<T, Histo2DPtr>& maps, CounterAdapter factor) {
1028 for (
auto& m : maps)
scale(m.second, factor);
1032 template <std::
size_t array_size>
1033 void scale(
const Histo2DPtr (&histos)[array_size], CounterAdapter factor) {
1034 for (
auto& h : histos)
scale(h, factor);
1044 void barchart(Histo1DPtr h, Scatter2DPtr s,
bool usefocus=
false)
const;
1049 void barchart(Histo2DPtr h, Scatter3DPtr s,
bool usefocus=
false)
const;
1055 void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s)
const;
1060 void divide(
const YODA::Counter& c1,
const YODA::Counter& c2, Scatter1DPtr s)
const;
1066 void divide(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s)
const;
1071 void divide(
const YODA::Histo1D& h1,
const YODA::Histo1D& h2, Scatter2DPtr s)
const;
1077 void divide(Profile1DPtr p1, Profile1DPtr p2, Scatter2DPtr s)
const;
1082 void divide(
const YODA::Profile1D& p1,
const YODA::Profile1D& p2, Scatter2DPtr s)
const;
1088 void divide(Histo2DPtr h1, Histo2DPtr h2, Scatter3DPtr s)
const;
1093 void divide(
const YODA::Histo2D& h1,
const YODA::Histo2D& h2, Scatter3DPtr s)
const;
1099 void divide(Profile2DPtr p1, Profile2DPtr p2, Scatter3DPtr s)
const;
1104 void divide(
const YODA::Profile2D& p1,
const YODA::Profile2D& p2, Scatter3DPtr s)
const;
1110 void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s)
const;
1115 void efficiency(
const YODA::Histo1D& h1,
const YODA::Histo1D& h2, Scatter2DPtr s)
const;
1121 void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s)
const;
1126 void asymm(
const YODA::Histo1D& h1,
const YODA::Histo1D& h2, Scatter2DPtr s)
const;
1132 void integrate(Histo1DPtr h, Scatter2DPtr s)
const;
1137 void integrate(
const Histo1D& h, Scatter2DPtr s)
const;
1146 return _analysisobjects;
1159 template <
typename YODAT>
1161 return dynamic_pointer_cast<YODAT>(_getPreload(path));
1166 template <
typename YODAT>
1167 rivet_shared_ptr< Wrapper<YODAT> >
registerAO(
const YODAT& yao) {
1168 typedef Wrapper<YODAT> WrapperT;
1169 typedef shared_ptr<YODAT> YODAPtrT;
1170 typedef rivet_shared_ptr<WrapperT> RAOT;
1172 if ( !_inInit() && !_inFinalize() ) {
1173 MSG_ERROR(
"Can't book objects outside of init() or finalize()");
1174 throw UserError(
name() +
": Can't book objects outside of init() or finalize().");
1181 if ( yao.path() == waold.get()->basePath() ) {
1182 const string msg =
"Found double-booking of " + yao.path() +
" in " +
name();
1189 return RAOT(dynamic_pointer_cast<WrapperT>(waold.get()));
1193 shared_ptr<WrapperT> wao = make_shared<WrapperT>();
1194 wao->_basePath = yao.path();
1195 YODAPtrT yaop = make_shared<YODAT>(yao);
1197 for (
const string& weightname : _weightNames()) {
1200 string finalpath = yao.path();
1201 if ( weightname !=
"" ) finalpath +=
"[" + weightname +
"]";
1202 YODAPtrT preload = getPreload<YODAT>(finalpath);
1206 MSG_WARNING(
"Found incompatible pre-existing data object with same base path " 1207 << finalpath <<
" for " <<
name());
1210 MSG_TRACE(
"Using preloaded " << finalpath <<
" in " <<
name());
1211 wao->_final.push_back(make_shared<YODAT>(*preload));
1215 wao->_final.push_back(make_shared<YODAT>(yao));
1216 wao->_final.back()->setPath(finalpath);
1220 string rawpath =
"/RAW" + finalpath;
1221 preload = getPreload<YODAT>(rawpath);
1224 MSG_WARNING(
"Found incompatible pre-existing data object with same base path " 1225 << rawpath <<
" for " <<
name());
1228 MSG_TRACE(
"Using preloaded " << rawpath <<
" in " <<
name());
1229 wao->_persistent.push_back(make_shared<YODAT>(*preload));
1233 wao->_persistent.push_back(make_shared<YODAT>(yao));
1234 wao->_persistent.back()->setPath(rawpath);
1237 rivet_shared_ptr<WrapperT> ret(wao);
1239 ret.get()->unsetActiveWeight();
1240 if ( _inFinalize() ) {
1243 ret.get()->pushToFinal();
1244 ret.get()->setActiveFinalWeightIdx(0);
1246 _analysisobjects.push_back(ret);
1253 template <
typename AO=MultiweightAOPtr>
1262 if (ao->path() != aonew->path())
continue;
1266 AO aoold = AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1268 MSG_WARNING(
"Found incompatible pre-existing data object with same base path " 1269 << aonew->path() <<
" for " <<
name());
1270 throw LookupError(
"Found incompatible pre-existing data object with same base path during AO booking");
1274 for (
size_t weightIdx = 0; weightIdx < _weightNames().size(); ++weightIdx) {
1275 aoold.get()->setActiveWeightIdx(weightIdx);
1276 aonew.get()->setActiveWeightIdx(weightIdx);
1277 if (aoold->path() != aonew->path()) {
1278 MSG_WARNING(
"Found incompatible pre-existing data object with different weight-path " 1279 << aonew->path() <<
" for " <<
name());
1280 throw LookupError(
"Found incompatible pre-existing data object with same weight-path during AO booking");
1285 aoold.get()->unsetActiveWeight();
1286 MSG_TRACE(
"Bound pre-existing data object " << aoold->path() <<
" for " <<
name());
1291 MSG_TRACE(
"Registered " << aonew->annotation(
"Type") <<
" " << aonew->path() <<
" for " <<
name());
1292 aonew.get()->unsetActiveWeight();
1294 _analysisobjects.push_back(aonew);
1310 template <
typename AO=MultiweightAOPtr>
1316 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1344 template <
typename AO=MultiweightAOPtr>
1346 const std::string& aoname) {
1347 MultiweightAOPtr ao = _getOtherAnalysisObject(ananame, aoname);
1349 return AO(dynamic_pointer_cast<typename AO::value_type>(ao.get()));
1463 string _defaultname;
1466 unique_ptr<AnalysisInfo> _info;
1470 vector<MultiweightAOPtr> _analysisobjects;
1474 double _crossSection;
1475 bool _gotCrossSection;
1483 mutable std::map<std::string, YODA::AnalysisObjectPtr> _refdata;
1486 map<string, string> _options;
1498 void _cacheRefData()
const;
1516 #include "Rivet/AnalysisBuilder.hh" 1524 #define RIVET_DECLARE_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname 1528 #define RIVET_DECLARE_ALIASED_PLUGIN(clsname, alias) RIVET_DECLARE_PLUGIN(clsname)( #alias ) 1532 #define RIVET_DEFAULT_ANALYSIS_CTOR(clsname) clsname() : Analysis(# clsname) {} 1540 #define DECLARE_RIVET_PLUGIN(clsname) ::Rivet::AnalysisBuilder<clsname> plugin_ ## clsname 1547 #define DECLARE_ALIASED_RIVET_PLUGIN(clsname, alias) DECLARE_RIVET_PLUGIN(clsname)( #alias ) 1553 #define DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname) clsname() : Analysis(# clsname) {} 1559 #define DEFAULT_RIVET_ANALYSIS_CTOR(clsname) DEFAULT_RIVET_ANALYSIS_CONSTRUCTOR(clsname)
double sumOfWeights() const
Alias.
Definition: Analysis.hh:378
Definition: MC_Cent_pPb.hh:10
const AO getAnalysisObject(const std::string &aoname) const
Get a Rivet data object from the histogram system.
Definition: Analysis.hh:1311
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
const vector< MultiweightAOPtr > & analysisObjects() const
List of registered analysis data objects.
Definition: Analysis.hh:1145
void divide(CounterPtr c1, CounterPtr c2, Scatter1DPtr s) const
double crossSectionErrorPerEvent() const
Used together with the percentile-based analysis objects Percentile and PercentileXaxis.
Definition: CentralityProjection.hh:26
virtual void init()
Definition: Analysis.hh:89
const std::map< std::string, YODA::AnalysisObjectPtr > & refData() const
Get all reference data objects for this analysis.
Definition: Analysis.hh:413
Holder of analysis metadata.
Definition: AnalysisInfo.hh:12
Base class for projections returning a single floating point value.
Definition: SingleValueProjection.hh:17
bool isCompatibleWithSqrtS(const float energy, float tolerance=1E-5) const
Check if sqrtS is compatible with provided value.
void scale(const std::map< T, Histo1DPtr > &maps, CounterAdapter factor)
Iteratively scale the histograms in the map, maps, by factor factor.
Definition: Analysis.hh:982
const CentralityProjection & declareCentrality(const SingleValueProjection &proj, string calAnaName, string calHistName, const string projName, bool increasing=false)
Book a CentralityProjection.
const ParticlePair & beams() const
Incoming beams for this run.
const std::map< std::string, std::string > & options() const
Return the map of all options given to this analysis.
Definition: Analysis.hh:701
CounterPtr & book(CounterPtr &, const std::string &name)
Book a counter.
Error specialisation for where the problem is between the chair and the computer. ...
Definition: Exceptions.hh:55
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:204
bool bookingCompatible(TPtr a, TPtr b)
Definition: RivetYODA.hh:849
size_t defaultWeightIndex() const
Get the default/nominal weight index.
virtual void analyze(const Event &event)=0
void removeAnalysisObject(const std::string &path)
Unregister a data object from the histogram system (by name)
void normalize(const Histo2DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:1011
void barchart(Histo1DPtr h, Scatter2DPtr s, bool usefocus=false) const
void add(TPtr ao, CounterPtr cnt, pair< float, float > cent={0.0, 100.0})
Add a new percentile bin.
Definition: Percentile.hh:122
Error for read failures.
Definition: Exceptions.hh:72
The Percentile class for centrality binning.
Definition: Percentile.hh:203
void normalize(const std::map< T, Histo2DPtr > &maps, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the histograms in map, maps, to area = norm.
Definition: Analysis.hh:1005
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't been set.
Logging system for controlled & formatted writing to stdout.
Definition: Logging.hh:10
const std::vector< std::string > & validation() const
List a series of command lines to be used for valdation.
Definition: AnalysisInfo.hh:270
void efficiency(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
virtual void finalize()
Definition: Analysis.hh:102
void scale(const std::vector< CounterPtr > &cnts, CounterAdapter factor)
Definition: Analysis.hh:930
const T & refData(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Definition: Analysis.hh:436
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:64
bool merging() const
Check if we are running rivet-merge.
Definition: Analysis.hh:318
Representation of a HepMC event, and enabler of Projection caching.
Definition: Event.hh:22
string toLower(const string &s)
Convert a string to lower-case.
Definition: Utils.hh:137
double sumW() const
Get the sum of event weights seen (via the analysis handler).
rivet_shared_ptr< Wrapper< YODAT > > registerAO(const YODAT &yao)
Register a new data object, optionally read in preloaded data.
Definition: Analysis.hh:1167
double sqrtS() const
Centre of mass energy for this run.
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:21
void scale(const std::map< T, CounterPtr > &maps, CounterAdapter factor)
Iteratively scale the counters in the map maps, by factor factor.
Definition: Analysis.hh:936
void normalize(const Histo1DPtr(&histos)[array_size], CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:966
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:346
double crossSectionError() const
Get the process cross-section error in pb. Throws if this hasn'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:999
const T & refData(const string &hname) const
Definition: Analysis.hh:422
Error Exception
Rivet::Exception is a synonym for Rivet::Error.
Definition: Exceptions.hh:18
size_t numEvents() const
Get the number of events seen (via the analysis handler).
void normalize(const std::vector< Histo1DPtr > &histos, CounterAdapter norm=1.0, bool includeoverflows=true)
Definition: Analysis.hh:954
The key class for coordination of Analysis objects and the event loop.
Definition: AnalysisHandler.hh:23
std::string getOption(std::string optname, string def="") const
Get an option for this analysis instance as a string.
Definition: Analysis.hh:706
#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.
AO getAnalysisObject(const std::string &ananame, const std::string &aoname)
Definition: Analysis.hh:1345
double sumW2() const
Get the sum of squared event weights seen (via the analysis handler).
const std::string mkAxisCode(unsigned int datasetId, unsigned int xAxisId, unsigned int yAxisId) const
Get the internal histogram name for given d, x and y (cf. HepData)
void scale(CounterPtr cnt, CounterAdapter factor)
Multiplicatively scale the given counter, cnt, by factor factor.
T getOption(std::string optname, T def) const
Get an option for this analysis instance converted to a specific type.
Definition: Analysis.hh:728
void integrate(Histo1DPtr h, Scatter2DPtr s) const
bool reentrant() const
Return true if finalize() can be run multiple times for this analysis.
Definition: AnalysisInfo.hh:209
shared_ptr< YODAT > getPreload(string path) const
Get a preloaded YODA object.
Definition: Analysis.hh:1160
void asymm(Histo1DPtr h1, Histo1DPtr h2, Scatter2DPtr s) const
bool getOption(std::string optname, bool def) const
Get an option for this analysis instance converted to a bool.
Definition: Analysis.hh:754
void scale(const CounterPtr(&cnts)[array_size], CounterAdapter factor)
Definition: Analysis.hh:942
Analysis(const std::string &name)
Constructor.
void scale(const std::vector< Histo1DPtr > &histos, CounterAdapter factor)
Definition: Analysis.hh:976
Log & getLog() const
Get a Log object based on the name() property of the calling analysis object.
#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 ~Analysis()
The destructor.
Definition: Analysis.hh:75
std::string getOption(std::string optname, const char *def)
Sane overload for literal character strings (which don't play well with stringstream) ...
Definition: Analysis.hh:716
void normalize(const std::map< T, Histo1DPtr > &maps, CounterAdapter norm=1.0, bool includeoverflows=true)
Normalize the histograms in map, maps, to area = norm.
Definition: Analysis.hh:960
std::string refFile() const
Find the path to the reference-data file for this analysis.
void scale(const Histo1DPtr(&histos)[array_size], CounterAdapter factor)
Definition: Analysis.hh:988
bool isCompatible(const ParticlePair &beams) const
Check if analysis is compatible with the provided beam particle IDs and energies. ...
AO addAnalysisObject(const AO &aonew)
Register a data object in the histogram system.
Definition: Analysis.hh:1254
Percentile< T > bookPercentile(string projName, vector< pair< float, float > > centralityBins, vector< tuple< int, int, int > > ref)
Book a Percentile wrapper around AnalysisObjects.
Definition: Analysis.hh:801