CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Member Functions | Private Attributes
LaserBeamsTEC2 Class Reference

#include <LaserBeamsTEC2.h>

Inheritance diagram for LaserBeamsTEC2:

Public Member Functions

void GeneratePrimaries (G4Event *myEvent)
 shoot optical photons into the detector at the beginning of an event More...
 
 LaserBeamsTEC2 ()
 default constructor More...
 
 LaserBeamsTEC2 (G4int nPhotonsInGun, G4int nPhotonsInBeam, G4double PhotonEnergy)
 constructor More...
 
void setOptPhotonPolar (G4double Angle)
 set the polarisation of the photons More...
 
 ~LaserBeamsTEC2 ()
 destructor More...
 

Private Attributes

CLHEP::DRand48Engine * theDRand48Engine
 
G4int thenParticle
 
G4int thenParticleInGun
 
G4ParticleGun * theParticleGun
 
G4double thePhotonEnergy
 

Detailed Description

Laser Beams in the left Endcap

Date:
2009/05/26 07:12:23
Revision:
1.4
Author
Maarten Thomas

Definition at line 21 of file LaserBeamsTEC2.h.

Constructor & Destructor Documentation

LaserBeamsTEC2::LaserBeamsTEC2 ( )

default constructor

Definition at line 20 of file LaserBeamsTEC2.cc.

20  :
21  theParticleGun(0),
23 {
24  G4int nPhotonsGun = 1;
25  G4int nPhotonsBeam = 1;
26  G4double Energy = 1.15 * eV;
27  // call constructor with options
28  LaserBeamsTEC2(nPhotonsGun, nPhotonsBeam, Energy);
29 }
G4ParticleGun * theParticleGun
LaserBeamsTEC2()
default constructor
CLHEP::DRand48Engine * theDRand48Engine
LaserBeamsTEC2::LaserBeamsTEC2 ( G4int  nPhotonsInGun,
G4int  nPhotonsInBeam,
G4double  PhotonEnergy 
)

constructor

Definition at line 31 of file LaserBeamsTEC2.cc.

References setOptPhotonPolar(), theDRand48Engine, thenParticle, thenParticleInGun, theParticleGun, and thePhotonEnergy.

31  : thenParticleInGun(0),
32  thenParticle(0),
33  thePhotonEnergy(0),
36 {
37  /* *********************************************************************** */
38  /* initialize and configure the particle gun */
39  /* *********************************************************************** */
40 
41  // the Photon energy
42  thePhotonEnergy = PhotonEnergy;
43 
44  // number of particles in the Laser beam
45  thenParticleInGun = nPhotonsInGun;
46 
47  // number of particles in one beam. ATTENTION: each beam contains nParticleInGun with the same
48  // startpoint and direction. nParticle gives the number of particles in the beam with a different
49  // startpoint. They are used to simulate the gaussian beamprofile of the Laser Beams.
50  thenParticle = nPhotonsInBeam;
51 
52  // create the particle gun
53  theParticleGun = new G4ParticleGun(thenParticleInGun);
54 
55  // default kinematics
56  G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
57  G4ParticleDefinition * theOpticalPhoton = theParticleTable->FindParticle("opticalphoton");
58 
59  theParticleGun->SetParticleDefinition(theOpticalPhoton);
60  theParticleGun->SetParticleTime(0.0 * ns);
61  theParticleGun->SetParticlePosition(G4ThreeVector(-500.0 * cm, 0.0 * cm, 0.0 * cm));
62  theParticleGun->SetParticleMomentumDirection(G4ThreeVector(5.0, 3.0, 0.0));
63  theParticleGun->SetParticleEnergy(10.0 * keV);
64  setOptPhotonPolar(90.0);
65 
66  // initialize the random number engine
67  theDRand48Engine = new CLHEP::DRand48Engine();
68 }
void setOptPhotonPolar(G4double Angle)
set the polarisation of the photons
G4ParticleGun * theParticleGun
G4int thenParticleInGun
CLHEP::DRand48Engine * theDRand48Engine
G4double thePhotonEnergy
LaserBeamsTEC2::~LaserBeamsTEC2 ( )

destructor

Definition at line 70 of file LaserBeamsTEC2.cc.

References theDRand48Engine, and theParticleGun.

71 {
72  if ( theParticleGun != 0 ) { delete theParticleGun; }
73  if ( theDRand48Engine != 0 ) { delete theDRand48Engine; }
74 }
G4ParticleGun * theParticleGun
CLHEP::DRand48Engine * theDRand48Engine

Member Function Documentation

void LaserBeamsTEC2::GeneratePrimaries ( G4Event *  myEvent)

shoot optical photons into the detector at the beginning of an event

Definition at line 76 of file LaserBeamsTEC2.cc.

References funct::cos(), M_PI, edm::RandomNumberGenerator::mySeed(), setOptPhotonPolar(), funct::sin(), theDRand48Engine, thenParticle, theParticleGun, and thePhotonEnergy.

Referenced by LaserPrimaryGeneratorAction::GeneratePrimaries().

77 {
78  // this function is called at the beginning of an Event in LaserAlignment::upDate(const BeginOfEvent * myEvent)
79 
80  // use the random number generator service of the framework
82  unsigned int seed = rng->mySeed();
83 
84  // set the seed
85  theDRand48Engine->setSeed(seed);
86 
87 
88  // number of LaserRings and Laserdiodes
89  const G4int nLaserRings = 2;
90  const G4int nLaserBeams = 8;
91 
92  // z position of the sixth Tracker Endcap Disc, where the Laserdiodes are positioned
93  G4double LaserPositionZ = -2057.5 * mm;
94 
95  // Radius of the inner and outer Laser ring
96  G4double LaserRingRadius[nLaserRings] = {564.0 * mm, 840.0 * mm};
97 
98  // phi position of the first Laserdiode
99  G4double LaserPhi0 = 0.392699082;
100 
101  // width of the LaserBeams
102  G4double LaserRingSigmaX[nLaserRings] = {0.5 * mm, 0.5 * mm};
103  G4double LaserRingSigmaY[nLaserRings] = {0.5 * mm, 0.5 * mm};
104 
105  // get the definition of the optical photon
106  G4ParticleTable * theParticleTable = G4ParticleTable::GetParticleTable();
107  G4ParticleDefinition * theOpticalPhoton= theParticleTable->FindParticle("opticalphoton");
108 
109  // loop over the LaserRings
110  for (int theRing = 0; theRing < nLaserRings; theRing++)
111  {
112  // loop over the LaserBeams
113  for (int theBeam = 0; theBeam < nLaserBeams; theBeam++)
114  {
115  // code for forward and backward beam
116  // calculate the right phi for the current beam
117  G4double LaserPositionPhi = LaserPhi0 + G4double(theBeam * G4double(G4double(2 * M_PI) / nLaserBeams));
118 
119  // calculate x and y position for the current beam
120  G4double LaserPositionX = cos(LaserPositionPhi) * LaserRingRadius[theRing];
121  G4double LaserPositionY = sin(LaserPositionPhi) * LaserRingRadius[theRing];
122 
123  // loop over all the particles in one beam
124  for (int theParticle = 0; theParticle < thenParticle; theParticle++)
125  {
126  // get randomnumbers and calculate the position
127  CLHEP::RandGaussQ aGaussObjX( *theDRand48Engine, LaserPositionX, LaserRingSigmaX[theRing] );
128  CLHEP::RandGaussQ aGaussObjY( *theDRand48Engine, LaserPositionY, LaserRingSigmaY[theRing] );
129 
130  G4double theXPosition = aGaussObjX.fire();
131  G4double theYPosition = aGaussObjY.fire();
132  G4double theZPosition = LaserPositionZ;
133 
134  // set the properties of the newly created particle
135  theParticleGun->SetParticleDefinition(theOpticalPhoton);
136  theParticleGun->SetParticleTime(0.0 * ns);
137  theParticleGun->SetParticlePosition(G4ThreeVector(theXPosition, theYPosition, theZPosition));
138  theParticleGun->SetParticleEnergy(thePhotonEnergy);
139 
140  // loop over both directions of the beam
141  for (int theDirection = 0; theDirection < 2; theDirection++)
142  {
143  // shoot in both beam directions ...
144  if (theDirection == 0) // shoot in forward direction (+z)
145  {
146  theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, 1.0));
147  // set the polarization
148  setOptPhotonPolar(90.0);
149  // generate the particle
150  theParticleGun->GeneratePrimaryVertex(myEvent);
151  }
152 
153  if (theDirection == 1) // shoot in backward direction (-z)
154  {
155  theParticleGun->SetParticleMomentumDirection(G4ThreeVector(0.0, 0.0, -1.0));
156  // set the polarization
157  setOptPhotonPolar(90.0);
158  // generate the particle
159  theParticleGun->GeneratePrimaryVertex(myEvent);
160  }
161  } // end loop over both beam directions
162  } // end loop over particles in beam
163  } // end loop over beams
164  } // end loop over rings
165 }
void setOptPhotonPolar(G4double Angle)
set the polarisation of the photons
G4ParticleGun * theParticleGun
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
CLHEP::DRand48Engine * theDRand48Engine
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
G4double thePhotonEnergy
#define M_PI
Definition: BFit3D.cc:3
virtual uint32_t mySeed() const =0
Exists for backward compatibility.
void LaserBeamsTEC2::setOptPhotonPolar ( G4double  Angle)

set the polarisation of the photons

Definition at line 167 of file LaserBeamsTEC2.cc.

References funct::cos(), funct::sin(), mathSSE::sqrt(), and theParticleGun.

Referenced by GeneratePrimaries(), and LaserBeamsTEC2().

168 {
169  /* *********************************************************************** */
170  /* to get optical processes working properly, you have to make sure *
171  * that the photon polarisation is defined. */
172  /* *********************************************************************** */
173 
174  // first check if we have an optical photon
175  if ( theParticleGun->GetParticleDefinition()->GetParticleName() != "opticalphoton" )
176  {
177  edm::LogWarning("SimLaserAlignment:LaserBeamsTEC2") << "<LaserBeamsTEC2::setOptPhotonPolar()>: WARNING! The ParticleGun is not an optical photon";
178  return;
179  }
180 
181 // G4cout << " AC1CMS: The ParticleGun is an " << theParticleGun->GetParticleDefinition()->GetParticleName();
182  G4ThreeVector normal(1.0, 0.0, 0.0);
183  G4ThreeVector kphoton = theParticleGun->GetParticleMomentumDirection();
184  G4ThreeVector product = normal.cross(kphoton);
185  G4double modul2 = product * product;
186 
187  G4ThreeVector e_perpendicular(0.0, 0.0, 1.0);
188 
189  if ( modul2 > 0.0 ) { e_perpendicular = (1.0 / sqrt(modul2)) * product; }
190 
191  G4ThreeVector e_parallel = e_perpendicular.cross(kphoton);
192 
193  G4ThreeVector polar = cos(Angle) * e_parallel + sin(Angle) * e_perpendicular;
194 
195 // G4cout << ", the polarization = " << polar << G4endl;
196  theParticleGun->SetParticlePolarization(polar);
197 }
G4ParticleGun * theParticleGun
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:48
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
Definition: Angle.h:17

Member Data Documentation

CLHEP::DRand48Engine* LaserBeamsTEC2::theDRand48Engine
private

Definition at line 46 of file LaserBeamsTEC2.h.

Referenced by GeneratePrimaries(), LaserBeamsTEC2(), and ~LaserBeamsTEC2().

G4int LaserBeamsTEC2::thenParticle
private

Definition at line 39 of file LaserBeamsTEC2.h.

Referenced by GeneratePrimaries(), and LaserBeamsTEC2().

G4int LaserBeamsTEC2::thenParticleInGun
private

Definition at line 38 of file LaserBeamsTEC2.h.

Referenced by LaserBeamsTEC2().

G4ParticleGun* LaserBeamsTEC2::theParticleGun
private
G4double LaserBeamsTEC2::thePhotonEnergy
private

Definition at line 40 of file LaserBeamsTEC2.h.

Referenced by GeneratePrimaries(), and LaserBeamsTEC2().