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 printf("\n\tPROCESSING DATA FOR TASKS [%d]:\n", fSteerTask);
78 for(Int_t itask = 1; itask <fknTasks; itask++){
79 if(!TESTBIT(fSteerTask, itask)) continue;
81 ctask = new TClass(fTaskClass[itask]);
82 task = (AliTRDrecoTask*)ctask->New();
83 task->SetDebugLevel(0);
85 task->SetFriends(friends);
86 printf("\t%s [%s]\n", task->GetTitle(), task->GetName());
89 TString pathname(dir ? "." : gSystem->ExpandPathName("$PWD"));
90 TString filestring((const Char_t*) pyshell->Eval(Form("commands.getstatusoutput(\"find %s | grep TRD.Task%s.root\")[1]", pathname.Data(), task->GetName())));
91 TObjArray *filenames = filestring.Tokenize("\n");
92 Int_t nFiles = filenames->GetEntriesFast();
94 printf("No Files found for Task %s\n", task->GetName());
101 fFM = new(fFM) TFileMerger(kTRUE);
102 fFM->OutputFile(Form("merge/TRD.Task%s.root", task->GetName()));
103 for(Int_t ifile = 0; ifile < nFiles; ifile++){
104 TString filename = (dynamic_cast<TObjString *>(filenames->UncheckedAt(ifile)))->String();
105 if(filename.Contains("merge")) continue;
106 printf("\tProcessing %s ...\n", filename.Data());
107 fFM->AddFile(filename.Data());
111 task->Load(Form("%s/merge/TRD.Task%s.root",gSystem->ExpandPathName("$PWD"), task->GetName()));
112 } else task->Load((dynamic_cast<TObjString *>(filenames->UncheckedAt(0)))->String().Data());
115 if(!(fContainer = task->Container())) {
122 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
123 TCanvas *c = new TCanvas("c", "", 500, 500);
124 Int_t ifirst, ilast; Option_t *opt;
125 TH1 *h = 0x0; TGraph *g = 0x0;
126 task->GetRefFigure(ipic, ifirst, ilast, opt);
127 if(!(o = fContainer->At(ifirst))) continue;
129 if(o->InheritsFrom("TH1")){
130 h = dynamic_cast<TH1*>(o);
132 } else if(o->InheritsFrom("TGraph")){
133 g = dynamic_cast<TGraph*>(o);
136 printf("No idea how to plot object of type %s.\n", o->IsA()->GetName());
137 printf("Please teach me.\n");
141 for(Int_t ig=ifirst+1; ig<ilast; ig++){
142 if(!(o = fContainer->At(ig))) continue;
143 if(o->InheritsFrom("TH1")){
144 h = dynamic_cast<TH1*>(o);
145 h->Draw(Form("%ssame", opt));
146 } else if(o->InheritsFrom("TGraph")){
147 g = dynamic_cast<TGraph*>(o);
151 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));