34 #include "HGCal/TBStandaloneSimulator/interface/PrimaryGeneratorAction.hh"
35 #include "HGCal/TBStandaloneSimulator/interface/DetectorConstruction.hh"
36 #include "HGCal/TBStandaloneSimulator/interface/PrimaryGeneratorMessenger.hh"
38 #include "G4RunManager.hh"
40 #include "G4ParticleGun.hh"
41 #include "G4ParticleTable.hh"
42 #include "G4ParticleDefinition.hh"
43 #include "G4SystemOfUnits.hh"
44 #include "Randomize.hh"
46 #include "HGCal/TBStandaloneSimulator/interface/HepMCG4AsciiReader.hh"
47 #include "HGCal/TBStandaloneSimulator/interface/HepMCG4PythiaInterface.hh"
49 #define PI 3.1415926535
53 PrimaryGeneratorAction::PrimaryGeneratorAction(G4int mod,
double eta)
56 int hack = CLHEP::HepRandomGenActive;
64 currentGenerator = particleGun =
new G4ParticleGun(n_particle);
65 currentGeneratorName =
"particleGun";
66 hepmcAscii =
new HepMCG4AsciiReader();
68 gentypeMap[
"particleGun"] = particleGun;
69 gentypeMap[
"hepmcAscii"] = hepmcAscii;
70 gentypeMap[
"pythia"] = pythiaGen;
72 Detector = (DetectorConstruction*)
73 G4RunManager::GetRunManager()->GetUserDetectorConstruction();
76 gunMessenger =
new PrimaryGeneratorMessenger(
this);
80 G4ParticleTable* particleTable = G4ParticleTable::GetParticleTable();
81 G4String particleName;
82 G4ParticleDefinition* particle
83 = particleTable->FindParticle(particleName =
"e-");
84 particleGun->SetParticleDefinition(particle);
85 particleGun->SetParticleMomentumDirection(G4ThreeVector(0., 0., 1.));
86 particleGun->SetParticleEnergy(10.*GeV);
87 particleGun->SetParticlePosition(G4ThreeVector(0.*cm, 0.*cm, 0.*cm));
94 PrimaryGeneratorAction::~PrimaryGeneratorAction()
104 void PrimaryGeneratorAction::GeneratePrimaries(G4Event* anEvent)
133 if(currentGenerator) {
134 currentGenerator->GeneratePrimaryVertex(anEvent);
136 G4Exception(
"PrimaryGeneratorAction::GeneratePrimaries",
137 "PrimaryGeneratorAction001", FatalException,
138 "generator is not instanciated." );