BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
|
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 |
Utility functions for data files.
Enum for which particles to make a spectra of.
typedef std::map<std::string, std::vector<std::string> > RBDS::BranchMap |
Definition at line 28 of file RebdsimTypes.hh.
typedef std::vector<std::string> RBDS::VectorString |
Definition at line 29 of file RebdsimTypes.hh.
|
strong |
Types of merging.
Definition at line 82 of file FileMapper.hh.
|
strong |
Definition at line 31 of file SpectraParticles.hh.
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
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().
std::string RBDS::LoadSelection | ( | const std::string & | selectionFile | ) |
Load a selection from a text file.
Definition at line 29 of file SelectionLoader.cc.
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.
void RBDS::WarningMissingHistogram | ( | const std::string & | histName, |
const std::string & | fileName | ||
) |
Common print out method.
Definition at line 147 of file FileMapper.cc.
|
static |
Definition at line 33 of file SpectraParticles.hh.