Belle II Software  release-08-01-10
MCParticleGenerator Class Reference

This class creates Geant4 primary particles from MCParticle list The generator assumes that each particle in the list has exactly one mother. More...

#include <MCParticleGenerator.h>

Inheritance diagram for MCParticleGenerator:
Collaboration diagram for MCParticleGenerator:

Public Member Functions

 MCParticleGenerator (const std::string &mcCollectionName, MCParticleGraph &mcParticleGraph)
 The constructor of the MCParticleGenerator class. More...
 
virtual ~MCParticleGenerator ()
 The destructor of the MCParticleGenerator class.
 
virtual void GeneratePrimaryVertex (G4Event *event)
 Create G4 primary particles from MCParticle list. More...
 

Protected Member Functions

void addParticle (const MCParticle &mcParticle, G4Event *event, G4PrimaryParticle *lastG4Mother, int motherIndex, bool useTime)
 Takes a MCParticle and creates a primary particle for Geant4. More...
 
G4PrimaryVertex * determineVertex (const MCParticleGraph::GraphParticle &p, double &productionTimeShift)
 Create a simulation vertex for the given particle. More...
 

Protected Attributes

G4VSolid * m_topSolid {nullptr}
 Pointer to the top level solid to check if particles are inside the simulation volume.
 
std::string m_mcCollectionName
 Name of the MCParticle collection.
 
MCParticleGraphm_mcParticleGraph
 Reference to the MCParticle graph.
 

Detailed Description

This class creates Geant4 primary particles from MCParticle list The generator assumes that each particle in the list has exactly one mother.

Definition at line 33 of file MCParticleGenerator.h.

Constructor & Destructor Documentation

◆ MCParticleGenerator()

MCParticleGenerator ( const std::string &  mcCollectionName,
MCParticleGraph mcParticleGraph 
)

The constructor of the MCParticleGenerator class.

Parameters
mcCollectionNameMCParticle collection from which MCParticles are read.
mcParticleGraphReference to the MCParticle graph that will be filled

Definition at line 32 of file MCParticleGenerator.cc.

32  :
33  G4VPrimaryGenerator(), m_mcCollectionName(mcCollectionName), m_mcParticleGraph(mcParticleGraph)
34 {
35  G4VPhysicalVolume* topVolume = geometry::GeometryManager::getInstance().getTopVolume();
36  if (topVolume) {
37  m_topSolid = topVolume->GetLogicalVolume()->GetSolid();
38  }
39 }
std::string m_mcCollectionName
Name of the MCParticle collection.
MCParticleGraph & m_mcParticleGraph
Reference to the MCParticle graph.
G4VSolid * m_topSolid
Pointer to the top level solid to check if particles are inside the simulation volume.
static GeometryManager & getInstance()
Return a reference to the instance.
G4VPhysicalVolume * getTopVolume()
Return a pointer to the top volume.

Member Function Documentation

◆ addParticle()

void addParticle ( const MCParticle mcParticle,
G4Event *  event,
G4PrimaryParticle *  lastG4Mother,
int  motherIndex,
bool  useTime 
)
protected

Takes a MCParticle and creates a primary particle for Geant4.

The daughters of the specified MCParticle are added recursively.

Parameters
mcParticlea reference to MCParticle
eventa pointer to Geant4 event
lastG4Mothera pointer to G4 mother particle
motherIndexmother index from MCParticle graph
useTimeuse MCParticle decay time (as given by the generator)

Definition at line 112 of file MCParticleGenerator.cc.

◆ determineVertex()

G4PrimaryVertex * determineVertex ( const MCParticleGraph::GraphParticle p,
double &  productionTimeShift 
)
protected

Create a simulation vertex for the given particle.

This checks if the particle starts inside the simulation volume. If it's inside trivially just create a vertex at the given position and time. If not check if the particle intersects with the simulation volume.

If it does intersect and will survive long enough to get there we create a vertex at the simulation volume boundary and also set productionTimeShift to the flight time to get to the simulation volume.

Parameters
pParticle to create the vertex for
productionTimeShiftreturn the flight time of the particle before reaching the simulation volume
Returns
a new G4PrimaryVertex or nullptr if the particle didn't intersect with the simulation volume in time.

Definition at line 74 of file MCParticleGenerator.cc.

◆ GeneratePrimaryVertex()

void GeneratePrimaryVertex ( G4Event *  event)
virtual

Create G4 primary particles from MCParticle list.

This method is called for each event.

Parameters
eventPointer to the G4Event.

Definition at line 48 of file MCParticleGenerator.cc.


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