FDsimG4PrimaryGeneratorAction.cc
Go to the documentation of this file.
1 //
2 // Description: PrimaryGeneratorAction for FDsimG4 application
3 //
4 
5 #include <math.h>
6 
9 
10 #include "globals.hh"
11 #include "G4RunManager.hh"
12 #include "G4Event.hh"
13 #include "G4GeneralParticleSource.hh"
14 #include "G4SPSAngDistribution.hh"
15 #include "G4SPSEneDistribution.hh"
16 #include "G4SPSPosDistribution.hh"
17 #include "G4ParticleTable.hh"
18 #include "G4ParticleDefinition.hh"
19 #include "TelescopeSimulator.h"
20 #include <fwk/RunController.h>
21 #include <fwk/VModule.h>
22 
23 
24 using namespace TelescopeSimulatorLX;
25 
27 {
28  fUseGenPartSource = true;
29 
30  particleGun = new G4GeneralParticleSource();
31  pParticleTable = G4ParticleTable::GetParticleTable();
32 
33  TelescopeSimulator &FDSimulator =
34  dynamic_cast<TelescopeSimulator&>(
35  fwk::RunController::GetInstance().GetModule("TelescopeSimulatorLX")
36  );
37 
38  theFDSimulator = &FDSimulator;
39 }
40 
41 
43 {
44  delete particleGun;
45 }
46 
47 
49 {
51  GenerateGPSPrimaries(anEvent);
52  else
53  ReadFDSimulatorEvent(anEvent);
54 }
55 
56 
58 {
59 
60  // Get position and thickness of the filter
61 
62  static G4ThreeVector FilterPosition =
63  (dynamic_cast<const FDsimG4DetectorConstruction *>
64  ((G4RunManager::GetRunManager())->GetUserDetectorConstruction()))->fFilterPosition;
65 
66  static G4double FilterThickness =
67  (dynamic_cast<const FDsimG4DetectorConstruction *>((G4RunManager::GetRunManager())->GetUserDetectorConstruction()))->fFilterThickness;
68 
69  G4PrimaryParticle* particle = new G4PrimaryParticle();
70 
72 
73  G4ThreeVector position =
74  G4ThreeVector(G4Photon->GetPosX()*m,G4Photon->GetPosY()*m,G4Photon->GetPosZ()*m);
75  position.setZ(FilterPosition.z() + FilterThickness/2.0 + 0.5*mm);
76 
77  G4ThreeVector momentum =
78  G4ThreeVector(G4Photon->GetDirX(),G4Photon->GetDirY(),G4Photon->GetDirZ());
79  momentum=momentum*(G4Photon->GetEnergy()*eV);
80 
81  G4double time = G4Photon->GetTime()*ns;
82  G4double w = G4Photon->GetWeight();
83 
84  particle->SetMomentum(momentum.x(),momentum.y(),momentum.z());
85  particle->SetPolarization(1.0,0.0,0.0);
86  particle->SetCharge(0.0);
87  particle->SetG4code(pParticleTable->FindParticle("opticalphoton"));
88 
89  G4PrimaryVertex * vertex = new G4PrimaryVertex(position,time);
90  vertex->SetPrimary( particle );
91  vertex->SetWeight(w);
92 
93  pEvent->AddPrimaryVertex( vertex );
94 }
95 
96 
98 {
99  particleGun->GeneratePrimaryVertex(anEvent);
100 }
const double eV
Definition: GalacticUnits.h:35
constexpr double mm
Definition: AugerUnits.h:113
const double ns
struct particle_info particle[80]
constexpr double m
Definition: AugerUnits.h:121

, generated on Tue Sep 26 2023.