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 *tasks = "ALL", Char_t* dir=0x0)
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;
39 // select tasks to process; we should move it to an
40 // individual function and move the task identifiers
41 // outside the const space
42 TObjArray *tasksArray = TString(tasks).Tokenize(" ");
44 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
45 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
46 if(s.CompareTo("ALL") == 0){
47 for(Int_t itask = 1; itask < fknTasks; itask++) SETBIT(fSteerTask, itask);
49 } else if(s.CompareTo("NOFR") == 0){
51 } else if(s.CompareTo("NOMC") == 0){
54 Bool_t foundOpt = kFALSE;
55 for(Int_t itask = 1; itask < fknTasks; itask++){
56 if(s.CompareTo(fTaskOpt[itask]) != 0) continue;
57 SETBIT(fSteerTask, itask);
61 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
66 // catch the list of files using the ROOT Python Interface
67 TPython *pyshell = new TPython();
68 pyshell->Exec("import commands");
71 TFileMerger *fFM = new TFileMerger();
74 TObjArray *fContainer = 0x0;
75 AliTRDrecoTask *task = 0x0;
77 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
79 printf("\n\tPROCESSING DATA FOR TASKS [%b]:\n", fSteerTask);
80 for(Int_t itask = 1; itask <fknTasks; itask++){
81 if(!TESTBIT(fSteerTask, itask)) continue;
83 ctask = new TClass(fTaskClass[itask]);
84 task = (AliTRDrecoTask*)ctask->New();
85 task->SetDebugLevel(0);
87 task->SetFriends(friends);
88 printf("\t%s [%s]\n", task->GetTitle(), task->GetName());
91 TString pathname = gSystem->ExpandPathName( dir ? dir : "$PWD");
92 TString filestring((const Char_t*) pyshell->Eval(Form("commands.getstatusoutput(\"find %s | grep TRD.Task%s.root\")[1]", pathname.Data(), task->GetName())));
93 TObjArray *filenames = filestring.Tokenize("\n");
94 Int_t nFiles = filenames->GetEntriesFast();
96 printf("No Files found for Task %s\n", task->GetName());
103 fFM = new(fFM) TFileMerger(kTRUE);
104 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
105 for(Int_t ifile = 0; ifile < nFiles; ifile++){
106 TString filename = (dynamic_cast<TObjString *>(filenames->UncheckedAt(ifile)))->String();
107 if(filename.Contains("merge")) continue;
108 //printf("\tProcessing %s ...\n", filename.Data());
109 fFM->AddFile(filename.Data());
113 task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
114 } else task->Load((dynamic_cast<TObjString *>(filenames->UncheckedAt(0)))->String().Data());
116 if(!(fContainer = task->Container())) {
123 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
124 TCanvas *c = new TCanvas("c", "", 500, 500);
125 Int_t ifirst, ilast; Option_t *opt;
126 TH1 *h = 0x0; TGraph *g = 0x0;
127 task->GetRefFigure(ipic, ifirst, ilast, opt);
128 if(!(o = fContainer->At(ifirst))) continue;
130 if(o->InheritsFrom("TH1")){
131 h = dynamic_cast<TH1*>(o);
133 } else if(o->InheritsFrom("TGraph")){
134 g = dynamic_cast<TGraph*>(o);
137 printf("No idea how to plot object of type %s.\n", o->IsA()->GetName());
138 printf("Please teach me.\n");
142 for(Int_t ig=ifirst+1; ig<ilast; ig++){
143 if(!(o = fContainer->At(ig))) continue;
144 if(o->InheritsFrom("TH1")){
145 h = dynamic_cast<TH1*>(o);
146 h->Draw(Form("%ssame", opt));
147 } else if(o->InheritsFrom("TGraph")){
148 g = dynamic_cast<TGraph*>(o);
152 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));