Belle II Software  release-08-01-10
SensitiveDetectorBase Class Referenceabstract

Base class for Sensitive Detector implementation of PXD and SVD. More...

#include <SensitiveDetectorBase.h>

Inheritance diagram for SensitiveDetectorBase:
Collaboration diagram for SensitiveDetectorBase:

Public Member Functions

 SensitiveDetectorBase (SensorInfoBase *info)
 Constructor. More...
 
void setOptions (bool seeNeutrons, bool onlyPrimaryTrueHits, float distanceTolerance, float electronTolerance, float minimumElectrons)
 Set all common options. More...
 
virtual ~SensitiveDetectorBase () override
 Destructor freeing the sensor Info.
 
SensorInfoBasegetSensorInfo ()
 Return a pointer to the SensorInfo associated with this instance.
 
VxdID getSensorID () const
 Return the VxdID belonging to this sensitive detector.
 

Static Public Member Functions

static const std::map< std::string, RelationArray::EConsolidationAction > & getMCParticleRelations ()
 Return a list of all registered Relations with MCParticles.
 
static void setActive (bool activeStatus)
 Enable/Disable all Sensitive Detectors. More...
 
static void registerMCParticleRelation (const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
 Register an relation involving MCParticles. More...
 
static void registerMCParticleRelation (const RelationArray &relation, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
 Overload to make it easer to register MCParticle relations. More...
 

Protected Member Functions

virtual int saveTrueHit (const SensorTraversal &traversal)=0
 Save the actual TrueHit for this sensor traversal. More...
 
virtual int saveSimHit (const SensorTraversal &traversal, const SensorTraversal::range &points)=0
 Save a SimHit for this track including the given points. More...
 
virtual void saveRelations (const SensorTraversal &traversal, int trueHitIndex, std::vector< std::pair< unsigned int, float >> simHitIndices)=0
 Save the relations between MCParticle, TrueHit and SimHits. More...
 
std::vector< unsigned int > simplifyEnergyDeposit (const SensorTraversal::range &points)
 Simplify the energy deposition profile using Douglas-Peuker-Algorithm We normally force a Geant4 step after 5µm but energy deposition does not necessarily vary much between these short steps. More...
 
StepInformation findMidPoint (const SensorTraversal &traversal)
 Find the mid-point of the track traversal. More...
 

Private Member Functions

bool step (G4Step *step, G4TouchableHistory *) override
 Process a single Geant4 Step. More...
 
bool finishTrack ()
 Process a track once all steps are known. More...
 
std::vector< std::pair< unsigned int, float > > createSimHits ()
 Determine which SimHits to create. More...
 
virtual bool ProcessHits (G4Step *aStep, G4TouchableHistory *aROhist)
 Check if recording hits is enabled and if so call step() and set the correct MCParticle flag. More...
 

Private Attributes

SensorInfoBasem_info {0}
 Pointer to the SensorInfo associated with this instance.
 
std::stack< SensorTraversalm_tracks
 stack of SensorTraversal information for all tracks not finished so far
 
float m_distanceTolerance {0}
 maximum distance between step point and linear interpolation of sensor traversal before a new simhit object is created
 
float m_electronTolerance {0}
 maximum relative difference between electron density of two steps where they can be considered similar enough to be merged
 
float m_minimumElectrons {0}
 minimum number of electrons a track must deposit for SimHit/TrueHits to be created
 
bool m_seeNeutrons {false}
 also create SimHit/TrueHit objects for neutrons (or charged particles which deposit less than m_minimumElectrons electrons
 
bool m_onlyPrimaryTrueHits {false}
 only create TrueHits for primary particles
 
Const::EDetector m_subdetector
 Subdetector the class belongs to.
 

Static Private Attributes

static std::map< std::string, RelationArray::EConsolidationActions_mcRelations
 Static set holding all relations which have to be updated at the end of the Event.
 
static bool s_active
 Static bool which indicates wether recording of hits is enabled.
 

Detailed Description

Base class for Sensitive Detector implementation of PXD and SVD.

This base class provides common access to sensor information (like transformation) and performs the the collection of energy depositing when particles cross the sensor. Most of the calculations are contained here while the detector dependent hit and relation creation is delegated to the derived VXD::SensitiveDetector<SimHitClass, TrueHitClass>.

Definition at line 37 of file SensitiveDetectorBase.h.

Constructor & Destructor Documentation

◆ SensitiveDetectorBase()

SensitiveDetectorBase ( SensorInfoBase info)
inlineexplicit

Constructor.

Parameters
infopointer to a valid SensorInfo instance providing information about the sensor this sensitive detector instance will handle. Ownership of the SensorInfo goes to the sensitive detector instance

Definition at line 45 of file SensitiveDetectorBase.h.

Member Function Documentation

◆ createSimHits()

std::vector< std::pair< unsigned int, float > > createSimHits ( )
private

Determine which SimHits to create.

A SimHit is a linear approximation of the particle trajectory. As such we try to combine as many Geant4 steps as possible by defining a distance tolerance and using the Douglas-Peucker algortihm to determine the required number of SimHits to keep the maximum distance of all Geant4 steps below that tolerance.

Returns
indices and electrons of all created simhits

Definition at line 126 of file SensitiveDetectorBase.cc.

◆ findMidPoint()

StepInformation findMidPoint ( const SensorTraversal traversal)
protected

Find the mid-point of the track traversal.

This function will return the position and momentum at the center of the track traversal, using cubic spline interpolation between the actual geant4 steps. Center is defined as "half the flight length" in this case.

Parameters
traversalinformation on the particle traversal to be used when finding the midpoint
Returns
position and momentum at the mid point

Definition at line 274 of file SensitiveDetectorBase.cc.

◆ finishTrack()

bool finishTrack ( )
private

Process a track once all steps are known.

This function decides whether TrueHit/SimHits will be saved

Definition at line 94 of file SensitiveDetectorBase.cc.

◆ ProcessHits()

bool ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  aROhist 
)
inlineprivatevirtualinherited

Check if recording hits is enabled and if so call step() and set the correct MCParticle flag.

Called by Geant4 for each step inside the sensitive volumes attached

Definition at line 94 of file SensitiveDetectorBase.h.

◆ registerMCParticleRelation() [1/2]

static void registerMCParticleRelation ( const RelationArray relation,
RelationArray::EConsolidationAction  ignoreAction = RelationArray::c_negativeWeight 
)
inlinestaticinherited

Overload to make it easer to register MCParticle relations.

Parameters
relationRelationArray to register
ignoreAction

Definition at line 66 of file SensitiveDetectorBase.h.

◆ registerMCParticleRelation() [2/2]

void registerMCParticleRelation ( const std::string &  name,
RelationArray::EConsolidationAction  ignoreAction = RelationArray::c_negativeWeight 
)
staticinherited

Register an relation involving MCParticles.

All Relations which point from an MCParticle to something have to be registered with addMCParticleRelation() because the index of the MCParticles might change at the end of the event. During simulation, the TrackID should be used as index of the MCParticle

Parameters
nameName of the relation to register
ignoreAction

Definition at line 22 of file SensitiveDetectorBase.cc.

◆ saveRelations()

virtual void saveRelations ( const SensorTraversal traversal,
int  trueHitIndex,
std::vector< std::pair< unsigned int, float >>  simHitIndices 
)
protectedpure virtual

Save the relations between MCParticle, TrueHit and SimHits.

Parameters
traversalinformation on the particle traversal to be used when creating the Relations
trueHitIndexindex of the TrueHit, <0 if no TrueHit was created
simHitIndicesindices of the SimHits along with the number of electrons deposited in each SimHit

Implemented in SensitiveDetector< SimHitClass, TrueHitClass >.

◆ saveSimHit()

virtual int saveSimHit ( const SensorTraversal traversal,
const SensorTraversal::range points 
)
protectedpure virtual

Save a SimHit for this track including the given points.

This function depends on the actual SimHit implementation and is implemented in VXD::SensitiveDetector.

Parameters
traversalinformation on the particle traversal to be used when creating the SimHit
pointspair of iterators to the first and last step position to be used for the SimHit
Returns
the index of the created SimHit in its StoreArray

Implemented in SensitiveDetector< SimHitClass, TrueHitClass >.

◆ saveTrueHit()

virtual int saveTrueHit ( const SensorTraversal traversal)
protectedpure virtual

Save the actual TrueHit for this sensor traversal.

This function depends on the actual TrueHit implementation and is implemented in VXD::SensitiveDetector.

Parameters
traversalinformation on the particle traversal to be used when creating the TrueHit
Returns
the index of the created TrueHit in its StoreArray

Implemented in SensitiveDetector< SimHitClass, TrueHitClass >.

◆ setActive()

static void setActive ( bool  activeStatus)
inlinestaticinherited

Enable/Disable all Sensitive Detectors.

By default, all sensitive detectors won't create hits to make it possible to use the Geant4 Navigator for non-simulation purposes. Only during simulation the sensitive detectors will be enabled to record hits

Parameters
activeStatusbool to indicate wether hits should be recorded

Definition at line 50 of file SensitiveDetectorBase.h.

◆ setOptions()

void setOptions ( bool  seeNeutrons,
bool  onlyPrimaryTrueHits,
float  distanceTolerance,
float  electronTolerance,
float  minimumElectrons 
)
inline

Set all common options.

Parameters
seeNeutronsif true, simhits are also stored for neutrons
onlyPrimaryTrueHitsif true, truehits will only be created for primary particles
distanceTolerancemaximal distance of step position from linear approximation.
electronTolerancemaximum deviation of energy deposition from linear approximation in electrons
minimumElectronsminimum number of electrons to be deposited before SimHits are created.

Definition at line 60 of file SensitiveDetectorBase.h.

◆ simplifyEnergyDeposit()

std::vector< unsigned int > simplifyEnergyDeposit ( const SensorTraversal::range points)
protected

Simplify the energy deposition profile using Douglas-Peuker-Algorithm We normally force a Geant4 step after 5µm but energy deposition does not necessarily vary much between these short steps.

Saving all steps would be a waste of space so we define a tolerance (in electrons) and keep only the points needed so that no point is further away from the profile than this tolerance.

Parameters
pointspair of iterators to the first and last point of the energy deposition profile
Returns
list of encoded EnergyDeposit values representing the simplified energy deposition profile.

Definition at line 183 of file SensitiveDetectorBase.cc.

◆ step()

bool step ( G4Step *  step,
G4TouchableHistory *   
)
overrideprivatevirtual

Process a single Geant4 Step.

This function stores the necessary information to create the TrueHits and SimHits and will call finishTrack() if a track leaves the volume or is stopped inside the volume.

Implements SensitiveDetectorBase.

Definition at line 28 of file SensitiveDetectorBase.cc.


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