BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Loading...
Searching...
No Matches
Data Structures | Typedefs | Enumerations | Functions | Variables
RBDS Namespace Reference

Utility functions for data files. More...

Data Structures

struct  HistogramPath
 Basic structure for accumulating histogram from rebdsim output files. More...
 
class  Logspace
 

Typedefs

typedef std::map< std::string, std::vector< std::string > > BranchMap
 
typedef std::vector< std::string > VectorString
 

Enumerations

enum class  MergeType { none , meanmerge , sum }
 Types of merging. More...
 
enum class  SpectraParticles { all , primary , secondary }
 

Functions

std::string DefaultOutputName (const std::string &inputFilePath, const std::string &suffix)
 
std::vector< double > LogSpace (double start, double stop, int nBins, double base=10, bool includeLastPoint=true)
 
std::vector< double > LinSpace (double start, double stop, int nBins, bool includeLastPoint=true)
 Linear range of values.
 
std::vector< double > * LoadBins (const std::string &fileName)
 Method to load a single column text file and return vector of values.
 
TFile * CreateEmptyRebdsimFile (const std::string &fileName, unsigned long long int nOriginalEventsIn=1)
 Create a new TFile and add a header to it. The header object is filled and written.
 
std::map< std::string, TDirectory * > CreateDirectories (TFile *outputFile, std::string treeName)
 
bool GetFileType (TFile *file, std::string &fileType, int *dataVersion=nullptr)
 
bool IsBDSIMOutputFile (TFile *file, int *dataVersion=nullptr)
 
bool IsBDSIMOutputFile (const std::string &filePath, int *dataVersion=nullptr)
 Similar but opens file first.
 
bool IsREBDSIMOutputFile (TFile *file)
 
bool IsREBDSIMOutputFile (const std::string &filePath)
 Similar but opens file first and closes afterward.
 
bool IsREBDSIMOrCombineOutputFile (TFile *file)
 
bool IsREBDSIMOrCombineOutputFile (const std::string &filePath)
 Similar but opens the file first and closes afterwards.
 
int DetermineDimensionality (TH1 *h)
 Determine the number of dimensions of a histogram by dynamically casting.
 
void WarningMissingHistogram (const std::string &histName, const std::string &fileName)
 Common print out method.
 
MergeType DetermineMergeType (const std::string &parentDir)
 Determine merge type from parent directory name.
 
std::string LoadSelection (const std::string &selectionFile)
 Load a selection from a text file.
 

Variables

static const std::map< std::string, SpectraParticles > spectraParticlesKeys
 

Detailed Description

Utility functions for data files.

Enum for which particles to make a spectra of.

Author
Laurie Nevay

Typedef Documentation

◆ BranchMap

typedef std::map<std::string, std::vector<std::string> > RBDS::BranchMap

Definition at line 28 of file RebdsimTypes.hh.

◆ VectorString

typedef std::vector<std::string> RBDS::VectorString

Definition at line 29 of file RebdsimTypes.hh.

Enumeration Type Documentation

◆ MergeType

enum class RBDS::MergeType
strong

Types of merging.

Definition at line 82 of file FileMapper.hh.

◆ SpectraParticles

enum class RBDS::SpectraParticles
strong

Definition at line 31 of file SpectraParticles.hh.

Function Documentation

◆ CreateDirectories()

std::map< std::string, TDirectory * > RBDS::CreateDirectories ( TFile *  outputFile,
std::string  treeName 
)

Add the treeName minus the last character (expected to be a '.') to the output file then inside that directory, add PerEntryHistograms, SimpleHistograms, and MergedHistograms.

Definition at line 79 of file Data.cc.

Referenced by CreateEmptyRebdsimFile().

Here is the caller graph for this function:

◆ CreateEmptyRebdsimFile()

TFile * RBDS::CreateEmptyRebdsimFile ( const std::string &  fileName,
unsigned long long int  nOriginalEventsIn = 1 
)

Create a new TFile and add a header to it. The header object is filled and written.

Definition at line 52 of file Data.cc.

References CreateDirectories(), BDSOutputROOTEventHeader::Fill(), BDSOutputROOTEventHeader::nOriginalEvents, and BDSOutputROOTEventHeader::SetFileType().

Here is the call graph for this function:

◆ DefaultOutputName()

std::string RBDS::DefaultOutputName ( const std::string &  inputFilePath,
const std::string &  suffix 
)

Provide a suggested default name based on an input file path. e.g. /path/to/file.root -> file_suffix.root or file.root -> file_suffix.root

Definition at line 65 of file AnalysisUtilities.cc.

Referenced by Config::Config().

Here is the caller graph for this function:

◆ DetermineDimensionality()

int RBDS::DetermineDimensionality ( TH1 *  h)

Determine the number of dimensions of a histogram by dynamically casting.

Definition at line 142 of file FileMapper.cc.

Referenced by HistogramMap::MapDirectory().

Here is the caller graph for this function:

◆ DetermineMergeType()

RBDS::MergeType RBDS::DetermineMergeType ( const std::string &  parentDir)

Determine merge type from parent directory name.

Definition at line 258 of file FileMapper.cc.

Referenced by HistogramMap::MapDirectory().

Here is the caller graph for this function:

◆ GetFileType()

bool RBDS::GetFileType ( TFile *  file,
std::string &  fileType,
int *  dataVersion = nullptr 
)

Get the format of the root file open (bdsim, rebdsim, combined). Returns true for success and false otherwise. Filetype string is written to the string passed by reference. Changes the branch address of header if it's already set. Optional dataVersion - if supplied it will be updated with the version of data in the file.

Definition at line 44 of file FileMapper.cc.

References BDSOutputROOTEventHeader::dataVersion, Header::header, and Header::SetBranchAddress().

Referenced by IsBDSIMOutputFile(), IsREBDSIMOrCombineOutputFile(), and IsREBDSIMOutputFile().

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

◆ IsBDSIMOutputFile() [1/2]

bool RBDS::IsBDSIMOutputFile ( const std::string &  filePath,
int *  dataVersion = nullptr 
)

Similar but opens file first.

Definition at line 83 of file FileMapper.cc.

References IsBDSIMOutputFile().

Here is the call graph for this function:

◆ IsBDSIMOutputFile() [2/2]

bool RBDS::IsBDSIMOutputFile ( TFile *  file,
int *  dataVersion = nullptr 
)

Whether the file type is a BDSIM output one. Does not close file. May change the branch address for the header in the file. Optional dataVersion.

Definition at line 66 of file FileMapper.cc.

References GetFileType().

Referenced by DataLoader::BuildInputFileList(), and IsBDSIMOutputFile().

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

◆ IsREBDSIMOrCombineOutputFile() [1/2]

bool RBDS::IsREBDSIMOrCombineOutputFile ( const std::string &  filePath)

Similar but opens the file first and closes afterwards.

Definition at line 133 of file FileMapper.cc.

References IsREBDSIMOrCombineOutputFile().

Here is the call graph for this function:

◆ IsREBDSIMOrCombineOutputFile() [2/2]

bool RBDS::IsREBDSIMOrCombineOutputFile ( TFile *  file)

Whether the file type is a REBDSIM or REBDSIMCOMBINE one. Does not close file. May change the branch address for the header in the file.

Definition at line 116 of file FileMapper.cc.

References GetFileType().

Referenced by IsREBDSIMOrCombineOutputFile().

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

◆ IsREBDSIMOutputFile() [1/2]

bool RBDS::IsREBDSIMOutputFile ( const std::string &  filePath)

Similar but opens file first and closes afterward.

Definition at line 107 of file FileMapper.cc.

References IsREBDSIMOutputFile().

Here is the call graph for this function:

◆ IsREBDSIMOutputFile() [2/2]

bool RBDS::IsREBDSIMOutputFile ( TFile *  file)

Whether the file type is a REBDSIM output one. Does not close file. May change the branch address for the header in the file.

Definition at line 93 of file FileMapper.cc.

References GetFileType().

Referenced by IsREBDSIMOutputFile().

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

◆ LinSpace()

std::vector< double > RBDS::LinSpace ( double  start,
double  stop,
int  nBins,
bool  includeLastPoint = true 
)

Linear range of values.

Definition at line 49 of file BinGeneration.cc.

Referenced by HistogramFactory::CreateHistogram3D(), HistogramFactory::CreateHistogram4D(), and AnalysisUtilities::LinSpace().

Here is the caller graph for this function:

◆ LoadBins()

std::vector< double > * RBDS::LoadBins ( const std::string &  fileName)

Method to load a single column text file and return vector of values.

Definition at line 30 of file BinLoader.cc.

Referenced by Config::ParseBinning().

Here is the caller graph for this function:

◆ LoadSelection()

std::string RBDS::LoadSelection ( const std::string &  selectionFile)

Load a selection from a text file.

Definition at line 29 of file SelectionLoader.cc.

◆ LogSpace()

std::vector< double > RBDS::LogSpace ( double  start,
double  stop,
int  nBins,
double  base = 10,
bool  includeLastPoint = true 
)

Definition at line 28 of file BinGeneration.cc.

◆ WarningMissingHistogram()

void RBDS::WarningMissingHistogram ( const std::string &  histName,
const std::string &  fileName 
)

Common print out method.

Definition at line 147 of file FileMapper.cc.

Variable Documentation

◆ spectraParticlesKeys

const std::map<std::string, SpectraParticles> RBDS::spectraParticlesKeys
static
Initial value:
=
{{"p", SpectraParticles::primary},
{"s", SpectraParticles::secondary}}

Definition at line 33 of file SpectraParticles.hh.