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