]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PWGPP/TRD/macros/makeResults.C
add V0 particle identification (Alex Markus)
[u/mrichter/AliRoot.git] / PWGPP / TRD / macros / makeResults.C
CommitLineData
1ee39b3a 1// Usage:
9e985d64 2// makeResults.C("tasks", "file_list", ""task_id, kGRID)
1ee39b3a 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
9e985d64 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)
1ee39b3a 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//
37ef945e 42//
43// In compiled mode :
44// Don't forget to load first the libraries
45// gSystem->Load("libANALYSIS.so")
46// gSystem->Load("libANALYSISalice.so")
47// gSystem->Load("libTENDER.so");
2bfe5463 48// gSystem->Load("libPWGPP.so");
37ef945e 49// gSystem->Load("libCORRFW.so");
f1b821e6 50// gSystem->Load("libPWGmuon.so");
37ef945e 51// gSystem->Load("libNetx.so") ;
52// gSystem->Load("libRAliEn.so");
53
1ee39b3a 54// Authors:
37ef945e 55// Alex Bercuci (A.Bercuci@gsi.de)
56// Markus Fasel (m.Fasel@gsi.de)
1ee39b3a 57//
58
59#if ! defined (__CINT__) || defined (__MAKECINT__)
60#include <fstream>
61#include "TError.h"
62#include <TClass.h>
63#include <TCanvas.h>
64#include <TH1.h>
65#include <TGraph.h>
66#include <TObjArray.h>
67#include <TObjString.h>
68#include <TString.h>
69#include <TROOT.h>
70#include <TStyle.h>
37ef945e 71#include <TSystem.h>
1ee39b3a 72#include <TGrid.h>
73#include <TGridResult.h>
74#include <TGridCollection.h>
75
02213fef 76#include "AliLog.h"
77
f01f8284 78#include "PWGPP/TRD/info/AliTRDtrendingManager.h"
2bfe5463 79#include "PWGPP/TRD/AliTRDpwgppHelper.h"
80#include "PWGPP/TRD/AliTRDrecoTask.h"
81#include "PWGPP/TRD/AliTRDcheckESD.h"
82#include "PWGPP/TRD/AliTRDinfoGen.h"
1ee39b3a 83#endif
84
96387ba8 85const Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libANALYSISalice.so", "libCORRFW", "libTENDER.so", "libPWGPP.so", "libPWGmuon.so"};
1ee39b3a 86// define setup
37ef945e 87TCanvas *c(NULL);
1ee39b3a 88Bool_t mc(kFALSE), friends(kFALSE);
b795b480 89Bool_t summary(kTRUE);
1ee39b3a 90
02213fef 91void processTRD(TNamed* task, const Char_t *filename);
92void processESD(TNamed* task, const Char_t *filename);
37ef945e 93void processGEN(TNamed* task, const Char_t *filename);
94void makeSummaryESD(const Char_t* filename="QAresults.root", Double_t* trendValues=0x0, Bool_t useCF=kFALSE, Bool_t useIsolatedBC=kFALSE, Bool_t cutTOFbc=kFALSE, const Char_t* dir="TRD_Performance", Bool_t isGrid=kFALSE);
95void makeResults(const Char_t *opt = "ALL",
96 const Char_t *files="QAresults.root",
97 const Char_t *cid = "",
98 Bool_t kGRID=kFALSE, Bool_t dosummary = kTRUE)
1ee39b3a 99{
37ef945e 100 if(kGRID) TGrid::Connect("alien://");
1ee39b3a 101
566c3d46 102 // Load Libraries in interactive mode
1ee39b3a 103 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
104 for(Int_t ilib=0; ilib<nlibs; ilib++){
105 if(gSystem->Load(libs[ilib]) >= 0) continue;
37ef945e 106 Error("makeResults.C", "Failed to load %s.", libs[ilib]);
1ee39b3a 107 return;
108 }
109
2bfe5463 110 mc = AliTRDpwgppHelper::HasReadMCData(opt);
111 friends = AliTRDpwgppHelper::HasReadFriendData(opt);
1ee39b3a 112
113 gStyle->SetOptStat(0);
114 gStyle->SetOptFit(0);
02213fef 115 TString outputFile;
37ef945e 116 if(!TString(files).EndsWith(".root")){
02213fef 117 outputFile = Form("%s/QAResults.root", gSystem->ExpandPathName("$PWD"));
2bfe5463 118 AliTRDpwgppHelper::MergeProd("QAResults.root", files);
02213fef 119 } else {
120 outputFile = files;
121 }
2bfe5463 122 Int_t fSteerTask = AliTRDpwgppHelper::ParseOptions(opt);
1ee39b3a 123
b795b480 124 if(!dosummary){
2ae60201 125 summary = kFALSE;
b795b480 126 if(!c) c=new TCanvas("c", "Performance", 10, 10, 800, 500);
127 }
1ee39b3a 128
129 TClass *ctask = new TClass;
847569f2 130 AliAnalysisTask *task = NULL;
2bfe5463 131 for(Int_t itask = AliTRDpwgppHelper::kNTRDQATASKS; itask--;){
132 if(!AliTRDpwgppHelper::DoTask(itask, fSteerTask)) continue;
133 new(ctask) TClass(AliTRDpwgppHelper::TaskClassName(itask));
1ee39b3a 134 task = (AliAnalysisTask*)ctask->New();
92d6d80c 135 task->SetName(Form("%s%s", task->GetName(), cid));
058c3053 136 printf(" *** task %s, output file %s\n", task->GetName(), outputFile.Data());
02213fef 137 if(task->IsA()->InheritsFrom("AliTRDrecoTask")) processTRD(task, outputFile.Data());
058c3053 138 else if(strcmp(task->IsA()->GetName(), "AliTRDcheckESD")==0) processESD(task, outputFile.Data());
566c3d46 139 else if(strcmp(task->IsA()->GetName(), "AliTRDinfoGen")==0) processGEN(task, outputFile.Data());
058c3053 140 else{
37ef945e 141 Error("makeResults.C", "Handling of class task \"%s\" not implemented.", task->IsA()->GetName());
058c3053 142 delete task;
143 }
1ee39b3a 144 }
145 delete ctask;
146 delete c;
847569f2 147 // write trending summary
148 AliTRDtrendingManager::Instance()->Terminate();
1ee39b3a 149}
150
151
152//______________________________________________________
02213fef 153void processTRD(TNamed *otask, const Char_t *filename)
1ee39b3a 154{
97d0ccba 155 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
92d6d80c 156 Int_t debug(0);
1ee39b3a 157 AliTRDrecoTask *task = dynamic_cast<AliTRDrecoTask*>(otask);
92d6d80c 158 task->SetDebugLevel(debug);
159 AliLog::SetClassDebugLevel(otask->IsA()->GetName(), debug);
1ee39b3a 160 task->SetMCdata(mc);
161 task->SetFriends(friends);
162
02213fef 163 //if(!task->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")))){
164 if(!task->Load(filename)){
37ef945e 165 Error("makeResults.C", "Load data container for task %s failed.", task->GetName());
1ee39b3a 166 delete task;
167 return;
168 }
8892a7f3 169 task->LoadDetectorMap(filename);
1ee39b3a 170 if(!task->PostProcess()){
37ef945e 171 Error("makeResults.C", "Processing data container for task %s failed.", task->GetName());
1ee39b3a 172 delete task;
173 return;
174 }
b795b480 175 if(summary) task->MakeSummary();
176 else{
177 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
178 c->Clear();
179 if(!task->GetRefFigure(ipic)) continue;
180 c->SaveAs(Form("%s_Fig%02d.gif", task->GetName(), ipic), "gif");
181 }
1ee39b3a 182 }
183 delete task;
184}
185
186//______________________________________________________
02213fef 187void processESD(TNamed *otask, const Char_t *filename)
1ee39b3a 188{
97d0ccba 189 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
3d2a3dff 190
1ee39b3a 191 AliTRDcheckESD *esd = dynamic_cast<AliTRDcheckESD*>(otask);
192 if(!esd){
37ef945e 193 Info("makeResults.C", "Processing of task %s failed.", otask->GetName());
1ee39b3a 194 delete otask;
195 return;
196 }
02213fef 197 //if(!esd->Load(Form("%s/AnalysisResults.root", gSystem->ExpandPathName("$PWD")), "TRD_Performance")){
198 if(!esd->Load(filename, "TRD_Performance")){
37ef945e 199 Error("makeResults.C", "Load data container for task %s failed.", esd->GetName());
1ee39b3a 200 delete esd;
201 return;
202 }
02213fef 203 esd->Terminate(NULL);
37ef945e 204
5047978d 205 if(summary) esd->MakeSummaryFromCF(0, "", kFALSE, kFALSE);
b795b480 206 else{
207 for(Int_t ipic(0); ipic<esd->GetNRefFigures(); ipic++){
37ef945e 208 c->Clear();
b795b480 209 if(!esd->GetRefFigure(ipic)) continue;
210 c->SaveAs(Form("%s_Fig%02d.gif", esd->GetName(), ipic));
211 }
1ee39b3a 212 }
213 delete esd;
214}
058c3053 215
216//______________________________________________________
217void processGEN(TNamed *otask, const Char_t *filename)
218{
219 printf("process[%s] : %s\n", otask->GetName(), otask->GetTitle());
220
221 AliTRDinfoGen *info = dynamic_cast<AliTRDinfoGen*>(otask);
222
223 if(!info->Load(filename, "TRD_Performance")){
37ef945e 224 Error("makeResults.C", "Load data container for task %s failed.", info->GetName());
058c3053 225 delete info;
226 return;
227 }
dffc3357 228 info->MakeSummary();
229// else{
230// for(Int_t ipic(0); ipic<info->GetNRefFigures(); ipic++){
231// c->Clear();
232// if(!info->GetRefFigure(ipic)) continue;
233// c->SaveAs(Form("%s_Fig%02d.gif", info->GetName(), ipic));
234// }
235// }
058c3053 236
237 delete info;
810660cc 238}
566c3d46 239
240//______________________________________________________
241void makeSummaryESD(const Char_t* filename, Double_t* trendValues, Bool_t useCF, Bool_t useIsolatedBC, Bool_t cutTOFbc, const Char_t* dir, Bool_t isGrid) {
242 //
243 // Make the summary picture and get trending variables from the ESD task
244 //
37ef945e 245 if(isGrid) TGrid::Connect("alien://");
246
566c3d46 247 // Load Libraries in interactive mode
248 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
249 for(Int_t ilib=0; ilib<nlibs; ilib++){
250 if(gSystem->Load(libs[ilib]) >= 0) continue;
37ef945e 251 Error("makeResults.C", "Failed to load %s.", libs[ilib]);
566c3d46 252 return;
253 }
37ef945e 254
566c3d46 255 AliTRDcheckESD *esd=new AliTRDcheckESD();
256 if(!esd->Load(filename,dir)) return;
257 //esd->Terminate();
b93fa72f 258 if(useCF) esd->MakeSummaryFromCF(trendValues, "", useIsolatedBC, cutTOFbc);
566c3d46 259 else esd->MakeSummary(trendValues);
260}