LBNEEventAction.cc
Go to the documentation of this file.
1 //
2 //LBNEEventAction.cc
3 //
4 
5 //C++
6 #include <string>
7 #include <stdlib.h>
8 
9 #include "LBNEEventAction.hh"
10 #include "LBNERunManager.hh"
11 #include "LBNEAnalysis.hh"
12 #include "LBNETrajectory.hh"
13 
14 #include "G4RunManager.hh"
15 #include "G4Run.hh"
16 #include "G4Event.hh"
17 #include "G4Track.hh"
18 #include "G4EventManager.hh"
19 #include "G4TrajectoryContainer.hh"
20 #include "G4Trajectory.hh"
21 #include "G4ios.hh"
22 #include "LBNEQuickPiToNu.hh"
23 
24 //-------------------------------------------------------------------------------------
26 {
27  pRunManager=(LBNERunManager*)LBNERunManager::GetRunManager();
28 
29  if(pRunManager->GetVerboseLevel() > 0)
30  {
31  std::cout << "LBNEEventAction Constructor Called." << std::endl;
32  }
33 
34 }
35 
36 //-------------------------------------------------------------------------------------
38 {
39 
40  if(pRunManager->GetVerboseLevel() > 0)
41  {
42  std::cout << "LBNEEventAction Destructor Called." << std::endl;
43  }
44 }
45 
46 //-------------------------------------------------------------------------------------
48 {
49  if(pRunManager->GetVerboseLevel() > 1)
50  {
51  G4cout << "LBNEEventAction::BeginOfEventAction called...Beginning Event #" << evt->GetEventID() << G4endl;
52  }
53  const LBNERunAction *runUserAction = reinterpret_cast<const LBNERunAction *>(G4RunManager::GetRunManager()->GetUserRunAction());
54  if (runUserAction->GetDoComputeEDepInGraphite()) {
55  LBNESteppingAction *stepAction = (LBNESteppingAction *) G4RunManager::GetRunManager()->GetUserSteppingAction();
56  stepAction->ResetEnergyDepInGraphite();
57 // std::cerr << " Ready to tally energy deposition in the graphite ... " << std::endl;
58  }
59  if (runUserAction->GetDoComputeEDepInArgonGas()) {
60  LBNESteppingAction *stepAction = (LBNESteppingAction *) G4RunManager::GetRunManager()->GetUserSteppingAction();
61  stepAction->ResetEnergyDepInArgonGas();
62 // std::cerr << " Ready to tally energy deposition in the graphite ... " << std::endl;
63  }
64  // This code does not work.. Need to be studied..
65 // if (evt->GetEventID() == -2222) {
66 //
67 // CLHEP::HepRandom::restoreEngineStatus("./rndm/beginRun_103Evt_32135.rndm");
68 // std::cerr << " Reloaded random from 103Evt_32135 " << std::endl;
69 // }
70 //
71 // if (evt->GetEventID() > 32130) {
72 // const G4Run* theRun = pRunManager->GetCurrentRun();
73 // std::ostringstream fOutRndmStrStr;
74 // fOutRndmStrStr << "./rndm/beginRun_" << theRun->GetRunID() << "Evt_" << evt->GetEventID() << ".rndm";
75 // std::string fOutRndmStr(fOutRndmStrStr.str());
76 // CLHEP::HepRandom::saveEngineStatus(fOutRndmStr.c_str());
77  // delete the previous previous file
78 // std::ostringstream fOutRndmPStrStr;
79 // fOutRndmPStrStr << "rm -f ./rndm/beginRun_" << theRun->GetRunID() << "Evt_" << evt->GetEventID()-2 << ".rndm";
80 // std::string fOutRndmPStr(fOutRndmPStrStr.str());
81 // system(fOutRndmPStr.c_str());
82  // Also get the seeds May this what we have to save...
83 // std::cerr << " The seed is now " << CLHEP::HepRandom::getTheSeed() << std::endl;
84 // }
85 
87  //--for tracking planes
89  analysis->ResetEvent();
90  }
91 
92 }
93 
94 
95 //-------------------------------------------------------------------------------------
97 {
98  if(pRunManager->GetVerboseLevel() > 1)
99  {
100  G4cout << "LBNEEventAction::EndOfEventAction called...Ending Event # " << evt-> GetEventID() << G4endl;
101  }
103 
104  const LBNERunAction *runUserAction = reinterpret_cast<const LBNERunAction *>(G4RunManager::GetRunManager()->GetUserRunAction());
105  if (runUserAction->GetDoComputeEDepInGraphite()) {
106  const LBNESteppingAction *stepAction =
107  reinterpret_cast<const LBNESteppingAction *>
108  (G4RunManager::GetRunManager()->GetUserSteppingAction());
109  runUserAction->storeEDepInGraphite(stepAction->GetEnergyDepInGraphite());
110  }
111  if (runUserAction->GetDoComputeEDepInArgonGas()) {
112  const LBNESteppingAction *stepAction =
113  reinterpret_cast<const LBNESteppingAction *>
114  (G4RunManager::GetRunManager()->GetUserSteppingAction());
115  const double eDepH1 = stepAction->GetEnergyDepInArgonGasH1();
116  const double eDepH2 = stepAction->GetEnergyDepInArgonGasH2();
117  runUserAction->storeEDepInArgonGas(eDepH1, eDepH2);
118  }
119 
120  //--for tracking planes
123  analysis->FillEvent();
124  }
125 
126 }
127 
bool GetDoComputeEDepInGraphite() const
void BeginOfEventAction(const G4Event *)
bool GetDoComputeEDepInArgonGas() const
double GetEnergyDepInArgonGasH1() const
bool GetCreateAlcoveTrackingOutput() const
double GetEnergyDepInGraphite() const
void storeEDepInGraphite(double edep) const
static LBNEAnalysis * getInstance()
void EndOfEventAction(const G4Event *)
void ResetEnergyDepInGraphite() const
bool GetCreateTrkPlaneOutput() const
static LBNEQuickPiToNuVect * Instance()
void storeEDepInArgonGas(double edepH1, double edepH2) const
void ResetEnergyDepInArgonGas() const
LBNERunManager * pRunManager
int GetVerboseLevel() const
TCEvent evt
Definition: DataStructs.cxx:5
double GetEnergyDepInArgonGasH2() const
QTextStream & endl(QTextStream &s)