2 // makeResults.C("tasks", "file_list", ""task_id, 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 // "PID" : TRD PID - pion efficiency
8 // "DET" : Basic TRD Detector checks
9 // "NOFR" : Data set does not have AliESDfriends.root
10 // "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
11 // on MC information are switched off
12 // file_list : is the list of the files to be processed.
13 // They should contain the full path. Here is an example:
14 // /lustre/alice/local/TRDdata/SIM/P-Flat/TRUNK/RUN0/TRD.Performance.root
15 // or for GRID alien:///alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/1/TRD.Performance.root
16 // task_id : identifier of task speciality as defined by the AddMacro.C.
17 // (e.g. AddTRDresolution.C defines "" for barrel tracks, "K" for kink tracks and "SA" for stand alone tracks)
18 // kGRID : specify if files are comming from a GRID collection [default kFALSE]
20 // HOW TO BUILD THE FILE LIST
22 // ls -1 BaseDir/RUN*/TRD.Performance.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.Performance.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__)
54 #include <TObjArray.h>
55 #include <TObjString.h>
60 #include <TGridResult.h>
61 #include <TGridCollection.h>
65 #include "PWG1/TRD/AliTRDrecoTask.h"
66 #include "PWG1/TRD/AliTRDcheckESD.h"
70 Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
73 Bool_t mc(kFALSE), friends(kFALSE);
74 Bool_t summary(kTRUE);
76 void processTRD(TNamed* task, const Char_t *filename);
77 void processESD(TNamed* task, const Char_t *filename);
78 void makeResults(Char_t *opt = "ALL", const Char_t *files="QAResults.root", Char_t *cid = "", Bool_t kGRID=kFALSE, Bool_t dosummary = kTRUE)
81 if(!gSystem->Getenv("GSHELL_ROOT")){
82 Error("makeResults.C", "AliEn not initialized.");
85 TGrid::Connect("alien://");
88 // Load Libraries in interactive mode
89 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
90 for(Int_t ilib=0; ilib<nlibs; ilib++){
91 if(gSystem->Load(libs[ilib]) >= 0) continue;
92 Error("makeResults.C", Form("Failed to load %s.", libs[ilib]));
96 mc = AliTRDpwg1Helper::HasReadMCData(opt);
97 friends = AliTRDpwg1Helper::HasReadFriendData(opt);
99 gStyle->SetOptStat(0);
100 gStyle->SetOptFit(0);
102 if(!TString(files).EndsWith(".root")){
103 outputFile = Form("%s/QAResults.root", gSystem->ExpandPathName("$PWD"));
104 AliTRDpwg1Helper::MergeProd("QAResults.root", files);
108 Int_t fSteerTask = AliTRDpwg1Helper::ParseOptions(opt);
112 if(!c) c=new TCanvas("c", "Performance", 10, 10, 800, 500);
115 TClass *ctask = new TClass;
116 AliAnalysisTask *task = 0x0;
117 for(Int_t itask = AliTRDpwg1Helper::kNTRDQATASKS; itask--;){
118 if(!AliTRDpwg1Helper::DoTask(itask, fSteerTask)) continue;
119 new(ctask) TClass(AliTRDpwg1Helper::TaskClassName(itask));
120 task = (AliAnalysisTask*)ctask->New();
121 task->SetName(Form("%s%s", task->GetName(), cid));
122 printf(" *** task %s, output file %s\n", task->GetName(), outputFile.Data());
123 if(task->IsA()->InheritsFrom("AliTRDrecoTask")) processTRD(task, outputFile.Data());
124 else if(strcmp(task->IsA()->GetName(), "AliTRDcheckESD")==0) processESD(task, outputFile.Data());
125 else if(strcmp(task->IsA()->GetName(), "AliTRDinfoGen")==0)processGEN(task, outputFile.Data());
127 Error("makeResults.C", Form("Handling of class task \"%s\" not implemented.", task->IsA()->GetName()));
136 //______________________________________________________
137 void processTRD(TNamed *otask, const Char_t *filename)
139 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
141 AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
142 task->SetDebugLevel(debug);
143 AliLog::SetClassDebugLevel(otask->IsA()->GetName(), debug);
145 task->SetFriends(friends);
147 //if(!task->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")))){
148 if(!task->Load(filename)){
149 Error("makeResults.C", Form("Load data container for task %s failed.", task->GetName()));
154 if(!task->PostProcess()){
155 Error("makeResults.C", Form("Processing data container for task %s failed.", task->GetName()));
159 if(summary) task->MakeSummary();
161 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
163 if(!task->GetRefFigure(ipic)) continue;
164 c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic), "gif");
170 //______________________________________________________
171 void processESD(TNamed *otask, const Char_t *filename)
173 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
175 AliTRDcheckESD *esd = dynamic_cast<AliTRDcheckESD*>(otask);
177 Info("makeResults.C", Form("Processing of task %s failed.", otask->GetName()));
181 //if(!esd->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")), "TRD_Performance")){
182 if(!esd->Load(filename, "TRD_Performance")){
183 Error("makeResults.C", Form("Load data container for task %s failed.", esd->GetName()));
187 esd->Terminate(NULL);
189 if(summary) esd->MakeSummary();
191 for(Int_t ipic(0); ipic<esd->GetNRefFigures(); ipic++){
193 if(!esd->GetRefFigure(ipic)) continue;
194 c->SaveAs(Form("%s_Fig%02d.gif", esd->GetName(), ipic));
200 //______________________________________________________
201 void processGEN(TNamed *otask, const Char_t *filename)
203 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
205 AliTRDinfoGen *info = dynamic_cast<AliTRDinfoGen*>(otask);
207 if(!info->Load(filename, "TRD_Performance")){
208 Error("makeResults.C", Form("Load data container for task %s failed.", info->GetName()));
213 for(Int_t ipic(0); ipic<info->GetNRefFigures(); ipic++){
215 if(!info->GetRefFigure(ipic)) continue;
216 c->SaveAs(Form("%s_Fig%02d.gif", info->GetName(), ipic));