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;
122 double fEventTimeWall = 0;
123 double fEventTimeWallPrimaryGeneration = 0;
126 std::vector<Int_t> fVolumeStored;
127 std::vector<std::string> fVolumeStoredNames;
128 std::vector<Double_t> fVolumeDepositedEnergy;
129 std::map<std::string, std::map<std::string, std::map<std::string, double>>>
130 fEnergyInVolumePerParticlePerProcess;
131 std::vector<TRestGeant4Track> fTracks;
134 void SetBoundaries();
135 void SetBoundaries(Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin,
140 inline size_t GetNumberOfPrimaries()
const {
return fPrimaryParticleNames.size(); }
142 inline TString GetPrimaryEventParticleName(
size_t n = 0)
const {
return fPrimaryParticleNames[n]; }
143 inline TVector3 GetPrimaryEventDirection(
size_t n = 0)
const {
return fPrimaryDirections[n]; }
144 inline TVector3 GetPrimaryEventOrigin()
const {
return fPrimaryPosition; }
145 inline Double_t GetPrimaryEventEnergy(
size_t n = 0)
const {
return fPrimaryEnergies[n]; }
147 inline Bool_t IsSubEvent()
const {
return fSubEventID > 0; }
148 inline TString GetSubEventPrimaryEventParticleName()
const {
return fSubEventPrimaryParticleName; }
149 inline TVector3 GetSubEventPrimaryEventDirection()
const {
return fSubEventPrimaryDirection; }
150 inline TVector3 GetSubEventPrimaryEventOrigin()
const {
return fSubEventPrimaryPosition; }
151 inline Double_t GetSubEventPrimaryEventEnergy()
const {
return fSubEventPrimaryEnergy; }
156 double GetEventTimeWall()
const {
return fEventTimeWall; }
157 double GetEventTimeWallPrimaryGeneration()
const {
return fEventTimeWallPrimaryGeneration; }
159 inline const std::vector<TRestGeant4Track>& GetTracks()
const {
return fTracks; }
160 inline size_t GetNumberOfTracks()
const {
return fTracks.size(); }
161 inline Int_t GetNumberOfActiveVolumes()
const {
return fNVolumes; }
163 inline Int_t isVolumeStored(
int n)
const {
return fVolumeStored[n]; }
168 inline Double_t GetTotalDepositedEnergy()
const {
return fTotalDepositedEnergy; }
170 inline Double_t GetSensitiveVolumeEnergy()
const {
return fSensitiveVolumeEnergy; }
171 TVector3 GetMeanPositionInVolume(Int_t volID)
const;
176 std::map<std::string, std::map<std::string, std::map<std::string, double>>>
177 GetEnergyInVolumePerParticlePerProcessMap()
const;
178 std::map<std::string, std::map<std::string, double>> GetEnergyInVolumePerProcessMap()
const;
179 std::map<std::string, std::map<std::string, double>> GetEnergyInVolumePerParticleMap()
const;
180 std::map<std::string, double> GetEnergyPerProcessMap()
const;
181 std::map<std::string, double> GetEnergyPerParticleMap()
const;
182 std::map<std::string, double> GetEnergyInVolumeMap()
const;
184 inline Double_t GetEnergyInVolume(
const std::string& volumeName)
const {
185 auto energyMap = GetEnergyInVolumeMap();
186 return energyMap[volumeName];
189 std::pair<double, double> GetTimeRangeOfIonizationInVolume(
const std::string& volumeName)
const;
191 inline void ClearTracks() { fTracks.clear(); }
194 inline TRestHits GetHitsInVolume(Int_t volID)
const {
return GetHits(volID); }
196 Int_t GetNumberOfTracksForParticle(
const TString& particleName)
const;
197 Double_t GetEnergyDepositedByParticle(
const TString& particleName)
const;
199 inline void ActivateVolumeForStorage(Int_t n) { fVolumeStored[n] = 1; }
200 inline void DisableVolumeForStorage(Int_t n) { fVolumeStored[n] = 0; }
202 void AddActiveVolume(
const std::string& volumeName);
204 inline void AddEnergyToSensitiveVolume(Double_t en) { fSensitiveVolumeEnergy += en; }
206 inline void SetEnergyDepositedInVolume(Int_t volID, Double_t eDep) {
207 fVolumeDepositedEnergy[volID] = eDep;
209 inline void SetSensitiveVolumeEnergy(Double_t en) { fSensitiveVolumeEnergy = en; }
211 inline Int_t GetLowestTrackID()
const {
213 if (GetNumberOfTracks() > 0) {
214 lowestID = GetTrack(0).GetTrackID();
217 for (
unsigned int i = 0; i < GetNumberOfTracks(); i++) {
218 auto tr = GetTrack(i);
219 if (tr.GetTrackID() < lowestID) lowestID = tr.GetTrackID();
225 std::set<std::string> GetUniqueParticles()
const;
227 Bool_t ContainsProcessInVolume(Int_t processID, Int_t volumeID = -1)
const;
228 inline Bool_t ContainsProcess(Int_t processID)
const {
return ContainsProcessInVolume(processID, -1); }
230 Bool_t ContainsProcessInVolume(
const TString& processName, Int_t volumeID = -1)
const;
231 inline Bool_t ContainsProcess(
const TString& processName)
const {
232 return ContainsProcessInVolume(processName, -1);
235 Bool_t ContainsParticle(
const TString& particleName)
const;
236 Bool_t ContainsParticleInVolume(
const TString& particleName, Int_t volumeID = -1)
const;
246 void PrintEvent(
int maxTracks = 0,
int maxHits = 0)
const;
247 void PrintEventFilterVolumes(
const std::set<std::string>& volumeNames)
const;
250 TPad*
DrawEvent(
const TString& option, Bool_t autoBoundaries);
264 void UpdateTrack(
const G4Track*);
265 void InsertStep(
const G4Step*);
267 friend class OutputManager;
271 std::map<Int_t, Int_t> fTrackIDToTrackIndex = {};
274 void AddEnergyInVolumeForParticleForProcess(Double_t energy,
const std::string& volumeName,
275 const std::string& particleName,
276 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.
TPad * DrawEvent(const TString &option="") override
Draw the event.
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
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.