BDSIM
BDSIM is a Geant4 extension toolkit for simulation of particle transport in accelerator beamlines.
Public Member Functions | Private Member Functions | Private Attributes
BDSOutputROOT Class Reference

ROOT Event output class. More...

#include <BDSOutputROOT.hh>

Inheritance diagram for BDSOutputROOT:
Inheritance graph
Collaboration diagram for BDSOutputROOT:
Collaboration graph

Public Member Functions

 BDSOutputROOT ()=delete
 No default constructor.
 
 BDSOutputROOT (const G4String &fileName, G4int fileNumberOffset, G4int compressionLevelIn=-1)
 
virtual void NewFile ()
 Open a new file. More...
 
virtual void CloseFile ()
 Write contents and close file. More...
 
virtual void UpdateSamplers ()
 Implementation for ROOT output. Only for link - not for regular use. More...
 
- Public Member Functions inherited from BDSOutput
 BDSOutput (const G4String &baseFileNameIn, const G4String &fileExtentionIn, G4int fileNumberOffset)
 Constructor with base file name (without extension or number suffix). More...
 
virtual void NewFile ()=0
 Open a new file. This should call WriteHeader() in it. More...
 
virtual void CloseFile ()=0
 
virtual void InitialiseGeometryDependent ()
 
virtual void UpdateSamplers ()
 Interface to allow updating samplers with dynamic construction. Only for link - not for regular use. More...
 
void FillHeader ()
 Fill the local structure header with information - updates time stamp. More...
 
void FillParticleData (G4bool writeIons)
 Fill the local structure particle data with information. Also calls WriteParticleData(). More...
 
void FillBeam (const GMAD::BeamBase *beam)
 
void FillOptions (const GMAD::OptionsBase *options)
 
void FillModel ()
 
void FillEventPrimaryOnly (const BDSParticleCoordsFullGlobal &coords, const BDSParticleDefinition *particle)
 
void FillEvent (const BDSEventInfo *info, const G4PrimaryVertex *vertex, const std::vector< BDSHitsCollectionSampler * > &samplerHitsPlane, const std::vector< BDSHitsCollectionSamplerCylinder * > &samplerHitsCylinder, const std::vector< BDSHitsCollectionSamplerSphere * > &samplerHitsSphere, const BDSHitsCollectionSamplerLink *samplerHitsLink, const BDSHitsCollectionEnergyDeposition *energyLoss, const BDSHitsCollectionEnergyDeposition *energyLossFull, const BDSHitsCollectionEnergyDeposition *energyLossVacuum, const BDSHitsCollectionEnergyDeposition *energyLossTunnel, const BDSHitsCollectionEnergyDepositionGlobal *energyLossWorld, const BDSHitsCollectionEnergyDepositionGlobal *energyLossWorldContents, const BDSHitsCollectionEnergyDepositionGlobal *worldExitHits, const std::vector< const BDSTrajectoryPointHit * > &primaryHits, const std::vector< const BDSTrajectoryPointHit * > &primaryLosses, const BDSTrajectoriesToStore *trajectories, const BDSHitsCollectionCollimator *collimatorHits, const BDSHitsCollectionApertureImpacts *apertureImpactHits, const std::map< G4String, G4THitsMap< G4double > * > &scorerHitsMap, const G4int turnsTaken)
 Copy event information from Geant4 simulation structures to output structures. More...
 
void CloseAndOpenNewFile ()
 Close a file and open a new one. More...
 
void FillRun (const BDSEventInfo *info)
 Copy run information to output structure. More...
 

Private Member Functions

virtual void WriteHeader ()
 Copy header and write to file. More...
 
virtual void WriteParticleData ()
 Copy geant4 data to file. More...
 
virtual void WriteBeam ()
 Copy beam and write to file. More...
 
virtual void WriteOptions ()
 Copy options and write to file. More...
 
virtual void WriteModel ()
 Copy model and write to file. More...
 
virtual void WriteFileEventLevel ()
 
virtual void WriteFileRunLevel ()
 
void Close ()
 

Private Attributes

G4int compressionLevel
 ROOT compression level for files. More...
 
TFile * theRootOutputFile
 Output file. More...
 
TTree * theHeaderOutputTree
 Header Tree. More...
 
TTree * theParticleDataTree
 Geant4 Data Tree. More...
 
TTree * theBeamOutputTree
 Beam Tree. More...
 
TTree * theOptionsOutputTree
 Options tree. More...
 
TTree * theModelOutputTree
 Model tree. More...
 
TTree * theEventOutputTree
 Event tree. More...
 
TTree * theRunOutputTree
 Output histogram tree. More...
 

Additional Inherited Members

- Static Public Member Functions inherited from BDSOutput
static G4bool InvalidSamplerName (const G4String &samplerName)
 Test whether a sampler name is invalid or not. More...
 
static void PrintProtectedNames (std::ostream &out)
 Feedback for protected names. More...
 
- Protected Member Functions inherited from BDSOutput
G4String GetNextFileName ()
 Get the next file name based on the base file name and the accrued number of files. More...
 
G4bool CreateCollimatorOutputStructures () const
 Whether to create the collimator structures in the output or not. More...
 
- Protected Member Functions inherited from BDSOutputStructures
 BDSOutputStructures (const BDSGlobalConstants *globals)
 
void InitialiseSamplers ()
 Construct samplers. More...
 
void InitialiseMaterialMap ()
 Construct a map of material pointer to integer ID and name. More...
 
G4int UpdateSamplerStructures ()
 Interface to allow setting up samplers later for dynamic geometry construction a la SixTrack. Not for regular use. More...
 
void PrepareCollimatorInformation ()
 
void InitialiseCollimators ()
 Construct collimtors. More...
 
void ClearStructuresParticleData ()
 Clear the local particle data structure. More...
 
void ClearStructuresHeader ()
 Clear the local header structure. More...
 
void ClearStructuresModel ()
 Clear the local model structure. More...
 
void ClearStructuresBeam ()
 Clear the local beam structure. More...
 
void ClearStructuresOptions ()
 Clear the local options structure. More...
 
void ClearStructuresEventLevel ()
 Clear the local structures in this class in preparation for a new event. More...
 
void ClearStructuresRunLevel ()
 Clear the local structures in this class in preparation for a new run. More...
 
G4int Create1DHistogram (G4String name, G4String title, G4int nbins, G4double xmin, G4double xmax)
 Create histograms for both evtHistos and runHistos. Return index from evtHistos. More...
 
G4int Create1DHistogram (G4String name, G4String title, std::vector< double > &edges)
 Create histograms for both evtHistos and runHistos. Return index from evtHistos. More...
 
G4int Create3DHistogram (G4String name, G4String title, G4int nBinsX, G4double xMin, G4double xMax, G4int nBinsY, G4double yMin, G4double yMax, G4int nBinsZ, G4double zMin, G4double zMax)
 Create histograms for both evtHistos and runHistos. Return index from evtHistos. More...
 
G4int Create4DHistogram (const G4String &name, const G4String &title, const G4String &eScale, const std::vector< double > &eBinsEdges, G4int nBinsX, G4double xMin, G4double xMax, G4int nBinsY, G4double yMin, G4double yMax, G4int nBinsZ, G4double zMin, G4double zMax, G4int nBinsE, G4double eMin, G4double eMax)
 Create histograms for both evtHistos and runHistos. Return index from evtHistos. More...
 
- Protected Attributes inherited from BDSOutput
std::map< G4String, G4int > blmCollectionNameToHistogramID
 
G4bool storeELoss
 Options for dynamic bits of output. More...
 
G4bool storeELossTunnel
 Options for dynamic bits of output. More...
 
G4bool storeELossVacuum
 Options for dynamic bits of output. More...
 
G4bool storeELossWorld
 Options for dynamic bits of output. More...
 
G4bool storeELossWorldContents
 Options for dynamic bits of output. More...
 
G4bool storeApertureImpacts
 Options for dynamic bits of output. More...
 
G4bool storeApertureImpactsHistograms
 Options for dynamic bits of output. More...
 
G4bool storePrimaries
 Options for dynamic bits of output. More...
 
G4bool storeTrajectory
 Options for dynamic bits of output. More...
 
- Protected Attributes inherited from BDSOutputStructures
BDSOutputROOTParticleDataparticleDataOutput
 Geant4 information / particle tables. More...
 
BDSOutputROOTEventHeaderheaderOutput
 Information about the file. More...
 
BDSOutputROOTEventBeambeamOutput
 Beam output. More...
 
BDSOutputROOTEventOptionsoptionsOutput
 Options output. More...
 
BDSOutputROOTEventModelmodelOutput
 Model output. More...
 
BDSOutputROOTEventSampler< double > * primary
 Primary sampler structure. More...
 
BDSOutputROOTEventSampler< float > * primary
 
BDSOutputROOTEventCoordsprimaryGlobal
 
std::vector< BDSOutputROOTEventSampler< double > * > samplerTrees
 Sampler structures. More...
 
std::vector< BDSOutputROOTEventSampler< float > * > samplerTrees
 
std::vector< std::string > samplerNames
 Sampler names to use. More...
 
std::vector< BDSOutputROOTEventSamplerC * > samplerCTrees
 
std::vector< BDSOutputROOTEventSamplerS * > samplerSTrees
 
std::vector< std::string > samplerCNames
 
std::vector< std::string > samplerSNames
 
std::map< G4int, G4int > samplerIDToIndexPlane
 
std::map< G4int, G4int > samplerIDToIndexCylinder
 
std::map< G4int, G4int > samplerIDToIndexSphere
 
BDSOutputROOTEventRunInforunInfo
 Run information. More...
 
BDSOutputROOTEventHistogramsrunHistos
 Run level histograms. More...
 
BDSOutputROOTEventLosseLoss
 General energy deposition. More...
 
BDSOutputROOTEventLosspFirstHit
 Primary hit point. More...
 
BDSOutputROOTEventLosspLastHit
 Primary loss point. More...
 
BDSOutputROOTEventLosseLossVacuum
 General energy deposition. More...
 
BDSOutputROOTEventLosseLossTunnel
 Tunnel energy deposition. More...
 
BDSOutputROOTEventLossWorldeLossWorld
 World energy deposition. More...
 
BDSOutputROOTEventLossWorldeLossWorldExit
 World exit hits. More...
 
BDSOutputROOTEventLossWorldeLossWorldContents
 Externally supplied world contents hits. More...
 
BDSOutputROOTEventApertureapertureImpacts
 Impacts on the aperture. More...
 
BDSOutputROOTEventTrajectorytraj
 Trajectories. More...
 
BDSOutputROOTEventHistogramsevtHistos
 Event level histograms. More...
 
BDSOutputROOTEventInfoevtInfo
 Event information. More...
 
std::vector< BDSOutputROOTEventCollimator * > collimators
 Collimator output structures. More...
 
std::vector< G4String > collimatorNames
 Names of collimators in output structures. More...
 
G4int nCollimators
 Number of collimators in beam line. More...
 
std::vector< G4int > collimatorIndices
 Indices in beam line that are collimators. More...
 
std::map< G4String, G4int > collimatorIndicesByName
 Indices mapped to their name. More...
 
std::vector< BDSOutputROOTEventCollimatorInfocollimatorInfo
 
std::vector< std::pair< G4double, G4double > > collimatorDifferences
 
std::map< G4Material *, short int > materialToID
 
std::map< short int, G4String > materialIDToNameUnique
 

Detailed Description

ROOT Event output class.

Author
Stewart Boogert

Definition at line 37 of file BDSOutputROOT.hh.

Constructor & Destructor Documentation

◆ BDSOutputROOT()

BDSOutputROOT::BDSOutputROOT ( const G4String &  fileName,
G4int  fileNumberOffset,
G4int  compressionLevelIn = -1 
)

Constructor with default file name (without extension or number suffix). Also, file number offset to start counting suffix from.

Definition at line 47 of file BDSOutputROOT.cc.

◆ ~BDSOutputROOT()

BDSOutputROOT::~BDSOutputROOT ( )
virtual

Definition at line 62 of file BDSOutputROOT.cc.

Member Function Documentation

◆ Close()

void BDSOutputROOT::Close ( )
private

An implementation only in this class. We need a non-virtual function to call in the class destructor.

Definition at line 231 of file BDSOutputROOT.cc.

References theRootOutputFile.

Referenced by CloseFile().

Here is the caller graph for this function:

◆ CloseFile()

void BDSOutputROOT::CloseFile ( )
virtual

Write contents and close file.

Implements BDSOutput.

Definition at line 226 of file BDSOutputROOT.cc.

References Close().

Here is the call graph for this function:

◆ NewFile()

void BDSOutputROOT::NewFile ( )
virtual

◆ UpdateSamplers()

void BDSOutputROOT::UpdateSamplers ( )
virtual

Implementation for ROOT output. Only for link - not for regular use.

Reimplemented from BDSOutput.

Definition at line 247 of file BDSOutputROOT.cc.

References BDSOutputStructures::samplerNames, BDSOutputStructures::samplerTrees, theEventOutputTree, and BDSOutputStructures::UpdateSamplerStructures().

Here is the call graph for this function:

◆ WriteBeam()

void BDSOutputROOT::WriteBeam ( )
privatevirtual

Copy beam and write to file.

Implements BDSOutput.

Definition at line 191 of file BDSOutputROOT.cc.

References theBeamOutputTree.

◆ WriteFileEventLevel()

void BDSOutputROOT::WriteFileEventLevel ( )
privatevirtual

Copy from local event structures to the actual file. Ony event level structures are copied.

Implements BDSOutput.

Definition at line 206 of file BDSOutputROOT.cc.

References theEventOutputTree, and theRootOutputFile.

◆ WriteFileRunLevel()

void BDSOutputROOT::WriteFileRunLevel ( )
privatevirtual

Copy from local run structures to the actual file. Only run level structures are copied.

Implements BDSOutput.

Definition at line 213 of file BDSOutputROOT.cc.

References theRootOutputFile, and theRunOutputTree.

◆ WriteHeader()

void BDSOutputROOT::WriteHeader ( )
privatevirtual

Copy header and write to file.

Implements BDSOutput.

Definition at line 181 of file BDSOutputROOT.cc.

References theHeaderOutputTree.

◆ WriteModel()

void BDSOutputROOT::WriteModel ( )
privatevirtual

Copy model and write to file.

Implements BDSOutput.

Definition at line 201 of file BDSOutputROOT.cc.

References theModelOutputTree.

◆ WriteOptions()

void BDSOutputROOT::WriteOptions ( )
privatevirtual

Copy options and write to file.

Implements BDSOutput.

Definition at line 196 of file BDSOutputROOT.cc.

References theOptionsOutputTree.

◆ WriteParticleData()

void BDSOutputROOT::WriteParticleData ( )
privatevirtual

Copy geant4 data to file.

Implements BDSOutput.

Definition at line 186 of file BDSOutputROOT.cc.

References theParticleDataTree.

Field Documentation

◆ compressionLevel

G4int BDSOutputROOT::compressionLevel
private

ROOT compression level for files.

Definition at line 83 of file BDSOutputROOT.hh.

Referenced by NewFile().

◆ theBeamOutputTree

TTree* BDSOutputROOT::theBeamOutputTree
private

Beam Tree.

Definition at line 87 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteBeam().

◆ theEventOutputTree

TTree* BDSOutputROOT::theEventOutputTree
private

Event tree.

Definition at line 90 of file BDSOutputROOT.hh.

Referenced by NewFile(), UpdateSamplers(), and WriteFileEventLevel().

◆ theHeaderOutputTree

TTree* BDSOutputROOT::theHeaderOutputTree
private

Header Tree.

Definition at line 85 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteHeader().

◆ theModelOutputTree

TTree* BDSOutputROOT::theModelOutputTree
private

Model tree.

Definition at line 89 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteModel().

◆ theOptionsOutputTree

TTree* BDSOutputROOT::theOptionsOutputTree
private

Options tree.

Definition at line 88 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteOptions().

◆ theParticleDataTree

TTree* BDSOutputROOT::theParticleDataTree
private

Geant4 Data Tree.

Definition at line 86 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteParticleData().

◆ theRootOutputFile

TFile* BDSOutputROOT::theRootOutputFile
private

Output file.

Definition at line 84 of file BDSOutputROOT.hh.

Referenced by Close(), NewFile(), WriteFileEventLevel(), and WriteFileRunLevel().

◆ theRunOutputTree

TTree* BDSOutputROOT::theRunOutputTree
private

Output histogram tree.

Definition at line 91 of file BDSOutputROOT.hh.

Referenced by NewFile(), and WriteFileRunLevel().


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