Skip to content

Commit

Permalink
Enabled production settings
Browse files Browse the repository at this point in the history
  • Loading branch information
cdean-github committed Jul 16, 2021
1 parent 229dc1b commit fcec1fb
Show file tree
Hide file tree
Showing 2 changed files with 195 additions and 12 deletions.
24 changes: 12 additions & 12 deletions detectors/EICDetector/Fun4All_G4_EICDetector.C
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down Expand Up @@ -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;

Expand All @@ -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
Expand Down Expand Up @@ -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;
Expand All @@ -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;

Expand All @@ -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;
Expand All @@ -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;
Expand All @@ -361,15 +361,15 @@ 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;
//Enable::BLACKHOLE_SAVEHITS = false; // turn off saving of bh hits
//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

Expand Down
183 changes: 183 additions & 0 deletions detectors/EICDetector/Fun4All_runEvaluators.C
Original file line number Diff line number Diff line change
@@ -0,0 +1,183 @@
#ifndef MACRO_FUN4ALLG4RUNEVALUATORS_C
#define MACRO_FUN4ALLG4RUNEVALUATORS_C

#include <dirent.h>
#include <fstream>
#include <map>
#include <stdlib.h>

#include <GlobalVariables.C>

#include <G4Setup_EICDetector.C>
#include <G4_DSTReader_EICDetector.C>
#include <G4_EventEvaluator.C>
#include <G4_FwdJets.C>
#include <G4_Global.C>
#include <G4_Input.C>
#include <G4_Production.C>
#include <G4_User.C>

#include <fun4all/Fun4AllServer.h>

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<string, string> 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<string, string> 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

0 comments on commit fcec1fb

Please sign in to comment.