CMS 3D CMS Logo

LaserPrimaryGeneratorAction.cc
Go to the documentation of this file.
1 
11 
13 
14 #include "G4SystemOfUnits.hh"
15 
17  : thePhotonEnergy(0),
18  thenParticleInGun(0),
19  thenParticle(0),
20  theLaserBeamsInTEC1(),
21  theLaserBeamsInTEC2(),
22  theLaserBeamsInTECTIBTOBTEC() {
23  // {{{ LaserPrimaryGeneratorAction constructor
24 
25  // get the PhotonEnergy from the parameter set
26  thePhotonEnergy = theConf.getUntrackedParameter<double>("PhotonEnergy", 1.15) * eV;
27 
28  // number of particles in the Laser beam
29  thenParticleInGun = theConf.getUntrackedParameter<int>("NumberOfPhotonsInParticleGun", 1);
30 
31  // number of particles in one beam. ATTENTION: each beam contains
32  // nParticleInGun with the same startpoint and direction. nParticle gives the
33  // number of particles in the beam with a different startpoint. They are used
34  // to simulate the gaussian beamprofile of the Laser Beams.
35  thenParticle = theConf.getUntrackedParameter<int>("NumberOfPhotonsInEachBeam", 1);
36 
37  // create a messenger for this class
38  // theGunMessenger = new LaserPrimaryGeneratorMessenger(this);
39 
40  // create the beams in the right endcap
42 
43  // create the beams in the left endcap
45 
46  // create the beams to connect the TECs with TOB and TIB
48  // }}}
49 }
50 
52  // {{{ LaserPrimaryGeneratorAction destructor
53 
54  if (theLaserBeamsInTEC1 != nullptr) {
55  delete theLaserBeamsInTEC1;
56  }
57  if (theLaserBeamsInTEC2 != nullptr) {
58  delete theLaserBeamsInTEC2;
59  }
60  if (theLaserBeamsInTECTIBTOBTEC != nullptr) {
62  }
63  // }}}
64 }
65 
67  // {{{ GeneratePrimaries (G4Event * myEvent)
68 
69  // this function is called at the beginning of an Event in
70  // LaserAlignment::upDate(const BeginOfEvent * myEvent)
71  LogDebug("LaserPrimaryGeneratorAction") << "<LaserPrimaryGeneratorAction::GeneratePrimaries(G4Event*)>: create a "
72  "new Laser Event";
73 
74  // shoot in the right endcap
76 
77  // shoot in the left endcap
79 
80  // shoot in the barrel
82 
83  // loop over all the generated vertices, get the primaries and set the user
84  // information
85  int theID = 0;
86 
87  for (int i = 1; i < myEvent->GetNumberOfPrimaryVertex(); i++) {
88  G4PrimaryVertex *theVertex = myEvent->GetPrimaryVertex(i);
89 
90  for (int j = 0; j < theVertex->GetNumberOfParticle(); j++) {
91  G4PrimaryParticle *thePrimary = theVertex->GetPrimary(j);
92 
93  setGeneratorId(thePrimary, theID);
94  theID++;
95  }
96  }
97  // }}}
98 }
99 
100 void LaserPrimaryGeneratorAction::setGeneratorId(G4PrimaryParticle *aParticle, int ID) const {
101  // {{{ SetGeneratorId(G4PrimaryParticle * aParticle, int ID) const
102 
103  /* *********************************************************************** */
104  /* OSCAR expacts each G4PrimaryParticle to have some User Information *
105  * therefore this function have been implemented */
106  /* *********************************************************************** */
107 
108  aParticle->SetUserInformation(new GenParticleInfo(ID));
109  // }}}
110 }
uint32_t ID
Definition: Definitions.h:24
void GeneratePrimaries(G4Event *myEvent) override
shoot optical photons into the detector at the beginning of an event
T getUntrackedParameter(std::string const &, T const &) const
LaserPrimaryGeneratorAction(edm::ParameterSet const &theConf)
constructor
void GeneratePrimaries(G4Event *myEvent) override
void GeneratePrimaries(G4Event *myEvent) override
shoot optical photons into the detector at the beginning of an event
void setGeneratorId(G4PrimaryParticle *aParticle, int ID) const
set Id of the optical photons
void GeneratePrimaries(G4Event *myEvent) override
shoot optical photons into the detector at the beginning of an event
~LaserPrimaryGeneratorAction() override
destructor
#define LogDebug(id)