diff --git a/common/framework/include/OMSimHitManager.hh b/common/framework/include/OMSimHitManager.hh index 7b50b50f9..d50abf266 100644 --- a/common/framework/include/OMSimHitManager.hh +++ b/common/framework/include/OMSimHitManager.hh @@ -65,6 +65,7 @@ public: static OMSimHitManager &getInstance(); void appendHitInfo( + G4int p_eventid, G4double pGlobalTime, G4double pLocalTime, G4double pTrackLength, diff --git a/common/framework/include/OMSimSensitiveDetector.hh b/common/framework/include/OMSimSensitiveDetector.hh index b121640c0..d372198ce 100644 --- a/common/framework/include/OMSimSensitiveDetector.hh +++ b/common/framework/include/OMSimSensitiveDetector.hh @@ -19,9 +19,7 @@ enum class DetectorType { PMT, ///< Photomultiplier tube detector. VolumePhotonDetector, ///< Photon detector based on absorption in volume. BoundaryPhotonDetector, ///< Photon detector based on absorption in boundary. - PerfectPMT, ///< Photomultiplier tube detector. - PerfectVolumePhotonDetector, ///< Photon detector based on absorption in volume 100% efficient. - PerfectBoundaryPhotonDetector ///< Photon detector based on absorption in boundary 100% efficient. + PerfectPMT ///< Photomultiplier tube detector. }; /** @@ -29,6 +27,7 @@ enum class DetectorType { * @brief Contains information about a detected photon which will be appended in HitManager. */ struct PhotonInfo { + G4int eventID; ///< Event ID of the photon hit. G4double globalTime; ///< Global time of the photon hit. G4double localTime; ///< Local time of the photon hit. G4double trackLength; ///< Length of the photon's track. diff --git a/common/framework/src/OMSimHitManager.cc b/common/framework/src/OMSimHitManager.cc index dd4dae29e..f2606ab38 100644 --- a/common/framework/src/OMSimHitManager.cc +++ b/common/framework/src/OMSimHitManager.cc @@ -97,6 +97,7 @@ void applyPermutation(std::vector &p_vector, const std::vector & * @param p_moduleNumber ID of the module in which the photon was detected. */ void OMSimHitManager::appendHitInfo( + G4int p_eventid, G4double p_globalTime, G4double p_localTime, G4double p_trackLength, @@ -124,9 +125,8 @@ void OMSimHitManager::appendHitInfo( } auto &moduleHits = m_threadData->moduleHits[p_moduleNumber]; - G4int eventID = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID(); //log_debug("Thread {} Seed {} event {} size {}", G4Threading::G4GetThreadId(), G4Random::getTheSeed(), eventID, moduleHits.eventId.size()); - moduleHits.eventId.push_back(eventID); + moduleHits.eventId.push_back(p_eventid); moduleHits.hitTime.push_back(p_globalTime); moduleHits.flightTime.push_back(p_localTime); moduleHits.pathLenght.push_back(p_trackLength); diff --git a/common/framework/src/OMSimPMTResponse.cc b/common/framework/src/OMSimPMTResponse.cc index b007d0e6b..c3ddb407a 100644 --- a/common/framework/src/OMSimPMTResponse.cc +++ b/common/framework/src/OMSimPMTResponse.cc @@ -372,7 +372,6 @@ OMSimPMTResponse::PMTPulse OMSimPMTResponse::processPhotocathodeHit(G4double p_x pulse = getPulseFromInterpolation(lW1, lW2); } pulse.detectionProbability = weightQE * weightCE; - return pulse; } diff --git a/common/framework/src/OMSimSensitiveDetector.cc b/common/framework/src/OMSimSensitiveDetector.cc index 8f5461fef..f7a0b06fc 100644 --- a/common/framework/src/OMSimSensitiveDetector.cc +++ b/common/framework/src/OMSimSensitiveDetector.cc @@ -19,6 +19,7 @@ #include "G4ProcessVector.hh" #include "G4ProcessManager.hh" #include "OMSimTools.hh" +#include thread_local G4OpBoundaryProcess *OMSimSensitiveDetector::m_boundaryProcess = nullptr; @@ -88,33 +89,35 @@ void OMSimSensitiveDetector::setPMTResponse(OMSimPMTResponse *p_response) */ G4bool OMSimSensitiveDetector::ProcessHits(G4Step *p_step, G4TouchableHistory *p_touchableHistory) { + // Return false if the track is not an optical photon if (p_step->GetTrack()->GetDefinition() != G4OpticalPhoton::Definition()) return false; - if (DetectorType::PerfectVolumePhotonDetector == m_detectorType || DetectorType::PerfectBoundaryPhotonDetector == m_detectorType || DetectorType::PerfectPMT == m_detectorType) + // Switch based on the detector type + switch (m_detectorType) { - if (m_detectorType == DetectorType::PerfectPMT) return handlePMT(p_step, p_touchableHistory); - return handleGeneralPhotonDetector(p_step, p_touchableHistory); - } + case DetectorType::PMT: + if (checkBoundaryAbsorption(p_step)) + return handlePMT(p_step, p_touchableHistory); + return false; - if (m_detectorType == DetectorType::VolumePhotonDetector) - { + case DetectorType::PerfectPMT: + return handlePMT(p_step, p_touchableHistory); + + case DetectorType::BoundaryPhotonDetector: + if (checkBoundaryAbsorption(p_step)) + return handleGeneralPhotonDetector(p_step, p_touchableHistory); + return false; + + case DetectorType::VolumePhotonDetector: if (checkVolumeAbsorption(p_step)) - { return handleGeneralPhotonDetector(p_step, p_touchableHistory); - } + return false; + + default: + return false; } - else if (checkBoundaryAbsorption(p_step)) //if none of the above, it is a boundary photon detector - { - switch (m_detectorType) - { - case DetectorType::PMT: - return handlePMT(p_step, p_touchableHistory); - case DetectorType::BoundaryPhotonDetector: - return handleGeneralPhotonDetector(p_step, p_touchableHistory); - } - } return false; } @@ -132,7 +135,7 @@ PhotonInfo OMSimSensitiveDetector::getPhotonInfo(G4Step *p_step) G4double h = 4.135667696E-15 * eV * s; G4double c = 2.99792458E17 * nm / s; G4double lEkin = track->GetKineticEnergy(); - + info.eventID = G4EventManager::GetEventManager()->GetConstCurrentEvent()->GetEventID(); info.globalTime = track->GetGlobalTime(); info.localTime = track->GetLocalTime(); info.trackLength = track->GetTrackLength() / m; @@ -250,6 +253,7 @@ void OMSimSensitiveDetector::storePhotonHit(PhotonInfo &p_info) { OMSimHitManager &hitManager = OMSimHitManager::getInstance(); hitManager.appendHitInfo( + p_info.eventID, p_info.globalTime, p_info.localTime, p_info.trackLength, diff --git a/simulations/CMakeLists.txt b/simulations/CMakeLists.txt index c6c29387e..b9ddcbe49 100755 --- a/simulations/CMakeLists.txt +++ b/simulations/CMakeLists.txt @@ -1,4 +1,4 @@ -#add_subdirectory(effective_area) +add_subdirectory(effective_area) #add_subdirectory(radioactive_decays) #add_subdirectory(supernova) -add_subdirectory(efficiency_calibration) +#add_subdirectory(efficiency_calibration)