BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes
EventAnalysis Class Reference

Event level analysis. More...

#include <EventAnalysis.hh>

Inheritance diagram for EventAnalysis:
Inheritance graph
Collaboration diagram for EventAnalysis:
Collaboration graph

Public Member Functions

 EventAnalysis ()
 
 EventAnalysis (Event *eventIn, TChain *chain, bool perEntryAnalysis=true, bool processSamplersIn=true, bool debugIn=false, bool printOutIn=true, double printModuloFraction=0.01, bool emittanceOnTheFlyIn=false, long int eventStartIn=0, long int eventEndIn=-1, const std::string &primaryParticleName="")
 Constructor intended for use to construct an event analysis object.
 
virtual void Execute ()
 
virtual void Process ()
 Operate on each entry in the event tree.
 
virtual void SimpleHistograms ()
 Process histogram definitions from configuration instance.
 
virtual void Terminate ()
 Terminate each individual sampler analysis and append optical functions.
 
virtual void Write (TFile *outputFileName)
 Write analysis including optical functions to an output file.
 
- Public Member Functions inherited from Analysis
 Analysis (const std::string &treeNameIn, TChain *chainIn, const std::string &mergedHistogramNameIn, bool perEntryAnalysis=true, bool debugIn=false)
 
virtual void Execute ()
 Method which calls all other methods in order.
 
virtual void Process ()=0
 
virtual void UserProcess ()
 Virtual function for user to overload and use. Does nothing by default.
 
virtual void SimpleHistograms ()
 Process histogram definitions from configuration instance.
 
void PreparePerEntryHistograms ()
 Create structures necessary for per entry histograms.
 
void AccumulatePerEntryHistograms (long int entryNumber)
 Accumulate means and variances for per entry histograms.
 
void TerminatePerEntryHistograms ()
 Prepare result of per entry histogram accumulation.
 
virtual void Terminate ()
 
virtual void Write (TFile *outputFile)
 Write rebdsim histograms.
 

Protected Member Functions

void PreparePerEntryHistogramSets ()
 
void AccumulatePerEntryHistogramSets (long int entryNumber)
 
void TerminatePerEntryHistogramSets ()
 
void CheckSpectraBranches ()
 
void FillHistogram (HistogramDefSet *definition)
 Fill a set of simple histograms across all events.
 
- Protected Member Functions inherited from Analysis
void FillHistogram (HistogramDef *definition, std::vector< TH1 * > *outputHistograms=nullptr)
 Create an individual histogram based on a definition.
 

Protected Attributes

Eventevent
 Event object that data loaded from the file will be loaded into.
 
std::vector< SamplerAnalysis * > samplerAnalyses
 Holder for sampler analysis objects.
 
std::vector< std::vector< std::vector< double > > > opticalFunctions
 Optical functions from all samplers.
 
- Protected Attributes inherited from Analysis
std::string treeName
 
TChain * chain
 
std::string mergedHistogramName
 Name of directory for merged histograms.
 
std::vector< TH1 * > simpleHistograms
 
std::vector< PerEntryHistogram * > perEntryHistograms
 
HistogramMeanFromFilehistoSum
 Merge of per event stored histograms.
 
bool debug
 Whether debug print out is used or not.
 
long int entries
 Number of entries in the chain.
 
bool perEntry
 Whether to analyse each entry in the tree in a for loop or not.
 

Private Member Functions

void SetPrintModuloFraction (double fraction)
 Set how often to print out information about the event.
 
void Initialise ()
 Initialise each sampler analysis object in samplerAnalysis.
 
void ProcessSamplers (bool firstTime=false)
 Process each sampler analysis object.
 
 ClassDef (EventAnalysis, 2)
 

Private Attributes

bool printOut
 Whether to print out at all per-event.
 
int printModulo
 Cache of print modulo fraction.
 
bool processSamplers
 Whether to process samplers.
 
bool emittanceOnTheFly
 Whether to calculate emittance fresh at each sampler.
 
long int eventStart
 Event index to start analysis from.
 
long int eventEnd
 Event index to end analysis at.
 
long int nEventsToProcess
 Difference between start and stop.
 
std::vector< PerEntryHistogramSet * > perEntryHistogramSets
 Cache of all per entry histogram sets.
 
std::map< HistogramDefSet *, std::vector< TH1 * > > simpleSetHistogramOutputs
 Map of simple histograms created per histogram set for writing out.
 

Detailed Description

Event level analysis.

Author
Stewart Boogert

Definition at line 41 of file EventAnalysis.hh.

Constructor & Destructor Documentation

◆ EventAnalysis() [1/2]

EventAnalysis::EventAnalysis ( )

The default constructor is not intended for use and will not work for the purpose of analysis. It is required by the ROOT C++ reflection system in case you wish to save the object.

◆ EventAnalysis() [2/2]

EventAnalysis::EventAnalysis ( Event eventIn,
TChain *  chain,
bool  perEntryAnalysis = true,
bool  processSamplersIn = true,
bool  debugIn = false,
bool  printOutIn = true,
double  printModuloFraction = 0.01,
bool  emittanceOnTheFlyIn = false,
long int  eventStartIn = 0,
long int  eventEndIn = -1,
const std::string &  primaryParticleName = "" 
)

Constructor intended for use to construct an event analysis object.

Definition at line 56 of file EventAnalysis.cc.

References Analysis::debug, event, Event::GetPrimaries(), nEventsToProcess, processSamplers, samplerAnalyses, Event::Samplers, SetPrintModuloFraction(), SamplerAnalysis::UpdateMass(), and Event::UsePrimaries().

Here is the call graph for this function:

◆ ~EventAnalysis()

EventAnalysis::~EventAnalysis ( )
virtualnoexcept

Definition at line 143 of file EventAnalysis.cc.

Member Function Documentation

◆ AccumulatePerEntryHistogramSets()

void EventAnalysis::AccumulatePerEntryHistogramSets ( long int  entryNumber)
protected

Definition at line 392 of file EventAnalysis.cc.

◆ CheckSpectraBranches()

void EventAnalysis::CheckSpectraBranches ( )
protected

Definition at line 219 of file EventAnalysis.cc.

◆ Execute()

void EventAnalysis::Execute ( )
virtual

Method which calls all other methods in order. Here we also test if we have to process the samplers on whether to call Process().

Reimplemented from Analysis.

Definition at line 116 of file EventAnalysis.cc.

References Analysis::perEntry, Analysis::PreparePerEntryHistograms(), Process(), processSamplers, SimpleHistograms(), and Terminate().

Here is the call graph for this function:

◆ FillHistogram()

void EventAnalysis::FillHistogram ( HistogramDefSet definition)
protected

Fill a set of simple histograms across all events.

Definition at line 404 of file EventAnalysis.cc.

References HistogramDefSet::definitionsV, Analysis::FillHistogram(), and simpleSetHistogramOutputs.

Referenced by SimpleHistograms().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Initialise()

void EventAnalysis::Initialise ( )
private

Initialise each sampler analysis object in samplerAnalysis.

Definition at line 372 of file EventAnalysis.cc.

References processSamplers, and samplerAnalyses.

Referenced by Process().

Here is the caller graph for this function:

◆ PreparePerEntryHistogramSets()

void EventAnalysis::PreparePerEntryHistogramSets ( )
protected

Definition at line 381 of file EventAnalysis.cc.

◆ Process()

void EventAnalysis::Process ( )
virtual

Operate on each entry in the event tree.

Implements Analysis.

Definition at line 151 of file EventAnalysis.cc.

References HistogramMeanFromFile::Accumulate(), Analysis::AccumulatePerEntryHistograms(), Analysis::debug, Analysis::entries, event, eventEnd, eventStart, Event::Histos, Analysis::histoSum, Initialise(), printModulo, printOut, ProcessSamplers(), processSamplers, and Analysis::UserProcess().

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ ProcessSamplers()

void EventAnalysis::ProcessSamplers ( bool  firstTime = false)
private

Process each sampler analysis object.

Definition at line 363 of file EventAnalysis.cc.

References processSamplers, and samplerAnalyses.

Referenced by Process().

Here is the caller graph for this function:

◆ SetPrintModuloFraction()

void EventAnalysis::SetPrintModuloFraction ( double  fraction)
private

Set how often to print out information about the event.

Definition at line 136 of file EventAnalysis.cc.

References nEventsToProcess, and printModulo.

Referenced by EventAnalysis().

Here is the caller graph for this function:

◆ SimpleHistograms()

void EventAnalysis::SimpleHistograms ( )
virtual

Process histogram definitions from configuration instance.

Reimplemented from Analysis.

Definition at line 242 of file EventAnalysis.cc.

References FillHistogram(), Config::Instance(), and Analysis::SimpleHistograms().

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ Terminate()

void EventAnalysis::Terminate ( )
virtual

Terminate each individual sampler analysis and append optical functions.

Reimplemented from Analysis.

Definition at line 225 of file EventAnalysis.cc.

References emittanceOnTheFly, opticalFunctions, processSamplers, samplerAnalyses, and Analysis::Terminate().

Referenced by Execute().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ TerminatePerEntryHistogramSets()

void EventAnalysis::TerminatePerEntryHistogramSets ( )
protected

Definition at line 398 of file EventAnalysis.cc.

◆ Write()

void EventAnalysis::Write ( TFile *  outputFileName)
virtual

Write analysis including optical functions to an output file.

Reimplemented from Analysis.

Definition at line 251 of file EventAnalysis.cc.

References opticalFunctions, perEntryHistogramSets, processSamplers, simpleSetHistogramOutputs, and Analysis::Write().

Here is the call graph for this function:

Field Documentation

◆ emittanceOnTheFly

bool EventAnalysis::emittanceOnTheFly
private

Whether to calculate emittance fresh at each sampler.

Definition at line 106 of file EventAnalysis.hh.

Referenced by Terminate().

◆ event

Event* EventAnalysis::event
protected

Event object that data loaded from the file will be loaded into.

Definition at line 80 of file EventAnalysis.hh.

Referenced by EventAnalysis(), and Process().

◆ eventEnd

long int EventAnalysis::eventEnd
private

Event index to end analysis at.

Definition at line 108 of file EventAnalysis.hh.

Referenced by Process().

◆ eventStart

long int EventAnalysis::eventStart
private

Event index to start analysis from.

Definition at line 107 of file EventAnalysis.hh.

Referenced by Process().

◆ nEventsToProcess

long int EventAnalysis::nEventsToProcess
private

Difference between start and stop.

Definition at line 109 of file EventAnalysis.hh.

Referenced by EventAnalysis(), and SetPrintModuloFraction().

◆ opticalFunctions

std::vector<std::vector<std::vector<double> > > EventAnalysis::opticalFunctions
protected

Optical functions from all samplers.

Definition at line 82 of file EventAnalysis.hh.

Referenced by Terminate(), and Write().

◆ perEntryHistogramSets

std::vector<PerEntryHistogramSet*> EventAnalysis::perEntryHistogramSets
private

Cache of all per entry histogram sets.

Definition at line 112 of file EventAnalysis.hh.

Referenced by Write().

◆ printModulo

int EventAnalysis::printModulo
private

Cache of print modulo fraction.

Definition at line 104 of file EventAnalysis.hh.

Referenced by Process(), and SetPrintModuloFraction().

◆ printOut

bool EventAnalysis::printOut
private

Whether to print out at all per-event.

Definition at line 103 of file EventAnalysis.hh.

Referenced by Process().

◆ processSamplers

bool EventAnalysis::processSamplers
private

Whether to process samplers.

Definition at line 105 of file EventAnalysis.hh.

Referenced by EventAnalysis(), Execute(), Initialise(), Process(), ProcessSamplers(), Terminate(), and Write().

◆ samplerAnalyses

std::vector<SamplerAnalysis*> EventAnalysis::samplerAnalyses
protected

Holder for sampler analysis objects.

Definition at line 81 of file EventAnalysis.hh.

Referenced by EventAnalysis(), EventAnalysisOrbit::ExtractOrbit(), Initialise(), ProcessSamplers(), and Terminate().

◆ simpleSetHistogramOutputs

std::map<HistogramDefSet*, std::vector<TH1*> > EventAnalysis::simpleSetHistogramOutputs
private

Map of simple histograms created per histogram set for writing out.

Definition at line 115 of file EventAnalysis.hh.

Referenced by FillHistogram(), and Write().


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