Analysis.hh
// -*- C++ -*-
#ifndef RIVET_Analysis_HH
#define RIVET_Analysis_HH
#include "Rivet/Rivet.hh"
#include "Rivet/Analysis.fhh"
#include "Rivet/AnalysisInfo.hh"
#include "Rivet/Event.hh"
#include "Rivet/Projection.hh"
#include "Rivet/ProjectionApplier.hh"
#include "Rivet/ProjectionHandler.hh"
#include "Rivet/Constraints.hh"
#include "Rivet/AnalysisHandler.fhh"
#include "Rivet/AnalysisLoader.hh"
#include "Rivet/Tools/Logging.fhh"
#include "Rivet/RivetAIDA.fhh"
#define vetoEvent \
do { MSG_DEBUG("Vetoing event on line " << __LINE__ << " of " << __FILE__); return; } while(0)
#define DECLARE_RIVET_PLUGIN(clsname) Rivet::AnalysisBuilder<clsname> plugin_ ## clsname
namespace Rivet {
class Analysis : public ProjectionApplier {
friend class AnalysisHandler;
public:
// /// The default constructor.
// Analysis();
Analysis(const std::string& name);
virtual ~Analysis() {}
public:
virtual void init() { }
virtual void analyze(const Event& event) = 0;
virtual void finalize() { }
public:
const AnalysisInfo& info() const {
assert(_info.get() != 0 && "No AnalysisInfo object :O");
return *_info;
}
virtual std::string name() const {
return (info().name().empty()) ? _defaultname : info().name();
}
virtual std::string inspireId() const {
return info().inspireId();
}
virtual std::string spiresId() const {
return info().spiresId();
}
virtual std::vector<std::string> authors() const {
return info().authors();
}
virtual std::string summary() const {
return info().summary();
}
virtual std::string description() const {
return info().description();
}
virtual std::string runInfo() const {
return info().runInfo();
}
virtual std::string experiment() const {
return info().experiment();
}
virtual std::string collider() const {
return info().collider();
}
virtual std::string year() const {
return info().year();
}
virtual std::vector<std::string> references() const {
return info().references();
}
virtual std::string bibKey() const {
return info().bibKey();
}
virtual std::string bibTeX() const {
return info().bibTeX();
}
virtual std::string status() const {
return (info().status().empty()) ? "UNVALIDATED" : info().status();
}
virtual std::vector<std::string> todos() const {
return info().todos();
}
virtual const std::vector<PdgIdPair>& requiredBeams() const {
return info().beams();
}
virtual Analysis& setRequiredBeams(const std::vector<PdgIdPair>& requiredBeams) {
info().setBeams(requiredBeams);
return *this;
}
virtual const std::vector<std::pair<double, double> >& requiredEnergies() const {
return info().energies();
}
virtual Analysis& setRequiredEnergies(const std::vector<std::pair<double, double> >& requiredEnergies) {
info().setEnergies(requiredEnergies);
return *this;
}
bool needsCrossSection() const {
return info().needsCrossSection();
}
Analysis& setNeedsCrossSection(bool needed=true) {
info().setNeedsCrossSection(needed);
return *this;
}
AnalysisInfo& info() {
assert(_info.get() != 0 && "No AnalysisInfo object :O");
return *_info;
}
virtual Analysis& setBeams(PdgId beam1, PdgId beam2) {
return setRequiredBeams(std::vector<PdgIdPair>(1, make_pair(beam1, beam2)));
}
const ParticlePair& beams() const;
const PdgIdPair beamIds() const;
double sqrtS() const;
bool isCompatible(const ParticlePair& beams) const;
bool isCompatible(PdgId beam1, PdgId beam2, double e1, double e2) const;
bool isCompatible(const PdgIdPair& beams, const std::pair<double,double>& energies) const;
public:
AnalysisHandler& handler() const { return *_analysishandler; }
void normalize(AIDA::IHistogram1D*& histo, double norm=1.0, bool includeoverflows=true);
void scale(AIDA::IHistogram1D*& histo, double scale);
void normalize(AIDA::IHistogram2D*& histo, double norm=1.0);
void scale(AIDA::IHistogram2D*& histo, double scale);
Analysis& setCrossSection(double xs);
protected:
Log& getLog() const;
double crossSection() const;
double crossSectionPerEvent() const;
size_t numEvents() const;
double sumOfWeights() const;
protected:
AIDA::IAnalysisFactory& analysisFactory();
AIDA::ITree& tree();
AIDA::IHistogramFactory& histogramFactory();
AIDA::IDataPointSetFactory& datapointsetFactory();
const std::string histoDir() const;
const std::string histoPath(const std::string& hname) const;
const std::string histoPath(size_t datasetId, size_t xAxisId, size_t yAxisId) const;
const std::string makeAxisCode(size_t datasetId, size_t xAxisId, size_t yAxisId) const;
const BinEdges& binEdges(const std::string& hname) const;
const BinEdges& binEdges(size_t datasetId, size_t xAxisId, size_t yAxisId) const;
BinEdges logBinEdges(size_t nbins, double lower, double upper);
AIDA::IHistogram1D* bookHistogram1D(const std::string& name,
size_t nbins, double lower, double upper,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IHistogram1D* bookHistogram1D(const std::string& name,
const std::vector<double>& binedges, const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IHistogram2D*
bookHistogram2D(const std::string& name,
size_t nxbins, double xlower, double xupper,
size_t nybins, double ylower, double yupper,
const std::string& title="", const std::string& xtitle="",
const std::string& ytitle="", const std::string& ztitle="");
AIDA::IHistogram2D*
bookHistogram2D(const std::string& name,
const std::vector<double>& xbinedges,
const std::vector<double>& ybinedges,
const std::string& title="", const std::string& xtitle="",
const std::string& ytitle="", const std::string& ztitle="");
AIDA::IHistogram1D* bookHistogram1D(const std::string& name, const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IHistogram1D* bookHistogram1D(size_t datasetId, size_t xAxisId, size_t yAxisId,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IProfile1D* bookProfile1D(const std::string& name,
size_t nbins, double lower, double upper,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IProfile1D* bookProfile1D(const std::string& name,
const std::vector<double>& binedges,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IProfile1D* bookProfile1D(const std::string& name, const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IProfile1D* bookProfile1D(size_t datasetId, size_t xAxisId, size_t yAxisId,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IDataPointSet* bookDataPointSet(const std::string& name, const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
AIDA::IDataPointSet* bookDataPointSet(const std::string& name,
size_t npts, double lower, double upper,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
//AIDA::IDataPointSet* bookDataPointSet(const std::string& name, const std::string& title);
AIDA::IDataPointSet* bookDataPointSet(size_t datasetId, size_t xAxisId, size_t yAxisId,
const std::string& title="",
const std::string& xtitle="", const std::string& ytitle="");
private:
void _makeHistoDir();
void _cacheBinEdges() const;
void _cacheXAxisData() const;
protected:
string _defaultname;
shared_ptr<AnalysisInfo> _info;
private:
double _crossSection;
bool _gotCrossSection;
AnalysisHandler* _analysishandler;
mutable bool _madeHistoDir;
mutable map<string, vector<DPSXPoint> > _dpsData;
mutable map<string, BinEdges> _histBinEdges;
private:
Analysis& operator=(const Analysis&);
};
}
// Include definition of analysis plugin system so that analyses automatically see it when including Analysis.hh
#include "Rivet/AnalysisBuilder.hh"
#endif
Rivet::PdgId
int PdgId
Typedef for a PDG ID code.
Definition: Particle.fhh:29
Rivet::Analysis::sumOfWeights
double sumOfWeights() const
Definition: Analysis.cc:113
Rivet::Analysis::summary
virtual std::string summary() const
Get a short description of the analysis.
Definition: Analysis.hh:145
Rivet::Analysis::histoDir
const std::string histoDir() const
Get the canonical histogram &quot;directory&quot; path for this analysis.
Definition: Analysis.cc:63
Rivet::AnalysisInfo::setNeedsCrossSection
void setNeedsCrossSection(bool needXsec)
Return true if this analysis needs to know the process cross-section.
Definition: AnalysisInfo.hh:184
Rivet::AnalysisInfo
Definition: AnalysisInfo.hh:11
Rivet::Analysis::todos
virtual std::vector< std::string > todos() const
Any work to be done on this analysis.
Definition: Analysis.hh:204
Rivet::Analysis::experiment
virtual std::string experiment() const
Experiment which performed and published this analysis.
Definition: Analysis.hh:169
Rivet::Analysis::logBinEdges
BinEdges logBinEdges(size_t nbins, double lower, double upper)
Get bin edges with logarithmic widths.
Definition: Analysis.cc:229
Rivet::Analysis::requiredBeams
virtual const std::vector< PdgIdPair > & requiredBeams() const
Return the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:210
Rivet::Analysis::bibTeX
virtual std::string bibTeX() const
BibTeX citation entry for this article.
Definition: Analysis.hh:194
Rivet::Analysis::analysisFactory
AIDA::IAnalysisFactory & analysisFactory()
Access the AIDA analysis factory of the controlling AnalysisHandler object.
Definition: Analysis.cc:30
Rivet::Analysis::beams
const ParticlePair & beams() const
Incoming beams for this run.
Definition: Analysis.cc:54
Rivet::Analysis::bookHistogram2D
AIDA::IHistogram2D * bookHistogram2D(const std::string &name, size_t nxbins, double xlower, double xupper, size_t nybins, double ylower, double yupper, const std::string &title="", const std::string &xtitle="", const std::string &ytitle="", const std::string &ztitle="")
Definition: Analysis.cc:295
Rivet::AnalysisInfo::collider
const std::string & collider() const
Collider on which the experiment ran.
Definition: AnalysisInfo.hh:130
Rivet::AnalysisInfo::year
const std::string & year() const
When the original experimental analysis was published. When the refereed paper on which this is based...
Definition: AnalysisInfo.hh:139
Rivet::Analysis::finalize
virtual void finalize()
Definition: Analysis.hh:95
Rivet::AnalysisInfo::bibKey
const std::string & bibKey() const
BibTeX citation key for this article.
Definition: AnalysisInfo.hh:153
Rivet::AnalysisInfo::spiresId
const std::string & spiresId() const
Get the SPIRES ID code for this analysis.
Definition: AnalysisInfo.hh:62
Rivet::Analysis::status
virtual std::string status() const
Whether this analysis is trusted (in any way!)
Definition: Analysis.hh:199
Rivet::AnalysisInfo::authors
const std::vector< std::string > & authors() const
Names &amp; emails of paper/analysis authors. Names and email of authors in &#39;NAME &lt;EMAIL&gt;&#39; format...
Definition: AnalysisInfo.hh:71
Rivet::Analysis::scale
void scale(AIDA::IHistogram1D *&histo, double scale)
Definition: Analysis.cc:511
Rivet::Analysis::runInfo
virtual std::string runInfo() const
Information about the events needed as input for this analysis.
Definition: Analysis.hh:164
Rivet::Analysis::analyze
virtual void analyze(const Event &event)=0
Rivet::Analysis::info
AnalysisInfo & info()
Get the actual AnalysisInfo object in which all this metadata is stored (non-const).
Definition: Analysis.hh:248
Rivet::Analysis::init
virtual void init()
Definition: Analysis.hh:82
Rivet::Analysis::setCrossSection
Analysis & setCrossSection(double xs)
Set the cross section from the generator.
Definition: Analysis.cc:165
Rivet::Log
Definition: Logging.hh:9
Rivet::AnalysisInfo::needsCrossSection
bool needsCrossSection() const
Return true if this analysis needs to know the process cross-section.
Definition: AnalysisInfo.hh:181
Rivet::Analysis::description
virtual std::string description() const
Get a full description of the analysis.
Definition: Analysis.hh:155
Rivet::Analysis::sqrtS
double sqrtS() const
Centre of mass energy for this run.
Definition: Analysis.cc:50
Rivet::AnalysisInfo::energies
const std::vector< std::pair< double, double > > & energies() const
Sets of valid beam energies.
Definition: AnalysisInfo.hh:116
Rivet::Analysis::bookDataPointSet
AIDA::IDataPointSet * bookDataPointSet(const std::string &name, const std::string &title="", const std::string &xtitle="", const std::string &ytitle="")
Definition: Analysis.cc:404
Rivet::Analysis::numEvents
size_t numEvents() const
Definition: Analysis.cc:108
Rivet::Analysis
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:51
Rivet::AnalysisInfo::runInfo
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:102
Rivet::Event
Definition: Event.hh:22
Rivet::Analysis::bibKey
virtual std::string bibKey() const
BibTeX citation key for this article.
Definition: Analysis.hh:189
Rivet::Analysis::beamIds
const PdgIdPair beamIds() const
Incoming beam IDs for this run.
Definition: Analysis.cc:58
Rivet::ParticlePair
std::pair< Particle, Particle > ParticlePair
Typedef for a pair of Particle objects.
Definition: Particle.fhh:20
Rivet::ProjectionApplier
Common base class for Projection and Analysis, used for internal polymorphism.
Definition: ProjectionApplier.hh:18
Rivet::Analysis::histoPath
const std::string histoPath(const std::string &hname) const
Get the canonical histogram path for the named histogram in this analysis.
Definition: Analysis.cc:76
Rivet::Analysis::getLog
Log & getLog() const
Get a Log object based on the name() property of the calling analysis object.
Definition: Analysis.cc:102
Rivet::Analysis::crossSectionPerEvent
double crossSectionPerEvent() const
Definition: Analysis.cc:179
Rivet::AnalysisInfo::description
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:92
Rivet::AnalysisInfo::status
const std::string & status() const
Whether this analysis is trusted (in any way!)
Definition: AnalysisInfo.hh:167
Rivet::Analysis::authors
virtual std::vector< std::string > authors() const
Names &amp; emails of paper/analysis authors.
Definition: Analysis.hh:136
Rivet::AnalysisInfo::todos
const std::vector< std::string > & todos() const
Any work to be done on this analysis.
Definition: AnalysisInfo.hh:174
Rivet::Analysis::setNeedsCrossSection
Analysis & setNeedsCrossSection(bool needed=true)
Declare whether this analysis needs to know the process cross-section from the generator.
Definition: Analysis.hh:236
Rivet::Analysis::handler
AnalysisHandler & handler() const
Access the controlling AnalysisHandler object.
Definition: Analysis.hh:296
Rivet::PdgIdPair
std::pair< PdgId, PdgId > PdgIdPair
Typedef for a pair of particle names.
Definition: Particle.fhh:32
Rivet::Analysis::histogramFactory
AIDA::IHistogramFactory & histogramFactory()
Access the AIDA histogram factory of the controlling AnalysisHandler object.
Definition: Analysis.cc:40
Rivet::Analysis::isCompatible
bool isCompatible(const ParticlePair &beams) const
Check if analysis is compatible with the provided beam particle IDs and energies. ...
Definition: Analysis.cc:121
Rivet::AnalysisInfo::name
std::string name() const
Definition: AnalysisInfo.hh:38
Rivet::AnalysisHandler
Definition: AnalysisHandler.hh:29
Rivet::AnalysisInfo::summary
const std::string & summary() const
Get a short description of the analysis. Short (one sentence) description used as an index entry...
Definition: AnalysisInfo.hh:81
Rivet::Analysis::references
virtual std::vector< std::string > references() const
Journal, and preprint references.
Definition: Analysis.hh:184
Rivet::Analysis::tree
AIDA::ITree & tree()
Access the AIDA tree of the controlling AnalysisHandler object.
Definition: Analysis.cc:35
Rivet::AnalysisInfo::experiment
const std::string & experiment() const
Experiment which performed and published this analysis.
Definition: AnalysisInfo.hh:123
Rivet::AnalysisInfo::beams
const std::vector< PdgIdPair > & beams() const
Beam particle types.
Definition: AnalysisInfo.hh:109
Rivet::Analysis::setRequiredEnergies
virtual Analysis & setRequiredEnergies(const std::vector< std::pair< double, double > > &requiredEnergies)
Declare the list of valid beam energy pairs, in GeV.
Definition: Analysis.hh:225
Rivet::Analysis::binEdges
const BinEdges & binEdges(const std::string &hname) const
Get bin edges for a named histo (using ref AIDA caching)
Definition: Analysis.cc:208
Rivet::AnalysisInfo::inspireId
const std::string & inspireId() const
Get the Inspire (SPIRES replacement) ID code for this analysis.
Definition: AnalysisInfo.hh:55
Rivet::BinEdges
std::vector< double > BinEdges
Typedef for a collection of bin edges.
Definition: RivetAIDA.fhh:28
Rivet::Analysis::datapointsetFactory
AIDA::IDataPointSetFactory & datapointsetFactory()
Access the AIDA histogram factory of the controlling AnalysisHandler object.
Definition: Analysis.cc:45
Rivet::Analysis::setBeams
virtual Analysis & setBeams(PdgId beam1, PdgId beam2)
Definition: Analysis.hh:255
Rivet::Analysis::setRequiredBeams
virtual Analysis & setRequiredBeams(const std::vector< PdgIdPair > &requiredBeams)
Declare the allowed pairs of incoming beams required by this analysis.
Definition: Analysis.hh:214
Rivet::Analysis::info
const AnalysisInfo & info() const
Get the actual AnalysisInfo object in which all this metadata is stored.
Definition: Analysis.hh:108
Rivet::Analysis::needsCrossSection
bool needsCrossSection() const
Return true if this analysis needs to know the process cross-section.
Definition: Analysis.hh:232
Rivet::Analysis::collider
virtual std::string collider() const
Collider on which the experiment ran.
Definition: Analysis.hh:174
Rivet::Analysis::crossSection
double crossSection() const
Get the process cross-section in pb. Throws if this hasn&#39;t been set.
Definition: Analysis.cc:171
Rivet::Analysis::name
virtual std::string name() const
Get the name of the analysis.
Definition: Analysis.hh:118
Rivet::Analysis::Analysis
Analysis(const std::string &name)
Constructor.
Definition: Analysis.cc:14
Rivet::Analysis::makeAxisCode
const std::string makeAxisCode(size_t datasetId, size_t xAxisId, size_t yAxisId) const
Get the internal histogram name for given d, x and y (cf. HepData)
Definition: Analysis.cc:87
Rivet::Analysis::bookHistogram1D
AIDA::IHistogram1D * bookHistogram1D(const std::string &name, size_t nbins, double lower, double upper, const std::string &title="", const std::string &xtitle="", const std::string &ytitle="")
Definition: Analysis.cc:261
Rivet::Analysis::year
virtual std::string year() const
When the original experimental analysis was published.
Definition: Analysis.hh:179
Rivet::Analysis::spiresId
virtual std::string spiresId() const
Get the SPIRES ID code for this analysis (~deprecated).
Definition: Analysis.hh:128
Rivet::AnalysisInfo::references
const std::vector< std::string > & references() const
Journal and preprint references.
Definition: AnalysisInfo.hh:146
Rivet::Analysis::~Analysis
virtual ~Analysis()
The destructor.
Definition: Analysis.hh:69
Rivet::AnalysisInfo::bibTeX
const std::string & bibTeX() const
BibTeX citation entry for this article.
Definition: AnalysisInfo.hh:160
Rivet::Analysis::normalize
void normalize(AIDA::IHistogram1D *&histo, double norm=1.0, bool includeoverflows=true)
Definition: Analysis.cc:479
Rivet::AnalysisInfo::setBeams
void setBeams(const std::vector< PdgIdPair > &beams)
Set beam particle types.
Definition: AnalysisInfo.hh:112
Rivet::Analysis::requiredEnergies
virtual const std::vector< std::pair< double, double > > & requiredEnergies() const
Sets of valid beam energy pairs, in GeV.
Definition: Analysis.hh:221
Rivet::Analysis::inspireId
virtual std::string inspireId() const
Get the Inspire ID code for this analysis.
Definition: Analysis.hh:123
Rivet::Analysis::bookProfile1D
AIDA::IProfile1D * bookProfile1D(const std::string &name, size_t nbins, double lower, double upper, const std::string &title="", const std::string &xtitle="", const std::string &ytitle="")
Definition: Analysis.cc:366
Rivet::AnalysisInfo::setEnergies
void setEnergies(const std::vector< std::pair< double, double > > &energies)
Set the valid beam energies.
Definition: AnalysisInfo.hh:119