15 #include "CLHEP/Random/RandGaussQ.h"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 #include "G4ParticleDefinition.hh"
19 #include "G4ParticleGun.hh"
25 G4int nPhotonsGun = 1;
26 G4int nPhotonsBeam = 1;
27 G4double Energy = 1.15 * eV;
57 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
58 G4ParticleDefinition * theOpticalPhoton = theParticleTable->FindParticle(
"opticalphoton");
62 theParticleGun->SetParticlePosition(G4ThreeVector(-500.0 * cm, 0.0 * cm, 0.0 * cm));
63 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(5.0, 3.0, 0.0));
90 const G4int nLaserRings = 2;
91 const G4int nLaserBeams = 8;
94 G4double LaserPositionZ = -2057.5 * mm;
97 G4double LaserRingRadius[nLaserRings] = {564.0 * mm, 840.0 * mm};
100 G4double LaserPhi0 = 0.392699082;
103 G4double LaserRingSigmaX[nLaserRings] = {0.5 * mm, 0.5 * mm};
104 G4double LaserRingSigmaY[nLaserRings] = {0.5 * mm, 0.5 * mm};
107 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
108 G4ParticleDefinition * theOpticalPhoton= theParticleTable->FindParticle(
"opticalphoton");
111 for (
int theRing = 0; theRing < nLaserRings; theRing++)
114 for (
int theBeam = 0; theBeam < nLaserBeams; theBeam++)
118 G4double LaserPositionPhi = LaserPhi0 + G4double(theBeam * G4double(G4double(2 *
M_PI) / nLaserBeams));
121 G4double LaserPositionX =
cos(LaserPositionPhi) * LaserRingRadius[theRing];
122 G4double LaserPositionY =
sin(LaserPositionPhi) * LaserRingRadius[theRing];
125 for (
int theParticle = 0; theParticle <
thenParticle; theParticle++)
128 CLHEP::RandGaussQ aGaussObjX( *
theDRand48Engine, LaserPositionX, LaserRingSigmaX[theRing] );
129 CLHEP::RandGaussQ aGaussObjY( *
theDRand48Engine, LaserPositionY, LaserRingSigmaY[theRing] );
131 G4double theXPosition = aGaussObjX.fire();
132 G4double theYPosition = aGaussObjY.fire();
133 G4double theZPosition = LaserPositionZ;
138 theParticleGun->SetParticlePosition(G4ThreeVector(theXPosition, theYPosition, theZPosition));
142 for (
int theDirection = 0; theDirection < 2; theDirection++)
145 if (theDirection == 0)
147 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, 1.0));
154 if (theDirection == 1)
156 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, -1.0));
176 if (
theParticleGun->GetParticleDefinition()->GetParticleName() !=
"opticalphoton" )
178 edm::LogWarning(
"SimLaserAlignment:LaserBeamsTEC2") <<
"<LaserBeamsTEC2::setOptPhotonPolar()>: WARNING! The ParticleGun is not an optical photon";
183 G4ThreeVector normal(1.0, 0.0, 0.0);
184 G4ThreeVector kphoton =
theParticleGun->GetParticleMomentumDirection();
185 G4ThreeVector product = normal.cross(kphoton);
186 G4double modul2 = product * product;
188 G4ThreeVector e_perpendicular(0.0, 0.0, 1.0);
190 if ( modul2 > 0.0 ) { e_perpendicular = (1.0 /
sqrt(modul2)) * product; }
192 G4ThreeVector e_parallel = e_perpendicular.cross(kphoton);
194 G4ThreeVector polar =
cos(Angle) * e_parallel +
sin(Angle) * e_perpendicular;
void setOptPhotonPolar(G4double Angle)
set the polarisation of the photons
G4ParticleGun * theParticleGun
Sin< T >::type sin(const T &t)
LaserBeamsTEC2()
default constructor
~LaserBeamsTEC2()
destructor
virtual std::uint32_t mySeed() const =0
void GeneratePrimaries(G4Event *myEvent)
shoot optical photons into the detector at the beginning of an event
CLHEP::DRand48Engine * theDRand48Engine
Cos< T >::type cos(const T &t)