1 #ifndef MACRO_FUN4ALLG4RUNEVALUATORS_C
2 #define MACRO_FUN4ALLG4RUNEVALUATORS_C
11 #include <G4Setup_EICDetector.C>
28 DIR*
dir = opendir(name.c_str());
30 return dir == NULL ? 0 : 1;
35 bool fileExists =
false;
37 for (
auto const& key : extension)
39 fileName = dir +
"/" + base + key.second;
40 ifstream
file(fileName.c_str());
41 if (
file.good()) fileExists =
true;
49 const string &inputFile =
"myInputFile.root",
50 const string &inputDir =
".",
52 const string &outdir =
".")
81 map<string, string> evaluatorNames;
82 evaluatorNames[
"event"] =
"_g4event_eval.root";
83 evaluatorNames[
"tracking"] =
"_g4tracking_eval.root";
84 evaluatorNames[
"becal"] =
"_g4becal_eval.root";
85 evaluatorNames[
"hcalin"] =
"_g4hcalin_eval.root";
86 evaluatorNames[
"hcalout"] =
"_g4hcalout_eval.root";
87 evaluatorNames[
"femc"] =
"_g4femc_eval.root";
88 evaluatorNames[
"fhcal"] =
"_g4fhcal_eval.root";
89 evaluatorNames[
"eemch"] =
"_g4eemch_eval.root";
90 evaluatorNames[
"ehcal"] =
"_g4ehcal_eval.root";
91 evaluatorNames[
"farfwd"] =
"_g4farfwd_eval.root";
131 string baseFile = inputFile;
132 string remove_this =
".root";
133 size_t pos = baseFile.find(remove_this);
134 if (pos != string::npos)
136 baseFile.erase(pos, remove_this.length());
139 string evalDir = outdir;
140 string outdirLastChar = outdir.substr(outdir.size() - 1, 1);
141 if (outdirLastChar !=
"/") evalDir +=
"/";
143 unsigned int revisionWidth = 5;
144 unsigned int revisionNumber = 0;
145 ostringstream evalRevision;
146 evalRevision << setfill(
'0') << setw(revisionWidth) <<
to_string(revisionNumber);
147 evalDir +=
"eval_" + evalRevision.str();
151 bool evalFileStatus =
checkForFile(evalDir, baseFile, evaluatorNames);
152 if (!evalFileStatus)
break;
153 evalDir = evalDir.substr(0, evalDir.size() - revisionWidth);
155 evalRevision.str(
"");
156 evalRevision.clear();
157 evalRevision << setfill(
'0') << setw(revisionWidth) <<
to_string(revisionNumber);
158 evalDir += evalRevision.str();
161 string makeDirectory =
"mkdir -p " + evalDir;
162 system(makeDirectory.c_str());
164 string outputroot = evalDir +
"/" + baseFile;
207 cout <<
"All done" << endl;