]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWG1/TRD/macros/makeResults.C
new design for performance plots of the resolution task
[u/mrichter/AliRoot.git] / PWG1 / TRD / macros / makeResults.C
CommitLineData
1ee39b3a 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
db37d6f8 69Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libTENDER.so", "libPWG1.so"};
1ee39b3a 70// define setup
71TCanvas *c = 0x0;
72Bool_t mc(kFALSE), friends(kFALSE);
73
74void processTRD(TNamed* task);
75void processESD(TNamed* task);
92d6d80c 76void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0, Char_t *cid = "", Bool_t kGRID=kFALSE)
1ee39b3a 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();
92d6d80c 110 task->SetName(Form("%s%s", task->GetName(), cid));
1ee39b3a 111 if(task->IsA()->InheritsFrom("AliTRDrecoTask")) processTRD(task);
112 else processESD(task);
113 }
114 delete ctask;
115 delete c;
116}
117
118
119//______________________________________________________
120void processTRD(TNamed *otask)
121{
3d2a3dff 122 printf("processTRD %s %s\n", otask->GetName(), otask->GetTitle());
92d6d80c 123 Int_t debug(0);
1ee39b3a 124 AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
92d6d80c 125 task->SetDebugLevel(debug);
126 AliLog::SetClassDebugLevel(otask->IsA()->GetName(), debug);
1ee39b3a 127 task->SetMCdata(mc);
128 task->SetFriends(friends);
129
130 if(!task->Load(Form("%s/TRD.Performance.root", gSystem->ExpandPathName("$PWD")))){
131 Error("makeResults.C", Form("Load data container for task %s failed.", task->GetName()));
132 delete task;
133 return;
134 }
135
136 if(!task->PostProcess()){
137 Error("makeResults.C", Form("Processing data container for task %s failed.", task->GetName()));
138 delete task;
139 return;
140 }
141 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
142 c->Clear();
143 if(!task->GetRefFigure(ipic)) continue;
144 c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic), "gif");
145 }
146 delete task;
147}
148
149//______________________________________________________
150void processESD(TNamed *otask)
151{
3d2a3dff 152 printf("processESD %s %s\n", otask->GetName(), otask->GetTitle());
153
1ee39b3a 154 AliTRDcheckESD *esd = dynamic_cast<AliTRDcheckESD*>(otask);
155 if(!esd){
3d2a3dff 156 Info("makeResults.C", Form("Processing of task %s failed.", otask->GetName()));
1ee39b3a 157 delete otask;
158 return;
159 }
3d2a3dff 160 printf("esd[%p]\n", (void*)esd);
1ee39b3a 161 if(!esd->Load(Form("%s/TRD.Performance.root", gSystem->ExpandPathName("$PWD")))){
162 Error("makeResults.C", Form("Load data container for task %s failed.", esd->GetName()));
163 delete esd;
164 return;
165 }
1ee39b3a 166 esd->Terminate();
167
629ae9b8 168 for(Int_t ipic(0); ipic<esd->GetNRefFigures(); ipic++){
169 c->Clear();
170 if(!esd->GetRefFigure(ipic)) continue;
1ee39b3a 171 c->SaveAs(Form("%s_Fig%02d.gif", esd->GetName(), ipic));
1ee39b3a 172 }
173 delete esd;
174}