Belle II Software  release-08-02-06
SensitivePMT Class Reference

Class providing SimHits. More...

#include <SensitivePMT.h>

Inheritance diagram for SensitivePMT:
Collaboration diagram for SensitivePMT:

Public Member Functions

 SensitivePMT ()
 Constructor.
 
bool step (G4Step *aStep, G4TouchableHistory *) override
 Process each step, fill TOPSimHits and TOPSimPhotons. More...
 
void setPMTReplicaDepth (int depth)
 Sets replica depth of PMT volume. More...
 
void setModuleReplicaDepth (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_pmtReplicaDepth = 2
 replica depth of PMT volume
 
int m_moduleReplicaDepth = 5
 replica depth of module volume
 
TOPGeometryParm_topgp = TOPGeometryPar::Instance()
 geometry parameters
 
StoreArray< MCParticlem_mcParticles
 collection of MC particles
 
StoreArray< TOPSimHitm_simHits
 collection of simulated hits
 
StoreArray< TOPSimPhotonm_simPhotons
 collection of simulated photons
 
RelationArray m_relParticleHit {m_mcParticles, m_simHits}
 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 SimHits.

Definition at line 30 of file SensitivePMT.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 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.

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

◆ setModuleReplicaDepth()

void setModuleReplicaDepth ( int  depth)
inline

Sets replica depth of module volume.

Parameters
depthreplica depth

Definition at line 56 of file SensitivePMT.h.

56 {m_moduleReplicaDepth = depth;}
int m_moduleReplicaDepth
replica depth of module volume
Definition: SensitivePMT.h:61

◆ setPMTReplicaDepth()

void setPMTReplicaDepth ( int  depth)
inline

Sets replica depth of PMT volume.

Parameters
depthreplica depth

Definition at line 50 of file SensitivePMT.h.

◆ step()

G4bool step ( G4Step *  aStep,
G4TouchableHistory *   
)
overridevirtual

Process each step, fill TOPSimHits and TOPSimPhotons.

Parameters
aStepCurrent Geant4 step in the sensitive medium.
Returns
true if optical photon detected.

Implements SensitiveDetectorBase.

Definition at line 50 of file SensitivePMT.cc.

51  {
52  // photon track
53  G4Track& photon = *aStep->GetTrack();
54 
55  // check if the track is an optical photon
56  if (photon.GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()) return false;
57 
58  // photon energy in [eV]
59  double energy = photon.GetKineticEnergy() * Unit::MeV / Unit::eV;
60 
61  // pmt and module ID
62  int pmtID = photon.GetTouchableHandle()->GetReplicaNumber(m_pmtReplicaDepth);
63  int moduleID = photon.GetTouchableHandle()->GetReplicaNumber(m_moduleReplicaDepth);
64 
65  // hit position in local frame, converted to Basf units
66  G4ThreeVector localPosition = photon.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(photon.GetPosition());
67  double xLocal = localPosition.x() * Unit::mm;
68  double yLocal = localPosition.y() * Unit::mm;
69 
70  // apply quantum efficiency if not yet done
71  bool applyQE = true;
72  double fraction = 1;
73  auto* info = dynamic_cast<Simulation::TrackInfo*>(photon.GetUserInformation());
74  if (info) {
75  applyQE = info->getStatus() < 3;
76  fraction = info->getFraction();
77  }
78  if (applyQE) {
79  double qeffi = m_topgp->getPMTEfficiency(energy, moduleID, pmtID, xLocal, yLocal);
80  if (qeffi == 0 or gRandom->Uniform() * fraction > qeffi) {
81  photon.SetTrackStatus(fStopAndKill);
82  return false;
83  }
84  info->setStatus(3);
85  info->setFraction(qeffi);
86  }
87 
88  // photon at detection
89  const G4ThreeVector& g_detPoint = photon.GetPosition();
90  const G4ThreeVector& g_detMomDir = photon.GetMomentumDirection();
91  ROOT::Math::XYZPoint detPoint(g_detPoint.x(), g_detPoint.y(), g_detPoint.z());
92  ROOT::Math::XYZVector detMomDir(g_detMomDir.x(), g_detMomDir.y(), g_detMomDir.z());
93  double detTime = photon.GetGlobalTime();
94  double length = photon.GetTrackLength();
95 
96  // photon at emission
97  const G4ThreeVector& g_emiPoint = photon.GetVertexPosition();
98  const G4ThreeVector& g_emiMomDir = photon.GetVertexMomentumDirection();
99  ROOT::Math::XYZPoint emiPoint(g_emiPoint.x(), g_emiPoint.y(), g_emiPoint.z());
100  ROOT::Math::XYZVector emiMomDir(g_emiMomDir.x(), g_emiMomDir.y(), g_emiMomDir.z());
101  double emiTime = photon.GetGlobalTime() - photon.GetLocalTime();
102 
103  // convert to basf2 units
104  emiPoint = emiPoint * Unit::mm;
105  detPoint = detPoint * Unit::mm;
106  length = length * Unit::mm;
107 
108  // write to store arrays; add relations
109 
110  auto* simHit = m_simHits.appendNew(moduleID, pmtID, xLocal, yLocal,
111  detTime, energy);
112 
113  int parentID = photon.GetParentID();
114  if (parentID == 0) parentID = photon.GetTrackID();
115  m_relParticleHit.add(parentID, simHit->getArrayIndex());
116 
117  const auto* geo = m_topgp->getGeometry();
118  if (geo->isModuleIDValid(moduleID)) {
119  // transform to local frame
120  const auto& module = geo->getModule(moduleID);
121  emiPoint = module.pointToLocal(emiPoint);
122  detPoint = module.pointToLocal(detPoint);
123  emiMomDir = module.momentumToLocal(emiMomDir);
124  detMomDir = module.momentumToLocal(detMomDir);
125  } else {
126  B2ERROR("TOP::SensitivePMT: undefined module ID."
127  << LogVar("moduleID", moduleID));
128  }
129  auto* simPhoton = m_simPhotons.appendNew(moduleID,
130  emiPoint, emiMomDir, emiTime,
131  detPoint, detMomDir, detTime,
132  length, energy);
133 
134  simHit->addRelationTo(simPhoton);
135 
136  // kill photon after detection
137  photon.SetTrackStatus(fStopAndKill);
138 
139  return true;
140  }
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
RelationArray m_relParticleHit
relations
Definition: SensitivePMT.h:67
int m_pmtReplicaDepth
replica depth of PMT volume
Definition: SensitivePMT.h:60
TOPGeometryPar * m_topgp
geometry parameters
Definition: SensitivePMT.h:62
StoreArray< TOPSimPhoton > m_simPhotons
collection of simulated photons
Definition: SensitivePMT.h:66
StoreArray< TOPSimHit > m_simHits
collection of simulated hits
Definition: SensitivePMT.h:65
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using basf2 units.
double getPMTEfficiency(double energy, int moduleID, int pmtID, double x, double y) const
Returns PMT pixel efficiency, a product of quantum and collection efficiency.
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: