15 #include "CLHEP/Random/RandGaussQ.h"
17 #include "G4ParticleDefinition.hh"
18 #include "G4ParticleGun.hh"
24 G4int nPhotonsGun = 1;
25 G4int nPhotonsBeam = 1;
26 G4double Energy = 1.15 * eV;
56 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
57 G4ParticleDefinition * theOpticalPhoton = theParticleTable->FindParticle(
"opticalphoton");
61 theParticleGun->SetParticlePosition(G4ThreeVector(-500.0 * cm, 0.0 * cm, 0.0 * cm));
62 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(5.0, 3.0, 0.0));
83 unsigned int seed = rng->
mySeed();
89 const G4int nLaserBeams = 8;
92 G4double LaserPositionZ = 1137.0 * mm;
95 G4double LaserRingRadius = 564.0 * mm;
98 G4double LaserPhi[nLaserBeams] = { G4double(7.0/112.0) * G4double(2.0 *
M_PI),
99 G4double(23.0/112.0) * G4double(2.0 *
M_PI),
100 G4double(33.0/112.0) * G4double(2.0 *
M_PI),
101 G4double(49.0/112.0) * G4double(2.0 *
M_PI),
102 G4double(65.0/112.0) * G4double(2.0 *
M_PI),
103 G4double(77.0/112.0) * G4double(2.0 *
M_PI),
104 G4double(93.0/112.0) * G4double(2.0 *
M_PI),
105 G4double(103.0/112.0) * G4double(2.0 *
M_PI) };
108 G4double LaserBeamSigmaX = 0.5 * mm;
109 G4double LaserBeamSigmaY = 0.5 * mm;
112 G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
113 G4ParticleDefinition * theOpticalPhoton = theParticleTable->FindParticle(
"opticalphoton");
116 for (
int theBeam = 0; theBeam < nLaserBeams; theBeam++)
120 G4double LaserPositionX =
cos(LaserPhi[theBeam]) * LaserRingRadius;
121 G4double LaserPositionY =
sin(LaserPhi[theBeam]) * LaserRingRadius;
124 for (
int theParticle = 0; theParticle <
thenParticle; theParticle++)
127 CLHEP::RandGaussQ aGaussObjX( *
theDRand48Engine, LaserPositionX, LaserBeamSigmaX );
128 CLHEP::RandGaussQ aGaussObjY( *
theDRand48Engine, LaserPositionY, LaserBeamSigmaY );
130 G4double theXPosition = aGaussObjX.fire();
131 G4double theYPosition = aGaussObjY.fire();
132 G4double theZPosition = LaserPositionZ;
137 theParticleGun->SetParticlePosition(G4ThreeVector(theXPosition, theYPosition, theZPosition));
141 for (
int theDirection = 0; theDirection < 2; theDirection++)
144 if (theDirection == 0)
146 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, 1.0));
152 else if (theDirection == 1)
154 theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, -1.0));
173 if (
theParticleGun->GetParticleDefinition()->GetParticleName() !=
"opticalphoton" )
175 edm::LogWarning(
"SimLaserAlignment:LaserBeamsBarrel") <<
"<LaserBeamsBarrel::setOptPhotonPolar()>: WARNING! The ParticleGun is not an optical photon";
180 G4ThreeVector normal(1.0, 0.0, 0.0);
181 G4ThreeVector kphoton =
theParticleGun->GetParticleMomentumDirection();
182 G4ThreeVector product = normal.cross(kphoton);
183 G4double modul2 = product * product;
185 G4ThreeVector e_perpendicular(0.0, 0.0, 1.0);
187 if ( modul2 > 0.0 ) { e_perpendicular = (1.0 /
sqrt(modul2)) * product; }
189 G4ThreeVector e_parallel = e_perpendicular.cross(kphoton);
191 G4ThreeVector polar =
cos(Angle) * e_parallel +
sin(Angle) * e_perpendicular;
void GeneratePrimaries(G4Event *myEvent)
shoot optical photons into the detector at the beginning of an event
Sin< T >::type sin(const T &t)
LaserBeamsBarrel()
default constructor
G4ParticleGun * theParticleGun
Cos< T >::type cos(const T &t)
~LaserBeamsBarrel()
destructor
void setOptPhotonPolar(G4double Angle)
set the polarisation of the photons
CLHEP::DRand48Engine * theDRand48Engine
virtual uint32_t mySeed() const =0
Exists for backward compatibility.