Skip to content

Commit

Permalink
changed location for getting eventid, no perfect
Browse files Browse the repository at this point in the history
  • Loading branch information
martinunland committed Sep 4, 2024
1 parent 7124884 commit 61c0893
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 27 deletions.
1 change: 1 addition & 0 deletions common/framework/include/OMSimHitManager.hh
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ public:
static OMSimHitManager &getInstance();

void appendHitInfo(
G4int p_eventid,
G4double pGlobalTime,
G4double pLocalTime,
G4double pTrackLength,
Expand Down
5 changes: 2 additions & 3 deletions common/framework/include/OMSimSensitiveDetector.hh
Original file line number Diff line number Diff line change
Expand Up @@ -19,16 +19,15 @@ 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.
};

/**
* @struct PhotonInfo
* @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.
Expand Down
4 changes: 2 additions & 2 deletions common/framework/src/OMSimHitManager.cc
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ void applyPermutation(std::vector<T> &p_vector, const std::vector<std::size_t> &
* @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,
Expand Down Expand Up @@ -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);
Expand Down
1 change: 0 additions & 1 deletion common/framework/src/OMSimPMTResponse.cc
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,6 @@ OMSimPMTResponse::PMTPulse OMSimPMTResponse::processPhotocathodeHit(G4double p_x
pulse = getPulseFromInterpolation(lW1, lW2);
}
pulse.detectionProbability = weightQE * weightCE;

return pulse;
}

Expand Down
42 changes: 23 additions & 19 deletions common/framework/src/OMSimSensitiveDetector.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
#include "G4ProcessVector.hh"
#include "G4ProcessManager.hh"
#include "OMSimTools.hh"
#include <G4EventManager.hh>

thread_local G4OpBoundaryProcess *OMSimSensitiveDetector::m_boundaryProcess = nullptr;

Expand Down Expand Up @@ -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;
}

Expand All @@ -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;
Expand Down Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions simulations/CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -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)

0 comments on commit 61c0893

Please sign in to comment.