Belle II Software  release-05-02-19
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 40 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 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.

◆ setModuleReplicaDepth()

void setModuleReplicaDepth ( int  depth)
inline

Sets replica depth of module volume.

Parameters
depthreplica depth

Definition at line 66 of file SensitivePMT.h.

◆ setPMTReplicaDepth()

void setPMTReplicaDepth ( int  depth)
inline

Sets replica depth of PMT volume.

Parameters
depthreplica depth

Definition at line 60 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 51 of file SensitivePMT.cc.

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

The documentation for this class was generated from the following files:
Belle2::TOP::SensitivePMT::m_topgp
TOPGeometryPar * m_topgp
geometry parameters
Definition: SensitivePMT.h:72
Belle2::TOP::SensitivePMT::m_simHits
StoreArray< TOPSimHit > m_simHits
collection of simulated hits
Definition: SensitivePMT.h:75
Belle2::TOP::SensitivePMT::m_mcParticles
StoreArray< MCParticle > m_mcParticles
collection of MC particles
Definition: SensitivePMT.h:74
Belle2::TOP::SensitivePMT::m_simPhotons
StoreArray< TOPSimPhoton > m_simPhotons
collection of simulated photons
Definition: SensitivePMT.h:76
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::TOP::SensitivePMT::m_relParticleHit
RelationArray m_relParticleHit
relations
Definition: SensitivePMT.h:77
LogVar
Class to store variables with their name which were sent to the logging service.
Definition: LogVariableStream.h:24
Belle2::RelationArray::add
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
Definition: RelationArray.h:291
Belle2::TOP::SensitivePMT::m_moduleReplicaDepth
int m_moduleReplicaDepth
replica depth of module volume
Definition: SensitivePMT.h:71
Belle2::Unit::mm
static const double mm
[millimeters]
Definition: Unit.h:80
Belle2::TOP::TOPGeometryPar::getGeometry
const TOPGeometry * getGeometry() const
Returns pointer to geometry object using Basf2 units.
Definition: TOPGeometryPar.cc:167
Belle2::TOP::TOPGeometryPar::getPMTEfficiency
double getPMTEfficiency(double energy, int moduleID, int pmtID, double x, double y) const
Returns PMT pixel efficiency, a product of quantum and collection efficiency.
Definition: TOPGeometryPar.cc:191
Belle2::TOP::SensitivePMT::m_pmtReplicaDepth
int m_pmtReplicaDepth
replica depth of PMT volume
Definition: SensitivePMT.h:70