2 // makeResults.C("tasks", "file_list", kGRID)
3 // tasks : "ALL" or one/more of the following separated by space:
4 // "EFF" : TRD Tracking Efficiency
5 // "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations
6 // "RES" : TRD tracking Resolution
7 // "CAL" : TRD calibration
8 // "PID" : TRD PID - pion efficiency
9 // "PIDR" : TRD PID - reference data
10 // "DET" : Basic TRD Detector checks
11 // "NOFR" : Data set does not have AliESDfriends.root
12 // "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
13 // on MC information are switched off
14 // file_list : is the list of the files to be processed.
15 // They should contain the full path. Here is an example:
16 // /lustre_alpha/alice/TRDdata/HEAD/1.0GeV/RUN0/TRD.TaskResolution.root
17 // or for GRID alien:///alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/1/TRD.TaskDetChecker.root
18 // kGRID : specify if files are comming from a GRID collection [default kFALSE]
20 // HOW TO BUILD THE FILE LIST
22 // ls -1 BaseDir/TRD.Task*.root > files.lst
25 // char *BaseDir="/alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/";
26 // TGrid::Connect("alien://");
27 // TGridResult *res = gGrid->Query(BaseDir, "%/TRD.Task%.root");
28 // TGridCollection *col = gGrid->OpenCollectionQuery(res);
31 // while(map = (TMap*)col->Next()){
32 // TIter it((TCollection*)map);
33 // TObjString *info = 0x0;
34 // while(info=(TObjString*)it()){
35 // printf("alien://%s\n", col->GetLFN(info->GetString().Data()));
39 // The files which will be processed are the intersection between the
40 // condition on the tasks and the files in the file list.
43 // Alex Bercuci (A.Bercuci@gsi.de)
44 // Markus Fasel (m.Fasel@gsi.de)
47 #if ! defined (__CINT__) || defined (__MAKECINT__)
51 #include <TFileMerger.h>
55 #include <TObjArray.h>
56 #include <TObjString.h>
62 #include "qaRec/AliTRDrecoTask.h"
68 Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so"};
70 void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0, Bool_t kGRID=kFALSE)
73 if(!gSystem->Getenv("GSHELL_ROOT")){
74 printf("alien not initialized.\n");
77 TGrid::Connect("alien://");
80 // Load Libraries in interactive mode
81 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
82 for(Int_t ilib=0; ilib<nlibs; ilib++){
83 if(gSystem->Load(libs[ilib]) >= 0) continue;
84 printf("Failed to load %s.\n", libs[ilib]);
89 gStyle->SetOptStat(0);
91 Bool_t friends = kTRUE;
93 // select tasks to process; we should move it to an
94 // individual function and move the task identifiers
95 // outside the const space
97 TObjArray *tasksArray = tasks.Tokenize(" ");
99 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
100 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
101 if(s.CompareTo("ALL") == 0){
102 for(Int_t itask = 1; itask < NQATASKS; itask++) SETBIT(fSteerTask, itask);
104 } else if(s.CompareTo("NOFR") == 0){
106 } else if(s.CompareTo("NOMC") == 0){
109 Bool_t foundOpt = kFALSE;
110 for(Int_t itask = 1; itask < NTRDTASKS; itask++){
111 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
112 SETBIT(fSteerTask, itask);
116 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
119 // extra rules for calibration tasks
120 if(TSTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution);
121 if(TSTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kPIDChecker);
122 if(TSTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution);
124 // file merger object
125 TFileMerger *fFM = 0x0;
126 TClass *ctask = new TClass;
127 AliTRDrecoTask *task = 0x0;
130 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
132 for(Int_t itask = 1; itask<NTRDTASKS; itask++){
133 if(!TSTBIT(fSteerTask, itask)) continue;
135 new(ctask) TClass(fgkTRDtaskClassName[itask]);
136 task = (AliTRDrecoTask*)ctask->New();
137 task->SetDebugLevel(0);
139 task->SetFriends(friends);
143 TString mark(Form("%s.root", task->GetName()));
146 ifstream filestream(files);
147 while(getline(filestream, filename)){
148 if(Int_t(filename.find(mark.Data())) < 0) continue;
152 nFiles = !gSystem->AccessPathName(Form("TRD.Task%s.root", task->GetName()));
156 Info("makeResults.C", Form("No Files found for Task %s", task->GetName()));
160 Info("makeResults.C", Form(" Processing %d files for task %s ...", nFiles, task->GetName()));
163 fFM = new TFileMerger(kTRUE);
164 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
166 ifstream file(files);
167 while(getline(file, filename)){
168 if(Int_t(filename.find(mark.Data())) < 0) continue;
169 fFM->AddFile(filename.c_str());
173 if(!task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
178 if(!task->Load(Form("%s/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
184 printf("Processing ...\n");
186 TCanvas *c=new TCanvas();
187 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
188 if(!task->GetRefFigure(ipic)) continue;
189 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));