5 #include "TProofLite.h" 7 #include "TSystemDirectory.h" 9 #include "TChainElement.h" 11 #include "TInterpreter.h" 18 #include "TStopwatch.h" 38 std::vector<std::string> tree_list;
42 TFile* in_file = TFile::Open(i.c_str());
43 if((in_file !=
nullptr) && in_file->IsOpen()) {
44 if(in_file->FindObjectAny(tree_type) !=
nullptr) {
45 tree_list.push_back(i);
50 if(in_file->Get(
"TPPG") !=
nullptr) {
51 std::cout<<in_file->GetName()<<
": adding ppg"<<std::endl;
52 gPpg->
Add(static_cast<TPPG*>(in_file->Get(
"TPPG")));
59 if(tree_list.empty()) {
69 auto* proof_chain =
new TChain(tree_type);
71 for(
auto& i : tree_list) {
72 proof_chain->Add(i.c_str());
77 proof_chain->SetProof();
81 std::cout<<
"Currently Running: "<<(Form(
"%s", macro_it.c_str()))<<std::endl;
84 proof_chain->Process(Form(
"%s+", macro_it.c_str()));
89 std::cout<<
DRED<<
"Exception when processing chain: "<<e.detail()<<
RESET_COLOR<<std::endl;
92 std::cout<<
"Done with "<<(Form(
"%s", macro_it.c_str()))<<std::endl;
96 if(proof_chain !=
nullptr) {
98 proof_chain =
nullptr;
109 std::cout<<
"getting session logs ..."<<std::endl;
110 TProofLog* pl = TProof::Mgr(
"proof://__lite__")->GetSessionLogs();
116 std::string firstMacro;
118 firstMacro = basename(firstMacro.c_str());
119 firstMacro = firstMacro.substr(0, firstMacro.find_last_of(
'.'));
121 if(runNumber != 0 && subRunNumber != -1) {
123 pl->Save(
"*", Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber));
124 std::cout<<
"Wrote logs to '"<<Form(
"%s%05d_%03d.log", firstMacro.c_str(), runNumber, subRunNumber)<<
"'"<<std::endl;
125 }
else if(runNumber != 0) {
128 std::cout<<
"Wrote logs to '"<<Form(
"%s%05d_%03d-%03d.log", firstMacro.c_str(), runNumber, runInfo->
FirstSubRunNumber(), runInfo->
LastSubRunNumber())<<
"'"<<std::endl;
132 std::cout<<
"Wrote logs to '"<<Form(
"%s%05d-%05d.log", firstMacro.c_str(), runInfo->
FirstRunNumber(), runInfo->
LastRunNumber())<<
"'"<<std::endl;
135 std::cout<<
"Failed to get logs!"<<std::endl;
138 std::cout<<
"stopping all workers ..."<<std::endl;
144 int hour =
static_cast<int>(realTime / 3600);
145 realTime -= hour * 3600;
146 int min =
static_cast<int>(realTime / 60);
147 realTime -= min * 60;
149 <<
"Done after "<<hour<<
":"<<std::setfill(
'0')<<std::setw(2)<<min<<
":" 150 <<std::setprecision(3)<<std::fixed<<realTime<<
" h:m:s" 166 sigemptyset(&
action.sa_mask);
167 sigaction(SIGINT, &
action, NULL);
168 sigaction(SIGTERM, &
action, NULL);
173 std::string grsi_path = getenv(
"GRSISYS");
174 if(grsi_path.length() > 0) {
178 grsi_path +=
".grsirc";
179 gEnv->ReadFile(grsi_path.c_str(), kEnvChange);
200 const char* pPath = getenv(
"GRSISYS");
201 gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
204 if(!library.empty()) {
205 size_t tmpPos = library.rfind(
"/lib/lib");
206 if(tmpPos != std::string::npos) {
207 gInterpreter->AddIncludePath(Form(
"%s/include", library.substr(0,tmpPos).c_str()));
209 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;
213 std::cout<<
"Warning, no dataparser/detector library provided, won't be able to add include path!"<<std::endl;
217 std::cout<<
DRED<<
"Can't PROOF if there is no MACRO"<<
RESET_COLOR<<std::endl;
220 std::cout<<
DCYAN<<
"************************* MACRO COMPILATION ****************************"<<
RESET_COLOR 223 Int_t error_code = gSystem->CompileMacro(i.c_str(),
"kgOs");
224 if(error_code == 0) {
225 std::cout<<
DRED<<i<<
" failed to compile properly.. ABORT!"<<
RESET_COLOR<<std::endl;
229 std::cout<<
DCYAN<<
"************************* END COMPILATION ******************************"<<
RESET_COLOR 233 std::cout<<
DRED<<
"Can't Proof a Midas file..."<<
RESET_COLOR<<std::endl;
241 std::cout<<
"Opening proof with one worker (selector-only)"<<std::endl;
248 std::cout<<
"Couldn't connect to proof on first attempt, trying again"<<std::endl;
253 std::cout<<
"Opening proof with one worker (selector-only)"<<std::endl;
261 std::cout<<
"Still can't connect to proof, try running it again?"<<std::endl;
269 gInterpreter->AddIncludePath(Form(
"%s/include", pPath));
270 gGRSIProof->AddIncludePath(Form(
"%s/include", pPath));
271 gGRSIProof->AddDynamicPath(Form(
"%s/lib", pPath));
274 gGRSIProof->AddInput(
new TNamed(
"pwd", getenv(
"PWD")));
277 gGRSIProof->AddInput(
new TNamed(Form(
"valFile%d", i++), valFile.c_str()));
281 gGRSIProof->AddInput(
new TNamed(Form(
"calFile%d", i++), calFile.c_str()));
285 gGRSIProof->AddInput(
new TNamed(Form(
"cutFile%d", i++), cutFile.c_str()));
287 gGRSIProof->AddInput(
new TNamed(
"ParserLibrary", library.c_str()));
const std::vector< std::string > & ValInputFiles()
const std::vector< std::string > & MacroInputFiles()
const std::vector< std::string > & InputFiles()
static TGRSIOptions * Get(int argc=0, char **argv=nullptr)
Do not use!
static TRunInfo * AddCurrent()
int GetMaxWorkers() const
size_t NumberOfEvents() const
bool SelectorOnly() const
static TRunInfo * Get(bool verbose=false)
static int LastRunNumber()
static int FirstSubRunNumber()
const std::vector< std::string > & CalInputFiles()
const std::vector< std::string > & RootInputFiles()
static TAnalysisOptions * AnalysisOptions()
static void CatchSignals()
void Print(Option_t *opt="") const override
static int SubRunNumber()
void ParserLibrary(std::string &library)
static TGRSIProof * Open(const char *worker="")
void Add(const TPPG *ppg)
static int FirstRunNumber()
static int LastSubRunNumber()
int main(int argc, char **argv)
void Analyze(const char *tree_type)
const std::vector< std::string > & InputCutFiles()