1#include "TRestGeant4ParticleSourceCry.h"
7TRestGeant4ParticleSourceCry::TRestGeant4ParticleSourceCry() {}
22 RESTMetadata <<
" ======= " <<
RESTendl;
26 RESTMetadata <<
" ======= " <<
RESTendl;
32 RESTMetadata <<
" ======= " <<
RESTendl;
37 RESTMetadata <<
"----------------------" <<
RESTendl;
67 std::string setupString =
"";
81 setupString +=
" date " +
fDate;
89 CRYSetup* setup =
new CRYSetup(setupString, CRY_DATA_PATH);
90 fCRYGenerator =
new CRYGenerator(setup);
103 std::vector<CRYParticle*>* ev =
new std::vector<CRYParticle*>;
105 fCRYGenerator->genEvent(ev);
110 for (
const auto& cryParticle : *ev) {
120 particle.SetParticleCharge(cryParticle->charge());
121 particle.SetExcitationLevel(0);
124 TVector3 position(cryParticle->x(), cryParticle->y(), cryParticle->z());
125 particle.SetOrigin(1000. * position);
128 TVector3 momDirection(cryParticle->u(), cryParticle->v(), cryParticle->w());
129 momDirection = momDirection.Unit();
130 particle.SetDirection(momDirection);
133 particle.SetEnergy(1000. * cryParticle->ke());
145 int id = cryParticle->id();
146 if (
id == 0) particle.SetParticleName(
"neutron");
147 if (
id == 1) particle.SetParticleName(
"proton");
149 if (cryParticle->charge() > 0)
150 particle.SetParticleName(
"pi+");
151 else if (cryParticle->charge() == 0)
152 particle.SetParticleName(
"pi0");
153 else if (cryParticle->charge() < 0)
154 particle.SetParticleName(
"pi-");
157 if (cryParticle->charge() > 0)
158 particle.SetParticleName(
"kaon+");
159 else if (cryParticle->charge() == 0)
160 particle.SetParticleName(
"kaon0");
161 else if (cryParticle->charge() < 0)
162 particle.SetParticleName(
"kaon-");
165 if (cryParticle->charge() > 0)
166 particle.SetParticleName(
"mu+");
167 else if (cryParticle->charge() < 0)
168 particle.SetParticleName(
"mu-");
171 if (cryParticle->charge() > 0)
172 particle.SetParticleName(
"e+");
173 else if (cryParticle->charge() < 0)
174 particle.SetParticleName(
"e-");
176 if (
id == 6) particle.SetParticleName(
"gamma");
178 AddParticle(particle);
182 cout <<
"TRestGeant4ParticleSourceCry - ERROR: Geant4lib was not linked to CRY libraries" << endl;
184 cout <<
"Please, compile REST using `cmake -DREST_CRY_PATH=/path/to/cry/installation/directory" << endl;
187 <<
"By default CRY libraries will generate just the static library, but REST needs the shared library"
189 cout <<
"In order to generate the SHARED object from the STATIC libCRY.a object, execute the following "
192 cout <<
"inside the CRY lib directory" << endl;
194 cout <<
"```" << endl;
195 cout <<
"gcc -shared -o libCRY.so -Wl,--whole-archive libCRY.a -Wl,--no-whole-archive" << endl;
196 cout <<
"```" << endl;
Int_t fReturnPions
It defines if secondary electrons will be produced by the generator.
std::string fDate
It will adjust the cosmic-ray distributions to the 11-year solar cycle.
Double_t fZOffset
This is likely the Z-coordinate where the box of generated particles is centered.
void PrintMetadata() override
It will print on screen the settings used for the CRY generator setup.
Int_t fReturnKaons
It defines if secondary pions will be produced by the generator.
Int_t fReturnNeutrons
It defines if secondary neutrons will be produced by the generator.
Double_t fXOffset
This is likely the X-coordinate where the box of generated particles is centered.
void Update() override
It is used by restG4 PrimaryGeneratorAction to update the particle source.
void InitFromConfigFile() override
Initialization of TRestGeant4ParticleSourceCry members through a RML file.
Double_t fLatitude
The allowed range is -90 to 90. 0 defines the magnetic equator.
Double_t fYOffset
This is likely the Y-coordinate where the box of generated particles is centered.
Int_t fNParticlesMax
Showers with number of particles above this number will be truncated.
Double_t fSubBoxLength
The size of the box where the CRY generator produces particles (in m).
Int_t fReturnMuons
It defines if secondary muons will be produced by the generator.
Int_t fReturnProtons
It defines if secondary protons will be produced by the generator.
Int_t fNParticlesMin
Showers with number of particles below this number will be truncated.
Int_t fReturnElectrons
It defines if secondary gammas will be produced by the generator.
Int_t fReturnGammas
It defines if secondary photons will be produced by the generator.
Double_t fAltitude
Allowed values are 0, 2100 and 11300 m.
virtual void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
A class used to store particle properties.
std::string IntegerToString(Int_t n, std::string format="%d")
Gets a string from an integer.
Double_t StringToDouble(std::string in)
Gets a double from a string.
Int_t StringToInteger(std::string in)
Gets an integer from a string.
std::string DoubleToString(Double_t d, std::string format="%8.6e")
Gets a string from a double.
std::string Replace(std::string in, std::string thisString, std::string byThisString, size_t fromPosition=0, Int_t N=0)
Replace any occurences of thisSring by byThisString inside string in.