BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
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, 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. More...
 
virtual void Execute ()
 
virtual void Process ()
 Operate on each entry in the event tree. More...
 
virtual void SimpleHistograms ()
 Process histogram definitions from configuration instance. More...
 
virtual void Terminate ()
 Terminate each individual sampler analysis and append optical functions. More...
 
virtual void Write (TFile *outputFileName)
 Write analysis including optical functions to an output file. More...
 
- 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. More...
 
virtual void Process ()=0
 
virtual void UserProcess ()
 Virtual function for user to overload and use. Does nothing by default. More...
 
virtual void SimpleHistograms ()
 Process histogram definitions from configuration instance. More...
 
void PreparePerEntryHistograms ()
 Create structures necessary for per entry histograms. More...
 
void AccumulatePerEntryHistograms (long int entryNumber)
 Accumulate means and variances for per entry histograms. More...
 
void TerminatePerEntryHistograms ()
 Prepare result of per entry histogram accumulation. More...
 
virtual void Terminate ()
 
virtual void Write (TFile *outputFile)
 Write rebdsim histograms. More...
 

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. More...
 
- Protected Member Functions inherited from Analysis
void FillHistogram (HistogramDef *definition, std::vector< TH1 * > *outputHistograms=nullptr)
 Create an individual histogram based on a definition. More...
 

Protected Attributes

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

Private Member Functions

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

Private Attributes

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

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,
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 54 of file EventAnalysis.cc.

References Analysis::debug, event, Event::GetPrimaries(), 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 134 of file EventAnalysis.cc.

Member Function Documentation

◆ AccumulatePerEntryHistogramSets()

void EventAnalysis::AccumulatePerEntryHistogramSets ( long int  entryNumber)
protected

Definition at line 383 of file EventAnalysis.cc.

◆ CheckSpectraBranches()

void EventAnalysis::CheckSpectraBranches ( )
protected

Definition at line 210 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 107 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 395 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 363 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 372 of file EventAnalysis.cc.

◆ Process()

void EventAnalysis::Process ( )
virtual

Operate on each entry in the event tree.

Implements Analysis.

Definition at line 142 of file EventAnalysis.cc.

References HistogramMeanFromFile::Accumulate(), Analysis::AccumulatePerEntryHistograms(), Analysis::debug, Analysis::entries, event, eventEnd, eventStart, Event::Histos, Analysis::histoSum, Initialise(), printModulo, 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 354 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 127 of file EventAnalysis.cc.

References Analysis::entries, 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 233 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 216 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 389 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 242 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 104 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 79 of file EventAnalysis.hh.

Referenced by EventAnalysis(), and Process().

◆ eventEnd

long int EventAnalysis::eventEnd
private

Event index to end analysis at.

Definition at line 106 of file EventAnalysis.hh.

Referenced by Process().

◆ eventStart

long int EventAnalysis::eventStart
private

Event index to start analysis from.

Definition at line 105 of file EventAnalysis.hh.

Referenced by Process().

◆ opticalFunctions

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

Optical functions from all samplers.

Definition at line 81 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 109 of file EventAnalysis.hh.

Referenced by Write().

◆ printModulo

int EventAnalysis::printModulo
private

Cache of print modulo fraction.

Definition at line 102 of file EventAnalysis.hh.

Referenced by Process(), and SetPrintModuloFraction().

◆ processSamplers

bool EventAnalysis::processSamplers
private

Whether to process samplers.

Definition at line 103 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 80 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 112 of file EventAnalysis.hh.

Referenced by FillHistogram(), and Write().


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