]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/makeResults.C
update for non null magnetic field
[u/mrichter/AliRoot.git] / TRD / qaRec / makeResults.C
CommitLineData
234a1f83 1// Usage:
d914ba4e 2// makeResults.C("tasks", "file_list", kGRID)
234a1f83 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// "CAL" : TRD calibration
8// "PID" : TRD PID - pion efficiency
9// "PIDR" : TRD PID - reference data
10// "DET" : Basic TRD Detector checks
11// "NOFR" : Data set does not have AliESDfriends.root
12// "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
13// on MC information are switched off
14// file_list : is the list of the files to be processed.
15// They should contain the full path. Here is an example:
16// /lustre_alpha/alice/TRDdata/HEAD/1.0GeV/RUN0/TRD.TaskResolution.root
d914ba4e 17// or for GRID alien:///alice/cern.ch/user/m/mfasel/MinBiasProd/results/ppMinBias80000/1/TRD.TaskDetChecker.root
18// kGRID : specify if files are comming from a GRID collection [default kFALSE]
234a1f83 19//
d914ba4e 20// HOW TO BUILD THE FILE LIST
21// 1. locally
22// ls -1 BaseDir/TRD.Task*.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.Task%.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.
234a1f83 41//
42// Authors:
43// Alex Bercuci (A.Bercuci@gsi.de)
44// Markus Fasel (m.Fasel@gsi.de)
45//
46
9fbe6f3e 47#if ! defined (__CINT__) || defined (__MAKECINT__)
4c0f3c82 48#include <fstream>
28efdace 49#include "TError.h"
9fbe6f3e 50#include <TClass.h>
51#include <TFileMerger.h>
28efdace 52#include <TCanvas.h>
9fbe6f3e 53#include <TH1.h>
54#include <TGraph.h>
55#include <TObjArray.h>
56#include <TObjString.h>
9fbe6f3e 57#include <TString.h>
58#include <TROOT.h>
59#include <TSystem.h>
28efdace 60#include <TStyle.h>
9fbe6f3e 61
62#include "qaRec/AliTRDrecoTask.h"
63
9fbe6f3e 64#endif
65
3d86166d 66#include "run.h"
9fbe6f3e 67
e15179be 68Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so"};
9fbe6f3e 69
d914ba4e 70void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0, Bool_t kGRID=kFALSE)
3d86166d 71{
d914ba4e 72 if(kGRID){
73 if(!gSystem->Getenv("GSHELL_ROOT")){
74 printf("alien not initialized.\n");
75 return;
76 }
77 TGrid::Connect("alien://");
78 }
79
9fbe6f3e 80 // Load Libraries in interactive mode
9fbe6f3e 81 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
3d86166d 82 for(Int_t ilib=0; ilib<nlibs; ilib++){
2b436dfa 83 if(gSystem->Load(libs[ilib]) >= 0) continue;
3d86166d 84 printf("Failed to load %s.\n", libs[ilib]);
85 return;
86 }
9fbe6f3e 87
88
c4c5bbfb 89 gStyle->SetOptStat(0);
9fbe6f3e 90 Bool_t mc = kTRUE;
91 Bool_t friends = kTRUE;
92
93 // select tasks to process; we should move it to an
94 // individual function and move the task identifiers
95 // outside the const space
e15179be 96 TString tasks(opt);
429d7256 97 TObjArray *tasksArray = tasks.Tokenize(" ");
9fbe6f3e 98 Int_t fSteerTask = 0;
99 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
100 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
101 if(s.CompareTo("ALL") == 0){
e15179be 102 for(Int_t itask = 1; itask < NQATASKS; itask++) SETBIT(fSteerTask, itask);
9fbe6f3e 103 continue;
28efdace 104 } else if(s.CompareTo("NOFR") == 0){
105 friends = kFALSE;
106 } else if(s.CompareTo("NOMC") == 0){
107 mc = kFALSE;
108 } else {
109 Bool_t foundOpt = kFALSE;
107fde80 110 for(Int_t itask = 1; itask < NTRDTASKS; itask++){
111 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
e15179be 112 SETBIT(fSteerTask, itask);
28efdace 113 foundOpt = kTRUE;
114 break;
115 }
116 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
9fbe6f3e 117 }
118 }
e15179be 119 // extra rules for calibration tasks
120 if(TSTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution);
121 if(TSTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kPIDChecker);
122 if(TSTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution);
3d86166d 123
3d86166d 124 // file merger object
e15179be 125 TFileMerger *fFM = 0x0;
52e4836c 126 TClass *ctask = new TClass;
3d86166d 127 AliTRDrecoTask *task = 0x0;
234a1f83 128 Int_t nFiles;
3d86166d 129
5eb2d6ea 130 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
131
e15179be 132 for(Int_t itask = 1; itask<NTRDTASKS; itask++){
c6db5a39 133 if(!TSTBIT(fSteerTask, itask)) continue;
3d86166d 134
52e4836c 135 new(ctask) TClass(fgkTRDtaskClassName[itask]);
3d86166d 136 task = (AliTRDrecoTask*)ctask->New();
28efdace 137 task->SetDebugLevel(0);
9fbe6f3e 138 task->SetMCdata(mc);
139 task->SetFriends(friends);
3d86166d 140
9fbe6f3e 141 // setup filelist
234a1f83 142 nFiles = 0;
52e4836c 143 TString mark(Form("%s.root", task->GetName()));
e15179be 144 string filename;
145 if(files){
146 ifstream filestream(files);
147 while(getline(filestream, filename)){
52e4836c 148 if(Int_t(filename.find(mark.Data())) < 0) continue;
e15179be 149 nFiles++;
150 }
151 } else {
152 nFiles = !gSystem->AccessPathName(Form("TRD.Task%s.root", task->GetName()));
234a1f83 153 }
e15179be 154
9fbe6f3e 155 if(!nFiles){
e15179be 156 Info("makeResults.C", Form("No Files found for Task %s", task->GetName()));
9fbe6f3e 157 delete task;
9fbe6f3e 158 continue;
3d86166d 159 }
e15179be 160 Info("makeResults.C", Form(" Processing %d files for task %s ...", nFiles, task->GetName()));
9fbe6f3e 161
e15179be 162 if(files){
163 fFM = new TFileMerger(kTRUE);
5eb2d6ea 164 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 165
e15179be 166 ifstream file(files);
4c0f3c82 167 while(getline(file, filename)){
52e4836c 168 if(Int_t(filename.find(mark.Data())) < 0) continue;
234a1f83 169 fFM->AddFile(filename.c_str());
9fbe6f3e 170 }
171 fFM->Merge();
e15179be 172 delete fFM;
52e4836c 173 if(!task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
174 delete task;
175 break;
176 }
234a1f83 177 } else{
52e4836c 178 if(!task->Load(Form("%s/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
179 delete task;
180 break;
181 }
234a1f83 182 }
9fbe6f3e 183
52e4836c 184 printf("Processing ...\n");
9fbe6f3e 185 task->PostProcess();
a391a274 186 TCanvas *c=new TCanvas();
3d86166d 187 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
b1957d3c 188 if(!task->GetRefFigure(ipic)) continue;
9fbe6f3e 189 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
a391a274 190 c->Clear();
3d86166d 191 }
a391a274 192 delete c;
3d86166d 193 delete task;
3d86166d 194 }
52e4836c 195 delete ctask;
9fbe6f3e 196}
197