]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/makeResults.C
! MAJOR ! update in the TRD tracking
[u/mrichter/AliRoot.git] / TRD / qaRec / makeResults.C
CommitLineData
234a1f83 1// Usage:
2// makeResults.C("tasks?file_list")
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
17// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN1/TRD.TaskResolution.root
18// /lustre_alpha/alice/TRDdata/HEAD/3.0GeV/RUN2/TRD.TaskResolution.root
19// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN0/TRD.TaskDetChecker.root
20// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN1/TRD.TaskDetChecker.root
21// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN2/TRD.TaskDetChecker.root
22// /lustre_alpha/alice/TRDdata/HEAD/2.0GeV/RUN0/TRD.TaskTrackingEff.root
23//
24// The files which will be processed are the initersaction between the
25// condition on the tasks and the files iin the file list.
26//
27// Authors:
28// Alex Bercuci (A.Bercuci@gsi.de)
29// Markus Fasel (m.Fasel@gsi.de)
30//
31
9fbe6f3e 32#if ! defined (__CINT__) || defined (__MAKECINT__)
4c0f3c82 33#include <fstream>
28efdace 34#include "TError.h"
9fbe6f3e 35#include <TClass.h>
36#include <TFileMerger.h>
28efdace 37#include <TCanvas.h>
9fbe6f3e 38#include <TH1.h>
39#include <TGraph.h>
40#include <TObjArray.h>
41#include <TObjString.h>
9fbe6f3e 42#include <TString.h>
43#include <TROOT.h>
44#include <TSystem.h>
28efdace 45#include <TStyle.h>
9fbe6f3e 46
47#include "qaRec/AliTRDrecoTask.h"
48
9fbe6f3e 49#endif
50
3d86166d 51#include "run.h"
9fbe6f3e 52
e15179be 53Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so"};
9fbe6f3e 54
e15179be 55void makeResults(Char_t *opt = "ALL", const Char_t *files=0x0)
3d86166d 56{
9fbe6f3e 57 // Load Libraries in interactive mode
9fbe6f3e 58 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
3d86166d 59 for(Int_t ilib=0; ilib<nlibs; ilib++){
2b436dfa 60 if(gSystem->Load(libs[ilib]) >= 0) continue;
3d86166d 61 printf("Failed to load %s.\n", libs[ilib]);
62 return;
63 }
9fbe6f3e 64
65
c4c5bbfb 66 gStyle->SetOptStat(0);
9fbe6f3e 67 Bool_t mc = kTRUE;
68 Bool_t friends = kTRUE;
69
70 // select tasks to process; we should move it to an
71 // individual function and move the task identifiers
72 // outside the const space
e15179be 73 TString tasks(opt);
429d7256 74 TObjArray *tasksArray = tasks.Tokenize(" ");
9fbe6f3e 75 Int_t fSteerTask = 0;
76 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
77 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
78 if(s.CompareTo("ALL") == 0){
e15179be 79 for(Int_t itask = 1; itask < NQATASKS; itask++) SETBIT(fSteerTask, itask);
9fbe6f3e 80 continue;
28efdace 81 } else if(s.CompareTo("NOFR") == 0){
82 friends = kFALSE;
83 } else if(s.CompareTo("NOMC") == 0){
84 mc = kFALSE;
85 } else {
86 Bool_t foundOpt = kFALSE;
107fde80 87 for(Int_t itask = 1; itask < NTRDTASKS; itask++){
88 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
e15179be 89 SETBIT(fSteerTask, itask);
28efdace 90 foundOpt = kTRUE;
91 break;
92 }
93 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
9fbe6f3e 94 }
95 }
e15179be 96 // extra rules for calibration tasks
97 if(TSTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution);
98 if(TSTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kPIDChecker);
99 if(TSTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution);
3d86166d 100
3d86166d 101 // file merger object
e15179be 102 TFileMerger *fFM = 0x0;
52e4836c 103 TClass *ctask = new TClass;
3d86166d 104 AliTRDrecoTask *task = 0x0;
234a1f83 105 Int_t nFiles;
3d86166d 106
5eb2d6ea 107 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
108
e15179be 109 for(Int_t itask = 1; itask<NTRDTASKS; itask++){
c6db5a39 110 if(!TSTBIT(fSteerTask, itask)) continue;
3d86166d 111
52e4836c 112 new(ctask) TClass(fgkTRDtaskClassName[itask]);
3d86166d 113 task = (AliTRDrecoTask*)ctask->New();
28efdace 114 task->SetDebugLevel(0);
9fbe6f3e 115 task->SetMCdata(mc);
116 task->SetFriends(friends);
3d86166d 117
9fbe6f3e 118 // setup filelist
234a1f83 119 nFiles = 0;
52e4836c 120 TString mark(Form("%s.root", task->GetName()));
e15179be 121 string filename;
122 if(files){
123 ifstream filestream(files);
124 while(getline(filestream, filename)){
52e4836c 125 if(Int_t(filename.find(mark.Data())) < 0) continue;
e15179be 126 nFiles++;
127 }
128 } else {
129 nFiles = !gSystem->AccessPathName(Form("TRD.Task%s.root", task->GetName()));
234a1f83 130 }
e15179be 131
9fbe6f3e 132 if(!nFiles){
e15179be 133 Info("makeResults.C", Form("No Files found for Task %s", task->GetName()));
9fbe6f3e 134 delete task;
9fbe6f3e 135 continue;
3d86166d 136 }
e15179be 137 Info("makeResults.C", Form(" Processing %d files for task %s ...", nFiles, task->GetName()));
9fbe6f3e 138
e15179be 139 if(files){
140 fFM = new TFileMerger(kTRUE);
5eb2d6ea 141 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 142
e15179be 143 ifstream file(files);
4c0f3c82 144 while(getline(file, filename)){
52e4836c 145 if(Int_t(filename.find(mark.Data())) < 0) continue;
234a1f83 146 fFM->AddFile(filename.c_str());
9fbe6f3e 147 }
148 fFM->Merge();
e15179be 149 delete fFM;
52e4836c 150 if(!task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
151 delete task;
152 break;
153 }
234a1f83 154 } else{
52e4836c 155 if(!task->Load(Form("%s/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()))){
156 delete task;
157 break;
158 }
234a1f83 159 }
9fbe6f3e 160
52e4836c 161 printf("Processing ...\n");
9fbe6f3e 162 task->PostProcess();
a391a274 163 TCanvas *c=new TCanvas();
3d86166d 164 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
b1957d3c 165 if(!task->GetRefFigure(ipic)) continue;
9fbe6f3e 166 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
a391a274 167 c->Clear();
3d86166d 168 }
a391a274 169 delete c;
3d86166d 170 delete task;
3d86166d 171 }
52e4836c 172 delete ctask;
9fbe6f3e 173}
174