23 #ifndef RestCore_TRestGeant4Event
24 #define RestCore_TRestGeant4Event
31 #include <TMultiGraph.h>
32 #include <TRestEvent.h>
39 #include "TRestGeant4Track.h"
50 Double_t fMinX, fMaxX;
51 Double_t fMinY, fMaxY;
52 Double_t fMinZ, fMaxZ;
53 Double_t fMinEnergy, fMaxEnergy;
56 void AddEnergyDepositToVolume(Int_t volID, Double_t eDep);
68 std::vector<TGraph*> fXYPcsMarker;
69 std::vector<TGraph*> fYZPcsMarker;
70 std::vector<TGraph*> fXZPcsMarker;
72 TMultiGraph* fXZMultiGraph;
73 TMultiGraph* fYZMultiGraph;
74 TMultiGraph* fXYMultiGraph;
89 std::vector<Int_t> legendAdded;
93 TMultiGraph* GetXZMultiGraph(Int_t gridElement, std::vector<TString> pcsList, Double_t minPointSize = 0.4,
94 Double_t maxPointSize = 4);
95 TMultiGraph* GetYZMultiGraph(Int_t gridElement, std::vector<TString> pcsList, Double_t minPointSize = 0.4,
96 Double_t maxPointSize = 4);
97 TMultiGraph* GetXYMultiGraph(Int_t gridElement, std::vector<TString> pcsList, Double_t minPointSize = 0.4,
98 Double_t maxPointSize = 4);
100 TH2F* GetXYHistogram(Int_t gridElement, std::vector<TString> optList);
101 TH2F* GetXZHistogram(Int_t gridElement, std::vector<TString> optList);
102 TH2F* GetYZHistogram(Int_t gridElement, std::vector<TString> optList);
104 TH1D* GetXHistogram(Int_t gridElement, std::vector<TString> optList);
105 TH1D* GetYHistogram(Int_t gridElement, std::vector<TString> optList);
106 TH1D* GetZHistogram(Int_t gridElement, std::vector<TString> optList);
109 TVector3 fPrimaryPosition;
110 std::vector<TString> fPrimaryParticleNames;
111 std::vector<Double_t> fPrimaryEnergies;
112 std::vector<TVector3> fPrimaryDirections;
114 TString fSubEventPrimaryParticleName;
115 Double_t fSubEventPrimaryEnergy;
116 TVector3 fSubEventPrimaryPosition;
117 TVector3 fSubEventPrimaryDirection;
119 Double_t fTotalDepositedEnergy = 0;
120 Double_t fSensitiveVolumeEnergy = 0;
123 std::vector<Int_t> fVolumeStored;
124 std::vector<std::string> fVolumeStoredNames;
125 std::vector<Double_t> fVolumeDepositedEnergy;
126 std::map<std::string, std::map<std::string, std::map<std::string, double>>>
127 fEnergyInVolumePerParticlePerProcess;
128 std::vector<TRestGeant4Track> fTracks;
131 void SetBoundaries();
132 void SetBoundaries(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin,
137 inline size_t GetNumberOfPrimaries()
const {
return fPrimaryParticleNames.size(); }
139 inline TString GetPrimaryEventParticleName(
size_t n = 0)
const {
return fPrimaryParticleNames[n]; }
140 inline TVector3 GetPrimaryEventDirection(
size_t n = 0)
const {
return fPrimaryDirections[n]; }
141 inline TVector3 GetPrimaryEventOrigin()
const {
return fPrimaryPosition; }
142 inline Double_t GetPrimaryEventEnergy(
size_t n = 0)
const {
return fPrimaryEnergies[n]; }
144 inline Bool_t IsSubEvent()
const {
return fSubEventID > 0; }
145 inline TString GetSubEventPrimaryEventParticleName()
const {
return fSubEventPrimaryParticleName; }
146 inline TVector3 GetSubEventPrimaryEventDirection()
const {
return fSubEventPrimaryDirection; }
147 inline TVector3 GetSubEventPrimaryEventOrigin()
const {
return fSubEventPrimaryPosition; }
148 inline Double_t GetSubEventPrimaryEventEnergy()
const {
return fSubEventPrimaryEnergy; }
153 inline const std::vector<TRestGeant4Track>& GetTracks()
const {
return fTracks; }
154 inline size_t GetNumberOfTracks()
const {
return fTracks.size(); }
155 inline Int_t GetNumberOfActiveVolumes()
const {
return fNVolumes; }
157 inline Int_t isVolumeStored(
int n)
const {
return fVolumeStored[n]; }
162 inline Double_t GetTotalDepositedEnergy()
const {
return fTotalDepositedEnergy; }
164 inline Double_t GetSensitiveVolumeEnergy()
const {
return fSensitiveVolumeEnergy; }
165 TVector3 GetMeanPositionInVolume(Int_t volID)
const;
170 std::map<std::string, std::map<std::string, std::map<std::string, double>>>
171 GetEnergyInVolumePerParticlePerProcessMap()
const;
172 std::map<std::string, std::map<std::string, double>> GetEnergyInVolumePerProcessMap()
const;
173 std::map<std::string, std::map<std::string, double>> GetEnergyInVolumePerParticleMap()
const;
174 std::map<std::string, double> GetEnergyPerProcessMap()
const;
175 std::map<std::string, double> GetEnergyPerParticleMap()
const;
176 std::map<std::string, double> GetEnergyInVolumeMap()
const;
178 inline Double_t GetEnergyInVolume(
const std::string& volumeName)
const {
179 auto energyMap = GetEnergyInVolumeMap();
180 return energyMap[volumeName];
184 inline TRestHits GetHitsInVolume(Int_t volID)
const {
return GetHits(volID); }
186 Int_t GetNumberOfTracksForParticle(
const TString& particleName)
const;
187 Double_t GetEnergyDepositedByParticle(
const TString& particleName)
const;
189 inline void ActivateVolumeForStorage(Int_t n) { fVolumeStored[n] = 1; }
190 inline void DisableVolumeForStorage(Int_t n) { fVolumeStored[n] = 0; }
192 void AddActiveVolume(
const std::string& volumeName);
194 inline void AddEnergyToSensitiveVolume(Double_t en) { fSensitiveVolumeEnergy += en; }
196 inline void SetEnergyDepositedInVolume(Int_t volID, Double_t eDep) {
197 fVolumeDepositedEnergy[volID] = eDep;
199 inline void SetSensitiveVolumeEnergy(Double_t en) { fSensitiveVolumeEnergy = en; }
201 inline Int_t GetLowestTrackID()
const {
203 if (GetNumberOfTracks() > 0) {
204 lowestID = GetTrack(0).GetTrackID();
207 for (
unsigned int i = 0; i < GetNumberOfTracks(); i++) {
208 auto tr = GetTrack(i);
209 if (tr.GetTrackID() < lowestID) lowestID = tr.GetTrackID();
215 std::set<std::string> GetUniqueParticles()
const;
217 Bool_t ContainsProcessInVolume(Int_t processID, Int_t volumeID = -1)
const;
218 inline Bool_t ContainsProcess(Int_t processID)
const {
return ContainsProcessInVolume(processID, -1); }
220 Bool_t ContainsProcessInVolume(
const TString& processName, Int_t volumeID = -1)
const;
221 inline Bool_t ContainsProcess(
const TString& processName)
const {
222 return ContainsProcessInVolume(processName, -1);
225 Bool_t ContainsParticle(
const TString& particleName)
const;
226 Bool_t ContainsParticleInVolume(
const TString& particleName, Int_t volumeID = -1)
const;
236 void PrintEvent(
int maxTracks = 0,
int maxHits = 0)
const;
239 TPad*
DrawEvent(
const TString& option, Bool_t autoBoundaries);
253 void UpdateTrack(
const G4Track*);
254 void InsertStep(
const G4Step*);
256 friend class OutputManager;
260 std::map<Int_t, Int_t> fTrackIDToTrackIndex = {};
263 void AddEnergyInVolumeForParticleForProcess(Double_t energy,
const std::string& volumeName,
264 const std::string& particleName,
265 const std::string& processName);
A base class for any REST event.
virtual void PrintEvent() const
Int_t fSubEventID
Sub-Event identification number.
An event class to store geant4 generated event information.
TVector3 GetFirstPositionInVolume(Int_t volID) const
Function to get the position (TVector3) of the first track that deposits energy in specified volume....
void InitializeReferences(TRestRun *run) override
Initialize dynamical references when loading the event from a root file.
size_t GetNumberOfHits(Int_t volID=-1) const
Function that returns the total number of hits in the Geant4 event. If a specific volume is given as ...
size_t GetNumberOfPhysicalHits(Int_t volID=-1) const
Function that returns the total number of hits with energy > 0 in the Geant4 event....
Double_t GetBoundingBoxSize()
This method returns the event size as the size of the bounding box enclosing all hits.
TVector3 GetPositionDeviationInVolume(Int_t volID) const
A method that gets the standard deviation from the hits happening at a particular volumeId inside the...
void Initialize() override
void PrintActiveVolumes() const
maxTracks : number of tracks to print, 0 = all
TVector3 GetLastPositionInVolume(Int_t volID) const
Function to get the position (TVector3) of the last track that deposits energy in specified volume....
TRestHits GetHits(Int_t volID=-1) const
Function that returns all the hit depositions in the Geant4 event. If a specific volume is given as a...
bool InsertTrack(const G4Track *)
// Implemented in restG4
TPad * DrawEvent(const TString &option="") override
Draw the event.
Recomputes the energy of every hit based on quenching factor for each particle and volume.
It saves a 3-coordinate position and an energy for each punctual deposition.
Data provider and manager in REST.