From fcbdc99f34f9b01fdac69b43125e4968e52628ae Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Fri, 17 May 2024 11:44:49 +0200 Subject: [PATCH 1/2] add fullChainStopIsotopes parameter --- inc/TRestGeant4Metadata.h | 15 +++++++++------ src/TRestGeant4Metadata.cxx | 12 +++++++++++- 2 files changed, 20 insertions(+), 7 deletions(-) diff --git a/inc/TRestGeant4Metadata.h b/inc/TRestGeant4Metadata.h index cffe64e..ea7195b 100644 --- a/inc/TRestGeant4Metadata.h +++ b/inc/TRestGeant4Metadata.h @@ -117,6 +117,9 @@ class TRestGeant4Metadata : public TRestMetadata { /// (fFullChain=true), or just a single decay (fFullChain=false). Bool_t fFullChain = true; + /// \brief If defined, it will stop the full chain decay simulation when one of these isotope appears. + std::set fFullChainStopIsotopes; + /// \brief The volume that serves as trigger for data storage. Only events that /// deposit a non-zero energy on this volume will be registered. std::vector fSensitiveVolumes; @@ -242,23 +245,23 @@ class TRestGeant4Metadata : public TRestMetadata { inline void SetFullChain(Bool_t fullChain) { fFullChain = fullChain; } /// It sets the location of the geometry files - inline void SetGeometryPath(std::string path) { fGeometryPath = path; } + inline void SetGeometryPath(const std::string& path) { fGeometryPath = path; } /// It sets the main filename to be used for the GDML geometry - inline void SetGdmlFilename(std::string gdmlFile) { fGdmlFilename = gdmlFile; } + inline void SetGdmlFilename(const std::string& gdmlFile) { fGdmlFilename = gdmlFile; } /// Returns the reference provided at the GDML file header - inline void SetGdmlReference(std::string reference) { fGdmlReference = reference; } + inline void SetGdmlReference(const std::string& reference) { fGdmlReference = reference; } /// Returns the reference provided at the materials file header - inline void SetMaterialsReference(std::string reference) { fMaterialsReference = reference; } + inline void SetMaterialsReference(const std::string& reference) { fMaterialsReference = reference; } /// Returns the number of events to be simulated. inline Long64_t GetNumberOfEvents() const { return fNEvents; } inline Long64_t GetNumberOfRequestedEntries() const { return fNRequestedEntries; } - inline Int_t GetSimulationMaxTimeSeconds() const { return fSimulationMaxTimeSeconds; } + inline Double_t GetSimulationMaxTimeSeconds() const { return fSimulationMaxTimeSeconds; } inline Double_t GetSimulationTime() const { return fSimulationTime; } @@ -398,7 +401,7 @@ class TRestGeant4Metadata : public TRestMetadata { TRestGeant4Metadata(const TRestGeant4Metadata& metadata); TRestGeant4Metadata& operator=(const TRestGeant4Metadata& metadata); - ClassDefOverride(TRestGeant4Metadata, 17); + ClassDefOverride(TRestGeant4Metadata, 18); // Allow modification of otherwise inaccessible / immutable members that shouldn't be modified by the user friend class SteppingAction; diff --git a/src/TRestGeant4Metadata.cxx b/src/TRestGeant4Metadata.cxx index 5b55282..40273d6 100644 --- a/src/TRestGeant4Metadata.cxx +++ b/src/TRestGeant4Metadata.cxx @@ -219,7 +219,7 @@ /// \endcode /// /// * **cosmic**: This is a special type of generator that is used to simulate cosmic particles. -/// It takes no parameters. It uses the world size to produce an homogeneous cosmic ray flux (according to +/// It takes no parameters. It uses the world size to produce an accurate cosmic ray flux (according to /// energy and angular distribution, which can be correlated) in the whole world volume. It is recommended to /// use this instead of other approaches such as an infinite plane above as this generator will be /// significantly more efficient since all particles are directed roughly towards the detector. @@ -736,6 +736,7 @@ #include #include +#include #include #include #include @@ -1103,6 +1104,15 @@ void TRestGeant4Metadata::ReadParticleSource(TRestGeant4ParticleSource* source, SetFullChain(true); } + TString fullChainStopIsotopesString = GetParameter("fullChainStopIsotopes", sourceDefinition, ""); + if (fullChainStopIsotopesString != "") { + TObjArray* fullChainStopIsotopesArray = fullChainStopIsotopesString.Tokenize(","); + for (int i = 0; i < fullChainStopIsotopesArray->GetEntries(); i++) { + TString isotope = ((TObjString*)fullChainStopIsotopesArray->At(i))->String(); + fFullChainStopIsotopes.insert(isotope.Data()); + } + } + // Angular distribution parameters TiXmlElement* angularDefinition = GetElement("angular", sourceDefinition); if (angularDefinition == nullptr) { From 7679256b9e913240fe125f2c4c5a5429a686e6da Mon Sep 17 00:00:00 2001 From: Luis Antonio Obis Aparicio Date: Fri, 17 May 2024 11:51:22 +0200 Subject: [PATCH 2/2] skip track if isotope in the ignore list --- inc/TRestGeant4Metadata.h | 10 ++++++++-- src/TRestGeant4Metadata.cxx | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/inc/TRestGeant4Metadata.h b/inc/TRestGeant4Metadata.h index ea7195b..f9f6c33 100644 --- a/inc/TRestGeant4Metadata.h +++ b/inc/TRestGeant4Metadata.h @@ -213,8 +213,14 @@ class TRestGeant4Metadata : public TRestMetadata { /// \brief Returns true in case full decay chain simulation is enabled. inline Bool_t isFullChainActivated() const { return fFullChain; } - /// \brief Returns the value of the maximum Geant4 step size in mm for the - /// target volume. + /// \brief Returns the isotopes that will stop the full chain decay simulation. + inline std::set GetFullChainStopIsotopes() const { return fFullChainStopIsotopes; } + + inline Bool_t IsIsotopeFullChainStop(const std::string& isotope) const { + return fFullChainStopIsotopes.count(isotope) > 0; + } + + /// \brief Returns the value of the maximum Geant4 step size in mm for the target volume. inline Double_t GetMaxTargetStepSize() const { return fMaxTargetStepSize; } /// \brief Returns the time gap, in us, required to consider a Geant4 hit as a diff --git a/src/TRestGeant4Metadata.cxx b/src/TRestGeant4Metadata.cxx index 40273d6..527b890 100644 --- a/src/TRestGeant4Metadata.cxx +++ b/src/TRestGeant4Metadata.cxx @@ -1104,7 +1104,7 @@ void TRestGeant4Metadata::ReadParticleSource(TRestGeant4ParticleSource* source, SetFullChain(true); } - TString fullChainStopIsotopesString = GetParameter("fullChainStopIsotopes", sourceDefinition, ""); + const TString fullChainStopIsotopesString = GetParameter("fullChainStopIsotopes", sourceDefinition, ""); if (fullChainStopIsotopesString != "") { TObjArray* fullChainStopIsotopesArray = fullChainStopIsotopesString.Tokenize(","); for (int i = 0; i < fullChainStopIsotopesArray->GetEntries(); i++) {