12 #include "G4UImanager.hh" 13 #include "G4VVisManager.hh" 18 #include "Randomize.hh" 22 #include "G4ProcessTable.hh" 23 #include "G4ExceptionSeverity.hh" 30 fDoComputeEDepInGraphite(false),
31 fDoComputeEDepInArgonGas(false),
32 fMeanEDepInGraphite(0.),
33 fRMSEDepInGraphite(0.),
34 fMeanEDepInArgonGasHorn1(0.),
35 fRMSEDepInArgonGasHorn1(0.),
36 fMeanEDepInArgonGasHorn2(0.),
37 fRMSEDepInArgonGasHorn2(0.),
38 fDoComputeEDepInHorns(false),
44 std::cout <<
"LBNERunAction Constructor Called." <<
std::endl;
56 std::cout <<
"LBNERunAction Destructor Called." <<
std::endl;
67 std::cout <<
"LBNERunAction::BeginOfRunAction() Called." <<
std::endl;
73 G4String spaces =
" ";
75 std::cout <<
"LBNERunAction::BeginOfRunAction() - Initializing Run " 76 << aRun->GetRunID() <<
"..." <<
std::endl;
83 G4String randomFile=
"rndm/beginOfRun_";
85 snprintf(runN, 4,
"%03d",aRun->GetRunID());
86 randomFile.append(runN);
87 randomFile.append(
".rndm");
88 CLHEP::HepRandom::saveEngineStatus(randomFile);
89 std::cout << spaces <<
"Intializing Random Number generator named " 90 << CLHEP::HepRandom::getTheEngine()->name() <<
" ... " <<
std::endl 91 << spaces <<
" Seed = " << CLHEP::HepRandom::getTheSeed() <<
std::endl 92 << spaces <<
" Saving Random engine status in "<< randomFile <<
std::endl;
112 if(!primaryGeneratorAction)
114 std::cout << spaces <<
"PROBLEM: INVALID LBNEPrimaryGeneratorAction POINTER" <<
std::endl;
131 std::ostringstream mStrStr;
132 mStrStr <<
"PROBLEM: FAILED TO OPEN INPUT NTUPLE. Fatal " <<
std::endl;
133 G4String mStr(mStrStr.str());
134 G4Exception(
"LBNERunAction::BeginOfRunAction",
" ", RunMustBeAborted, mStr.c_str());
139 std::cout << spaces <<
"Successfully opened input ntuple \"" 160 if(theRunManager -> GetCreateOutput())
162 std::ostringstream mStrStr;
163 mStrStr <<
"PROBLEM: FAILED TO OPEN OUTPUT NTUPLE. Fatal " <<
std::endl;
164 G4String mStr(mStrStr.str());
165 G4Exception(
"LBNERunAction::BeginOfRunAction",
" ", RunMustBeAborted, mStr.c_str());
168 if(theRunManager -> GetCreateDk2NuOutput()) {
170 std::ostringstream mStrStr;
171 mStrStr <<
"PROBLEM: FAILED TO OPEN Dk2Nu OUTPUT NTUPLE. Fatal " <<
std::endl;
172 G4String mStr(mStrStr.str());
173 G4Exception(
"LBNERunAction::BeginOfRunAction",
" ", RunMustBeAborted, mStr.c_str());
179 const bool doLBNEQuickPiToNu =
false;
180 if (doLBNEQuickPiToNu) {
183 std::ostringstream fNameStr;
186 fNameStr << theRunManager->GetCurrentRun()->GetRunID();
188 std::cerr <<
" QuickPitoNu file name " << fName <<
std::endl;
197 std::cout <<
"LBNERunAction::BeginOfRunAction() - ...completed run initialization. " <<
std::endl;
212 std::cout <<
"LBNERunAction::EndOfRunAction() Called." <<
std::endl;
216 std::cout <<
" End of Run. Number of tracks killed because stuck " 221 G4String spaces =
" ";
223 std::cout <<
"LBNERunAction::EndOfRunAction() - Terminating Run " 224 << aRun->GetRunID() <<
"..." <<
std::endl;
229 G4String randomFile=
"rndm/endOfRun_";
231 snprintf(runN, 4,
"%03d",aRun->GetRunID());
232 randomFile.append(runN);
233 randomFile.append(
".rndm");
234 CLHEP::HepRandom::saveEngineStatus(randomFile);
235 std::cout << spaces <<
"Closing Random Number generator... " << std::endl
236 << spaces <<
" Seed = " << CLHEP::HepRandom::getTheSeed() << std::endl
237 << spaces <<
" Random engine status saved in "<< randomFile <<
std::endl;
243 std::cout << spaces <<
"Closing Input File... " <<
std::endl;
246 if(primaryGeneratorAction)
251 if(theRunManager -> GetCreateOutput())
253 std::cout << spaces <<
"Closing Output File... " <<
std::endl;
257 if(theRunManager -> GetCreateDk2NuOutput())
259 std::cout << spaces <<
"Closing Dk2Nu Output File... " <<
std::endl;
265 int numEvts = aRun->GetNumberOfEvent();
269 std::cout <<
"LBNERunAction::EndOfRunAction .. Average energy deposition in target [GeV] " 273 int numEvts = aRun->GetNumberOfEvent();
277 std::cout <<
"LBNERunAction::EndOfRunAction .. Average energy deposition in Argon Gas Horn1 [MeV] " 282 std::cout <<
"LBNERunAction::EndOfRunAction .. Average energy deposition in Argon Gas Horn2 [MeV] " 288 const char* aDirGG =
getenv(
"_CONDOR_SCRATCH_DIR");
291 std::cerr <<
" Before deleting fG4MARSDeDxMap " <<
std::endl;
296 std::cout <<
"LBNERunAction::EndOfRunAction() - ...completed run termination. " <<
std::endl;
374 double vm_usage = 0.0;
379 ifstream stat_stream(
"/proc/self/stat",ios_base::in);
383 string pid, comm, state, ppid, pgrp, session, tty_nr;
384 string tpgid, flags, minflt, cminflt, majflt, cmajflt;
385 string utime, stime, cutime, cstime, priority, nice;
386 string O, itrealvalue, starttime;
393 stat_stream >> pid >> comm >> state >> ppid >> pgrp >> session >> tty_nr
394 >> tpgid >> flags >> minflt >> cminflt >> majflt >> cmajflt
395 >> utime >> stime >> cutime >> cstime >> priority >> nice
396 >> O >> itrealvalue >> starttime >> vsize >> rss;
403 vm_usage = vsize / 1024.0;
405 if (vm_usage > VMlimit) {
406 std::cerr <<
" Current memory usage " << vm_usage <<
" Too much above limit " << VMlimit <<
std::endl;
double fRMSEDepInArgonGasHorn1
bool fDoComputeEDepInArgonGas
double fRMSEDepInGraphite
bool fDoComputeEDepInHorns
constexpr auto const & right(const_AssnsIter< L, R, D, Dir > const &a, const_AssnsIter< L, R, D, Dir > const &b)
LBNFDeDxMap * fG4MARSDeDxMap
LBNEPrimaryGeneratorAction * GetLBNEPrimaryGeneratorAction()
void dumpASCII(const std::string &aDirectory, int nEvt)
void SetNumberOfEventsLBNE(int n)
bool GetUseMarsInput() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
LBNERunActionMessenger * runMessenger
static LBNEAnalysis * getInstance()
bool fDoComputeEDepInGraphite
double fMeanEDepInArgonGasHorn2
std::string getenv(std::string const &name)
G4bool OpenNtuple(G4String ntupleName)
double fRMSEDepInArgonGasHorn2
static LBNEQuickPiToNuVect * Instance()
double fMeanEDepInArgonGasHorn1
double fMeanEDepInGraphite
void CheckMemoryUsage(double VMLimit) const
G4String GetOutputNtpFileName() const
void EndOfRunAction(const G4Run *)
void BeginOfRunAction(const G4Run *)
void open(const std::string &prefix)
int GetNumTracksKilledAsStuck() const
int GetVerboseLevel() const
G4bool CreateDk2NuOutput()
bool GetUseFlukaInput() const
G4String GetNptInputFileName() const
QTextStream & endl(QTextStream &s)