7#include "TSystemDirectory.h" 
    9#include "TChainElement.h" 
   11#include "TInterpreter.h" 
   18#include "TStopwatch.h" 
   39   std::vector<std::string> treeList;
 
   44      TFile* inputFile = TFile::Open(i.c_str());
 
   45      if((inputFile != 
nullptr) && inputFile->IsOpen()) {
 
   46         if(inputFile->FindObjectAny(treeType) != 
nullptr) {
 
   47            treeList.push_back(i);
 
   52            if(inputFile->Get(
"TPPG") != 
nullptr) {
 
   53               std::cout << inputFile->GetName() << 
": adding ppg" << std::endl;
 
   54               gPpg->
Add(
static_cast<TPPG*
>(inputFile->Get(
"TPPG")));
 
   57         if(channel == 
nullptr || inputFile->FindObjectAny(
"Channel") != 
nullptr) {
 
   58            channel = 
static_cast<TChannel*
>(inputFile->Get(
"Channel"));
 
   67   if(treeList.empty()) {
 
   77   auto* proofChain = 
new TChain(treeType);
 
   79   for(
auto& i : treeList) {
 
   80      proofChain->Add(i.c_str());   
 
   85      proofChain->SetProof();
 
   89      std::cout << 
"Currently Running: " << (Form(
"%s", macroIt.c_str())) << std::endl;
 
   92            proofChain->Process(Form(
"%s+", macroIt.c_str()));
 
  100      std::cout << 
"Done with " << (Form(
"%s", macroIt.c_str())) << std::endl;
 
 
  114      std::cout << 
"getting session logs ..." << std::endl;
 
  115      TProofLog* pl = TProof::Mgr(
"proof://__lite__")->GetSessionLogs();
 
  120         std::string firstMacro;
 
  122         firstMacro = basename(
const_cast<char*
>(firstMacro.c_str()));      
 
  123         firstMacro = firstMacro.substr(0, firstMacro.find_last_of(
'.'));   
 
  125         if(runNumber != 0 && subRunNumber != -1) {
 
  127            pl->Save(
"*", Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber));
 
  128            std::cout << 
"Wrote logs to '" << Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber) << 
"'" << std::endl;
 
  129         } 
else if(runNumber != 0) {
 
  139         std::cout << 
"Failed to get logs!" << std::endl;
 
  142      std::cout << 
"stopping all workers ..." << std::endl;
 
  148   int    hour     = 
static_cast<int>(realTime / 3600);
 
  149   realTime -= hour * 3600;
 
  150   int min = 
static_cast<int>(realTime / 60);
 
  151   realTime -= min * 60;
 
  153             << 
"Done after " << hour << 
":" << std::setfill(
'0') << std::setw(2) << min << 
":" 
  154             << std::setprecision(3) << std::fixed << realTime << 
" h:m:s" 
 
  167   struct sigaction action{};
 
  170   sigemptyset(&action.sa_mask);
 
  171   sigaction(SIGINT, &action, 
nullptr);
 
  172   sigaction(SIGTERM, &action, 
nullptr);
 
 
  177   std::string grsiPath = getenv(
"GRSISYS");   
 
  178   if(grsiPath.length() > 0) {
 
  182   grsiPath += 
".grsirc";
 
  183   gEnv->ReadFile(grsiPath.c_str(), kEnvChange);
 
 
  204   const char* pPath = getenv(
"GRSISYS");
 
  205   gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
 
  208   if(!library.empty()) {
 
  209      size_t tmpPos = library.rfind(
"/lib/lib");
 
  210      if(tmpPos != std::string::npos) {
 
  211         gInterpreter->AddIncludePath(Form(
"%s/include", library.substr(0, tmpPos).c_str()));
 
  213         std::cout << 
"Warning, expected dataparser/detector library location to be of form <path>/lib/lib<name>.so, but it is " << library << 
". Won't be able to add include path!" << std::endl;
 
  217      std::cout << 
"Warning, no dataparser/detector library provided, won't be able to add include path!" << std::endl;
 
  221      std::cout << 
DRED << 
"Can't PROOF if there is no MACRO" << 
RESET_COLOR << std::endl;
 
  224   std::cout << 
DCYAN << 
"************************* MACRO COMPILATION ****************************" << 
RESET_COLOR 
  227      Int_t errorCode = gSystem->CompileMacro(i.c_str(), 
"kgOs");   
 
  229         std::cout << 
DRED << i << 
" failed to compile properly.. ABORT!" << 
RESET_COLOR << std::endl;
 
  233   std::cout << 
DCYAN << 
"************************* END COMPILATION ******************************" << 
RESET_COLOR 
  237      std::cout << 
DRED << 
"Can't Proof a Midas file..." << 
RESET_COLOR << std::endl;
 
  242      std::cout << 
"Opening proof with '" << Form(
"workers=%d", 
gGRSIOpt->
GetMaxWorkers()) << 
"'" << std::endl;
 
  245      std::cout << 
"Opening proof with one worker (selector-only)" << std::endl;
 
  252      std::cout << 
"Couldn't connect to proof on first attempt, trying again" << std::endl;
 
  254         std::cout << 
"Opening proof with '" << Form(
"workers=%d", 
gGRSIOpt->
GetMaxWorkers()) << 
"'" << std::endl;
 
  257         std::cout << 
"Opening proof with one worker (selector-only)" << std::endl;
 
  265      std::cout << 
"Still can't connect to proof, try running it again?" << std::endl;
 
  277      gGRSIProof->SetParameter(
"PROOF_UseParallelUnzip", 1);
 
  279      gGRSIProof->SetParameter(
"PROOF_UseParallelUnzip", 0);
 
  285         gGRSIProof->SetParameter(
"PROOF_UseTreeCache", 0);
 
  287         gGRSIProof->SetParameter(
"PROOF_UseTreeCache", 1);
 
  292      gGRSIProof->DeleteParameters(
"PROOF_UseTreeCache");
 
  293      gGRSIProof->DeleteParameters(
"PROOF_CacheSize");
 
  300      gGRSIProof->DeleteParameters(
"PROOF_UseMergers");
 
  305      gGRSIProof->SetParameter(
"PROOF_StatsHist", 
"");
 
  306      gGRSIProof->SetParameter(
"PROOF_StatsTrace", 
"");
 
  307      gGRSIProof->SetParameter(
"PROOF_RateTrace", 
"");
 
  308      gGRSIProof->SetParameter(
"PROOF_SlaveStatsTrace", 
"");
 
  312   TGRSIProof::AddEnvVar(
"GRSISYS", pPath);
 
  313   gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
 
  314   gGRSIProof->AddIncludePath(Form(
"%s/include", pPath));
 
  315   gGRSIProof->AddDynamicPath(Form(
"%s/lib", pPath));
 
  318   gGRSIProof->AddInput(
new TNamed(
"pwd", getenv(
"PWD")));
 
  321      gGRSIProof->AddInput(
new TNamed(Form(
"valFile%d", index++), valFile.c_str()));
 
  325      gGRSIProof->AddInput(
new TNamed(Form(
"calFile%d", index++), calFile.c_str()));
 
  329      gGRSIProof->AddInput(
new TNamed(Form(
"cutFile%d", index++), cutFile.c_str()));
 
  331   gGRSIProof->AddInput(
new TNamed(
"ParserLibrary", library.c_str()));
 
  338      std::cout << 
"Running selector on tree '" << 
gGRSIOpt->
TreeName() << 
"'" << std::endl;
 
 
std::string detail() const noexcept
 
const std::vector< std::string > & RootInputFiles() const
 
bool AverageRateEstimation() const
 
bool SelectorOnly() const
 
static TGRSIOptions * Get(int argc=0, char **argv=nullptr)
Do not use!
 
const std::vector< std::string > & InputFiles() const
 
size_t NumberOfEvents() const
 
const std::vector< std::string > & InputCutFiles() const
 
static TAnalysisOptions * AnalysisOptions()
 
std::string TreeName() const
 
const std::vector< std::string > & ValInputFiles() const
 
bool ParallelUnzip() const
 
const std::vector< std::string > & CalInputFiles() const
 
void ParserLibrary(std::string &library)
 
const std::vector< std::string > & MacroInputFiles() const
 
int GetMaxWorkers() const
 
static TGRSIProof * Open(const char *worker="")
 
void Add(const TPPG *ppg)
 
static int LastRunNumber()
 
static int SubRunNumber()
 
static int LastSubRunNumber()
 
static int FirstSubRunNumber()
 
void Print(Option_t *opt="") const override
 
static int FirstRunNumber()
 
static TRunInfo * AddCurrent()
 
static TRunInfo * Get(bool verbose=false)
 
int main(int argc, char **argv)
 
static void CatchSignals()
 
void Analyze(const char *treeType)