]> git.uio.no Git - u/mrichter/AliRoot.git/blob - PWG1/TRD/macros/makeResults.C
f004a3f99ba819a89ffd9722be0bff4a354d8613
[u/mrichter/AliRoot.git] / PWG1 / TRD / macros / makeResults.C
1 // Usage:
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]
19 //
20 // HOW TO BUILD THE FILE LIST
21 //   1. locally
22 // ls -1 BaseDir/RUN*/TRD.Performance.root > files.lst
23 // 
24 //   2. on Grid
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);
29 // col->Reset();
30 // TMap *map = 0x0;
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()));
36 //   }
37 // }
38 //
39 // The files which will be processed are the intersection between the
40 // condition on the tasks and the files in the file list.
41 //
42 // Authors:
43 //   Alex Bercuci (A.Bercuci@gsi.de) 
44 //   Markus Fasel (m.Fasel@gsi.de) 
45 //
46
47 #if ! defined (__CINT__) || defined (__MAKECINT__)
48 #include <fstream>
49 #include "TError.h"
50 #include <TClass.h>
51 #include <TCanvas.h>
52 #include <TH1.h>
53 #include <TGraph.h>
54 #include <TObjArray.h>
55 #include <TObjString.h>
56 #include <TString.h>
57 #include <TROOT.h>
58 #include <TStyle.h>
59 #include <TGrid.h>
60 #include <TGridResult.h>
61 #include <TGridCollection.h>
62
63 #include "qaRec/AliTRDrecoTask.h"
64
65 #endif
66
67 #include "AliTRDperformanceTrain.h"
68 #include "helper.C"
69 //#include "../../PWG1/macros/AddPerformanceTask.h"
70
71 Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
72 // define setup
73 TCanvas *c = 0x0;
74 Bool_t mc(kFALSE), friends(kFALSE);
75
76 void processTRD(TNamed* task);
77 void processESD(TNamed* task);
78 void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0, Char_t *cid = "", Bool_t kGRID=kFALSE)
79 {
80   if(kGRID){
81     if(!gSystem->Getenv("GSHELL_ROOT")){
82       Error("makeResults.C", "AliEn not initialized.");
83       return;
84     }
85     TGrid::Connect("alien://");
86   }
87
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]));
93     return;
94   }
95
96   mc = HasReadMCData(opt);
97   friends = HasReadFriendData(opt);
98
99   gStyle->SetOptStat(0);
100   gStyle->SetOptFit(0);
101   if(files) mergeProd("TRD.Performance.root", files);
102   Int_t fSteerTask = ParseOptions(opt);
103
104   if(!c) c=new TCanvas("c", "Performance", 10, 10, 800, 500);
105
106   TClass *ctask = new TClass;
107   AliAnalysisTask *task = 0x0;
108   for(Int_t itask = NTRDQATASKS; itask--;){
109     if(!TSTBIT(fSteerTask, itask)) continue;
110     new(ctask) TClass(fgkTRDtaskClassName[itask]);
111     task = (AliAnalysisTask*)ctask->New();
112     task->SetName(Form("%s%s", task->GetName(), cid));
113     if(task->IsA()->InheritsFrom("AliTRDrecoTask")) processTRD(task);
114     else processESD(task);
115   }
116   delete ctask;
117   delete c;
118 }
119
120
121 //______________________________________________________
122 void processTRD(TNamed *otask)
123 {
124   printf("processTRD %s %s\n", otask->GetName(), otask->GetTitle());
125   Int_t debug(0);
126   AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
127   task->SetDebugLevel(debug);
128   AliLog::SetClassDebugLevel(otask->IsA()->GetName(), debug);
129   task->SetMCdata(mc);
130   task->SetFriends(friends);
131
132   if(!task->Load(Form("%s/TRD.Performance.root", gSystem->ExpandPathName("$PWD")))){
133     Error("makeResults.C", Form("Load data container for task %s failed.", task->GetName()));
134     delete task;
135     return;
136   }
137
138   if(!task->PostProcess()){
139     Error("makeResults.C", Form("Processing data container for task %s failed.", task->GetName()));
140     delete task;
141     return;
142   }
143   for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
144     c->Clear();
145     if(!task->GetRefFigure(ipic)) continue;
146     c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic), "gif");
147   }
148   delete task;
149 }
150
151 //______________________________________________________
152 void processESD(TNamed *otask)
153 {
154   printf("processESD %s %s\n", otask->GetName(), otask->GetTitle());
155
156   AliTRDcheckESD *esd = dynamic_cast<AliTRDcheckESD*>(otask);
157   if(!esd){
158     Info("makeResults.C", Form("Processing of task %s failed.", otask->GetName()));
159     delete otask;
160     return;
161   }
162   printf("esd[%p]\n", (void*)esd);
163   if(!esd->Load(Form("%s/TRD.Performance.root", gSystem->ExpandPathName("$PWD")))){
164     Error("makeResults.C", Form("Load data container for task %s failed.", esd->GetName()));
165     delete esd;
166     return;
167   }
168   esd->Terminate();
169
170   for(Int_t ipic(0); ipic<esd->GetNRefFigures(); ipic++){
171     c->Clear(); 
172     if(!esd->GetRefFigure(ipic)) continue;
173     c->SaveAs(Form("%s_Fig%02d.gif", esd->GetName(), ipic));
174   }
175   delete esd;
176 }