rivet is hosted by Hepforge, IPPP Durham
Rivet  2.7.0
Rivet::AnalysisHandler Class Reference

#include <AnalysisHandler.hh>

Public Member Functions

Constructors and destructors. */
 AnalysisHandler (const string &runname="")
 Preferred constructor, with optional run name.
 
 ~AnalysisHandler ()
 Destructor The destructor is not virtual, as this class should not be inherited from.
 
Run properties
string runName () const
 Get the name of this run.
 
size_t numEvents () const
 
double sumW () const
 Access the sum of the event weights seen. More...
 
double sumW2 () const
 Access to the sum of squared-weights.
 
double sumOfWeights () const
 Compatibility alias for sumOfWeights. More...
 
void setSumOfWeights (const double &sum)
 Set the sum of weights. More...
 
bool needCrossSection () const
 
bool hasCrossSection () const
 
double crossSection () const
 Get the cross-section known to the handler.
 
AnalysisHandlersetCrossSection (double xs, double xserr=0)
 Set the cross-section for the process being generated.
 
AnalysisHandlersetRunBeams (const ParticlePair &beams)
 Set the beam particles for this run.
 
const ParticlePair & beams () const
 Get the beam particles for this run, usually determined from the first event.
 
PdgIdPair beamIds () const
 
double sqrtS () const
 
void setIgnoreBeams (bool ignore=true)
 Setter for _ignoreBeams.
 
Handle analyses
std::vector< std::string > analysisNames () const
 Get a list of the currently registered analyses' names.
 
const std::set< AnaHandle, CmpAnaHandle > & analyses () const
 Get the collection of currently registered analyses.
 
const AnaHandle analysis (const std::string &analysisname) const
 Get a registered analysis by name.
 
AnalysisHandleraddAnalysis (Analysis *analysis)
 Add an analysis to the run list by object.
 
AnalysisHandleraddAnalysis (const std::string &analysisname)
 Add an analysis to the run list using its name. More...
 
AnalysisHandleraddAnalysis (const std::string &analysisname, std::map< string, string > pars)
 Add an analysis with a map of analysis options.
 
AnalysisHandleraddAnalyses (const std::vector< std::string > &analysisnames)
 Add analyses to the run list using their names. More...
 
AnalysisHandlerremoveAnalysis (const std::string &analysisname)
 Remove an analysis from the run list using its name.
 
AnalysisHandlerremoveAnalyses (const std::vector< std::string > &analysisnames)
 Remove analyses from the run list using their names.
 
Main init/execute/finalise
void init (const GenEvent &event)
 Initialize a run, with the run beams taken from the example event.
 
void analyze (const GenEvent &event)
 Analyze the given event by reference. More...
 
void analyze (const GenEvent *event)
 Analyze the given event by pointer. More...
 
void finalize ()
 
Histogram / data object access
void addData (const std::vector< AnalysisObjectPtr > &aos)
 Add a vector of analysis objects to the current state. More...
 
void readData (const std::string &filename)
 Read analysis plots into the histo collection (via addData) from the named file. More...
 
std::vector< AnalysisObjectPtr > getData (bool includeorphans=false, bool includetmps=false) const
 Get all analyses' plots as a vector of analysis objects. More...
 
void writeData (const std::string &filename) const
 Write all analyses' plots (via getData) to the named file.
 
void dump (string dumpfile, int period)
 
void mergeYodas (const vector< string > &aofiles, const vector< string > &delopts=vector< string >(), bool equiv=false)
 
void stripOptions (AnalysisObjectPtr ao, const vector< string > &delopts) const
 Helper function to strip specific options from data object paths.
 

Detailed Description

A class which handles a number of analysis objects to be applied to generated events. An Analysis' AnalysisHandler is also responsible for handling the final writing-out of histograms.

Member Function Documentation

◆ addAnalyses()

AnalysisHandler & Rivet::AnalysisHandler::addAnalyses ( const std::vector< std::string > &  analysisnames)

Add analyses to the run list using their names.

The actual Analysis' to be used will be obtained via AnalysisHandler::addAnalysis(string), which in turn uses AnalysisLoader::getAnalysis(string). If no matching analysis is found for a given name, no analysis is added, but also no error is thrown.

References addAnalysis().

◆ addAnalysis()

AnalysisHandler & Rivet::AnalysisHandler::addAnalysis ( const std::string &  analysisname)

Add an analysis to the run list using its name.

The actual Analysis to be used will be obtained via AnalysisLoader::getAnalysis(string). If no matching analysis is found, no analysis is added (i.e. the null pointer is checked and discarded.

Todo:
Might we want to be able to run an analysis twice, with different params? Requires avoiding histo tree clashes, i.e. storing the histos on the analysis objects.

References analysis(), Rivet::AnalysisLoader::getAnalysis(), and Rivet::split().

◆ addData()

void Rivet::AnalysisHandler::addData ( const std::vector< AnalysisObjectPtr > &  aos)

Add a vector of analysis objects to the current state.

Todo:
Need to statistically merge...

References analysis(), and Rivet::split().

Referenced by readData().

◆ analyze() [1/2]

void Rivet::AnalysisHandler::analyze ( const GenEvent &  event)

Analyze the given event by reference.

This function will call the AnalysisBase::analyze() function of all included analysis objects.

Todo:
Filter/normalize the event here
Todo:
Drop this / just report first weight when we support multiweight events

References Rivet::beamIds(), beams(), Rivet::compatible(), finalize(), Rivet::fuzzyEquals(), init(), numEvents(), Rivet::sqrtS(), sqrtS(), Rivet::Event::weight(), and writeData().

Referenced by analyze().

◆ analyze() [2/2]

void Rivet::AnalysisHandler::analyze ( const GenEvent *  event)

Analyze the given event by pointer.

This function will call the AnalysisBase::analyze() function of all included analysis objects, after checking the event pointer validity.

References analyze().

◆ beamIds()

PdgIdPair Rivet::AnalysisHandler::beamIds ( ) const

Get beam IDs for this run, usually determined from the first event.

Deprecated:
Use standalone beamIds(ah.beams()), to clean AH interface

References Rivet::beamIds(), and beams().

Referenced by Rivet::Analysis::beamIds().

◆ dump()

void Rivet::AnalysisHandler::dump ( string  dumpfile,
int  period 
)
inline

Tell Rivet to dump intermediate result to a file named dumpfile every period'th event. If is not positive, no dumping will be done.

◆ finalize()

void Rivet::AnalysisHandler::finalize ( )

Finalize a run. This function calls the AnalysisBase::finalize() functions of all included analysis objects.

References analysis(), Rivet::copyao(), getData(), and Rivet::split().

Referenced by analyze(), and mergeYodas().

◆ getData()

vector< AnalysisObjectPtr > Rivet::AnalysisHandler::getData ( bool  includeorphans = false,
bool  includetmps = false 
) const

Get all analyses' plots as a vector of analysis objects.

Todo:
This needs to be much more nuanced for re-entrant histogramming

References analyses().

Referenced by finalize(), Rivet::Analysis::getAllData(), mergeYodas(), readData(), and writeData().

◆ hasCrossSection()

bool Rivet::AnalysisHandler::hasCrossSection ( ) const

Whether the handler knows about a cross-section.

Deprecated:
Should no-longer be an issue: does any generator not write the cross-section?

References crossSection().

◆ mergeYodas()

void Rivet::AnalysisHandler::mergeYodas ( const vector< string > &  aofiles,
const vector< string > &  delopts = vector<string>(),
bool  equiv = false 
)

Take the vector of yoda files and merge them together using the cross section and weight information provided in each file. Each file in aofiles is assumed to have been produced by Rivet. By default the files are assumed to contain different processes (or the same processs but mutually exclusive cuts), but if equiv if ture, the files are assumed to contain output of completely equivalent (but statistically independent) Rivet runs. The corresponding analyses will be loaded and their analysis objects will be filled with the merged result. finalize() will be run on each relevant anslysis. The resulting YODA file can then be rwitten out by writeData(). If delopts is non-empty, it is assumed to contain names different options to be merged into the same analysis objects.

Todo:
Use new YODA SFINAE to fill the smart ptr vector directly

References addAnalysis(), Rivet::addaos(), finalize(), getData(), Rivet::split(), Rivet::sqr(), sqrtS(), and stripOptions().

Referenced by stripOptions().

◆ needCrossSection()

bool Rivet::AnalysisHandler::needCrossSection ( ) const

Is cross-section information required by at least one child analysis?

Deprecated:
Should no-longer be an issue: does any generator not write the cross-section?

◆ numEvents()

size_t Rivet::AnalysisHandler::numEvents ( ) const
inline

Get the number of events seen. Should only really be used by external steering code or analyses in the finalize phase.

Referenced by analyze(), and Rivet::Analysis::numEvents().

◆ readData()

void Rivet::AnalysisHandler::readData ( const std::string &  filename)

Read analysis plots into the histo collection (via addData) from the named file.

Todo:
Use new YODA SFINAE to fill the smart ptr vector directly

References addData(), and getData().

◆ setSumOfWeights()

void Rivet::AnalysisHandler::setSumOfWeights ( const double &  sum)
inline

Set the sum of weights.

This is useful if Rivet is steered externally and the analyses are run for a sub-contribution of the events (but of course have to be normalised to the total sum of weights)

Todo:
What about the sumW2 term? That needs to be set coherently. Need a new version, with all three N,sumW,sumW2 numbers (or a counter) supplied.
Deprecated:
Weight sums are no longer tracked this way...

◆ sqrtS()

double Rivet::AnalysisHandler::sqrtS ( ) const

Get energy for this run, usually determined from the first event.

Deprecated:
Use standalone sqrtS(ah.beams()), to clean AH interface

References beams(), and Rivet::sqrtS().

Referenced by analyze(), mergeYodas(), and Rivet::Analysis::sqrtS().

◆ sumOfWeights()

double Rivet::AnalysisHandler::sumOfWeights ( ) const
inline

Compatibility alias for sumOfWeights.

Deprecated:
Prefer sumW

◆ sumW()

double Rivet::AnalysisHandler::sumW ( ) const
inline

Access the sum of the event weights seen.

This is the weighted equivalent of the number of events. It should only be used by external steering code or analyses in the finalize phase.

Referenced by Rivet::Analysis::sumW().


The documentation for this class was generated from the following files: