OMSim
Geant4 for IceCube optical module studies
Loading...
Searching...
No Matches
simulations/wavepid/include/OMSimHitManager.hh
Go to the documentation of this file.
1
9#pragma once
10
11#include "OMSimPMTResponse.hh"
12#include "ROOTHitManager.hh"
13
14#include <G4ThreeVector.hh>
15#include <fstream>
16#include <G4AutoLock.hh>
17#include <G4Threading.hh>
18#include <map>
19#include <vector>
20
25struct HitStats
26{
27 std::vector<G4long> eventId;
28 std::vector<G4double> hitTime;
29 std::vector<G4double> entryTime;
30 std::vector<G4double> flightTime;
31 std::vector<G4double> pathLenght;
32 std::vector<G4double> energy;
33 std::vector<G4int> PMTnr;
34 std::vector<G4ThreeVector> direction;
35 std::vector<G4ThreeVector> localPosition;
36 std::vector<G4ThreeVector> globalPosition;
37 std::vector<G4double> generationDetectionDistance;
38 std::vector<OMSimPMTResponse::PMTPulse> PMTresponse;
39 std::vector<G4String> photonOrigin;
40 std::vector<G4int> parentID;
41 std::vector<G4String> parentType;
42 std::vector<G4String> parentProcess;
43};
44
50{
52 ~OMSimHitManager() = default;
53 OMSimHitManager(const OMSimHitManager&) = delete;
54 OMSimHitManager& operator=(const OMSimHitManager&) = delete;
55
56public:
60 static void init();
61
66 static void setROOTOutputFile(const std::string& filename);
67
71 static void shutdown();
72
77
81 void appendHitInfo(
82 G4int p_eventid,
83 G4double p_globalTime,
84 G4double p_entryTime,
85 G4double p_localTime,
86 G4double p_trackLength,
87 G4double p_energy,
88 G4int pPMTHitNumber,
89 G4ThreeVector pMomentumDirection,
90 G4ThreeVector pGlobalPos,
91 G4ThreeVector pLocalPos,
92 G4double p_distance,
94 G4String pPhotonOrigin,
95 G4int pParentID,
96 std::string pParentType,
97 G4String pParentProcess,
98 G4double p_wavelength,
99 G4int pModuleIndex);
100
101 void reset();
102 std::vector<double> countMergedHits(int pModuleIndex = 0, bool pDEweight = false);
103 void setNumberOfPMTs(int pNumberOfPMTs, int pModuleIndex = 0);
104 HitStats getMergedHitsOfModule(int pModuleIndex = 0);
105 HitStats getSingleThreadHitsOfModule(int pModuleIndex = 0);
106 bool areThereHitsInModuleSingleThread(int pModuleIndex = 0);
107 void sortHitStatsByTime(HitStats& pHits);
108 std::vector<int> calculateMultiplicity(const G4double pTimeWindow, int pModuleNumber = 0);
109 G4int getNextDetectorIndex() { return ++m_currentIndex; }
110 G4int getNumberOfModules() { return m_currentIndex + 1; }
111
112 void mergeThreadData();
113
114 std::map<G4int, HitStats> m_moduleHits;
115
116private:
117 std::map<G4int, G4int> m_numberOfPMTs;
118 G4int m_currentIndex;
119 static G4Mutex m_mutex;
120 static OMSimHitManager* m_instance;
121
122 struct ThreadLocalData {
123 std::map<G4int, HitStats> moduleHits;
124 };
125 G4ThreadLocal static ThreadLocalData* m_threadData;
126
127 ROOTHitManager* m_rootManager = nullptr;
128};
129
130inline OMSimHitManager* g_hitManager = nullptr;
Simulation of PMT response.
ROOT-based output manager for WavePID photon hit data.
Manages detected photon information.
Definition common/framework/include/OMSimHitManager.hh:56
void reset()
Deletes hit information in memory for all modules.
Definition common/framework/src/OMSimHitManager.cc:188
std::vector< int > calculateMultiplicity(const G4double pTimeWindow, int pModuleNumber=0)
Calculates the multiplicity of hits within a specified time window for a given module.
Definition common/framework/src/OMSimHitManager.cc:274
static void init()
Initialize the global instance (called by OMSim::initialiseSimulation).
static void shutdown()
Shutdown and cleanup the global instance.
std::map< G4int, G4int > m_numberOfPMTs
Map of number of PMTs in the used optical modules.
Definition common/framework/include/OMSimHitManager.hh:97
static void setROOTOutputFile(const std::string &filename)
Set the ROOT output file (call after init, before simulation runs).
Definition simulations/wavepid/src/OMSimHitManager.cc:30
HitStats getSingleThreadHitsOfModule(int pModuleIndex=0)
Retrieves the HitStats structure for the specified module of single thread.
Definition common/framework/src/OMSimHitManager.cc:172
static OMSimHitManager & getInstance()
Get reference to the global instance.
void sortHitStatsByTime(HitStats &pHits)
Sorts the hit statistics by the hit time.
Definition common/framework/src/OMSimHitManager.cc:230
std::vector< double > countMergedHits(int pModuleIndex=0, bool pDEweight=false)
Counts hits for a specified module.
Definition common/framework/src/OMSimHitManager.cc:209
void appendHitInfo(G4int p_eventid, G4double pGlobalTime, G4double pLocalTime, G4double pTrackLength, G4double pEnergy, G4int pPMTHitNumber, G4ThreeVector pMomentumDirection, G4ThreeVector pGlobalPos, G4ThreeVector pLocalPos, G4double pDistance, OMSimPMTResponse::PMTPulse pResponse, G4int pModuleIndex=0)
Appends hit information for a detected photon to the corresponding module's hit data.
Definition common/framework/src/OMSimHitManager.cc:99
void setNumberOfPMTs(int pNumberOfPMTs, int pModuleIndex=0)
Stores the number of PMTs in a module for correct data handling.
Definition common/framework/src/OMSimHitManager.cc:148
std::map< G4int, HitStats > m_moduleHits
Map of a HitStats containing hit information for each simulated optical module.
Definition common/framework/include/OMSimHitManager.hh:94
HitStats getMergedHitsOfModule(int pModuleIndex=0)
Retrieves the HitStats structure for the specified module, should be called after data between thread...
Definition common/framework/src/OMSimHitManager.cc:159
Manages ROOT file output for photon hit data.
Definition ROOTHitManager.hh:50
A structure of vectors to store information about detected photons.
Definition common/framework/include/OMSimHitManager.hh:28
std::vector< G4double > flightTime
Photon flight time.
Definition common/framework/include/OMSimHitManager.hh:31
std::vector< G4double > pathLenght
Length of the photon's path before hitting.
Definition common/framework/include/OMSimHitManager.hh:32
std::vector< G4double > entryTime
Time photon entered DOM.
Definition simulations/wavepid/include/OMSimHitManager.hh:29
std::vector< G4double > generationDetectionDistance
Distance between generation and detection of photon.
Definition common/framework/include/OMSimHitManager.hh:38
std::vector< G4ThreeVector > direction
Momentum direction of the photon at the time of detection.
Definition common/framework/include/OMSimHitManager.hh:35
std::vector< G4double > energy
Energy of the detected photon.
Definition common/framework/include/OMSimHitManager.hh:33
std::vector< G4String > parentType
Parent particle type (e.g., "mu-", "e-")
Definition simulations/wavepid/include/OMSimHitManager.hh:41
std::vector< G4String > photonOrigin
Origin classification (e.g., "Cerenkov from Muon")
Definition simulations/wavepid/include/OMSimHitManager.hh:39
std::vector< G4int > parentID
Parent track ID.
Definition simulations/wavepid/include/OMSimHitManager.hh:40
std::vector< G4ThreeVector > globalPosition
Global position of the detected photon.
Definition common/framework/include/OMSimHitManager.hh:37
std::vector< G4String > parentProcess
Process that created parent.
Definition simulations/wavepid/include/OMSimHitManager.hh:42
std::vector< G4double > hitTime
Time of detection.
Definition common/framework/include/OMSimHitManager.hh:30
std::vector< G4int > PMTnr
ID of the PMT that detected the photon.
Definition common/framework/include/OMSimHitManager.hh:34
std::vector< G4long > eventId
ID of the event.
Definition common/framework/include/OMSimHitManager.hh:29
std::vector< OMSimPMTResponse::PMTPulse > PMTresponse
PMT's response to the detected photon, encapsulated as a PMTPulse.
Definition common/framework/include/OMSimHitManager.hh:39
std::vector< G4ThreeVector > localPosition
Local position of the detected photon within the PMT.
Definition common/framework/include/OMSimHitManager.hh:36
Represents the output pulse for a detected photon.
Definition OMSimPMTResponse.hh:29