OMSim
Geant4 for IceCube optical module studies
Loading...
Searching...
No Matches
OMSimHitManager.hh
Go to the documentation of this file.
1
13#pragma once
14
15#include "OMSimPMTResponse.hh"
16
17#include <G4ThreeVector.hh>
18#include <fstream>
19#include <G4AutoLock.hh>
20#include <G4Threading.hh>
21
28{
29 std::vector<G4long> eventId;
30 std::vector<G4double> hitTime;
31 std::vector<G4double> flightTime;
32 std::vector<G4double> pathLenght;
33 std::vector<G4double> energy;
34 std::vector<G4int> PMTnr;
35 std::vector<G4ThreeVector> direction;
36 std::vector<G4ThreeVector> localPosition;
37 std::vector<G4ThreeVector> globalPosition;
38 std::vector<G4double> generationDetectionDistance;
39 std::vector<OMSimPMTResponse::PMTPulse> PMTresponse;
40};
41
56{
58 ~OMSimHitManager() = default;
59 OMSimHitManager(const OMSimHitManager &) = delete;
60 OMSimHitManager &operator=(const OMSimHitManager &) = delete;
61
62public:
63 static void init();
64 static void shutdown();
66
67 void appendHitInfo(
68 G4int p_eventid,
69 G4double pGlobalTime,
70 G4double pLocalTime,
71 G4double pTrackLength,
72 G4double pEnergy,
73 G4int pPMTHitNumber,
74 G4ThreeVector pMomentumDirection,
75 G4ThreeVector pGlobalPos,
76 G4ThreeVector pLocalPos,
77 G4double pDistance,
79 G4int pModuleIndex = 0);
80
81 void reset();
82 std::vector<double> countMergedHits(int pModuleIndex = 0, bool pDEweight = false);
83 void setNumberOfPMTs(int pNumberOfPMTs, int pModuleIndex = 0);
84 HitStats getMergedHitsOfModule(int pModuleIndex = 0);
85 HitStats getSingleThreadHitsOfModule(int pModuleIndex = 0);
86 bool areThereHitsInModuleSingleThread(int pModuleIndex = 0);
87 void sortHitStatsByTime(HitStats &pHits);
88 std::vector<int> calculateMultiplicity(const G4double pTimeWindow, int pModuleNumber = 0);
89 G4int getNextDetectorIndex() { return ++m_currentIndex; }
90 G4int getNumberOfModules() { return m_currentIndex + 1; }
91
92 void mergeThreadData();
93
94 std::map<G4int, HitStats> m_moduleHits;
95
96private:
97 std::map<G4int, G4int> m_numberOfPMTs;
98 G4int m_currentIndex;
99 static G4Mutex m_mutex;
100 static OMSimHitManager *m_instance;
102 {
103 std::map<G4int, HitStats> moduleHits;
104 };
105 G4ThreadLocal static ThreadLocalData *m_threadData;
106};
107
108inline OMSimHitManager *g_hitManager = nullptr;
109
Simulation of PMT response.
Manages detected photon information.
Definition OMSimHitManager.hh:56
void reset()
Deletes hit information in memory for all modules.
Definition 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 OMSimHitManager.cc:274
std::map< G4int, HitStats > m_moduleHits
Map of a HitStats containing hit information for each simulated optical module.
Definition OMSimHitManager.hh:94
HitStats getSingleThreadHitsOfModule(int pModuleIndex=0)
Retrieves the HitStats structure for the specified module of single thread.
Definition OMSimHitManager.cc:172
void sortHitStatsByTime(HitStats &pHits)
Sorts the hit statistics by the hit time.
Definition OMSimHitManager.cc:230
std::map< G4int, G4int > m_numberOfPMTs
Map of number of PMTs in the used optical modules.
Definition OMSimHitManager.hh:97
std::vector< double > countMergedHits(int pModuleIndex=0, bool pDEweight=false)
Counts hits for a specified module.
Definition OMSimHitManager.cc:209
static OMSimHitManager & getInstance()
Definition OMSimHitManager.cc:44
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 OMSimHitManager.cc:99
void setNumberOfPMTs(int pNumberOfPMTs, int pModuleIndex=0)
Stores the number of PMTs in a module for correct data handling.
Definition OMSimHitManager.cc:148
static void init()
Initializes the global instance of OMSimHitManager.
Definition OMSimHitManager.cc:23
static void shutdown()
Deletes the global instance of OMSimHitManager.
Definition OMSimHitManager.cc:33
HitStats getMergedHitsOfModule(int pModuleIndex=0)
Retrieves the HitStats structure for the specified module, should be called after data between thread...
Definition OMSimHitManager.cc:159
A structure of vectors to store information about detected photons.
Definition OMSimHitManager.hh:28
std::vector< G4double > flightTime
Photon flight time.
Definition OMSimHitManager.hh:31
std::vector< G4ThreeVector > direction
Momentum direction of the photon at the time of detection.
Definition OMSimHitManager.hh:35
std::vector< OMSimPMTResponse::PMTPulse > PMTresponse
PMT's response to the detected photon, encapsulated as a PMTPulse.
Definition OMSimHitManager.hh:39
std::vector< G4double > energy
Energy of the detected photon.
Definition OMSimHitManager.hh:33
std::vector< G4long > eventId
ID of the event.
Definition OMSimHitManager.hh:29
std::vector< G4ThreeVector > globalPosition
Global position of the detected photon.
Definition OMSimHitManager.hh:37
std::vector< G4ThreeVector > localPosition
Local position of the detected photon within the PMT.
Definition OMSimHitManager.hh:36
std::vector< G4double > hitTime
Time of detection.
Definition OMSimHitManager.hh:30
std::vector< G4double > generationDetectionDistance
Distance between generation and detection of photon.
Definition OMSimHitManager.hh:38
std::vector< G4double > pathLenght
Length of the photon's path before hitting.
Definition OMSimHitManager.hh:32
std::vector< G4int > PMTnr
ID of the PMT that detected the photon.
Definition OMSimHitManager.hh:34
Definition OMSimHitManager.hh:102
Represents the output pulse for a detected photon.
Definition OMSimPMTResponse.hh:29