32 fParticleGun->SetParticlePosition(G4ThreeVector(0., 0., 0.));
33 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
71 PrimariesForCountingCosmicRaysMode();
79 G4cerr <<
"Not valid mode! Standard mode is selected!" << G4endl;
93 G4ThreeVector pos(0., 0., 0.);
97 G4double fCosThetaMax = std::cos(fThetaMax);
99 G4double cosTheta = 1-G4UniformRand()*(1-fCosThetaMax);
100 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
101 G4double phi = CLHEP::twopi*G4UniformRand();
103 G4double ux = sinTheta*std::cos(phi);
104 G4double uy = sinTheta*std::sin(phi);
105 G4double uz = cosTheta;
107 G4ThreeVector mom(ux, uy, uz);
119 G4double posPhi = CLHEP::twopi*G4UniformRand();
121 G4ThreeVector pos(posR*std::cos(posPhi), posR*std::sin(posPhi), 0);
124 fParticleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
132 G4ParticleDefinition *particle = G4ParticleTable::GetParticleTable()->FindParticle(
"gamma");
156 G4ThreeVector posLed;
157 G4ThreeVector momLed;
165 G4cerr <<
"Option for detector face not valid. 'Front' has been setted" << G4endl;
176 G4cerr <<
"Option for LED not valid. 'up' has been setted" << G4endl;
182 G4double cosTheta = 2*G4UniformRand() - 1.;
183 G4double phi = CLHEP::twopi*G4UniformRand();
184 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
185 G4double ux = sinTheta*std::cos(phi);
186 G4double uy = sinTheta*std::sin(phi);
187 G4double uz = cosTheta;
188 momLed = G4ThreeVector(ux,uy,uz);
191 G4ParticleDefinition* particle = G4ParticleTable::GetParticleTable()->FindParticle(
"opticalphoton");
201 G4ThreeVector posDecay;
202 G4ThreeVector momDecay;
203 G4double posZ, posR, posPhi;
211 posPhi = CLHEP::twopi*G4UniformRand();
212 posDecay = G4ThreeVector(posR*std::cos(posPhi), posR*std::sin(posPhi), posZ);
226 G4double cosTheta = 2*G4UniformRand() - 1.;
227 G4double phi = CLHEP::twopi*G4UniformRand();
228 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
229 G4double ux = sinTheta*std::cos(phi);
230 G4double uy = sinTheta*std::sin(phi);
231 G4double uz = cosTheta;
233 momDecay = G4ThreeVector(ux,uy,uz);
236 G4int Z = 71, A = 176;
237 G4ParticleDefinition* ion = G4IonTable::GetIonTable()->GetIon(Z, A, 0.*keV);
249 G4ThreeVector posRay;
250 G4ThreeVector momRay;
253 G4double posX = GS::xCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
254 G4double posY = GS::yCosmicRayDetector + GS::halfYsideCosmicRayDetector;
255 G4double posZ = GS::zCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
257 posRay = G4ThreeVector(posX, posY, posZ);
260 G4double cosTheta = -G4UniformRand();
261 G4double cosThetaa = G4UniformRand();
262 G4double phi = CLHEP::twopi*G4UniformRand();
263 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
264 G4double uz = sinTheta*std::cos(phi);
265 G4double ux = sinTheta*std::sin(phi);
266 G4double uy = cosTheta;
268 momRay = G4ThreeVector(ux, uy, uz);
270 while(std::abs(ProjectOnBottomDetector(posRay, momRay).x() - GS::xCosmicRayDetector) > GS::halfZXsideCosmicRayDetector || std::abs(ProjectOnBottomDetector(posRay, momRay).z() - GS::zCosmicRayDetector) > GS::halfZXsideCosmicRayDetector)
272 posX = GS::xCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
273 posZ = GS::zCosmicRayDetector + 2*(G4UniformRand()-0.5)*GS::halfZXsideCosmicRayDetector;
275 posRay = G4ThreeVector(posX, posY, posZ);
277 cosTheta = -G4UniformRand();
278 cosThetaa = G4UniformRand();
279 phi = CLHEP::twopi*G4UniformRand();
280 while(cosThetaa > (cosTheta*cosTheta))
282 cosTheta = -G4UniformRand();
283 cosThetaa = G4UniformRand();
285 phi = CLHEP::twopi*G4UniformRand();
287 sinTheta = std::sqrt(1. - cosTheta*cosTheta);
288 uz = sinTheta*std::cos(phi);
289 ux = sinTheta*std::sin(phi);
292 momRay = G4ThreeVector(ux, uy, uz);
297 G4double energy = 999.;
298 G4double energyy = 1.;
300 G4double emax = 1.*TeV;
302 while(energyy > PDF_E_CosmicRay(energy))
304 energy = emin + emax*G4UniformRand();
306 energyy = PDF_E_CosmicRay(emin)*G4UniformRand();
310 G4ParticleDefinition* particle =
nullptr;
311 if(G4UniformRand() < 0.5)
312 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu-");
314 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu+");
323 void MyPrimaryGenerator::PrimariesForCountingCosmicRaysMode()
325 G4ThreeVector posRay;
326 G4ThreeVector momRay;
329 G4double posX = GS::xCosmicRayDetector + (G4UniformRand()-0.5) * 10*cm;
330 G4double posY = GS::yCosmicRayDetector + GS::halfYsideCosmicRayDetector;
331 G4double posZ = GS::zCosmicRayDetector + (G4UniformRand()-0.5) * 10*cm;
333 posRay = G4ThreeVector(posX, posY, posZ);
336 G4double cosTheta = -G4UniformRand();
337 G4double cosThetaa = G4UniformRand();
338 while(cosThetaa > (cosTheta*cosTheta))
340 cosTheta = -G4UniformRand();
341 cosThetaa = G4UniformRand();
344 G4double phi = CLHEP::twopi*G4UniformRand();
345 G4double sinTheta = std::sqrt(1. - cosTheta*cosTheta);
346 G4double uz = sinTheta*std::cos(phi);
347 G4double ux = sinTheta*std::sin(phi);
348 G4double uy = cosTheta;
350 momRay = G4ThreeVector(ux, uy, uz);
353 G4double energy = 999.;
354 G4double energyy = 1.;
356 G4double emax = 1.*TeV;
358 while(energyy > PDF_E_CosmicRay(energy))
360 energy = emin + emax*G4UniformRand();
362 energyy = PDF_E_CosmicRay(emin)*G4UniformRand();
366 G4ParticleDefinition* particle =
nullptr;
367 if(G4UniformRand() < 0.5)
368 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu-");
370 particle = G4ParticleTable::GetParticleTable()->FindParticle(
"mu+");
379 G4double MyPrimaryGenerator::PDF_E_CosmicRay(G4double energy)
383 return std::pow(3.4*GeV, -2.7);
387 return std::pow(energy, -2.7);
393 G4ThreeVector MyPrimaryGenerator::ProjectOnBottomDetector(G4ThreeVector pos0, G4ThreeVector mom0)
395 G4double y_b = -(GS::yCosmicRayDetector + GS::halfYsideCosmicRayDetector);
397 G4double t = (y_b - pos0.y())/mom0.y();
399 x_b = pos0.x() + mom0.x()*t;
400 z_b = pos0.z() + mom0.z()*t;
402 return G4ThreeVector(x_b, y_b, z_b);
410 fMessenger_Mode =
new G4GenericMessenger(
this,
"/MC_LYSO/",
"Commands for MC_LYSO run");
411 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");
414 fMessenger_Gun =
new G4GenericMessenger(
this,
"/MC_LYSO/myGun/",
"Cinematical settings for primary particle");
415 fMessenger_Gun->DeclarePropertyWithUnit(
"meanEnergy",
"MeV",
fMeanEnergy,
"Mean of the gaussian distribution of initial gamma energy");
416 fMessenger_Gun->DeclarePropertyWithUnit(
"sigmaEnergy",
"MeV",
fSigmaEnergy,
"Sigma of the gaussian distribution of initial gamma energy");
417 fMessenger_Gun->DeclarePropertyWithUnit(
"radiusSpread",
"mm",
fRadiusSpread,
"Set radius of the spread on the front face of scintillator");
422 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.