51 {
52
53 G4Track& photon = *aStep->GetTrack();
54
55
56 if (photon.GetDefinition() != G4OpticalPhoton::OpticalPhotonDefinition()) return false;
57
58
60
61
64
65
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
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) {
80 if (qeffi == 0 or gRandom->Uniform() * fraction > qeffi) {
81 photon.SetTrackStatus(fStopAndKill);
82 return false;
83 }
84 if (info) {
85 info->setStatus(3);
86 info->setFraction(qeffi);
87 }
88 }
89
90
91 const G4ThreeVector& g_detPoint = photon.GetPosition();
92 const G4ThreeVector& g_detMomDir = photon.GetMomentumDirection();
93 ROOT::Math::XYZPoint detPoint(g_detPoint.x(), g_detPoint.y(), g_detPoint.z());
94 ROOT::Math::XYZVector detMomDir(g_detMomDir.x(), g_detMomDir.y(), g_detMomDir.z());
95 double detTime = photon.GetGlobalTime();
96 double length = photon.GetTrackLength();
97
98
99 const G4ThreeVector& g_emiPoint = photon.GetVertexPosition();
100 const G4ThreeVector& g_emiMomDir = photon.GetVertexMomentumDirection();
101 ROOT::Math::XYZPoint emiPoint(g_emiPoint.x(), g_emiPoint.y(), g_emiPoint.z());
102 ROOT::Math::XYZVector emiMomDir(g_emiMomDir.x(), g_emiMomDir.y(), g_emiMomDir.z());
103 double emiTime = photon.GetGlobalTime() - photon.GetLocalTime();
104
105
109
110
111
112 auto* simHit =
m_simHits.appendNew(moduleID, pmtID, xLocal, yLocal,
113 detTime, energy);
114
115 int parentID = photon.GetParentID();
116 if (parentID == 0) parentID = photon.GetTrackID();
118
120 if (geo->isModuleIDValid(moduleID)) {
121
122 const auto& module = geo->getModule(moduleID);
123 emiPoint = module.pointToLocal(emiPoint);
124 detPoint = module.pointToLocal(detPoint);
125 emiMomDir = module.momentumToLocal(emiMomDir);
126 detMomDir = module.momentumToLocal(detMomDir);
127 } else {
128 B2ERROR("TOP::SensitivePMT: undefined module ID."
129 <<
LogVar(
"moduleID", moduleID));
130 }
132 emiPoint, emiMomDir, emiTime,
133 detPoint, detMomDir, detTime,
134 length, energy);
135
136 simHit->addRelationTo(simPhoton);
137
138
139 photon.SetTrackStatus(fStopAndKill);
140
141 return true;
142 }
void add(index_type from, index_type to, weight_type weight=1.0)
Add a new element to the relation.
TOPGeometryPar * m_topgp
geometry parameters
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.