WCSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
WCSimPrimaryGeneratorAction.hh
Go to the documentation of this file.
1 #ifndef WCSimPrimaryGeneratorAction_h
2 #define WCSimPrimaryGeneratorAction_h
3 
4 #include "G4VUserPrimaryGeneratorAction.hh"
5 #include "G4ThreeVector.hh"
6 #include "globals.hh"
7 #include "jhfNtuple.h"
8 #include <vector>
9 
10 #include <fstream>
11 
12 #include "WCSimRootOptions.hh"
14 
16 class G4ParticleGun;
17 class G4GeneralParticleSource;
18 class G4Event;
20 class G4Generator;
21 
22 class WCSimPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
23 {
24 
26  G4String IsotopeName;
27  G4String IsotopeLocation;
28  G4double IsotopeActivity;
29  };
30 
31 
32 public:
35 
36 public:
37  void GeneratePrimaries(G4Event* anEvent);
38 
39  // Gun, laser & gps setting calls these functions to fill jhfNtuple and Root tree
40  void SetVtx(G4ThreeVector i) { vtxs[0] = i; nvtxs = 1; };
41  void SetBeamEnergy(G4double i, G4int n = 0) { beamenergies[n] = i;};
42  void SetBeamDir(G4ThreeVector i, G4int n = 0) { beamdirs[n] = i;};
43  void SetBeamPDG(G4int i, G4int n = 0) { beampdgs[n] = i;};
44  void SetNvtxs(G4int i) { nvtxs = i; };
45  void SetVtxs(G4int i, G4ThreeVector v) { vtxs[i] = v; };
46 
47  // These go with jhfNtuple
48  G4int GetVecRecNumber(){return vecRecNumber;}
49  G4int GetMode() {return mode[0];};
50  G4int GetMode(int vertex){return mode[vertex];};
51  G4int GetNvtxs() {return nvtxs;};
52  G4int GetVtxVol(G4int n = 0) {return vtxsvol[n];};
53  G4ThreeVector GetVtx(G4int n = 0) {return vtxs[n];}
54  G4double GetVertexTime(G4int n = 0){return vertexTimes[n];}
55  G4int GetNpar() {return npar;};
56  G4int GetBeamPDG(G4int n = 0) {return beampdgs[n];};
57  G4double GetBeamEnergy(G4int n = 0) {return beamenergies[n];};
58  G4ThreeVector GetBeamDir(G4int n = 0) {return beamdirs[n];};
59  G4int GetTargetPDG(G4int n = 0) {return targetpdgs[n];};
60  G4double GetTargetEnergy(G4int n = 0) {return targetenergies[n];};
61  G4ThreeVector GetTargetDir(G4int n = 0) {return targetdirs[n];};
62 
63  // older ...
64  G4double GetNuEnergy() {return nuEnergy;};
65  G4double GetEnergy() {return energy;};
66  G4double GetXPos() {return xPos;};
67  G4double GetYPos() {return yPos;};
68  G4double GetZPos() {return zPos;};
69  G4double GetXDir() {return xDir;};
70  G4double GetYDir() {return yDir;};
71  G4double GetZDir() {return zDir;};
72 
73  G4String GetGeneratorTypeString();
74 
76 
77 private:
79  G4ParticleGun* particleGun;
80  G4GeneralParticleSource* MyGPS; //T. Akiri: GPS to run Laser
82 
83  // Variables set by the messenger
84  G4bool useMulineEvt;
85  G4bool useGunEvt;
86  G4bool useLaserEvt; //T. Akiri: Laser flag
87  G4bool useGPSEvt;
88  G4bool useRadioactiveEvt; // F. Nova: Radioactive flag
89  G4bool useRadonEvt; // G. Pronost: Radon flag
90 
91  std::fstream inputFile;
92  G4String vectorFileName;
94 
95  // Variables for Radioactive and Radon generators
96  std::vector<struct radioactive_source> radioactive_sources;
98 
99  // For Rn event
101  G4int fRnScenario;
102  G4int fRnSymmetry;
103 
104  //
105  G4double fTimeUnit;
106 
107  // These go with jhfNtuple
109  G4int nvtxs;
111  G4ThreeVector vtxs[MAX_N_VERTICES];
113  G4int npar;
118 
119  G4double nuEnergy;
120  G4double energy;
121  G4double xPos, yPos, zPos;
122  G4double xDir, yDir, zDir;
123 
124  G4int _counterRock;
126 public:
127 
128  inline void SetMulineEvtGenerator(G4bool choice) { useMulineEvt = choice; }
129  inline G4bool IsUsingMulineEvtGenerator() { return useMulineEvt; }
130 
131  inline void SetGunEvtGenerator(G4bool choice) { useGunEvt = choice; }
132  inline G4bool IsUsingGunEvtGenerator() { return useGunEvt; }
133 
134  //T. Akiri: Addition of function for the laser flag
135  inline void SetLaserEvtGenerator(G4bool choice) { useLaserEvt = choice; }
136  inline G4bool IsUsingLaserEvtGenerator() { return useLaserEvt; }
137 
138  inline void SetGPSEvtGenerator(G4bool choice) { useGPSEvt = choice; }
139  inline G4bool IsUsingGPSEvtGenerator() { return useGPSEvt; }
140 
141  inline void OpenVectorFile(G4String fileName)
142  {
143  if ( inputFile.is_open() )
144  inputFile.close();
145 
146  vectorFileName = fileName;
147  inputFile.open(vectorFileName, std::fstream::in);
148 
149  if ( !inputFile.is_open() ) {
150  G4cout << "Vector file " << vectorFileName << " not found" << G4endl;
151  exit(-1);
152  }
153  }
154 
155  inline G4bool IsGeneratingVertexInRock() { return GenerateVertexInRock; }
156  inline void SetGenerateVertexInRock(G4bool choice) { GenerateVertexInRock = choice; }
157 
158  inline void AddRadioactiveSource(G4String IsotopeName, G4String IsotopeLocation, G4double IsotopeActivity){
159  struct radioactive_source r;
160  r.IsotopeName = IsotopeName;
161  r.IsotopeLocation = IsotopeLocation;
162  r.IsotopeActivity = IsotopeActivity;
163  radioactive_sources.push_back(r);
164  }
165  inline std::vector<struct radioactive_source> Radioactive_Sources() { return radioactive_sources; }
166 
167  inline void SetRadioactiveEvtGenerator(G4bool choice) { useRadioactiveEvt = choice; }
169 
170  inline void SetRadioactiveTimeWindow(G4double choice) { radioactive_time_window = choice; }
171  inline G4double GetRadioactiveTimeWindow() { return radioactive_time_window; }
172 
173  inline void SetRadonEvtGenerator(G4bool choice) { useRadonEvt = choice; }
174  inline G4bool IsUsingRadonEvtGenerator() { return useRadonEvt; }
175 
176  inline void SetRadonScenario(G4int choice) { fRnScenario = choice; }
177  inline G4int GetRadonScenario() { return fRnScenario; }
178 
179  inline void SetRadonSymmetry(G4int choice) { fRnSymmetry = choice; }
180  inline G4int GetRadonSymmetry() { return fRnSymmetry; }
181  //static const HepDouble nanosecond = 1.;
182  //static const HepDouble second = 1.e+9 *nanosecond;
183  //static const HepDouble millisecond = 1.e-3 *second;
184  //static const HepDouble microsecond = 1.e-6 *second;
185  //static const HepDouble picosecond = 1.e-12*second;
186  inline void SetTimeUnit(G4String choice)
187  {
188 
189 
190  if(choice == "ns" || choice=="nanosecond")
191  fTimeUnit=CLHEP::nanosecond;//*second;
192  else if(choice == "s" || choice=="second")
193  fTimeUnit=CLHEP::second;
194  else if (choice = "ms" || choice=="millisecond")
195  fTimeUnit=CLHEP::millisecond;
196  else if (choice="microsecond")
197  fTimeUnit=CLHEP::microsecond;
198  else if(choice="ps" || choice=="picosecond")
199  fTimeUnit=CLHEP::picosecond;
200  else
201  fTimeUnit=CLHEP::nanosecond;
202  }
203  inline G4double GetTimeUnit() { return fTimeUnit; }
204 
205  };
206 
207 #endif
208 
209 
WCSimGenerator_Radioactivity * myRn222Generator
static const int MAX_N_PRIMARIES
Definition: jhfNtuple.h:4
WCSimPrimaryGeneratorMessenger * messenger
void SetBeamDir(G4ThreeVector i, G4int n=0)
WCSimDetectorConstruction * myDetector
std::vector< struct radioactive_source > Radioactive_Sources()
std::vector< struct radioactive_source > radioactive_sources
void SetBeamEnergy(G4double i, G4int n=0)
G4ThreeVector vtxs[MAX_N_VERTICES]
void SetVtxs(G4int i, G4ThreeVector v)
G4ThreeVector beamdirs[MAX_N_PRIMARIES]
G4double targetenergies[MAX_N_PRIMARIES]
void AddRadioactiveSource(G4String IsotopeName, G4String IsotopeLocation, G4double IsotopeActivity)
void SaveOptionsToOutput(WCSimRootOptions *wcopt)
WCSimPrimaryGeneratorAction(WCSimDetectorConstruction *)
G4double beamenergies[MAX_N_PRIMARIES]
static const int MAX_N_VERTICES
Definition: jhfNtuple.h:3
void SetRadioactiveTimeWindow(G4double choice)
G4ThreeVector targetdirs[MAX_N_PRIMARIES]