]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/makeResults.C
update for the new Rezidual plots
[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>
42#include <TPython.h>
43#include <TString.h>
44#include <TROOT.h>
45#include <TSystem.h>
28efdace 46#include <TStyle.h>
9fbe6f3e 47
48#include "qaRec/AliTRDrecoTask.h"
49
9fbe6f3e 50#endif
51
3d86166d 52#include "run.h"
9fbe6f3e 53
54Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libPyROOT"};
55
429d7256 56void makeResults(Char_t *args = "ALL")
3d86166d 57{
9fbe6f3e 58 // Load Libraries in interactive mode
9fbe6f3e 59 Int_t nlibs = static_cast<Int_t>(sizeof(libs)/sizeof(Char_t *));
3d86166d 60 for(Int_t ilib=0; ilib<nlibs; ilib++){
2b436dfa 61 if(gSystem->Load(libs[ilib]) >= 0) continue;
3d86166d 62 printf("Failed to load %s.\n", libs[ilib]);
63 return;
64 }
9fbe6f3e 65
66
c4c5bbfb 67 gStyle->SetOptStat(0);
9fbe6f3e 68 Bool_t mc = kTRUE;
69 Bool_t friends = kTRUE;
70
4c0f3c82 71 const Char_t *dir = 0x0;
429d7256 72 TString tasks;
73 TObjArray *argsArray = TString(args).Tokenize("?");
74 switch(argsArray->GetEntriesFast()){
75 case 1:
76 tasks = ((TObjString*)(*argsArray)[0])->String();
77 dir=0x0;
78 break;
79 case 2:
80 tasks = ((TObjString*)(*argsArray)[0])->String();
81 dir = ((TObjString*)(*argsArray)[1])->GetName();
82 break;
83 default:
84 printf("Macro accepts 2 arguments separated by a '?'.\n");
85 printf("arg #1 : list of tasks/options\n");
234a1f83 86 printf("arg #2 : list of files to be processed\n");
429d7256 87 return;
88 }
89
9fbe6f3e 90 // select tasks to process; we should move it to an
91 // individual function and move the task identifiers
92 // outside the const space
429d7256 93 TObjArray *tasksArray = tasks.Tokenize(" ");
9fbe6f3e 94 Int_t fSteerTask = 0;
95 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
96 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
97 if(s.CompareTo("ALL") == 0){
c6db5a39 98 for(Int_t itask = 1; itask < NTRDTASKS; itask++) SETBIT(fSteerTask, itask - 1);
9fbe6f3e 99 continue;
28efdace 100 } else if(s.CompareTo("NOFR") == 0){
101 friends = kFALSE;
102 } else if(s.CompareTo("NOMC") == 0){
103 mc = kFALSE;
104 } else {
105 Bool_t foundOpt = kFALSE;
107fde80 106 for(Int_t itask = 1; itask < NTRDTASKS; itask++){
107 if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue;
c6db5a39 108 SETBIT(fSteerTask, itask - 1);
28efdace 109 foundOpt = kTRUE;
110 break;
111 }
112 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
9fbe6f3e 113 }
114 }
3d86166d 115
3d86166d 116 // file merger object
9fbe6f3e 117 TFileMerger *fFM = new TFileMerger();
3d86166d 118 TClass *ctask = 0x0;
3d86166d 119 AliTRDrecoTask *task = 0x0;
234a1f83 120 Int_t nFiles;
3d86166d 121
5eb2d6ea 122 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
123
124 printf("\n\tPROCESSING DATA FOR TASKS [%b]:\n", fSteerTask);
c6db5a39 125 for(Int_t itask = 0; itask <NTRDTASKS; itask++){
126 if(!TSTBIT(fSteerTask, itask)) continue;
3d86166d 127
107fde80 128 ctask = new TClass(fgkTRDtaskClassName[itask]);
3d86166d 129 task = (AliTRDrecoTask*)ctask->New();
28efdace 130 task->SetDebugLevel(0);
9fbe6f3e 131 task->SetMCdata(mc);
132 task->SetFriends(friends);
3d86166d 133
9fbe6f3e 134 // setup filelist
234a1f83 135 string filename;
136 nFiles = 0;
137 ifstream filestream(dir);
138 while(getline(filestream, filename)){
139 if(Int_t(filename.find(task->GetName())) < 0) continue;
140 if(Int_t(filename.find("merge")) >= 0) continue;
141 nFiles++;
142 }
9fbe6f3e 143 if(!nFiles){
144 printf("No Files found for Task %s\n", task->GetName());
145 delete task;
146 delete ctask;
147 continue;
3d86166d 148 }
234a1f83 149 printf("Processing %d files for task %s ...\n", nFiles, task->GetName());
9fbe6f3e 150
4c0f3c82 151 ifstream file(dir);
9fbe6f3e 152 if(nFiles>1){
153 fFM = new(fFM) TFileMerger(kTRUE);
5eb2d6ea 154 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 155
4c0f3c82 156 while(getline(file, filename)){
234a1f83 157 if(Int_t(filename.find(task->GetName())) < 0) continue;
158 if(Int_t(filename.find("merge")) >= 0) continue;
159 fFM->AddFile(filename.c_str());
9fbe6f3e 160 }
161 fFM->Merge();
162 fFM->~TFileMerger();
5eb2d6ea 163 task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 164 } else{
4c0f3c82 165 getline(file, filename);
234a1f83 166 task->Load(filename.c_str());
167 }
9fbe6f3e 168
9fbe6f3e 169 task->PostProcess();
a391a274 170 TCanvas *c=new TCanvas();
3d86166d 171 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
a391a274 172 task->GetRefFigure(ipic);
9fbe6f3e 173 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
a391a274 174 c->Clear();
3d86166d 175 }
a391a274 176 delete c;
3d86166d 177 delete task;
178 delete ctask;
179 }
9fbe6f3e 180}
181