AnalysisHandler.hh
// -*- C++ -*-
#ifndef RIVET_RivetHandler_HH
#define RIVET_RivetHandler_HH
#include "Rivet/Rivet.hh"
#include "Rivet/RivetBoost.hh"
#include "Rivet/Tools/Logging.fhh"
#include "Rivet/AnalysisHandler.fhh"
#include "Rivet/Analysis.fhh"
#include "Rivet/Event.fhh"
#include "Rivet/AnalysisLoader.hh"
namespace Rivet {
typedef shared_ptr<Analysis> AnaHandle;
// Needed to make smart pointers compare equivalent in the STL set
struct AnaHandleLess {
bool operator()(const AnaHandle& a, const AnaHandle& b) {
return a.get() < b.get();
}
};
class AnalysisHandler {
public:
AnalysisHandler(const string& runname="");
AnalysisHandler(const string& basefilename, const string& runname, HistoFormat storetype=AIDAML);
~AnalysisHandler();
private:
void _setupFactories(const string& basefilename, HistoFormat storetype);
void _setupFactories();
void _normalizeTree(AIDA::ITree& tree);
Log& getLog() const;
public:
string runName() const;
size_t numEvents() const;
double sumOfWeights() const;
void setSumOfWeights(const double& sum);
bool needCrossSection() const;
AnalysisHandler& setCrossSection(double xs);
double crossSection() const {
return _xs;
}
bool hasCrossSection() const;
AnalysisHandler& setRunBeams(const ParticlePair& beams) {
_beams = beams;
MSG_DEBUG("Setting run beams = " << beams << " @ " << sqrtS()/GeV << " GeV");
return *this;
}
const ParticlePair& beams() const {
return _beams;
}
PdgIdPair beamIds() const;
double sqrtS() const;
void setIgnoreBeams(bool ignore=true);
std::vector<std::string> analysisNames() const;
const std::set<AnaHandle, AnaHandleLess>& analyses() const {
return _analyses;
}
AnalysisHandler& addAnalysis(const std::string& analysisname);
AnalysisHandler& removeAnalysis(const std::string& analysisname);
AnalysisHandler& addAnalyses(const std::vector<std::string>& analysisnames);
AnalysisHandler& removeAnalyses(const std::vector<std::string>& analysisnames);
AnalysisHandler& addAnalysis(Analysis* analysis);
void init() {}
void init(const GenEvent& event);
void analyze(const GenEvent& event);
void finalize();
AIDA::IAnalysisFactory& analysisFactory();
void commitData();
void writeData(const std::string& filename);
AIDA::ITree& tree();
AIDA::IHistogramFactory& histogramFactory();
AIDA::IDataPointSetFactory& datapointsetFactory();
private:
set<AnaHandle, AnaHandleLess> _analyses;
std::string _runname;
size_t _numEvents;
double _sumOfWeights;
double _xs;
ParticlePair _beams;
bool _initialised;
bool _ignoreBeams;
shared_ptr<AIDA::IAnalysisFactory> _theAnalysisFactory;
AIDA::ITreeFactory* _theTreeFactory;
AIDA::ITree* _theTree;
AIDA::IHistogramFactory* _theHistogramFactory;
AIDA::IDataPointSetFactory* _theDataPointSetFactory;
private:
AnalysisHandler& operator=(const AnalysisHandler&);
AnalysisHandler(const AnalysisHandler&);
};
}
#endif
Rivet
Definition: MC_JetAnalysis.hh:9
Rivet::HistoFormat
HistoFormat
Enumeration of available histogram output formats.
Definition: HistoFormat.hh:11
Rivet::AnalysisHandler::analyses
const std::set< AnaHandle, AnaHandleLess > & analyses() const
Get the collection of currently registered analyses.
Definition: AnalysisHandler.hh:149
Rivet::AnalysisHandler::beams
const ParticlePair & beams() const
Get beam IDs for this run, usually determined from the first event.
Definition: AnalysisHandler.hh:126
Rivet::beams
ParticlePair beams(const Event &e)
Function to get beam particles from an event.
Definition: Beam.cc:9
Rivet::AnalysisHandler::crossSection
double crossSection() const
Get the cross-section known to the handler.
Definition: AnalysisHandler.hh:110
Rivet::AnaHandleLess
Definition: AnalysisHandler.hh:19
Rivet::Log
Definition: Logging.hh:9
Rivet::Analysis
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:51
Rivet::AnalysisHandler::init
void init()
Definition: AnalysisHandler.hh:184
Rivet::sqrtS
double sqrtS(const Event &e)
Function to get beam centre of mass energy from an event.
Definition: Beam.cc:25
Rivet::AnalysisHandler
Definition: AnalysisHandler.hh:29
Rivet::beamIds
PdgIdPair beamIds(const Event &e)
Function to get beam particle IDs from an event.
Definition: Beam.cc:15
Rivet::AnaHandle
shared_ptr< Analysis > AnaHandle
Typedef for Analysis (smart) pointer.
Definition: AnalysisHandler.hh:16
Rivet::AnalysisHandler::setRunBeams
AnalysisHandler & setRunBeams(const ParticlePair &beams)
Set beams for this run.
Definition: AnalysisHandler.hh:119