Belle II Software  release-05-01-25
SensitiveDetector Class Reference

Sensitive Detector implementation of the CLAWS detector. More...

#include <SensitiveDetector.h>

Inheritance diagram for SensitiveDetector:
Collaboration diagram for SensitiveDetector:

Public Member Functions

 SensitiveDetector ()
 Constructor.
 

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

bool step (G4Step *step, G4TouchableHistory *) override
 Step processing method. More...
 

Private Member Functions

bool finishTrack ()
 finish a track
 
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

G4EmSaturation * m_saturationEngine
 needed to call Birk's law
 
StoreArray< MCParticlem_mcParticles
 store array of the MCParticles
 
StoreArray< CLAWSSimHitm_simHits
 store array of the SimHits
 
RelationArray m_relMCSimHit {m_mcParticles, m_simHits}
 relation array of the MCParticle -> SimHit relation
 
std::stack< SensorTraversalm_tracks
 Stack of tracks to keep track of 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

Sensitive Detector implementation of the CLAWS detector.

Definition at line 39 of file SensitiveDetector.h.

Member Function Documentation

◆ 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 98 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 70 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 24 of file SensitiveDetectorBase.cc.

◆ 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 54 of file SensitiveDetectorBase.h.

◆ step()

bool step ( G4Step *  step,
G4TouchableHistory *   
)
overrideprotectedvirtual

Step processing method.

Parameters
stepthe G4Step with the current step information
Returns
true if a Hit has been created, false if the hit was ignored

Implements SensitiveDetectorBase.

Definition at line 62 of file SensitiveDetector.cc.

83  {
84  m_tracks.push(SensorTraversal());
85  }
86  // get the top of the stack
87  SensorTraversal& traversal = m_tracks.top();
88 
89  //If new track, remember values
90  if (traversal.getTrackID() == 0) {
91  bool isPrimary = Simulation::TrackInfo::getInfo(track).hasStatus(MCParticle::c_PrimaryParticle);
92  //Add start position
93  const G4ThreeVector preStepPos = preStep.GetPosition() / CLHEP::mm * Unit::mm;
94  const G4ThreeVector preStepMom = preStep.GetMomentum() / CLHEP::MeV * Unit::MeV;
95  const double time = preStep.GetGlobalTime() / CLHEP::ns * Unit::ns;
96  traversal.setInitial(trackID, ladderID, sensorID, pdgCode, isPrimary, preStepPos, preStepMom, time);
97  //Remember if the track came from the outside
98  if (preStep.GetStepStatus() == fGeomBoundary) traversal.hasEntered();
99  }
100 
101  //Add current step
102  const G4ThreeVector postStepPos = postStep.GetPosition() / CLHEP::mm * Unit::mm;
103  const double length = step->GetStepLength() / CLHEP::cm * Unit::cm;
104  traversal.add(postStepPos, depEnergy, visibleEnergy, length);
105 
106  //check if we are leaving the volume
107  bool isLeaving = (postStep.GetStepStatus() == fGeomBoundary);
108  if (isLeaving) traversal.hasLeft();
109 
110  //if we are leaving or the track is stopped, finish it
111  if (isLeaving || track.GetTrackStatus() >= fStopAndKill) {
112  bool contained = traversal.isContained();
113  bool saved = finishTrack();
114  //we mark all particles as important which created a hit and entered or left the volume
115  if (saved && !contained) {
116  Simulation::TrackInfo::getInfo(track).setIgnore(false);
117  }
118  return saved;
119  }
120  // Track not finished, return false right now
121  return false;
122  }
123 
125  {
126  SensorTraversal& traversal = m_tracks.top();
127  // ignore everything below 1eV
128  bool save = traversal.getDepEnergy() > Unit::eV;
129  if (save) {
130  auto momEntry = vecToFloat(traversal.getEntryMomentum());

The documentation for this class was generated from the following files:
Belle2::Unit::cm
static const double cm
Standard units with the value = 1.
Definition: Unit.h:57
Belle2::Unit::ns
static const double ns
Standard of [time].
Definition: Unit.h:58
Belle2::claws::SensitiveDetector::m_tracks
std::stack< SensorTraversal > m_tracks
Stack of tracks to keep track of particles.
Definition: SensitiveDetector.h:64
Belle2::Simulation::UserInfo::getInfo
static Payload getInfo(Carrier &obj)
Static function to just return UserInformation attached to the obj of type Carrier.
Definition: UserInfo.h:110
Belle2::Unit::MeV
static const double MeV
[megaelectronvolt]
Definition: Unit.h:124
Belle2::Unit::eV
static const double eV
[electronvolt]
Definition: Unit.h:122
Belle2::Unit::mm
static const double mm
[millimeters]
Definition: Unit.h:80
Belle2::claws::SensitiveDetector::finishTrack
bool finishTrack()
finish a track
Definition: SensitiveDetector.cc:132
Belle2::claws::SensitiveDetector::step
bool step(G4Step *step, G4TouchableHistory *) override
Step processing method.
Definition: SensitiveDetector.cc:62
Belle2::MCParticle::c_PrimaryParticle
@ c_PrimaryParticle
bit 0: Particle is primary particle.
Definition: MCParticle.h:58