Go to the documentation of this file.00001
00009 #include "Alignment/LaserAlignmentSimulation/interface/LaserPrimaryGeneratorAction.h"
00010 #include "SimG4Core/Notification/interface/GenParticleInfo.h"
00011
00012 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00013
00014 LaserPrimaryGeneratorAction::LaserPrimaryGeneratorAction(edm::ParameterSet const& theConf)
00015 : thePhotonEnergy(0),
00016 thenParticleInGun(0),
00017 thenParticle(0),
00018 theLaserBeamsInTEC1(),
00019 theLaserBeamsInTEC2(),
00020 theLaserBeamsInTECTIBTOBTEC()
00021 {
00022
00023
00024
00025 thePhotonEnergy = theConf.getUntrackedParameter<double>("PhotonEnergy",1.15) * eV;
00026
00027
00028 thenParticleInGun = theConf.getUntrackedParameter<int>("NumberOfPhotonsInParticleGun",1);
00029
00030
00031
00032
00033 thenParticle = theConf.getUntrackedParameter<int>("NumberOfPhotonsInEachBeam",1);
00034
00035
00036
00037
00038
00039 theLaserBeamsInTEC1 = new LaserBeamsTEC1(thenParticleInGun, thenParticle, thePhotonEnergy);
00040
00041
00042 theLaserBeamsInTEC2 = new LaserBeamsTEC2(thenParticleInGun, thenParticle, thePhotonEnergy);
00043
00044
00045 theLaserBeamsInTECTIBTOBTEC = new LaserBeamsBarrel(thenParticleInGun, thenParticle, thePhotonEnergy);
00046
00047 }
00048
00049 LaserPrimaryGeneratorAction::~LaserPrimaryGeneratorAction()
00050 {
00051
00052
00053 if ( theLaserBeamsInTEC1 != 0 ) { delete theLaserBeamsInTEC1; }
00054 if ( theLaserBeamsInTEC2 != 0 ) { delete theLaserBeamsInTEC2; }
00055 if ( theLaserBeamsInTECTIBTOBTEC != 0 ) { delete theLaserBeamsInTECTIBTOBTEC; }
00056
00057 }
00058
00059 void LaserPrimaryGeneratorAction::GeneratePrimaries(G4Event* myEvent)
00060 {
00061
00062
00063
00064 LogDebug("LaserPrimaryGeneratorAction") << "<LaserPrimaryGeneratorAction::GeneratePrimaries(G4Event*)>: create a new Laser Event";
00065
00066
00067 theLaserBeamsInTEC1->GeneratePrimaries(myEvent);
00068
00069
00070 theLaserBeamsInTEC2->GeneratePrimaries(myEvent);
00071
00072
00073 theLaserBeamsInTECTIBTOBTEC->GeneratePrimaries(myEvent);
00074
00075
00076 int theID = 0;
00077
00078 for (int i = 1; i < myEvent->GetNumberOfPrimaryVertex(); i++)
00079 {
00080 G4PrimaryVertex * theVertex = myEvent->GetPrimaryVertex(i);
00081
00082 for (int j = 0; j < theVertex->GetNumberOfParticle(); j++)
00083 {
00084 G4PrimaryParticle * thePrimary = theVertex->GetPrimary(j);
00085
00086 setGeneratorId(thePrimary, theID);
00087 theID++;
00088 }
00089 }
00090
00091 }
00092
00093 void LaserPrimaryGeneratorAction::setGeneratorId(G4PrimaryParticle * aParticle, int ID) const
00094 {
00095
00096
00097
00098
00099
00100
00101
00102 aParticle->SetUserInformation(new GenParticleInfo(ID));
00103
00104 }