From fcec1fb8cf6146bb6b7023f430938be3382e1d70 Mon Sep 17 00:00:00 2001 From: cdean-github Date: Fri, 16 Jul 2021 11:29:46 -0400 Subject: [PATCH] Enabled production settings --- .../EICDetector/Fun4All_G4_EICDetector.C | 24 +-- detectors/EICDetector/Fun4All_runEvaluators.C | 183 ++++++++++++++++++ 2 files changed, 195 insertions(+), 12 deletions(-) create mode 100644 detectors/EICDetector/Fun4All_runEvaluators.C diff --git a/detectors/EICDetector/Fun4All_G4_EICDetector.C b/detectors/EICDetector/Fun4All_G4_EICDetector.C index 75844cfc..9b399ccc 100644 --- a/detectors/EICDetector/Fun4All_G4_EICDetector.C +++ b/detectors/EICDetector/Fun4All_G4_EICDetector.C @@ -48,7 +48,7 @@ int Fun4All_G4_EICDetector( // which will produce identical results so you can debug your code // rc->set_IntFlag("RANDOMSEED", 12345); - bool generate_seed = false; + bool generate_seed = true; if (generate_seed) { @@ -102,7 +102,7 @@ int Fun4All_G4_EICDetector( // Input::SARTRE = true; // Simple multi particle generator in eta/phi/pt ranges - Input::SIMPLE = true; + // Input::SIMPLE = true; // Input::SIMPLE_NUMBER = 2; // if you need 2 of them // Input::SIMPLE_VERBOSITY = 1; @@ -119,7 +119,7 @@ int Fun4All_G4_EICDetector( // And/Or read generated particles from file // eic-smear output - // Input::READEIC = true; + Input::READEIC = true; INPUTREADEIC::filename = inputFile; // HepMC2 files @@ -289,7 +289,7 @@ int Fun4All_G4_EICDetector( Enable::CTTL = true; Enable::TRACKING = true; - Enable::TRACKING_EVAL = Enable::TRACKING && true; + Enable::TRACKING_EVAL = Enable::TRACKING && false; G4TRACKING::DISPLACED_VERTEX = false; // this option exclude vertex in the track fitting and use RAVE to reconstruct primary and 2ndary vertexes // projections to calorimeters G4TRACKING::PROJECTION_EEMC = true; @@ -302,14 +302,14 @@ int Fun4All_G4_EICDetector( Enable::CEMC_CELL = Enable::CEMC && true; Enable::CEMC_TOWER = Enable::CEMC_CELL && true; Enable::CEMC_CLUSTER = Enable::CEMC_TOWER && true; - Enable::CEMC_EVAL = Enable::CEMC_CLUSTER && true; + Enable::CEMC_EVAL = Enable::CEMC_CLUSTER && false Enable::HCALIN = true; // Enable::HCALIN_ABSORBER = true; Enable::HCALIN_CELL = Enable::HCALIN && true; Enable::HCALIN_TOWER = Enable::HCALIN_CELL && true; Enable::HCALIN_CLUSTER = Enable::HCALIN_TOWER && true; - Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && true; + Enable::HCALIN_EVAL = Enable::HCALIN_CLUSTER && false; Enable::MAGNET = true; @@ -318,7 +318,7 @@ int Fun4All_G4_EICDetector( Enable::HCALOUT_CELL = Enable::HCALOUT && true; Enable::HCALOUT_TOWER = Enable::HCALOUT_CELL && true; Enable::HCALOUT_CLUSTER = Enable::HCALOUT_TOWER && true; - Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && true; + Enable::HCALOUT_EVAL = Enable::HCALOUT_CLUSTER && false; // EICDetector geometry - barrel Enable::DIRC = true; @@ -333,19 +333,19 @@ int Fun4All_G4_EICDetector( // Enable::FEMC_ABSORBER = true; Enable::FEMC_TOWER = Enable::FEMC && true; Enable::FEMC_CLUSTER = Enable::FEMC_TOWER && true; - Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && true; + Enable::FEMC_EVAL = Enable::FEMC_CLUSTER && false; Enable::FHCAL = true; // Enable::FHCAL_ABSORBER = true; Enable::FHCAL_TOWER = Enable::FHCAL && true; Enable::FHCAL_CLUSTER = Enable::FHCAL_TOWER && true; - Enable::FHCAL_EVAL = Enable::FHCAL_CLUSTER && true; + Enable::FHCAL_EVAL = Enable::FHCAL_CLUSTER && false; // EICDetector geometry - 'electron' direction Enable::EEMC = true; Enable::EEMC_TOWER = Enable::EEMC && true; Enable::EEMC_CLUSTER = Enable::EEMC_TOWER && true; - Enable::EEMC_EVAL = Enable::EEMC_CLUSTER && true; + Enable::EEMC_EVAL = Enable::EEMC_CLUSTER && false; Enable::EHCAL = true; Enable::EHCAL_CELL = Enable::EHCAL && true; @@ -361,7 +361,7 @@ int Fun4All_G4_EICDetector( // jet reconstruction Enable::FWDJETS = true; - Enable::FWDJETS_EVAL = Enable::FWDJETS && true; + Enable::FWDJETS_EVAL = Enable::FWDJETS && false; // new settings using Enable namespace in GlobalVariables.C Enable::BLACKHOLE = true; @@ -369,7 +369,7 @@ int Fun4All_G4_EICDetector( //BlackHoleGeometry::visible = true; // Enabling the event evaluator? - Enable::EVENT_EVAL = true; + Enable::EVENT_EVAL = false; // EVENT_EVALUATOR::Verbosity = 1; // EVENT_EVALUATOR::EnergyThreshold = 0.05; // GeV diff --git a/detectors/EICDetector/Fun4All_runEvaluators.C b/detectors/EICDetector/Fun4All_runEvaluators.C new file mode 100644 index 00000000..d1fbba27 --- /dev/null +++ b/detectors/EICDetector/Fun4All_runEvaluators.C @@ -0,0 +1,183 @@ +#ifndef MACRO_FUN4ALLG4RUNEVALUATORS_C +#define MACRO_FUN4ALLG4RUNEVALUATORS_C + +#include +#include +#include +#include + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +#include + +using namespace std; + +R__LOAD_LIBRARY(libfun4all.so) + +bool checkForDir(string name) +{ + DIR* dir = opendir(name.c_str()); + + return dir == NULL ? 0 : 1; +} + +bool checkForFile(string dir, string base, map extension) +{ + bool fileExists = false; + string fileName; + for (auto const& key : extension) + { + fileName = dir + "/" + base + key.second; + ifstream file(fileName.c_str()); + if (file.good()) fileExists = true; + } + + return fileExists; +} + +int Fun4All_runEvaluators( + const int nEvents = 1, + const string &inputFile = "myInputFile.root", + const string &inputDir = ".", + const int skip = 0, + const string &outdir = ".") +{ + Fun4AllServer *se = Fun4AllServer::instance(); + se->Verbosity(0); + + Input::READHITS = true; + INPUTREADHITS::filename[0] = inputDir + "/" + inputFile; + + InputInit(); + + //----- + // What to run + //----- + + Enable::DSTREADER = false; + Enable::USER = false; + + Enable::EVENT_EVAL = true; + Enable::TRACKING_EVAL = true; + Enable::CEMC_EVAL = true; + Enable::HCALIN_EVAL = true; + Enable::HCALOUT_EVAL = true; + Enable::FEMC_EVAL = true; + Enable::FHCAL_EVAL = true; + Enable::EEMC_EVAL = true; + Enable::FWDJETS_EVAL = true; + + map evaluatorNames; + evaluatorNames["event"] = "_g4event_eval.root"; + evaluatorNames["tracking"] = "_g4tracking_eval.root"; + evaluatorNames["cemc"] = "_g4cemc_eval.root"; + evaluatorNames["hcalin"] = "_g4hcalin_eval.root"; + evaluatorNames["hcalout"] = "_g4hcalout_eval.root"; + evaluatorNames["femc"] = "_g4femc_eval.root"; + evaluatorNames["fhcal"] = "_g4fhcal_eval.root"; + evaluatorNames["eemc"] = "_g4eemc_eval.root"; + + Enable::TRACKING = true; + Enable::CEMC_CLUSTER = true; + Enable::EEMC_CLUSTER = true; + Enable::FEMC_CLUSTER = true; + Enable::HCALIN_CLUSTER = true; + Enable::HCALOUT_CLUSTER = true; + Enable::FHCAL_CLUSTER = true; + + //----- + // Output file headers and path + //----- + + //Get base file name + string baseFile = inputFile; + string remove_this = ".root"; + size_t pos = baseFile.find(remove_this); + if (pos != string::npos) + { + baseFile.erase(pos, remove_this.length()); + } + + string evalDir = outdir; + string outdirLastChar = outdir.substr(outdir.size() - 1, 1); + if (outdirLastChar != "/") evalDir += "/"; + + unsigned int revisionWidth = 5; + unsigned int revisionNumber = 0; + ostringstream evalRevision; + evalRevision << setfill('0') << setw(revisionWidth) << to_string(revisionNumber); + evalDir += "eval_" + evalRevision.str(); + + while (checkForDir(evalDir)) + { + bool evalFileStatus = checkForFile(evalDir, baseFile, evaluatorNames); + if (!evalFileStatus) break; + evalDir = evalDir.substr(0, evalDir.size() - revisionWidth); + revisionNumber++; + evalRevision.str(""); + evalRevision.clear(); + evalRevision << setfill('0') << setw(revisionWidth) << to_string(revisionNumber); + evalDir += evalRevision.str(); + } + + string makeDirectory = "mkdir -p " + evalDir; + system(makeDirectory.c_str()); + + string outputroot = evalDir + "/" + baseFile; + + //----- + // Reader and User analysis + //----- + + if (Enable::DSTREADER) G4DSTreader_EICDetector(outputroot + "_DSTReader.root"); + if (Enable::USER) UserAnalysisInit(); + + //----- + // Evaluators + //----- + + if (Enable::EVENT_EVAL) Event_Eval(outputroot + evaluatorNames.find("event")->second); + if (Enable::TRACKING_EVAL) Tracking_Eval(outputroot + evaluatorNames.find("tracking")->second); + if (Enable::CEMC_EVAL) CEMC_Eval(outputroot + evaluatorNames.find("cemc")->second); + if (Enable::HCALIN_EVAL) HCALInner_Eval(outputroot + evaluatorNames.find("hcalin")->second); + if (Enable::HCALOUT_EVAL) HCALOuter_Eval(outputroot + evaluatorNames.find("hcalout")->second); + if (Enable::FEMC_EVAL) FEMC_Eval(outputroot + evaluatorNames.find("femc")->second); + if (Enable::FHCAL_EVAL) FHCAL_Eval(outputroot + evaluatorNames.find("fhcal")->second); + if (Enable::EEMC_EVAL) EEMC_Eval(outputroot + evaluatorNames.find("eemc")->second); + //if (Enable::FWDJETS_EVAL) Jet_FwdEval(); + + //-------------- + // Set up Input Managers + //-------------- + + InputManagers(); + + //----- + // Run + //----- + + se->skip(skip); + se->run(nEvents); + + //----- + // Exit + //----- + + se->End(); + cout << "All done" << endl; + delete se; + + gSystem->Exit(0); + return 0; +} + +#endif