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

Loader to use any HepMC3 compatible file. More...

#include <BDSHepMC3Reader.hh>

Inheritance diagram for BDSHepMC3Reader:
Inheritance graph
Collaboration diagram for BDSHepMC3Reader:
Collaboration graph

Public Member Functions

 BDSHepMC3Reader ()=delete
 Do not require default constructor.
 
 BDSHepMC3Reader (const G4String &distrType, const G4String &fileNameIn, BDSBunchEventGenerator *bunchIn, G4bool removeUnstableWithoutDecayIn=true, G4bool warnAboutSkippedParticlesIn=true)
 
HepMC3::GenEvent * GetHepMCGenEvent () const
 Accessor. More...
 
virtual void GeneratePrimaryVertex (G4Event *anEvent)
 
virtual void RecreateAdvanceToEvent (G4int eventOffset)
 Advance to the correct event number in the file for recreation. More...
 

Protected Member Functions

void OpenFile ()
 Construct the member "reader" and open the file for reading. More...
 
void CloseFile ()
 
void ReadSingleEvent ()
 Clear the hepmcEvent object, reallocate and read a single event and fill that member. More...
 
void HepMC2G4 (const HepMC3::GenEvent *hepmcevt, G4Event *g4event)
 Conversion from HepMC::GenEvent to G4Event. More...
 
virtual G4bool VertexInsideWorld (const G4ThreeVector &pos) const
 

Protected Attributes

HepMC3::GenEvent * hepmcEvent
 

Private Attributes

HepMC3::Reader * reader
 
G4String fileName
 
BDSBunchEventGeneratorbunch
 
G4bool removeUnstableWithoutDecay
 
G4bool warnAboutSkippedParticles
 
BDSEventGeneratorFileType fileType
 
G4RotationMatrix referenceBeamMomentumOffset
 
G4VSolid * worldSolid
 

Detailed Description

Loader to use any HepMC3 compatible file.

Interface to use HepMC3 library to load a variety of files.

This is largely based on Geant4's example examples/extended/eventgenerator/HepMC/HepMCEx01, however it has been rewritten to use HepMC3 library rather than HepMC2. Additionally, the interface has been written based on HepMC3 example "convert_example" to use multiple reader classes.

Author
Helena Pikhartova, Laurie Nevay

Definition at line 55 of file BDSHepMC3Reader.hh.

Constructor & Destructor Documentation

◆ BDSHepMC3Reader()

BDSHepMC3Reader::BDSHepMC3Reader ( const G4String &  distrType,
const G4String &  fileNameIn,
BDSBunchEventGenerator bunchIn,
G4bool  removeUnstableWithoutDecayIn = true,
G4bool  warnAboutSkippedParticlesIn = true 
)

Constructor takes full distrType string including semicolon and eventgeneratorfile prefix. The filename is assumed to be correctly prefixed if a relative path already. The bunch definition is used for the reference coordinates and offset of the beam point.

Definition at line 62 of file BDSHepMC3Reader.cc.

References BDS::DetermineEventGeneratorFileType(), OpenFile(), BDSBunchEventGenerator::ReferenceBeamMomentumOffset(), and BDS::SplitOnColon().

Here is the call graph for this function:

◆ ~BDSHepMC3Reader()

BDSHepMC3Reader::~BDSHepMC3Reader ( )
virtual

Definition at line 82 of file BDSHepMC3Reader.cc.

Member Function Documentation

◆ CloseFile()

void BDSHepMC3Reader::CloseFile ( )
protected

Close and delete reader. Have to delete as HepMC3 readers have no iteration or ability to loop back to the beginning.

Definition at line 135 of file BDSHepMC3Reader.cc.

Referenced by ReadSingleEvent().

Here is the caller graph for this function:

◆ GeneratePrimaryVertex()

void BDSHepMC3Reader::GeneratePrimaryVertex ( G4Event *  anEvent)
virtual

Definition at line 88 of file BDSHepMC3Reader.cc.

◆ GetHepMCGenEvent()

HepMC3::GenEvent * BDSHepMC3Reader::GetHepMCGenEvent ( ) const
inline

Accessor.

Definition at line 72 of file BDSHepMC3Reader.hh.

◆ HepMC2G4()

void BDSHepMC3Reader::HepMC2G4 ( const HepMC3::GenEvent *  hepmcevt,
G4Event *  g4event 
)
protected

Conversion from HepMC::GenEvent to G4Event.

Definition at line 163 of file BDSHepMC3Reader.cc.

References BDSBunchEventGenerator::AcceptParticle(), BDSBunch::ApplyTransform(), BDS::cOverGeV, BDSBunch::GetNextParticleLocal(), BDS::IsFinite(), and BDSParticleCoordsFull::s.

Here is the call graph for this function:

◆ OpenFile()

void BDSHepMC3Reader::OpenFile ( )
protected

Construct the member "reader" and open the file for reading.

Definition at line 104 of file BDSHepMC3Reader.cc.

References BDSTypeSafeEnum< def, inner >::underlying().

Referenced by BDSHepMC3Reader(), and ReadSingleEvent().

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

◆ ReadSingleEvent()

void BDSHepMC3Reader::ReadSingleEvent ( )
protected

Clear the hepmcEvent object, reallocate and read a single event and fill that member.

Definition at line 142 of file BDSHepMC3Reader.cc.

References CloseFile(), and OpenFile().

Referenced by RecreateAdvanceToEvent().

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

◆ RecreateAdvanceToEvent()

void BDSHepMC3Reader::RecreateAdvanceToEvent ( G4int  eventOffset)
virtual

Advance to the correct event number in the file for recreation.

Definition at line 97 of file BDSHepMC3Reader.cc.

References ReadSingleEvent().

Referenced by BDSPrimaryGeneratorAction::BDSPrimaryGeneratorAction().

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

◆ VertexInsideWorld()

G4bool BDSHepMC3Reader::VertexInsideWorld ( const G4ThreeVector &  pos) const
protectedvirtual

Definition at line 277 of file BDSHepMC3Reader.cc.

Field Documentation

◆ bunch

BDSBunchEventGenerator* BDSHepMC3Reader::bunch
private

Definition at line 107 of file BDSHepMC3Reader.hh.

◆ fileName

G4String BDSHepMC3Reader::fileName
private

Definition at line 106 of file BDSHepMC3Reader.hh.

◆ fileType

BDSEventGeneratorFileType BDSHepMC3Reader::fileType
private

Definition at line 110 of file BDSHepMC3Reader.hh.

◆ hepmcEvent

HepMC3::GenEvent* BDSHepMC3Reader::hepmcEvent
protected

Definition at line 102 of file BDSHepMC3Reader.hh.

◆ reader

HepMC3::Reader* BDSHepMC3Reader::reader
private

Definition at line 105 of file BDSHepMC3Reader.hh.

◆ referenceBeamMomentumOffset

G4RotationMatrix BDSHepMC3Reader::referenceBeamMomentumOffset
private

Definition at line 111 of file BDSHepMC3Reader.hh.

◆ removeUnstableWithoutDecay

G4bool BDSHepMC3Reader::removeUnstableWithoutDecay
private

Definition at line 108 of file BDSHepMC3Reader.hh.

◆ warnAboutSkippedParticles

G4bool BDSHepMC3Reader::warnAboutSkippedParticles
private

Definition at line 109 of file BDSHepMC3Reader.hh.

◆ worldSolid

G4VSolid* BDSHepMC3Reader::worldSolid
mutableprivate

Definition at line 112 of file BDSHepMC3Reader.hh.


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