32 fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
33 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
77 G4cerr <<
"Not valid mode! Standard mode is selected!" << G4endl;
91 G4ThreeVector pos(0., 0., 0.);
95 G4double fCosThetaMax = std::cos(fThetaMax);
97 G4double cosTheta = 1-G4UniformRand()*(1-fCosThetaMax);
98 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
99 G4double phi = CLHEP::twopi*G4UniformRand();
101 G4double ux = sinTheta*std::cos(phi);
102 G4double uy = sinTheta*std::sin(phi);
103 G4double uz = cosTheta;
105 G4ThreeVector mom(ux, uy, uz);
117 G4double posPhi = CLHEP::twopi*G4UniformRand();
119 G4ThreeVector pos(posR*std::cos(posPhi), posR*std::sin(posPhi), 0);
122 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
130 G4ParticleDefinition *particle = G4ParticleTable::GetParticleTable()->FindParticle(
"gamma");
154 G4ThreeVector posLed;
155 G4ThreeVector momLed;
163 G4cerr <<
"Option for detector face not valid. 'Front' has been setted" << G4endl;
174 G4cerr <<
"Option for LED not valid. 'up' has been setted" << G4endl;
180 G4double cosTheta = 2*G4UniformRand() - 1.;
181 G4double phi = CLHEP::twopi*G4UniformRand();
182 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
183 G4double ux = sinTheta*std::cos(phi);
184 G4double uy = sinTheta*std::sin(phi);
185 G4double uz = cosTheta;
186 momLed = G4ThreeVector(ux,uy,uz);
189 G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle(
"opticalphoton");
199 G4ThreeVector posDecay;
200 G4ThreeVector momDecay;
201 G4double posZ, posR, posPhi;
209 posPhi = CLHEP::twopi*G4UniformRand();
210 posDecay = G4ThreeVector(posR*std::cos(posPhi), posR*std::sin(posPhi), posZ);
224 G4double cosTheta = 2*G4UniformRand() - 1.;
225 G4double phi = CLHEP::twopi*G4UniformRand();
226 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
227 G4double ux = sinTheta*std::cos(phi);
228 G4double uy = sinTheta*std::sin(phi);
229 G4double uz = cosTheta;
231 momDecay = G4ThreeVector(ux,uy,uz);
234 G4int Z = 71, A = 176;
235 G4ParticleDefinition* ion = G4IonTable::GetIonTable()->GetIon(Z, A, 0.*keV);
247 G4ThreeVector posRay;
248 G4ThreeVector momRay;
251 G4double posX = GS::xCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
252 G4double posY = GS::yCosmicRayDetector + GS::halfYsideCosmicRayDetector;
253 G4double posZ = GS::zCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
255 posRay = G4ThreeVector(posX, posY, posZ);
258 G4double cosTheta = -G4UniformRand();
259 G4double cosThetaa = G4UniformRand();
260 G4double phi = CLHEP::twopi*G4UniformRand();
261 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
262 G4double uz = sinTheta*std::cos(phi);
263 G4double ux = sinTheta*std::sin(phi);
264 G4double uy = cosTheta;
266 momRay = G4ThreeVector(ux, uy, uz);
268 while(std::abs(ProjectOnBottomDetector(posRay, momRay).x() - GS::xCosmicRayDetector) > GS::halfZXsideCosmicRayDetector || std::abs(ProjectOnBottomDetector(posRay, momRay).z() - GS::zCosmicRayDetector) > GS::halfZXsideCosmicRayDetector)
270 posX = GS::xCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
271 posZ = GS::zCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
273 posRay = G4ThreeVector(posX, posY, posZ);
275 cosTheta = -G4UniformRand();
276 cosThetaa = G4UniformRand();
277 phi = CLHEP::twopi*G4UniformRand();
278 while(cosThetaa > (cosTheta*cosTheta))
280 cosTheta = -G4UniformRand();
281 cosThetaa = G4UniformRand();
283 phi = CLHEP::twopi*G4UniformRand();
285 sinTheta = std::sqrt(1. - cosTheta*cosTheta);
286 uz = sinTheta*std::cos(phi);
287 ux = sinTheta*std::sin(phi);
290 momRay = G4ThreeVector(ux, uy, uz);
295 G4double energy = 999.;
296 G4double energyy = 1.;
298 G4double emax = 1.*TeV;
300 while(energyy > PDF_E_CosmicRay(energy))
302 energy = emin + emax*G4UniformRand();
304 energyy = PDF_E_CosmicRay(emin)*G4UniformRand();
308 G4ParticleDefinition* particle =
nullptr;
309 if(G4UniformRand() < 0.5)
310 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu-");
312 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu+");
321 G4double MyPrimaryGenerator::PDF_E_CosmicRay(G4double energy)
325 return std::pow(3.4*GeV, -2.7);
329 return std::pow(energy, -2.7);
335 G4ThreeVector MyPrimaryGenerator::ProjectOnBottomDetector(G4ThreeVector pos0, G4ThreeVector mom0)
337 G4double y_b = -(GS::yCosmicRayDetector + GS::halfYsideCosmicRayDetector);
339 G4double t = (y_b - pos0.y())/mom0.y();
341 x_b = pos0.x() + mom0.x()*t;
342 z_b = pos0.z() + mom0.z()*t;
344 return G4ThreeVector(x_b, y_b, z_b);
352 fMessenger_Mode =
new G4GenericMessenger(
this,
"/MC_LYSO/",
"Commands for MC_LYSO run");
353 fMessenger_Mode->DeclareProperty(
"Mode",
fModeType,
"Available modes are: 10 = Standard with pointlike beam, 11 = Standard with spread beam, 12 = Standard with circle beam, 20 = Lu decay, 21 = Lu decay with fixed position, 22 = Lu decay with Si trigger test, 30 = Cosmic Rays, 40 = LED-system");
356 fMessenger_Gun =
new G4GenericMessenger(
this,
"/MC_LYSO/myGun/",
"Cinematical settings for primary particle");
357 fMessenger_Gun->DeclarePropertyWithUnit(
"meanEnergy",
"MeV",
fMeanEnergy,
"Mean of the gaussian distribution of initial gamma energy");
358 fMessenger_Gun->DeclarePropertyWithUnit(
"sigmaEnergy",
"MeV",
fSigmaEnergy,
"Sigma of the gaussian distribution of initial gamma energy");
359 fMessenger_Gun->DeclarePropertyWithUnit(
"radiusSpread",
"mm",
fRadiusSpread,
"Set radius of the spread on the front face of scintillator");
364 fMessenger_Calib =
new G4GenericMessenger(
this,
"/MC_LYSO/myGun/LED-System/",
"Settings for LED-system calibration");
G4double fRadiusSpread
Radius of the area on the front face of the crystal that could be hit by primary gamma when spread is...
void PrimariesForSpreadBeam()
Generate primaries auxiliary function for spread beam.
void PrimariesForCosmicRaysMode()
Generate primaries auxiliary function for Cosmic rays mode.
G4double fSigmaEnergy
Sigma of the gaussian distribution of the energy of the primary particle.
void PrimariesForLuDecayMode()
Generate primaries auxiliary function for Lu decay mode.
G4GenericMessenger * fMessenger_Calib
Generic messenger for the calibration mode.
G4GenericMessenger * fMessenger_Mode
Generic messenger for mode selection.
void PrimariesForStandardMode()
Generate primaries auxiliary function for Standard mode.
G4double fRadiusCircle
Radius of the beam profile in circle type.
G4double fMeanEnergy
Mean of the gaussian distribution of the energy of the primary particle.
MyPrimaryGenerator()
Constructor of the class.
G4String fChooseFrontorBack
Flag indicating on which face of the crystal a LED has to be switched ON.
G4int fModeType
Flag indicating the mode type.
void PrimariesForCircleBeam()
Generate primaries auxiliary function for circle beam.
void GeneratePrimaries(G4Event *anEvent) override
It generates the primary vertex of the event.
G4ParticleGun * fParticleGun
Pointer to the G4ParticleGun object.
G4GenericMessenger * fMessenger_Gun
Generic messenger for the standard gamma mode.
~MyPrimaryGenerator() override
Destructor of the class.
G4String fSwitchOnLED
Flag indicating which LED has to be switched ON.
G4ThreeVector fPosFixedDecay
Position of 176Lu isotope for fixed-position mode.
void DefineCommands()
Defines new user commands for primary particle generation.
void PrimariesForLEDMode()
Generate primaries auxiliary function for LED mode.
Declaration of the class MyPrimaryGenerator.
constexpr G4double zScintillator
z-position of the scintillator crystal.
constexpr G4double radiusScintillator
Radius of the scintillator crystal.
constexpr G4double zBackFaceScintillator
z-position of the back face of the scintillator crystal.
constexpr G4double zFrontFaceScintillator
z-position of the front face of the scintillator crystal.
constexpr G4double halfheightLightGuide
Half the height of the light guide.
constexpr G4double radiusLightGuide
Radius of the light guide.
constexpr G4double halfheightScintillator
Half the height of the scintillator crystal.
constexpr G4double energyLED
Energy of the optical photons emitted by the LED.
constexpr G4double depthLED
Depth of the LED inside the hole.