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::AnalysisHandler::addAnalyses
AnalysisHandler & addAnalyses(const std::vector< std::string > &analysisnames)
Definition: AnalysisHandler.cc:328
Rivet
Definition: MC_JetAnalysis.hh:9
Rivet::HistoFormat
HistoFormat
Enumeration of available histogram output formats.
Definition: HistoFormat.hh:11
Rivet::AnalysisHandler::crossSection
double crossSection() const
Get the cross-section known to the handler.
Definition: AnalysisHandler.hh:110
Rivet::AnalysisHandler::sqrtS
double sqrtS() const
Get energy for this run, usually determined from the first event.
Definition: AnalysisHandler.cc:402
Rivet::AnalysisHandler::needCrossSection
bool needCrossSection() const
Is cross-section information required by at least one child analysis?
Definition: AnalysisHandler.cc:366
Rivet::AnalysisHandler::analyses
const std::set< AnaHandle, AnaHandleLess > & analyses() const
Get the collection of currently registered analyses.
Definition: AnalysisHandler.hh:149
Rivet::AnalysisHandler::datapointsetFactory
AIDA::IDataPointSetFactory & datapointsetFactory()
Definition: AnalysisHandler.cc:361
Rivet::AnalysisHandler::tree
AIDA::ITree & tree()
Definition: AnalysisHandler.cc:351
Rivet::AnalysisHandler::beams
const ParticlePair & beams() const
Get beam IDs for this run, usually determined from the first event.
Definition: AnalysisHandler.hh:126
Rivet::AnalysisHandler::analyze
void analyze(const GenEvent &event)
Definition: AnalysisHandler.cc:106
Rivet::AnalysisHandler::setSumOfWeights
void setSumOfWeights(const double &sum)
Definition: AnalysisHandler.cc:314
Rivet::AnaHandleLess
Definition: AnalysisHandler.hh:19
Rivet::AnalysisHandler::AnalysisHandler
AnalysisHandler(const string &runname="")
Preferred constructor, with optional run name.
Definition: AnalysisHandler.cc:17
Rivet::AnalysisHandler::hasCrossSection
bool hasCrossSection() const
Whether the handler knows about a cross-section.
Definition: AnalysisHandler.cc:385
Rivet::AnalysisHandler::setCrossSection
AnalysisHandler & setCrossSection(double xs)
Set the cross-section for the process being generated.
Definition: AnalysisHandler.cc:376
Rivet::AnalysisHandler::finalize
void finalize()
Definition: AnalysisHandler.cc:150
Rivet::Log
Definition: Logging.hh:9
Rivet::AnalysisHandler::~AnalysisHandler
~AnalysisHandler()
Destructor The destructor is not virtual, as this class should not be inherited from.
Definition: AnalysisHandler.cc:40
Rivet::AnalysisHandler::runName
string runName() const
Get the name of this run.
Definition: AnalysisHandler.cc:309
Rivet::Analysis
This is the base class of all analysis classes in Rivet.
Definition: Analysis.hh:51
Rivet::AnalysisHandler::removeAnalyses
AnalysisHandler & removeAnalyses(const std::vector< std::string > &analysisnames)
Remove analyses from the run list using their names.
Definition: AnalysisHandler.cc:337
Rivet::AnalysisHandler::writeData
void writeData(const std::string &filename)
Definition: AnalysisHandler.cc:252
Rivet::AnalysisHandler::analysisNames
std::vector< std::string > analysisNames() const
Get a list of the currently registered analyses' names.
Definition: AnalysisHandler.cc:319
Rivet::AnalysisHandler::init
void init()
Definition: AnalysisHandler.hh:184
Rivet::AnalysisHandler::sumOfWeights
double sumOfWeights() const
Definition: AnalysisHandler.cc:311
Rivet::AnalysisHandler
Definition: AnalysisHandler.hh:29
Rivet::AnalysisHandler::numEvents
size_t numEvents() const
Definition: AnalysisHandler.cc:310
Rivet::AnalysisHandler::addAnalysis
AnalysisHandler & addAnalysis(const std::string &analysisname)
Definition: AnalysisHandler.cc:182
Rivet::AnalysisHandler::removeAnalysis
AnalysisHandler & removeAnalysis(const std::string &analysisname)
Remove an analysis from the run list using its name.
Definition: AnalysisHandler.cc:204
Rivet::AnalysisHandler::histogramFactory
AIDA::IHistogramFactory & histogramFactory()
Definition: AnalysisHandler.cc:356
Rivet::AnaHandle
shared_ptr< Analysis > AnaHandle
Typedef for Analysis (smart) pointer.
Definition: AnalysisHandler.hh:16
Rivet::AnalysisHandler::setIgnoreBeams
void setIgnoreBeams(bool ignore=true)
Setter for _ignoreBeams.
Definition: AnalysisHandler.cc:406
Rivet::AnalysisHandler::commitData
void commitData()
Definition: AnalysisHandler.cc:247
Rivet::AnalysisHandler::analysisFactory
AIDA::IAnalysisFactory & analysisFactory()
Definition: AnalysisHandler.cc:346
Rivet::AnalysisHandler::beamIds
PdgIdPair beamIds() const
Get beam IDs for this run, usually determined from the first event.
Definition: AnalysisHandler.cc:397
Rivet::AnalysisHandler::setRunBeams
AnalysisHandler & setRunBeams(const ParticlePair &beams)
Set beams for this run.
Definition: AnalysisHandler.hh:119