LBNEPrimaryGeneratorAction.hh
Go to the documentation of this file.
1 
2 #ifndef LBNEPrimaryGeneratorAction_h
3 #define LBNEPrimaryGeneratorAction_h 1
4 
5 #include "G4VUserPrimaryGeneratorAction.hh"
6 #include "G4ParticleGun.hh"
7 #include "Randomize.hh"
8 #include "G4ThreeVector.hh"
9 #include "globals.hh"
10 
11 class G4ParticleGun;
12 class G4Event;
14 class TFile;
15 class TTree;
16 class LBNERunManager;
17 class TH1F;
18 class TF1; // for the annulus beam .
19 
20 class LBNEPrimaryGeneratorAction : public G4VUserPrimaryGeneratorAction
21 {
22  public:
25 
26  void GeneratePrimaries(G4Event* anEvent);
27  void GenerateG4ProtonBeam(G4Event* anEvent);
28  void GenerateBeamFromInput(G4Event* anEvent);
29  void GenerateFlukaPrimary(G4Event* anEvent);
30  void Geantino(G4Event* anEvent);
31 
32  G4ParticleGun* GetParticleGun() {return fParticleGun;};
33  void SetProtonBeam();
34 
35  G4bool OpenNtuple(G4String ntupleName);
36  G4bool OpenNtupleFLUKAASCII(G4String ntupleName); // New, January 2015, P.Lebrun
37  void CloseNtuple(); // Will also
38 
39  G4int GetNoOfPrimaries() { return fNoOfPrimaries; }
40 
41  //
42  // Primary proton information when using G4Pbeam
43  //
44  G4ThreeVector GetProtonOrigin() { return fProtonOrigin; }
45  G4ThreeVector GetProtonMomentum() { return fProtonMomentum; }
46  G4ThreeVector GetProtonIntVertex() { return fProtonIntVertex; }
47 
48  //
49  // Info about a particle leaving the target (when using external ntuple)
50  //
51  G4ThreeVector GetParticlePosition() { return fParticlePosition; }
52  G4ThreeVector GetParticleMomentum() { return fParticleMomentum; }
53  G4double GetWeight() { return fWeight; }
54  G4int GetTgen() { return fTgen; }
55  G4int GetParticleType() { return fType; }
56 
57  G4int GetProtonNumber() { return fProtonN; }
58 
59  void SetCorrectForAngle(G4bool aBool) { fCorrectForAngle = aBool; }
60  void SetBeamOnTarget(G4bool aBool) { fBeamOnTarget = aBool; }
61  void SetBeamOffsetX(G4double x) { fBeamOffsetX = x; }
62  void SetBeamOffsetY(G4double y) { fBeamOffsetY = y; }
63  void SetBeamSigmaX(G4double x) { fBeamSigmaX = x; }
64  void SetBeamSigmaY(G4double y) { fBeamSigmaY = y; }
65  void SetBeamMaxValX(G4double x) { fBeamMaxValX = x; }
66  void SetBeamMaxValY(G4double y) { fBeamMaxValY = y; }
67  void SetBeamTheta(G4double theta) { fBeamAngleTheta = theta; }
68  void SetBeamPhi(G4double phi) { fBeamAnglePhi = phi; }
70 
72  inline void SetUseJustSigmaCoord(G4bool t) {fUseJustSigmaCoord = t;}
73 
75  inline G4bool GetUseJustSigmaCoord() {return fUseJustSigmaCoord;}
76 
77  inline void SetBeamEmittanceX(G4double t) {fBeamEmittanceX = t;}
78  inline void SetBeamEmittanceY(G4double t) {fBeamEmittanceY = t;}
79  inline void SetBeamBetaFunctionX(G4double t) {fBeamBetaFunctionX = t;}
80  inline void SetBeamBetaFunctionY(G4double t) {fBeamBetaFunctionY = t;}
81  inline void SetRadiusAnnularBeam(G4double t) {fRadiusAnnularBeam = t;}
82 
83  inline double GetBeamSigmaX() const { return fBeamSigmaX; }
84  inline double GetBeamSigmaY() const { return fBeamSigmaY; }
85  inline double GetBeamOffsetX() const { return fBeamOffsetX; }
86  inline double GetBeamOffsetY() const { return fBeamOffsetY; }
87  inline double GetBeamOffsetZ() const { return fBeamOffsetZ; }
88  inline double GetBeamMaxValX() const { return fBeamMaxValX; }
89  inline double GetBeamMaxValY() const { return fBeamMaxValY; }
90 
91  inline double GetBeamEmittanceX() const { return fBeamEmittanceX;}
92  inline double GetBeamBetaFunctionX() const { return fBeamBetaFunctionX;}
93 
94  inline double GetBeamEmittanceY() const { return fBeamEmittanceY;}
95  inline double GetBeamBetaFunctionY() const { return fBeamBetaFunctionY;}
96 
97  inline double GetBeamAngleTheta() const { return fBeamAngleTheta; }
98 
99 private:
100 
103 
104  G4ParticleGun* fParticleGun;
105 
106  TFile *fInputFile;
107  TTree *fInputTree;
108  std::ifstream fFlukaASCII;
111 
112  G4int fProtonN;
115 
116  //G4ThreeVector fTunnelPos;
117 
119  G4ThreeVector fProtonOrigin;
120  G4ThreeVector fProtonMomentum;
121  G4ThreeVector fProtonIntVertex;
122  G4ThreeVector fParticleMomentum;
123  G4ThreeVector fParticlePosition;
124 
125  G4int fTgen;
126  G4int fType;
128  G4double fWeight;
129 
132  G4double fBeamOffsetX;
133  G4double fBeamOffsetY;
134  G4double fBeamOffsetZ;
135  G4double fBeamMaxValX;
136  G4double fBeamMaxValY;
137  G4double fBeamSigmaX;
138  G4double fBeamSigmaY;
139  G4double fBeamAngleTheta;
140  G4double fBeamAnglePhi;
141 
142  G4bool fUseCourantSniderParams; // new way to set the Proton beam paramters
143  G4bool fUseJustSigmaCoord;// Old way One and only of these flags should be set to true.
144  G4double fRadiusAnnularBeam; // Set the annular beam, following recipe provided by Bob Zwaska, July 22 2016.
145  G4double fSigmaForAnnularbeam; // Based on sigmaX and sigmaY
146  G4double fBeamEmittanceX; // 95 % value
147  G4double fBeamEmittanceY;
148  G4double fBeamBetaFunctionX; // in meters. Assumed to be at the waist point, (beta*)
150  G4double fBeamBetaFunctionAt120; // in meters
151  G4double fBeamBetaFunctionAt80; // in meters
153 
154  // We are at a waste, so aplha = 0 and gamma = 1/beta (or close to it. )
155  // Except that we generate the beam upstream. So we need the alpha
156 
157  G4double fBeamAlphaFunctionX; // The alha at the place where the beam is generated.
158  G4double fBeamAlphaFunctionY; // The alha at the place where the beam is generated.
159  G4double fBeamBetaFuncGenX; // Actually used at the place where the beam is generated
160  G4double fBeamBetaFuncGenY;
161 
162  G4bool fUseGeantino;
169 //
170 // For muon scans ..
171 //
172  G4ThreeVector fZOriginForMuGeantino;
173  G4ThreeVector fYOriginForMuGeantino;
174  G4ThreeVector fMomentumForMuGeantino;
175  G4ThreeVector fPtForMuGeantino;
176  G4ThreeVector fAngleForMuGeantino;
177 //
178 // For the generation of an annular beam..
179 //
182 
183 
184 
185  //double DoubleRand() {return 2*G4UniformRand()-1.;}
186 public:
187 
188  inline void SetPolarAngleGeantino(double r) {fPolarAngleGeantino=r;}
189  inline void SetPolarAngleGeantinoMin(double r) {fPolarAngleGeantinoMin=r;}
190  inline void SetUseGeantino(bool t) {fUseGeantino=t;}
191  inline void SetUseMuonGeantino(bool t) {fUseMuonGeantino=t;}
192  inline void SetUseChargedGeantino(bool t) {fUseChargedGeantino=t;}
193  inline void SetZOriginGeantino(double v) {fZOriginGeantino=v;}
194  inline void SetSigmaZOriginGeantino(double v) {fSigmaZOriginGeantino=v;}
195 
196  inline bool GetUseMuonGeantino() const { return fUseMuonGeantino; }
197  inline bool GetUseGeantino() const { return fUseGeantino; }
198  inline bool GetUseChargedGeantino() const { return fUseChargedGeantino; }
199 
200  double GetBetaFunctionvsBeamEnergy(double pz);
201  // quadratic interpolation, based on the e-mail from
202  // John Jostone.
203  inline void SetZOriginForMuGeantinoScan(G4ThreeVector v) {fZOriginForMuGeantino = v;}
204  inline void SetYOriginForMuGeantinoScan(G4ThreeVector v) {fYOriginForMuGeantino = v;}
205  inline void SetMomentumForMuGeantinoScan(G4ThreeVector v) {fMomentumForMuGeantino = v;}
206  inline void SetPtForMuGeantinoScan(G4ThreeVector v) {fPtForMuGeantino = v;}
207  inline void SetAngleForMuGeantinoScan(G4ThreeVector v) {fAngleForMuGeantino = v;}
208 
209  inline G4ThreeVector GetZOriginForMuGeantinoScan() const { return fZOriginForMuGeantino;}
210  inline G4ThreeVector GetYOriginForMuGeantinoScan() const { return fYOriginForMuGeantino;}
211  inline G4ThreeVector GetMomentumForMuGeantinoScan() const { return fMomentumForMuGeantino;}
212  inline G4ThreeVector GetPtForMuGeantinoScan() const { return fPtForMuGeantino;}
213  inline G4ThreeVector GetAngleForMuGeantinoScan() const { return fAngleForMuGeantino;}
214 
215 };
216 
217 #endif
218 
219 
G4bool OpenNtupleFLUKAASCII(G4String ntupleName)
void GenerateBeamFromInput(G4Event *anEvent)
void SetYOriginForMuGeantinoScan(G4ThreeVector v)
void SetPtForMuGeantinoScan(G4ThreeVector v)
void SetAngleForMuGeantinoScan(G4ThreeVector v)
G4ThreeVector GetMomentumForMuGeantinoScan() const
double y
G4ThreeVector GetPtForMuGeantinoScan() const
G4bool OpenNtuple(G4String ntupleName)
G4ThreeVector GetYOriginForMuGeantinoScan() const
void SetMomentumForMuGeantinoScan(G4ThreeVector v)
void GeneratePrimaries(G4Event *anEvent)
p
Definition: test.py:223
G4ThreeVector GetZOriginForMuGeantinoScan() const
LBNEPrimaryMessenger * fPrimaryMessenger
list x
Definition: train.py:276
void SetZOriginForMuGeantinoScan(G4ThreeVector v)
G4ThreeVector GetAngleForMuGeantinoScan() const
void GenerateG4ProtonBeam(G4Event *anEvent)
void GenerateFlukaPrimary(G4Event *anEvent)