15 #include "CLHEP/Random/RandGaussQ.h"
16 #include "G4ParticleDefinition.hh"
17 #include "G4ParticleGun.hh"
18 #include "G4SystemOfUnits.hh"
22 G4int nPhotonsGun = 1;
23 G4int nPhotonsBeam = 1;
24 G4double Energy = 1.15 * eV;
30 : thenParticleInGun(0), thenParticle(0), thePhotonEnergy(0), theParticleGun(), theDRand48Engine() {
51 G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
52 G4ParticleDefinition *theOpticalPhoton = theParticleTable->FindParticle(
"opticalphoton");
56 theParticleGun->SetParticlePosition(G4ThreeVector(-500.0 * cm, 0.0 * cm, 0.0 * cm));
57 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(5.0, 3.0, 0.0));
86 const G4int nLaserBeams = 8;
89 G4double LaserPositionZ = 1137.0 * mm;
92 G4double LaserRingRadius = 564.0 * mm;
96 G4double LaserPhi[nLaserBeams] = {G4double(7.0 / 112.0) * G4double(2.0 *
M_PI),
97 G4double(23.0 / 112.0) * G4double(2.0 *
M_PI),
98 G4double(33.0 / 112.0) * G4double(2.0 *
M_PI),
99 G4double(49.0 / 112.0) * G4double(2.0 *
M_PI),
100 G4double(65.0 / 112.0) * G4double(2.0 *
M_PI),
101 G4double(77.0 / 112.0) * G4double(2.0 *
M_PI),
102 G4double(93.0 / 112.0) * G4double(2.0 *
M_PI),
103 G4double(103.0 / 112.0) * G4double(2.0 *
M_PI)};
106 G4double LaserBeamSigmaX = 0.5 * mm;
107 G4double LaserBeamSigmaY = 0.5 * mm;
110 G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
111 G4ParticleDefinition *theOpticalPhoton = theParticleTable->FindParticle(
"opticalphoton");
114 for (
int theBeam = 0; theBeam < nLaserBeams; theBeam++) {
117 G4double LaserPositionX =
cos(LaserPhi[theBeam]) * LaserRingRadius;
118 G4double LaserPositionY =
sin(LaserPhi[theBeam]) * LaserRingRadius;
121 for (
int theParticle = 0; theParticle <
thenParticle; theParticle++) {
123 CLHEP::RandGaussQ aGaussObjX(*
theDRand48Engine, LaserPositionX, LaserBeamSigmaX);
124 CLHEP::RandGaussQ aGaussObjY(*
theDRand48Engine, LaserPositionY, LaserBeamSigmaY);
126 G4double theXPosition = aGaussObjX.fire();
127 G4double theYPosition = aGaussObjY.fire();
128 G4double theZPosition = LaserPositionZ;
133 theParticleGun->SetParticlePosition(G4ThreeVector(theXPosition, theYPosition, theZPosition));
137 for (
int theDirection = 0; theDirection < 2; theDirection++) {
139 if (theDirection == 0)
141 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, 1.0));
146 }
else if (theDirection == 1)
148 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, -1.0));
166 if (
theParticleGun->GetParticleDefinition()->GetParticleName() !=
"opticalphoton") {
168 <<
"<LaserBeamsBarrel::setOptPhotonPolar()>: WARNING! The ParticleGun "
169 "is not an optical photon";
175 G4ThreeVector normal(1.0, 0.0, 0.0);
176 G4ThreeVector kphoton =
theParticleGun->GetParticleMomentumDirection();
177 G4ThreeVector product = normal.cross(kphoton);
178 G4double modul2 = product * product;
180 G4ThreeVector e_perpendicular(0.0, 0.0, 1.0);
183 e_perpendicular = (1.0 /
sqrt(modul2)) * product;
186 G4ThreeVector e_parallel = e_perpendicular.cross(kphoton);
188 G4ThreeVector polar =
cos(Angle) * e_parallel +
sin(Angle) * e_perpendicular;
Sin< T >::type sin(const T &t)
LaserBeamsBarrel()
default constructor
virtual std::uint32_t mySeed() const =0
G4ParticleGun * theParticleGun
Cos< T >::type cos(const T &t)
~LaserBeamsBarrel() override
destructor
void setOptPhotonPolar(G4double Angle)
set the polarisation of the photons
CLHEP::DRand48Engine * theDRand48Engine
Log< level::Warning, false > LogWarning
void GeneratePrimaries(G4Event *myEvent) override
shoot optical photons into the detector at the beginning of an event