Belle II Software  release-06-01-15
SensitiveBar Class Reference

Class providing information on MCParticles hitting the bars. More...

#include <SensitiveBar.h>

Inheritance diagram for SensitiveBar:
Collaboration diagram for SensitiveBar:

Public Member Functions

 SensitiveBar ()
 Constructor.
 
bool step (G4Step *aStep, G4TouchableHistory *) override
 Process each step and fill TOPBarHits. More...
 
void setReplicaDepth (int depth)
 Sets replica depth of module volume. More...
 

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...
 

Private Member Functions

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

int m_replicaDepth = 2
 replica depth of module volume
 
TOPGeometryParm_topgp = TOPGeometryPar::Instance()
 geometry parameters
 
std::vector< int > m_trackIDs
 track ID's
 
StoreArray< MCParticlem_mcParticles
 collection of MC particles
 
StoreArray< TOPBarHitm_barHits
 collection of entrance-to-bar hits
 
RelationArray m_relParticleHit {m_mcParticles, m_barHits}
 relations
 
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

Class providing information on MCParticles hitting the bars.

Applies also quantum efficiency to reduce the number of propagating photons.

Definition at line 31 of file SensitiveBar.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 96 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 68 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.

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

◆ setReplicaDepth()

void setReplicaDepth ( int  depth)
inline

Sets replica depth of module volume.

Parameters
depthreplica depth

Definition at line 51 of file SensitiveBar.h.

51 {m_replicaDepth = depth;}
int m_replicaDepth
replica depth of module volume
Definition: SensitiveBar.h:55

◆ step()

bool step ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Process each step and fill TOPBarHits.

Parameters
aStepCurrent Geant4 step in the sensitive medium.
Returns
true when particle that is not an optical photon enters the bar

Implements SensitiveDetectorBase.

Definition at line 53 of file SensitiveBar.cc.

54  {
55 
56  // get track and particle definition
57 
58  G4Track* aTrack = aStep->GetTrack();
59  G4ParticleDefinition* particle = aTrack->GetDefinition();
60 
61  // if optical photon, apply QE and return false
62 
63  if (particle == G4OpticalPhoton::OpticalPhotonDefinition()) {
64  auto* info = dynamic_cast<Simulation::TrackInfo*>(aTrack->GetUserInformation());
65  if (!info) return false;
66  if (info->getStatus() < 2) {
67  double energy = aTrack->GetKineticEnergy() * Unit::MeV / Unit::eV;
68  double qeffi = m_topgp->getPMTEfficiencyEnvelope(energy);
69  double fraction = info->getFraction();
70  if (qeffi == 0 or gRandom->Uniform() * fraction > qeffi) {
71  aTrack->SetTrackStatus(fStopAndKill);
72  return false;
73  }
74  info->setStatus(2);
75  info->setFraction(qeffi);
76  }
77  return false;
78  }
79 
80  // continue for other particles, if they enter the volume for the first time
81 
82  G4StepPoint* PrePosition = aStep->GetPreStepPoint();
83  if (PrePosition->GetStepStatus() != fGeomBoundary) return false; // not on boundary
84 
85  if (m_barHits.getEntries() == 0) {
86  for (auto& trackID : m_trackIDs) trackID = -1; // reset on new event
87  }
88 
89  int moduleID = PrePosition->GetTouchableHandle()->GetReplicaNumber(m_replicaDepth);
90  const auto* geo = m_topgp->getGeometry();
91  if (!geo->isModuleIDValid(moduleID)) {
92  B2ERROR("TOP::SensitiveBar: undefined module ID."
93  << LogVar("moduleID", moduleID));
94  return false;
95  }
96 
97  int trackID = aTrack->GetTrackID();
98  if (trackID == m_trackIDs[moduleID - 1]) return false; // not first time on boundary
99  m_trackIDs[moduleID - 1] = trackID;
100 
101  // particle other than optical photon entered the volume for the first time
102  // convert to basf2 units and write-out the hit
103 
104  G4ThreeVector worldPosition = PrePosition->GetPosition();
105  double tracklength = aTrack->GetTrackLength() - aStep->GetStepLength();
106  double globalTime = PrePosition->GetGlobalTime();
107  G4ThreeVector momentum = PrePosition->GetMomentum();
108 
109  TVector3 TPosition(worldPosition.x(), worldPosition.y(), worldPosition.z());
110  TVector3 TMomentum(momentum.x(), momentum.y(), momentum.z());
111  TVector3 TOrigin(aTrack->GetVertexPosition().x(),
112  aTrack->GetVertexPosition().y(),
113  aTrack->GetVertexPosition().z());
114 
115  // convert to basf2 units
116  TPosition = TPosition * Unit::mm;
117  TMomentum = TMomentum * Unit::MeV;
118  TOrigin = TOrigin * Unit::mm;
119  tracklength = tracklength * Unit::mm;
120 
121  const auto& module = geo->getModule(moduleID);
122  TVector3 locPosition = module.pointToLocal(TPosition);
123  TVector3 locMomentum = module.momentumToLocal(TMomentum);
124  double theta = locMomentum.Theta();
125  double phi = locMomentum.Phi();
126 
127  int PDG = (int)(particle->GetPDGEncoding());
128 
129  // write hit to datastore
130  auto* hit = m_barHits.appendNew(moduleID, PDG, TOrigin, TPosition, TMomentum,
131  globalTime, tracklength, locPosition,
132  theta, phi);
133 
134  // set the relation
135  m_relParticleHit.add(trackID, hit->getArrayIndex());
136 
137  return true;
138  }
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
std::vector< int > m_trackIDs
track ID's
Definition: SensitiveBar.h:57
RelationArray m_relParticleHit
relations
Definition: SensitiveBar.h:61
TOPGeometryPar * m_topgp
geometry parameters
Definition: SensitiveBar.h:56
StoreArray< TOPBarHit > m_barHits
collection of entrance-to-bar hits
Definition: SensitiveBar.h:60
double getPMTEfficiencyEnvelope(double energy) const
Returns PMT efficiency envelope, e.g.
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
static const double mm
[millimeters]
Definition: Unit.h:70
static const double eV
[electronvolt]
Definition: Unit.h:112
static const double MeV
[megaelectronvolt]
Definition: Unit.h:114
Class to store variables with their name which were sent to the logging service.

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