LBNESteppingAction.hh
Go to the documentation of this file.
1 //
2 // LBNESteppingAction.hh
3 //
4 
5 #ifndef LBNESteppingAction_H
6 #define LBNESteppingAction_H 1
7 #include <fstream>
8 #include <iostream>
9 #include "globals.hh"
10 #include "G4UserSteppingAction.hh"
11 #include "G4LogicalVolume.hh"
13 
14 class G4EventManager;
15 class LBNEEventAction;
16 class LBNERunManager;
17 class TFile;
18 class TTree;
19 
20 //
21 // Investigating why fixing the Ring Hanger diameter gave no change at 3GeV.
22 // We will try to correlate the pion that crosses the
23 
24 class LBNESteppingAction : public G4UserSteppingAction
25 {
26 
27  public:
29  virtual ~LBNESteppingAction();
30 
31  virtual void UserSteppingAction(const G4Step*);
32 
33  void KillNonNuThresholdParticles(const G4Step * theStep);
34  void CheckDecay(const G4Step * theStep);
35  void SetMomentumInfoForParticle(const G4Step * theStep);//A. Bashyal ...ppfx
36 
37  void CheckInHornEndPlane(const G4Step * theStep);
38 
39  void CheckInTgtEndPlane(const G4Step * theStep);
40 
41  void OpenAscii(const char *fname); // for Geantino studies. (Absorption studies..)
42  void OpenNtuple(const char *fname); // for Geantino studies. (Absorption studies..)
43  // Extended to Particle flux with PoT at exit of Horn1, entrance of Horn2, exit of Horn2
44 
45 
46 
47 private:
48 
50  G4EventManager *EvtManager;
52  G4LogicalVolume *TrkPlnLogical; // tracking plane stuff
53  G4LogicalVolume *TrkPlnH1Logical; //tracking plane in the end of Horn1
54  G4LogicalVolume *TrkPlnH2Logical; //tracking plane in the end of Horn2
55  G4LogicalVolume *DecayPipeHall;
56  G4LogicalVolume *TrkPlnDPLogical; //tracking plane at the end of DecayPipe
57 //
58 // This partly "private code" from P. Lebrun, but could be used as template for other studies.
59 // Should not hurt if not activated..
60 //
62  std::ofstream fOutStudy;
63  std::ofstream fOutStepStudy;
64  bool makeSteppingTuple = false;
66  TTree *steppingTuple;
71 
73 
74 
75  // Study Geantino and absorption length patterns in the target/horn .
76 
77  double totalAbsDecayChan; // total absorption probability.
78  double totalAbsHorn1Neck; //At various Z locations..
83  double alumAbsHorn2Entr; // to check inner conductor horm geometry.
84 
87  mutable int fNumStepsCurrentTrack;
88 
93  mutable std::ofstream fStrHadronFluxFromTargetASCII;
95 
97  mutable std::ofstream fOutMuonSculptedAbsorber;
103  //
104  // More code bloat, quick study for Sergei Striganov, April 3 - 2017
105  //
106  mutable std::vector<std::ofstream*> fOutPtrsForMarsCmpApr2017;
107 
108  mutable double fEnergyDepInGraphite;
109  mutable double fEnergyDepInArgonGasHorn1;
111 
112  mutable bool fThisParticleGotToHAFront; // for computing the probability that a muon detected
113  // at the back of HA was created in the HA.
114  std::map<int,int> fRZVoxelsData; // Yet an other tool to debug geometry problem.
115  // contains the multiplicity on volume crossings for Geantinos
116 
123 
124  void StudyAbsorption(const G4Step*);
125  void StudyPropagation(const G4Step*);
126  void StudyCheckOverlap(const G4Step*);
127  void GenerateVolumeCrossingsRZMap(const G4Step * theStep);
128  // The above allow for a semi-blind test of the geometry,
129  // by filling a set of 2D (R-Z plane) of voxels.
130  void StudyCheckMagneticTilts(const G4Step*);
131  void dumpStepCheckVolumeAndFields(const G4Step*);
132  void StudyParticleThroughHorns(const G4Step*);
133  void StudyPionsThroughHorn2(const G4Step*);
134 
135 
136 public:
137  void CheckInTrackingDetectorH1Plane(const G4Step *theStep);
138  void CheckInTrackingDetectorH2Plane(const G4Step *theStep);
139  void CheckInTrackingDetectorDPPlane(const G4Step *theStep);
140  void CheckInTargetOutput(const G4Step *theStep);
141  void CheckInTrackingDetectorPlane(const G4Step *theStep);
142  void CheckInAlcoveTrackingPlane(const G4Step *theStep);
143  void SetKillTrackingThreshold(double t) {fKillTrackingThreshold = t;}
145  G4String GetStudyGeantinoMode() const { return fStudyGeantinoMode; }
146  void SetStudyGeantinoMode(G4String v) {fStudyGeantinoMode = v; }
147  void SetKeyVolumeForOutput(G4String v) {fKeyVolumeForOutput = v; }
148  void SetKeyVolumeForOutputTo(G4String v) {fKeyVolumeForOutputTo = v; }
149  void SetStudyParticleThroughHorns(bool t) {doStudyParticleThroughHorns = t;}
150  void InitiateHadronFluxFromTargetASCII() const; // Pseudo Const..
151  void FillHadronFluxFromTargetASCII(const G4Step *theStep) const;// Pseudo Const..
153  inline void ResetNumSteps() const {fNumStepsCurrentTrack = 0;} // Not const on mutable. Screw you..
154  inline void ResetEnergyDepInGraphite() const { fEnergyDepInGraphite = 0.;} // Same
155  inline void ResetEnergyDepInArgonGas() const {
156  fEnergyDepInArgonGasHorn1= 0.; fEnergyDepInArgonGasHorn2= 0.; } // Same
157  inline double GetEnergyDepInGraphite() const { return fEnergyDepInGraphite; }
158  inline double GetEnergyDepInArgonGasH1() const { return fEnergyDepInArgonGasHorn1; }
159  inline double GetEnergyDepInArgonGasH2() const { return fEnergyDepInArgonGasHorn2; }
160  void SetGenerateMuonSculptedAbsorberFlux(bool t){GenerateMuonSculptedAbsorberFlux = t;}
161  void SetMuonSculptedAbsorberFluxFilename(G4String str = "./MuonFluxAtSculptedAbsorber.txt")
162  {fOutMuonSculptedAbsorberFilename = str; }
163  void StudyMuonSculptedAbsorberFlux(const G4Step *theStep); // Also for LBNE Absorber, saving a method.
164  void StudySculptedAbsorberTrackingFlux(const G4Step *theStep); // Also for LBNE Absorber, saving a method.
166  inline void ResetFlagParticleGotToHAFront () const {fThisParticleGotToHAFront=false; } // pseudo const, for HA muon
167  // contamination studies.
168 
169  private:
170  void CheckHadronsMarsCmpApr2017(const G4Step *theStep);
171 
172 };
173 
174 #endif
175 
void SetKillTrackingThreshold(double t)
LBNESteppingActionMessenger * pMessenger
void StudyCheckOverlap(const G4Step *)
void SetStudyGeantinoMode(G4String v)
void dumpStepCheckVolumeAndFields(const G4Step *)
std::vector< std::ofstream * > fOutPtrsForMarsCmpApr2017
double GetEnergyDepInArgonGasH1() const
G4LogicalVolume * DecayPipeHall
std::map< int, int > fRZVoxelsData
void CheckInTrackingDetectorDPPlane(const G4Step *theStep)
void CloseSculptedAbsorberTrackingFlux()
void GenerateVolumeCrossingsRZMap(const G4Step *theStep)
void CheckInTrackingDetectorPlane(const G4Step *theStep)
void CheckInTargetOutput(const G4Step *theStep)
G4LogicalVolume * TrkPlnH1Logical
double GetEnergyDepInGraphite() const
void SetKeyVolumeForOutputTo(G4String v)
G4LogicalVolume * TrkPlnH2Logical
std::ofstream fOutMuonSculptedAbsorber
void StudyMuonSculptedAbsorberFlux(const G4Step *theStep)
void StudyCheckMagneticTilts(const G4Step *)
void CheckInTgtEndPlane(const G4Step *theStep)
void SetGenerateMuonSculptedAbsorberFlux(bool t)
void InitiateHadronFluxFromTargetASCII() const
void StudyPropagation(const G4Step *)
void SetKeyVolumeForOutput(G4String v)
void ResetEnergyDepInGraphite() const
void StudyParticleThroughHorns(const G4Step *)
void StudyPionsThroughHorn2(const G4Step *)
std::ofstream fStrHadronFluxFromTargetASCII
void StudySculptedAbsorberTrackingFlux(const G4Step *theStep)
void SetStudyParticleThroughHorns(bool t)
G4LogicalVolume * TrkPlnDPLogical
LBNERunManager * pRunManager
void ResetEnergyDepInArgonGas() const
void OpenNtuple(const char *fname)
void SetMuonSculptedAbsorberFluxFilename(G4String str="./MuonFluxAtSculptedAbsorber.txt")
void ResetFlagParticleGotToHAFront() const
void CheckInTrackingDetectorH2Plane(const G4Step *theStep)
std::ofstream fOutStepStudy
G4String GetStudyGeantinoMode() const
void KillNonNuThresholdParticles(const G4Step *theStep)
int GetNumTracksKilledAsStuck() const
LBNEEventAction * LBNEEvtAct
void CheckHadronsMarsCmpApr2017(const G4Step *theStep)
G4LogicalVolume * TrkPlnLogical
void OpenAscii(const char *fname)
void CheckInAlcoveTrackingPlane(const G4Step *theStep)
void CheckInTrackingDetectorH1Plane(const G4Step *theStep)
void CheckDecay(const G4Step *theStep)
void ResetNumSteps() const
void SetMomentumInfoForParticle(const G4Step *theStep)
double GetEnergyDepInArgonGasH2() const
void FillHadronFluxFromTargetASCII(const G4Step *theStep) const
G4EventManager * EvtManager
G4String fOutMuonSculptedAbsorberFilename
static QCString str
void CheckInHornEndPlane(const G4Step *theStep)
double GetKillTrackingThreshold() const
void StudyAbsorption(const G4Step *)
virtual void UserSteppingAction(const G4Step *)