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
ParticleSetAccumulator Class Reference

Class to accumulate and merge ParticleSets in different ways. More...

#include <ParticleSetAccumulator.hh>

Collaboration diagram for ParticleSetAccumulator:
Collaboration graph

Public Member Functions

 ParticleSetAccumulator ()
 Default constructor only for ROOT reflexivity - not intended for use.
 
 ParticleSetAccumulator (ParticleSet *baseHistogram, const std::string &resultHistName, const std::string &resultHistTitle)
 
virtual ~ParticleSetAccumulator ()
 
virtual void Accumulate (ParticleSet *newValue)
 
virtual ParticleSetTerminate ()
 
ParticleSetResult () const
 Accessor.
 
void AddNEmptyEntries (unsigned long i)
 

Protected Member Functions

virtual void AccumulateSingleValue (double oldMean, double oldVari, double x, double xVari, unsigned long nEntriesAccumulated, unsigned long nEntriesToAccumulate, double &newMean, double &newVari) const
 
 ClassDef (ParticleSetAccumulator, 1)
 

Protected Attributes

unsigned long n
 Counter.
 
bool terminated
 Whether this instance has been finished.
 
const std::string resultHistName
 Name for resultant histogram.
 
const std::string resultHistTitle
 Title for resultant histogram.
 
ParticleSetmean
 
ParticleSetvariance
 
ParticleSetresult
 

Detailed Description

Class to accumulate and merge ParticleSets in different ways.

Author
Laurie Nevay

Definition at line 34 of file ParticleSetAccumulator.hh.

Constructor & Destructor Documentation

◆ ParticleSetAccumulator()

ParticleSetAccumulator::ParticleSetAccumulator ( ParticleSet baseHistogram,
const std::string &  resultHistName,
const std::string &  resultHistTitle 
)

Construct accumulator based on another histogram of 1,2 or 3 dimensions. Note, the result name must be different from that of baseHistogram if baseHistogram exists in the currently open file.

Definition at line 37 of file ParticleSetAccumulator.cc.

References resultHistName.

◆ ~ParticleSetAccumulator()

ParticleSetAccumulator::~ParticleSetAccumulator ( )
virtual

Destructor deletes mean and variance temporary histograms but leaks result as deleting it would remove it from the open file in ROOT.

Definition at line 55 of file ParticleSetAccumulator.cc.

Member Function Documentation

◆ Accumulate()

void ParticleSetAccumulator::Accumulate ( ParticleSet newValue)
virtual

Loop over the bins in a histogram and accumulate that bin from a new histogram ("newValue"). newValue is assumed to be the exact same as the baseHistogram the instance of this class was constructed with.

Definition at line 62 of file ParticleSetAccumulator.cc.

References AccumulateSingleValue(), and n.

Here is the call graph for this function:

◆ AccumulateSingleValue()

void ParticleSetAccumulator::AccumulateSingleValue ( double  oldMean,
double  oldVari,
double  x,
double  xVari,
unsigned long  nEntriesAccumulated,
unsigned long  nEntriesToAccumulate,
double &  newMean,
double &  newVari 
) const
protectedvirtual

Accumulate a single value into the online mean and variance histograms. This by default accumulates the mean and variance with a new value x. The xVari argument is not used in the implementation provided with this class but is used in derived classes with different AccumulateSingleValue implementations.

Definition at line 107 of file ParticleSetAccumulator.cc.

Referenced by Accumulate().

Here is the caller graph for this function:

◆ AddNEmptyEntries()

void ParticleSetAccumulator::AddNEmptyEntries ( unsigned long  i)
inline

Permit the number of recorded entries to be incremented with zero values, ie just increment n.

Definition at line 65 of file ParticleSetAccumulator.hh.

References n.

◆ Result()

ParticleSet * ParticleSetAccumulator::Result ( ) const
inline

Accessor.

Definition at line 61 of file ParticleSetAccumulator.hh.

◆ Terminate()

ParticleSet * ParticleSetAccumulator::Terminate ( )
virtual

Write the result to the result histogram. Calculate the standard error on the mean from the variance for the error in each bin.

Definition at line 83 of file ParticleSetAccumulator.cc.

References n.

Field Documentation

◆ mean

ParticleSet* ParticleSetAccumulator::mean
protected

Definition at line 86 of file ParticleSetAccumulator.hh.

◆ n

unsigned long ParticleSetAccumulator::n
protected

Counter.

Definition at line 82 of file ParticleSetAccumulator.hh.

Referenced by Accumulate(), AddNEmptyEntries(), and Terminate().

◆ result

ParticleSet* ParticleSetAccumulator::result
protected

Definition at line 88 of file ParticleSetAccumulator.hh.

◆ resultHistName

const std::string ParticleSetAccumulator::resultHistName
protected

Name for resultant histogram.

Definition at line 84 of file ParticleSetAccumulator.hh.

Referenced by ParticleSetAccumulator().

◆ resultHistTitle

const std::string ParticleSetAccumulator::resultHistTitle
protected

Title for resultant histogram.

Definition at line 85 of file ParticleSetAccumulator.hh.

◆ terminated

bool ParticleSetAccumulator::terminated
protected

Whether this instance has been finished.

Definition at line 83 of file ParticleSetAccumulator.hh.

◆ variance

ParticleSet* ParticleSetAccumulator::variance
protected

Definition at line 87 of file ParticleSetAccumulator.hh.


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