9 #include <top/simulation/SensitivePMT.h>
11 #include <simulation/kernel/UserInfo.h>
14 #include <G4UnitsTable.hh>
15 #include <G4ParticleDefinition.hh>
16 #include <G4ParticleTypes.hh>
18 #include <framework/logging/Logger.h>
19 #include <framework/gearbox/Unit.h>
33 SensitivePMT::SensitivePMT():
34 Simulation::SensitiveDetectorBase(
"TOP",
Const::TOP)
52 G4Track& photon = *aStep->GetTrack();
55 if (photon.GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition())
return false;
65 G4ThreeVector localPosition = photon.GetTouchableHandle()->GetHistory()->GetTopTransform().TransformPoint(photon.GetPosition());
66 double xLocal = localPosition.x() *
Unit::mm;
67 double yLocal = localPosition.y() *
Unit::mm;
74 applyQE = info->getStatus() < 3;
75 fraction = info->getFraction();
79 if (qeffi == 0 or gRandom->Uniform() * fraction > qeffi) {
80 photon.SetTrackStatus(fStopAndKill);
84 info->setFraction(qeffi);
88 const G4ThreeVector& g_detPoint = photon.GetPosition();
89 const G4ThreeVector& g_detMomDir = photon.GetMomentumDirection();
90 TVector3 detPoint(g_detPoint.x(), g_detPoint.y(), g_detPoint.z());
91 TVector3 detMomDir(g_detMomDir.x(), g_detMomDir.y(), g_detMomDir.z());
92 double detTime = photon.GetGlobalTime();
93 double length = photon.GetTrackLength();
96 const G4ThreeVector& g_emiPoint = photon.GetVertexPosition();
97 const G4ThreeVector& g_emiMomDir = photon.GetVertexMomentumDirection();
98 TVector3 emiPoint(g_emiPoint.x(), g_emiPoint.y(), g_emiPoint.z());
99 TVector3 emiMomDir(g_emiMomDir.x(), g_emiMomDir.y(), g_emiMomDir.z());
100 double emiTime = photon.GetGlobalTime() - photon.GetLocalTime();
109 auto* simHit =
m_simHits.appendNew(moduleID, pmtID, xLocal, yLocal,
112 int parentID = photon.GetParentID();
113 if (parentID == 0) parentID = photon.GetTrackID();
117 if (geo->isModuleIDValid(moduleID)) {
119 const auto& module = geo->getModule(moduleID);
120 emiPoint = module.pointToLocal(emiPoint);
121 detPoint = module.pointToLocal(detPoint);
122 emiMomDir = module.momentumToLocal(emiMomDir);
123 detMomDir = module.momentumToLocal(detMomDir);
125 B2ERROR(
"TOP::SensitivePMT: undefined module ID."
126 <<
LogVar(
"moduleID", moduleID));
129 emiPoint, emiMomDir, emiTime,
130 detPoint, detMomDir, detTime,
133 simHit->addRelationTo(simPhoton);
136 photon.SetTrackStatus(fStopAndKill);
This class provides a set of constants for the framework.
@ c_DontWriteOut
Object/array should be NOT saved by output modules.
@ c_Event
Different object in each event, all objects/arrays are invalidated after event() function has been ca...
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
static void registerMCParticleRelation(const std::string &name, RelationArray::EConsolidationAction ignoreAction=RelationArray::c_negativeWeight)
Register an relation involving MCParticles.
UserInfo class which is used to attach additional information to Geant4 particles and tracks.
bool registerRelationTo(const StoreArray< TO > &toArray, DataStore::EDurability durability=DataStore::c_Event, DataStore::EStoreFlags storeFlags=DataStore::c_WriteOut, const std::string &namedRelation="") const
Register a relation to the given StoreArray.
RelationArray m_relParticleHit
relations
int m_pmtReplicaDepth
replica depth of PMT volume
TOPGeometryPar * m_topgp
geometry parameters
int m_moduleReplicaDepth
replica depth of module volume
StoreArray< MCParticle > m_mcParticles
collection of MC particles
bool step(G4Step *aStep, G4TouchableHistory *) override
Process each step, fill TOPSimHits and TOPSimPhotons.
StoreArray< TOPSimPhoton > m_simPhotons
collection of simulated photons
StoreArray< TOPSimHit > m_simHits
collection of simulated hits
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]
static const double eV
[electronvolt]
static const double MeV
[megaelectronvolt]
Class to store variables with their name which were sent to the logging service.
Abstract base class for different kinds of events.