REST-for-Physics  v2.3
Rare Event Searches ToolKit for Physics
Public Member Functions | Protected Member Functions | Protected Attributes | Private Member Functions | Private Attributes | Friends
TRestGeant4Event Class Reference

Detailed Description

An event class to store geant4 generated event information.

Definition at line 47 of file TRestGeant4Event.h.

#include <TRestGeant4Event.h>

Inheritance diagram for TRestGeant4Event:
TRestEvent

Public Member Functions

void ActivateVolumeForStorage (Int_t n)
 
void AddActiveVolume (const std::string &volumeName)
 
void AddEnergyToSensitiveVolume (Double_t en)
 
 ClassDefOverride (TRestGeant4Event, 8)
 
void ClearVolumes ()
 
Bool_t ContainsParticle (const TString &particleName) const
 
Bool_t ContainsParticleInVolume (const TString &particleName, Int_t volumeID=-1) const
 
Bool_t ContainsProcess (const TString &processName) const
 
Bool_t ContainsProcess (Int_t processID) const
 
Bool_t ContainsProcessInVolume (const TString &processName, Int_t volumeID=-1) const
 
Bool_t ContainsProcessInVolume (Int_t processID, Int_t volumeID=-1) const
 
void DisableVolumeForStorage (Int_t n)
 
TPad * DrawEvent (const TString &option, Bool_t autoBoundaries)
 This method draws the geant4 event that it is available at the moment in memory. It uses TGraph and TH2D ROOT drawing objects. This method generates a drawing TPad with enough divisions to host all the options given by argument. More...
 
TPad * DrawEvent (const TString &option="") override
 Draw the event. More...
 
Double_t GetBoundingBoxSize ()
 This method returns the event size as the size of the bounding box enclosing all hits.
 
Double_t GetEnergyDepositedByParticle (const TString &particleName) const
 
Double_t GetEnergyInVolume (const std::string &volumeName) const
 
std::map< std::string, double > GetEnergyInVolumeMap () const
 
std::map< std::string, std::map< std::string, double > > GetEnergyInVolumePerParticleMap () const
 
std::map< std::string, std::map< std::string, std::map< std::string, double > > > GetEnergyInVolumePerParticlePerProcessMap () const
 
std::map< std::string, std::map< std::string, double > > GetEnergyInVolumePerProcessMap () const
 
std::map< std::string, double > GetEnergyPerParticleMap () const
 
std::map< std::string, double > GetEnergyPerProcessMap () const
 
TVector3 GetFirstPositionInVolume (Int_t volID) const
 Function to get the position (TVector3) of the first track that deposits energy in specified volume. If no hit is found for the volume, returns TVector3(nan, nan, nan) vector. More...
 
const TRestGeant4MetadataGetGeant4Metadata () const
 
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 argument only the hits of that specific volume will be added to the TRestHits returned object.
 
TRestHits GetHitsInVolume (Int_t volID) const
 
TVector3 GetLastPositionInVolume (Int_t volID) const
 Function to get the position (TVector3) of the last track that deposits energy in specified volume. If no hit is found for the volume, returns TVector3(nan, nan, nan) vector. If an event enters and exits a volume multiple times this will only return the last exit position, one needs to keep this in mind when using this observable. More...
 
Int_t GetLowestTrackID () const
 
TVector3 GetMeanPositionInVolume (Int_t volID) const
 
Int_t GetNumberOfActiveVolumes () const
 
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 argument only the hits of that specific volume will be counted.
 
size_t GetNumberOfPhysicalHits (Int_t volID=-1) const
 Function that returns the total number of hits with energy > 0 in the Geant4 event. If a specific volume is given as argument only the hits of that specific volume will be counted.
 
size_t GetNumberOfPrimaries () const
 
size_t GetNumberOfTracks () const
 
Int_t GetNumberOfTracksForParticle (const TString &particleName) const
 
TVector3 GetPositionDeviationInVolume (Int_t volID) const
 A method that gets the standard deviation from the hits happening at a particular volumeId inside the geometry. More...
 
TVector3 GetPrimaryEventDirection (size_t n=0) const
 
Double_t GetPrimaryEventEnergy (size_t n=0) const
 
TVector3 GetPrimaryEventOrigin () const
 
TString GetPrimaryEventParticleName (size_t n=0) const
 
Double_t GetSensitiveVolumeEnergy () const
 
TVector3 GetSubEventPrimaryEventDirection () const
 
Double_t GetSubEventPrimaryEventEnergy () const
 
TVector3 GetSubEventPrimaryEventOrigin () const
 
TString GetSubEventPrimaryEventParticleName () const
 
Double_t GetTotalDepositedEnergy () const
 
const TRestGeant4TrackGetTrack (int n) const
 
TRestGeant4TrackGetTrackByID (Int_t trackID) const
 
TRestGeant4TrackGetTrackPointer (int n)
 
const std::vector< TRestGeant4Track > & GetTracks () const
 
std::set< std::string > GetUniqueParticles () const
 
void Initialize () override
 
void InitializeReferences (TRestRun *run) override
 Initialize dynamical references when loading the event from a root file. More...
 
void InsertStep (const G4Step *)
 
bool InsertTrack (const G4Track *)
 // Implemented in restG4
 
Bool_t IsSubEvent () const
 
Int_t isVolumeStored (int n) const
 
void PrintActiveVolumes () const
 maxTracks : number of tracks to print, 0 = all
 
void PrintEvent (int maxTracks=0, int maxHits=0) const
 
void SetBoundaries ()
 
void SetBoundaries (Double_t xMin, Double_t xMax, Double_t yMin, Double_t yMax, Double_t zMin, Double_t zMax)
 
void SetEnergyDepositedInVolume (Int_t volID, Double_t eDep)
 
void SetSensitiveVolumeEnergy (Double_t en)
 
 TRestGeant4Event (const G4Event *)
 
void UpdateTrack (const G4Track *)
 
- Public Member Functions inherited from TRestEvent
virtual void CloneTo (TRestEvent *target)
 Clone the content of this TRestEvent object to another. More...
 
Int_t GetID () const
 
Int_t GetRunOrigin () const
 
TString GetSubEventTag () const
 
Int_t GetSubID () const
 
Int_t GetSubRunOrigin () const
 
Double_t GetTime () const
 
TTimeStamp GetTimeStamp () const
 
virtual void InitializeWithMetadata (TRestRun *run)
 
Bool_t isOk () const
 
virtual void PrintEvent () const
 
void SetEventInfo (TRestEvent *eve)
 
void SetID (Int_t id)
 
void SetOK (Bool_t state)
 
void SetRunOrigin (Int_t run_origin)
 
void SetState (Bool_t state)
 
void SetSubEventTag (const TString &tag)
 
void SetSubID (Int_t id)
 
void SetSubRunOrigin (Int_t sub_run_origin)
 
void SetTime (Double_t seconds, Double_t nanoseconds)
 
void SetTime (Double_t time)
 
void SetTimeStamp (const TTimeStamp &time)
 
 TRestEvent ()
 
virtual ~TRestEvent ()
 

Protected Member Functions

TH1D * GetXHistogram (Int_t gridElement, std::vector< TString > optList)
 
TH2F * GetXYHistogram (Int_t gridElement, std::vector< TString > optList)
 
TMultiGraph * GetXYMultiGraph (Int_t gridElement, std::vector< TString > pcsList, Double_t minPointSize=0.4, Double_t maxPointSize=4)
 
TH2F * GetXZHistogram (Int_t gridElement, std::vector< TString > optList)
 
TMultiGraph * GetXZMultiGraph (Int_t gridElement, std::vector< TString > pcsList, Double_t minPointSize=0.4, Double_t maxPointSize=4)
 
TH1D * GetYHistogram (Int_t gridElement, std::vector< TString > optList)
 
TH2F * GetYZHistogram (Int_t gridElement, std::vector< TString > optList)
 
TMultiGraph * GetYZMultiGraph (Int_t gridElement, std::vector< TString > pcsList, Double_t minPointSize=0.4, Double_t maxPointSize=4)
 
TH1D * GetZHistogram (Int_t gridElement, std::vector< TString > optList)
 
- Protected Member Functions inherited from TRestEvent
void RestartPad (Int_t nElements)
 

Protected Attributes

std::map< std::string, std::map< std::string, std::map< std::string, double > > > fEnergyInVolumePerParticlePerProcess
 
TLegend * fLegend_XY
 
TLegend * fLegend_XZ
 
TLegend * fLegend_YZ
 
Int_t fNVolumes
 
std::vector< TVector3 > fPrimaryDirections
 
std::vector< Double_t > fPrimaryEnergies
 
std::vector< TString > fPrimaryParticleNames
 
TVector3 fPrimaryPosition
 
Double_t fSensitiveVolumeEnergy = 0
 
TVector3 fSubEventPrimaryDirection
 
Double_t fSubEventPrimaryEnergy
 
TString fSubEventPrimaryParticleName
 
TVector3 fSubEventPrimaryPosition
 
Double_t fTotalDepositedEnergy = 0
 
Int_t fTotalHits
 
std::vector< TRestGeant4TrackfTracks
 
std::vector< Double_t > fVolumeDepositedEnergy
 
std::vector< Int_t > fVolumeStored
 
std::vector< std::string > fVolumeStoredNames
 
TH1D * fXHisto
 
TH2F * fXYHisto
 
TGraph * fXYHitGraph
 
TMultiGraph * fXYMultiGraph
 
std::vector< TGraph * > fXYPcsMarker
 
TH2F * fXZHisto
 
TGraph * fXZHitGraph
 
TMultiGraph * fXZMultiGraph
 
std::vector< TGraph * > fXZPcsMarker
 
TH1D * fYHisto
 
TH2F * fYZHisto
 
TGraph * fYZHitGraph
 
TMultiGraph * fYZMultiGraph
 
std::vector< TGraph * > fYZPcsMarker
 
TH1D * fZHisto
 
std::vector< Int_t > legendAdded
 
- Protected Attributes inherited from TRestEvent
Int_t fEventID
 Event identification number.
 
TTimeStamp fEventTime
 Absolute event time.
 
Bool_t fOk
 Flag to be used by processes to define an event status. fOk=true is the default.
 
TPad * fPad
 
TRestRunfRun = nullptr
 
Int_t fRunOrigin
 Run ID number of the event.
 
Int_t fSubEventID
 Sub-Event identification number.
 
TString fSubEventTag
 A short length label to identify the sub-Event.
 
Int_t fSubRunOrigin
 Sub-run ID number of the event.
 

Private Member Functions

void AddEnergyDepositToVolume (Int_t volID, Double_t eDep)
 
void AddEnergyInVolumeForParticleForProcess (Double_t energy, const std::string &volumeName, const std::string &particleName, const std::string &processName)
 

Private Attributes

TRestGeant4Hits fInitialStep
 
Double_t fMaxEnergy
 
Double_t fMaxX
 
Double_t fMaxY
 
Double_t fMaxZ
 
Double_t fMinEnergy
 
Double_t fMinX
 
Double_t fMinY
 
Double_t fMinZ
 
std::map< Int_t, Int_t > fTrackIDToTrackIndex = {}
 

Friends

class OutputManager
 
class TRestGeant4QuenchingProcess
 

Member Function Documentation

◆ DrawEvent() [1/2]

TPad * TRestGeant4Event::DrawEvent ( const TString &  option,
Bool_t  autoBoundaries 
)

This method draws the geant4 event that it is available at the moment in memory. It uses TGraph and TH2D ROOT drawing objects. This method generates a drawing TPad with enough divisions to host all the options given by argument.

This method receives an optional argument as string that allows to control which plots are generated. Different options can be passed to the string separated by the options using colons, as "option1:option2:option3". Each option will generate a new independent drawing pad.

The following options are allowed:

  1. histX,Y,Z: It generates a 1-dimensional TH1D histogram with the projected event hits at the corresponding axis, the bins are weighted with their correspoding energy. Histograms will accept as argument, between parenthesis, a conventional ROOT option, i.e. histX(rootOption), where rootOption is any valid ROOT option as described by the THistPainter ROOT class. On top of that, we may pass additional options using the [ ] to change the default binning size, which is set to 3, or draw the stats box, i.e. histX(Cont0,colz)[binSize=1,stats].
  2. histXY,XZ,YZ: It generates a bi-dimensional TH2D histogram with the projected event hits at the corresponding plane, the bins are weighted with their corresponding energy. Histograms will accept as argument, between parenthesis, a conventional ROOT option, i.e. histX(rootOption), where rootOption is any valid ROOT option as described by the THistPainter ROOT class. On top of that, we may pass additional options using the [ ] to change the default binning size, which is set to 3, or draw the stats box, i.e. histXY(Cont0,colz)[binSize=1,stats].
  3. graphXY,XZ,YZ: It generates a bi-dimensional TH2D histogram with the projected event hits at the corresponding plane, the bins are weighted with their corresponding energy. We may specify physical Geant4 processes such as photoeletric or Compton, existing at the Geant4 processes list, you may check the process names at the TRestGeant4Track source implementation, till we get a better way of storing the processes list or retrieve them directly from Geant4. Specifying a physical process between square brackets [ ] will mark those hits at the event drawing pad that match those given at the argument, i.e. graphXY[eBrem,phot,compt].
  4. print: Prints in the screen terminal the output of the TRestGeant4Event::PrintEvent method. This option will not generate a new drawing pad.

Example 1:

DrawEvent("graphXY[eBrem,phot,compt]:graphXZ[eIoni,annihil]")
TPad * DrawEvent(const TString &option="") override
Draw the event.

Example 2:

DrawEvent("histX[binSize=1]:histY[binSize=2]:histZ[binSize=3]");

If not argument is given, the default option list is equivalent to execute the following:

DrawEvent("graphXZ:graphYZ:histXZ(Cont0,colz):histYZ(Cont0,colz)")

Definition at line 1020 of file TRestGeant4Event.cxx.

◆ DrawEvent() [2/2]

TPad* TRestGeant4Event::DrawEvent ( const TString &  option = "")
inlineoverridevirtual

Draw the event.

To be implemented in the derived class

Reimplemented from TRestEvent.

Definition at line 238 of file TRestGeant4Event.h.

◆ GetFirstPositionInVolume()

TVector3 TRestGeant4Event::GetFirstPositionInVolume ( Int_t  volID) const

Function to get the position (TVector3) of the first track that deposits energy in specified volume. If no hit is found for the volume, returns TVector3(nan, nan, nan) vector.

Parameters
volIDInt_t specifying volume ID

Definition at line 166 of file TRestGeant4Event.cxx.

◆ GetLastPositionInVolume()

TVector3 TRestGeant4Event::GetLastPositionInVolume ( Int_t  volID) const

Function to get the position (TVector3) of the last track that deposits energy in specified volume. If no hit is found for the volume, returns TVector3(nan, nan, nan) vector. If an event enters and exits a volume multiple times this will only return the last exit position, one needs to keep this in mind when using this observable.

Parameters
volIDInt_t specifying volume ID

Definition at line 183 of file TRestGeant4Event.cxx.

◆ GetPositionDeviationInVolume()

TVector3 TRestGeant4Event::GetPositionDeviationInVolume ( Int_t  volID) const

A method that gets the standard deviation from the hits happening at a particular volumeId inside the geometry.

Parameters
volIDInt_t specifying volume ID

Definition at line 135 of file TRestGeant4Event.cxx.

◆ Initialize()

void TRestGeant4Event::Initialize ( )
overridevirtual

Run to initialize event data. To be re-implemented in derived class, you may want to call the base class at the end of the re-implemented, by calling TRestEvent::Initialize();

Implements TRestEvent.

Definition at line 43 of file TRestGeant4Event.cxx.

◆ InitializeReferences()

void TRestGeant4Event::InitializeReferences ( TRestRun run)
overridevirtual

Initialize dynamical references when loading the event from a root file.

This method should only be called from TRestRun::GetEntry and it will give the corresponding TRestEvent access to the instance of TRestRun. In a derived class such as TRestGeant4Event, it can be overwritten to give each track access to the event

Reimplemented from TRestEvent.

Definition at line 1219 of file TRestGeant4Event.cxx.


The documentation for this class was generated from the following files: