7#include "TInterpreter.h"
14#include "TStopwatch.h"
33 std::vector<std::string> treeList;
38 TFile* inputFile = TFile::Open(i.c_str());
39 if((inputFile !=
nullptr) && inputFile->IsOpen()) {
40 if(inputFile->FindObjectAny(treeType) !=
nullptr) {
41 treeList.push_back(i);
46 if(inputFile->Get(
"TPPG") !=
nullptr) {
47 std::cout << inputFile->GetName() <<
": adding ppg" << std::endl;
48 gPpg->
Add(
static_cast<TPPG*
>(inputFile->Get(
"TPPG")));
51 if(channel ==
nullptr || inputFile->FindObjectAny(
"Channel") !=
nullptr) {
52 channel =
static_cast<TChannel*
>(inputFile->Get(
"Channel"));
61 if(treeList.empty()) {
71 auto* proofChain =
new TChain(treeType);
73 for(
auto& i : treeList) {
74 proofChain->Add(i.c_str());
79 proofChain->SetProof();
83 std::cout <<
"Currently Running: " << (Form(
"%s", macroIt.c_str())) << std::endl;
86 proofChain->Process(Form(
"%s+", macroIt.c_str()));
94 std::cout <<
"Done with " << (Form(
"%s", macroIt.c_str())) << std::endl;
108 std::cout <<
"getting session logs ..." << std::endl;
109 TProofLog* pl = TProof::Mgr(
"proof://__lite__")->GetSessionLogs();
114 std::string firstMacro;
116 firstMacro = basename(
const_cast<char*
>(firstMacro.c_str()));
117 firstMacro = firstMacro.substr(0, firstMacro.find_last_of(
'.'));
119 if(runNumber != 0 && subRunNumber != -1) {
121 pl->Save(
"*", Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber));
122 std::cout <<
"Wrote logs to '" << Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber) <<
"'" << std::endl;
123 }
else if(runNumber != 0) {
133 std::cout <<
"Failed to get logs!" << std::endl;
136 std::cout <<
"stopping all workers ..." << std::endl;
142 int hour =
static_cast<int>(realTime / 3600);
143 realTime -= hour * 3600;
144 int min =
static_cast<int>(realTime / 60);
145 realTime -= min * 60;
147 <<
"Done after " << hour <<
":" << std::setfill(
'0') << std::setw(2) << min <<
":"
148 << std::setprecision(3) << std::fixed << realTime <<
" h:m:s"
161 struct sigaction action{};
164 sigemptyset(&action.sa_mask);
165 sigaction(SIGINT, &action,
nullptr);
166 sigaction(SIGTERM, &action,
nullptr);
171 std::string grsiPath = getenv(
"GRSISYS");
172 if(grsiPath.length() > 0) {
176 grsiPath +=
".grsirc";
177 gEnv->ReadFile(grsiPath.c_str(), kEnvChange);
198 const char* pPath = getenv(
"GRSISYS");
199 gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
202 if(!library.empty()) {
203 size_t tmpPos = library.rfind(
"/lib/lib");
204 if(tmpPos != std::string::npos) {
205 gInterpreter->AddIncludePath(Form(
"%s/include", library.substr(0, tmpPos).c_str()));
207 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;
211 std::cout <<
"Warning, no dataparser/detector library provided, won't be able to add include path!" << std::endl;
215 std::cout <<
DRED <<
"Can't PROOF if there is no MACRO" <<
RESET_COLOR << std::endl;
218 std::cout <<
DCYAN <<
"************************* MACRO COMPILATION ****************************" <<
RESET_COLOR
221 Int_t errorCode = gSystem->CompileMacro(i.c_str(),
"kgOs");
223 std::cout <<
DRED << i <<
" failed to compile properly.. ABORT!" <<
RESET_COLOR << std::endl;
227 std::cout <<
DCYAN <<
"************************* END COMPILATION ******************************" <<
RESET_COLOR
231 std::cout <<
DRED <<
"Can't Proof a Midas file..." <<
RESET_COLOR << std::endl;
236 std::cout <<
"Opening proof with '" << Form(
"workers=%d",
gGRSIOpt->
GetMaxWorkers()) <<
"'" << std::endl;
239 std::cout <<
"Opening proof with one worker (selector-only)" << std::endl;
246 std::cout <<
"Couldn't connect to proof on first attempt, trying again" << std::endl;
248 std::cout <<
"Opening proof with '" << Form(
"workers=%d",
gGRSIOpt->
GetMaxWorkers()) <<
"'" << std::endl;
251 std::cout <<
"Opening proof with one worker (selector-only)" << std::endl;
259 std::cout <<
"Still can't connect to proof, try running it again?" << std::endl;
271 gGRSIProof->SetParameter(
"PROOF_UseParallelUnzip", 1);
273 gGRSIProof->SetParameter(
"PROOF_UseParallelUnzip", 0);
279 gGRSIProof->SetParameter(
"PROOF_UseTreeCache", 0);
281 gGRSIProof->SetParameter(
"PROOF_UseTreeCache", 1);
286 gGRSIProof->DeleteParameters(
"PROOF_UseTreeCache");
287 gGRSIProof->DeleteParameters(
"PROOF_CacheSize");
294 gGRSIProof->DeleteParameters(
"PROOF_UseMergers");
299 gGRSIProof->SetParameter(
"PROOF_StatsHist",
"");
300 gGRSIProof->SetParameter(
"PROOF_StatsTrace",
"");
301 gGRSIProof->SetParameter(
"PROOF_RateTrace",
"");
302 gGRSIProof->SetParameter(
"PROOF_SlaveStatsTrace",
"");
306 TGRSIProof::AddEnvVar(
"GRSISYS", pPath);
307 gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
308 gGRSIProof->AddIncludePath(Form(
"%s/include", pPath));
309 gGRSIProof->AddDynamicPath(Form(
"%s/lib", pPath));
312 gGRSIProof->AddInput(
new TNamed(
"pwd", getenv(
"PWD")));
315 gGRSIProof->AddInput(
new TNamed(Form(
"valFile%d", index++), valFile.c_str()));
319 gGRSIProof->AddInput(
new TNamed(Form(
"calFile%d", index++), calFile.c_str()));
323 gGRSIProof->AddInput(
new TNamed(Form(
"cutFile%d", index++), cutFile.c_str()));
325 gGRSIProof->AddInput(
new TNamed(
"ParserLibrary", library.c_str()));
332 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)