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 #include "AliTRDperformanceTrain.h"
72 //#include "../../PWG1/macros/AddPerformanceTask.h"
74 Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
77 Bool_t mc(kFALSE), friends(kFALSE);
78 Bool_t summary(kTRUE);
80 void processTRD(TNamed* task, const Char_t *filename);
81 void processESD(TNamed* task, const Char_t *filename);
82 void makeResults(Char_t *opt = "ALL", const Char_t *files="QAResults.root", Char_t *cid = "", Bool_t kGRID=kFALSE, Bool_t dosummary = kTRUE)
85 if(!gSystem->Getenv("GSHELL_ROOT")){
86 Error("makeResults.C", "AliEn not initialized.");
89 TGrid::Connect("alien://");
92 // Load Libraries in interactive mode
93 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
94 for(Int_t ilib=0; ilib<nlibs; ilib++){
95 if(gSystem->Load(libs[ilib]) >= 0) continue;
96 Error("makeResults.C", Form("Failed to load %s.", libs[ilib]));
100 mc = HasReadMCData(opt);
101 friends = HasReadFriendData(opt);
103 gStyle->SetOptStat(0);
104 gStyle->SetOptFit(0);
106 if(!TString(files).EndsWith(".root")){
107 outputFile = Form("%s/QAResults.root", gSystem->ExpandPathName("$PWD"));
108 mergeProd("QAResults.root", files);
112 Int_t fSteerTask = ParseOptions(opt);
116 if(!c) c=new TCanvas("c", "Performance", 10, 10, 800, 500);
119 TClass *ctask = new TClass;
120 AliAnalysisTask *task = 0x0;
121 for(Int_t itask = NTRDQATASKS; itask--;){
122 if(!TSTBIT(fSteerTask, itask)) continue;
123 new(ctask) TClass(fgkTRDtaskClassName[itask]);
124 task = (AliAnalysisTask*)ctask->New();
125 task->SetName(Form("%s%s", task->GetName(), cid));
126 printf(" *** task %s, output file %s\n", task->GetName(), outputFile.Data());
127 if(task->IsA()->InheritsFrom("AliTRDrecoTask")) processTRD(task, outputFile.Data());
128 else if(strcmp(task->IsA()->GetName(), "AliTRDcheckESD")==0) processESD(task, outputFile.Data());
129 else if(strcmp(task->IsA()->GetName(), "AliTRDinfoGen")==0)processGEN(task, outputFile.Data());
131 Error("makeResults.C", Form("Handling of class task \"%s\" not implemented.", task->IsA()->GetName()));
140 //______________________________________________________
141 void processTRD(TNamed *otask, const Char_t *filename)
143 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
145 AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
146 task->SetDebugLevel(debug);
147 AliLog::SetClassDebugLevel(otask->IsA()->GetName(), debug);
149 task->SetFriends(friends);
151 //if(!task->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")))){
152 if(!task->Load(filename)){
153 Error("makeResults.C", Form("Load data container for task %s failed.", task->GetName()));
158 if(!task->PostProcess()){
159 Error("makeResults.C", Form("Processing data container for task %s failed.", task->GetName()));
163 if(summary) task->MakeSummary();
165 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
167 if(!task->GetRefFigure(ipic)) continue;
168 c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic), "gif");
174 //______________________________________________________
175 void processESD(TNamed *otask, const Char_t *filename)
177 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
179 AliTRDcheckESD *esd = dynamic_cast<AliTRDcheckESD*>(otask);
181 Info("makeResults.C", Form("Processing of task %s failed.", otask->GetName()));
185 //if(!esd->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")), "TRD_Performance")){
186 if(!esd->Load(filename, "TRD_Performance")){
187 Error("makeResults.C", Form("Load data container for task %s failed.", esd->GetName()));
191 esd->Terminate(NULL);
193 if(summary) esd->MakeSummary();
195 for(Int_t ipic(0); ipic<esd->GetNRefFigures(); ipic++){
197 if(!esd->GetRefFigure(ipic)) continue;
198 c->SaveAs(Form("%s_Fig%02d.gif", esd->GetName(), ipic));
204 //______________________________________________________
205 void processGEN(TNamed *otask, const Char_t *filename)
207 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
209 AliTRDinfoGen *info = dynamic_cast<AliTRDinfoGen*>(otask);
211 if(!info->Load(filename, "TRD_Performance")){
212 Error("makeResults.C", Form("Load data container for task %s failed.", info->GetName()));
217 for(Int_t ipic(0); ipic<info->GetNRefFigures(); ipic++){
219 if(!info->GetRefFigure(ipic)) continue;
220 c->SaveAs(Form("%s_Fig%02d.gif", info->GetName(), ipic));