]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/makeResults.C
reduce memory consumption in the histo process. Update for getting right
[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__)
28efdace 33#include "TError.h"
9fbe6f3e 34#include <TClass.h>
35#include <TFileMerger.h>
28efdace 36#include <TCanvas.h>
9fbe6f3e 37#include <TH1.h>
38#include <TGraph.h>
39#include <TObjArray.h>
40#include <TObjString.h>
41#include <TPython.h>
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
53Char_t *libs[] = {"libProofPlayer.so", "libANALYSIS.so", "libTRDqaRec.so", "libPyROOT"};
54
429d7256 55void makeResults(Char_t *args = "ALL")
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
429d7256 70 Char_t *dir = 0x0;
71 TString tasks;
72 TObjArray *argsArray = TString(args).Tokenize("?");
73 switch(argsArray->GetEntriesFast()){
74 case 1:
75 tasks = ((TObjString*)(*argsArray)[0])->String();
76 dir=0x0;
77 break;
78 case 2:
79 tasks = ((TObjString*)(*argsArray)[0])->String();
80 dir = ((TObjString*)(*argsArray)[1])->GetName();
81 break;
82 default:
83 printf("Macro accepts 2 arguments separated by a '?'.\n");
84 printf("arg #1 : list of tasks/options\n");
234a1f83 85 printf("arg #2 : list of files to be processed\n");
429d7256 86 return;
87 }
88
9fbe6f3e 89 // select tasks to process; we should move it to an
90 // individual function and move the task identifiers
91 // outside the const space
429d7256 92 TObjArray *tasksArray = tasks.Tokenize(" ");
9fbe6f3e 93 Int_t fSteerTask = 0;
94 for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){
95 TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String();
96 if(s.CompareTo("ALL") == 0){
97 for(Int_t itask = 1; itask < fknTasks; itask++) SETBIT(fSteerTask, itask);
98 continue;
28efdace 99 } else if(s.CompareTo("NOFR") == 0){
100 friends = kFALSE;
101 } else if(s.CompareTo("NOMC") == 0){
102 mc = kFALSE;
103 } else {
104 Bool_t foundOpt = kFALSE;
105 for(Int_t itask = 1; itask < fknTasks; itask++){
106 if(s.CompareTo(fTaskOpt[itask]) != 0) continue;
107 SETBIT(fSteerTask, itask);
108 foundOpt = kTRUE;
109 break;
110 }
111 if(!foundOpt) Info("makeResults.C", Form("Task %s not implemented (yet).", s.Data()));
9fbe6f3e 112 }
113 }
3d86166d 114
3d86166d 115 // file merger object
9fbe6f3e 116 TFileMerger *fFM = new TFileMerger();
3d86166d 117 TClass *ctask = 0x0;
118 TObject *o = 0x0;
119 TObjArray *fContainer = 0x0;
120 AliTRDrecoTask *task = 0x0;
234a1f83 121 Int_t nFiles;
3d86166d 122
5eb2d6ea 123 if(gSystem->AccessPathName(Form("%s/merge", gSystem->ExpandPathName("$PWD")))) gSystem->Exec(Form("mkdir -v %s/merge", gSystem->ExpandPathName("$PWD")));
124
125 printf("\n\tPROCESSING DATA FOR TASKS [%b]:\n", fSteerTask);
9fbe6f3e 126 for(Int_t itask = 1; itask <fknTasks; itask++){
3d86166d 127 if(!TESTBIT(fSteerTask, itask)) continue;
128
129 ctask = new TClass(fTaskClass[itask]);
130 task = (AliTRDrecoTask*)ctask->New();
28efdace 131 task->SetDebugLevel(0);
9fbe6f3e 132 task->SetMCdata(mc);
133 task->SetFriends(friends);
3d86166d 134
9fbe6f3e 135 // setup filelist
234a1f83 136 string filename;
137 nFiles = 0;
138 ifstream filestream(dir);
139 while(getline(filestream, filename)){
140 if(Int_t(filename.find(task->GetName())) < 0) continue;
141 if(Int_t(filename.find("merge")) >= 0) continue;
142 nFiles++;
143 }
9fbe6f3e 144 if(!nFiles){
145 printf("No Files found for Task %s\n", task->GetName());
146 delete task;
147 delete ctask;
148 continue;
3d86166d 149 }
234a1f83 150 printf("Processing %d files for task %s ...\n", nFiles, task->GetName());
9fbe6f3e 151
234a1f83 152 ifstream filestream(dir);
9fbe6f3e 153 if(nFiles>1){
154 fFM = new(fFM) TFileMerger(kTRUE);
5eb2d6ea 155 fFM->OutputFile(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 156
157 while(getline(filestream, filename)){
158 if(Int_t(filename.find(task->GetName())) < 0) continue;
159 if(Int_t(filename.find("merge")) >= 0) continue;
160 fFM->AddFile(filename.c_str());
9fbe6f3e 161 }
162 fFM->Merge();
163 fFM->~TFileMerger();
5eb2d6ea 164 task->Load(Form("%s/merge/TRD.Task%s.root", gSystem->ExpandPathName("$PWD"), task->GetName()));
234a1f83 165 } else{
166 getline(filestream, filename);
167 task->Load(filename.c_str());
168 }
9fbe6f3e 169
9fbe6f3e 170 task->PostProcess();
a391a274 171 TCanvas *c=new TCanvas();
3d86166d 172 for(Int_t ipic=0; ipic<task->GetNRefFigures(); ipic++){
a391a274 173 task->GetRefFigure(ipic);
9fbe6f3e 174 c->SaveAs(Form("%s_fig%d.gif", task->GetName(), ipic));
a391a274 175 c->Clear();
3d86166d 176 }
a391a274 177 delete c;
3d86166d 178 delete task;
179 delete ctask;
180 }
9fbe6f3e 181}
182