1 #if ! defined (__CINT__) || defined (__MAKECINT__)
4 #include <TFileMerger.h>
9 #include <TObjString.h>
16 #include "qaRec/AliTRDrecoTask.h"
22 Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libPyROOT"};
24 void makeResults(Char_t *args = "ALL")
26 // Load Libraries in interactive mode
27 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
28 for(Int_t ilib=0; ilib<nlibs; ilib++){
29 if(gSystem->Load(libs[ilib]) >= 0) continue;
30 printf("Failed to load %s.\n", libs[ilib]);
35 gStyle->SetOptStat(0);
37 Bool_t friends = kTRUE;
41 TObjArray *argsArray = TString(args).Tokenize("?");
42 switch(argsArray->GetEntriesFast()){
44 tasks = ((TObjString*)(*argsArray)[0])->String();
48 tasks = ((TObjString*)(*argsArray)[0])->String();
49 dir = ((TObjString*)(*argsArray)[1])->GetName();
52 printf("Macro accepts 2 arguments separated by a '?'.\n");
53 printf("arg #1 : list of tasks/options\n");
54 printf("arg #2 : base directory to be processed\n");
58 // select tasks to process; we should move it to an
59 // individual function and move the task identifiers
60 // outside the const space
61 TObjArray *tasksArray = tasks.Tokenize(" ");
63 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
64 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
65 if(s.CompareTo("ALL") == 0){
66 for(Int_t itask = 1; itask < fknTasks; itask++) SETBIT(fSteerTask, itask);
68 } else if(s.CompareTo("NOFR") == 0){
70 } else if(s.CompareTo("NOMC") == 0){
73 Bool_t foundOpt = kFALSE;
74 for(Int_t itask = 1; itask < fknTasks; itask++){
75 if(s.CompareTo(fTaskOpt[itask]) != 0) continue;
76 SETBIT(fSteerTask, itask);
80 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
85 // catch the list of files using the ROOT Python Interface
86 TPython *pyshell = new TPython();
87 pyshell->Exec("import commands");
90 TFileMerger *fFM = new TFileMerger();
93 TObjArray *fContainer = 0x0;
94 AliTRDrecoTask *task = 0x0;
96 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
98 printf("\n\tPROCESSING DATA FOR TASKS [%b]:\n", fSteerTask);
99 for(Int_t itask = 1; itask <fknTasks; itask++){
100 if(!TESTBIT(fSteerTask, itask)) continue;
102 ctask = new TClass(fTaskClass[itask]);
103 task = (AliTRDrecoTask*)ctask->New();
104 task->SetDebugLevel(0);
106 task->SetFriends(friends);
107 printf("\t%s [%s]\n", task->GetTitle(), task->GetName());
110 TString pathname = gSystem->ExpandPathName( dir ? dir : "$PWD");
111 TString filestring((const Char_t*) pyshell->Eval(Form("commands.getstatusoutput(\"find %s | grep TRD.Task%s.root\")[1]", pathname.Data(), task->GetName())));
112 TObjArray *filenames = filestring.Tokenize("\n");
113 Int_t nFiles = filenames->GetEntriesFast();
115 printf("No Files found for Task %s\n", task->GetName());
122 fFM = new(fFM) TFileMerger(kTRUE);
123 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
124 for(Int_t ifile = 0; ifile < nFiles; ifile++){
125 TString filename = (dynamic_cast<TObjString *>(filenames->UncheckedAt(ifile)))->String();
126 if(filename.Contains("merge")) continue;
127 //printf("\tProcessing %s ...\n", filename.Data());
128 fFM->AddFile(filename.Data());
132 task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
133 } else task->Load((dynamic_cast<TObjString *>(filenames->UncheckedAt(0)))->String().Data());
136 TCanvas *c=new TCanvas();
137 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
138 task->GetRefFigure(ipic);
139 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));