@@ -45,8 +45,8 @@ OMSimSensitiveDetector::~OMSimSensitiveDetector()
45
45
46
46
/* *
47
47
* @brief Fetches the boundary process for detecting boundary absorptions.
48
- *
49
- * Retrieves and stores the `G4OpBoundaryProcess` to check for photon detection
48
+ *
49
+ * Retrieves and stores the `G4OpBoundaryProcess` to check for photon detection
50
50
* at boundaries. Logs an error if the process is not found.
51
51
*/
52
52
void OMSimSensitiveDetector::fetchBoundaryProcess ()
@@ -78,58 +78,50 @@ void OMSimSensitiveDetector::setPMTResponse(OMSimPMTResponse *p_response)
78
78
79
79
/* *
80
80
* @brief Processes hits for optical photons in the detector.
81
- *
82
- * If the detector type is one of the perfect detectors (100% efficient),
83
- * the photon hit is registered directly. Otherwise, it checks for volume
81
+ *
82
+ * If the detector type is one of the perfect detectors (100% efficient),
83
+ * the photon hit is registered directly. Otherwise, it checks for volume
84
84
* or boundary absorption based on the detector type.
85
- *
85
+ *
86
86
* @param p_step The current step information.
87
87
* @param p_touchableHistory The history of touchable objects.
88
88
* @return True if the photon hit was stored, false otherwise.
89
89
*/
90
90
G4bool OMSimSensitiveDetector::ProcessHits (G4Step *p_step, G4TouchableHistory *p_touchableHistory)
91
91
{
92
- if (p_step->GetTrack ()->GetDefinition () == G4OpticalPhoton::Definition ()) // check if particle is a photon
93
- {
94
-
95
- switch (m_detectorType)
96
- {
97
- case DetectorType::PerfectVolumePhotonDetector: // 100% efficient VolumePhotonDetector
98
- return handleGeneralPhotonDetector (p_step, p_touchableHistory);
92
+ if (p_step->GetTrack ()->GetDefinition () != G4OpticalPhoton::Definition ())
93
+ return false ;
99
94
100
- case DetectorType::PerfectBoundaryPhotonDetector: // 100% efficient BoundaryPhotonDetector
101
- return handleGeneralPhotonDetector (p_step, p_touchableHistory);
95
+ if (DetectorType::PerfectVolumePhotonDetector == m_detectorType || DetectorType::PerfectBoundaryPhotonDetector == m_detectorType || DetectorType::PerfectPMT == m_detectorType)
96
+ {
97
+ if (m_detectorType == DetectorType::PerfectPMT) return handlePMT (p_step, p_touchableHistory);
98
+ return handleGeneralPhotonDetector (p_step, p_touchableHistory);
99
+ }
102
100
103
- case DetectorType::PerfectPMT: // 100% efficient PMT
104
- return handlePMT (p_step, p_touchableHistory);
105
- }
101
+ if (m_detectorType == DetectorType::VolumePhotonDetector)
102
+ {
106
103
if (checkVolumeAbsorption (p_step))
107
104
{
108
- switch (m_detectorType)
109
- {
110
- case DetectorType::VolumePhotonDetector:
111
- return handleGeneralPhotonDetector (p_step, p_touchableHistory);
112
- }
105
+ return handleGeneralPhotonDetector (p_step, p_touchableHistory);
113
106
}
114
- else if (checkBoundaryAbsorption (p_step))
107
+ }
108
+
109
+ else if (checkBoundaryAbsorption (p_step)) // if none of the above, it is a boundary photon detector
110
+ {
111
+ switch (m_detectorType)
115
112
{
116
- switch (m_detectorType)
117
- {
118
- case DetectorType::BoundaryPhotonDetector:
119
- return handleGeneralPhotonDetector (p_step, p_touchableHistory);
120
- case DetectorType::PMT:
121
- return handlePMT (p_step, p_touchableHistory);
122
- }
113
+ case DetectorType::PMT:
114
+ return handlePMT (p_step, p_touchableHistory);
115
+ case DetectorType::BoundaryPhotonDetector:
116
+ return handleGeneralPhotonDetector (p_step, p_touchableHistory);
123
117
}
124
118
}
125
-
126
119
return false ;
127
120
}
128
121
129
-
130
122
/* *
131
123
* @brief Retrieves photon information from a given step.
132
- *
124
+ *
133
125
* @param p_step The current step information.
134
126
* @return PhotonInfo struct containing the photon details.
135
127
*/
@@ -156,10 +148,9 @@ PhotonInfo OMSimSensitiveDetector::getPhotonInfo(G4Step *p_step)
156
148
return info;
157
149
}
158
150
159
-
160
151
/* *
161
152
* @brief Checks if the photon was absorbed in the volume.
162
- *
153
+ *
163
154
* @param p_step The current step information.
164
155
* @return True if the photon was absorbed, false otherwise.
165
156
*/
@@ -168,7 +159,6 @@ G4bool OMSimSensitiveDetector::checkVolumeAbsorption(G4Step *p_step)
168
159
return p_step->GetPostStepPoint ()->GetProcessDefinedStep ()->GetProcessName () == " OpAbsorption" ;
169
160
}
170
161
171
-
172
162
/* *
173
163
* @brief Checks if the photon was detected at a boundary.
174
164
* @param p_step The current step information.
@@ -200,10 +190,9 @@ G4bool OMSimSensitiveDetector::checkBoundaryAbsorption(G4Step *p_step)
200
190
*/
201
191
bool OMSimSensitiveDetector::isPhotonDetected (double p_efficiency)
202
192
{
203
- return G4UniformRand () < p_efficiency;
193
+ return G4UniformRand () < p_efficiency;
204
194
}
205
195
206
-
207
196
/* *
208
197
* @brief Handles hits for PMT detectors.
209
198
* @param p_step The current step information.
@@ -215,7 +204,7 @@ G4bool OMSimSensitiveDetector::handlePMT(G4Step *p_step, G4TouchableHistory *p_t
215
204
PhotonInfo info = getPhotonInfo (p_step);
216
205
217
206
// if QE cut is enabled, check if photon is detected (using detection probability, if detail PMT is enabled)
218
- if (m_QEcut && !isPhotonDetected (info.PMTResponse .detectionProbability ))
207
+ if (m_QEcut && !isPhotonDetected (info.PMTResponse .detectionProbability ))
219
208
return false ;
220
209
else if (m_QEcut)
221
210
info.PMTResponse .detectionProbability = 1 ; // if QE cut is enabled, detection probability is 1 as photon was detected
@@ -282,4 +271,3 @@ void OMSimSensitiveDetector::killParticle(G4Track *p_track)
282
271
p_track->SetTrackStatus (fStopAndKill );
283
272
}
284
273
}
285
-
0 commit comments