]> git.uio.no Git - u/mrichter/AliRoot.git/blame - TRD/qaRec/run.C
move reconstruction setup parameters to debug level 1 (asked by
[u/mrichter/AliRoot.git] / TRD / qaRec / run.C
CommitLineData
77203477 1// Steer TRD QA train for Reconstruction (Clusterizer, Tracking and PID).
2//
3// Usage:
e15179be 4// run.C(tasks, files)
77203477 5// tasks : "ALL" or one/more of the following:
6// "EFF" : TRD Tracking Efficiency
7// "EFFC" : TRD Tracking Efficiency Combined (barrel + stand alone) - only in case of simulations
c792ca2e 8// "MULT" : TRD single track selection
77203477 9// "RES" : TRD tracking Resolution
5198d8c6 10// "CLRES": clusters Resolution
ba2773d0 11// "CAL" : TRD calibration
56bb0e8e 12// "ALGN" : TRD alignment
77203477 13// "PID" : TRD PID - pion efficiency
14// "PIDR" : TRD PID - reference data
2b468513 15// "DET" : Basic TRD Detector checks
28efdace 16// "NOFR" : Data set does not have AliESDfriends.root
4b8f8a35 17// "NOMC" : Data set does not have Monte Carlo Informations (real data), so all tasks which rely
18// on MC information are switched off
2c0cf367 19//
20// In compiled mode :
21// Don't forget to load first the libraries
22// gSystem->Load("libMemStat.so")
23// gSystem->Load("libMemStatGui.so")
24// gSystem->Load("libANALYSIS.so")
b94feda9 25// gSystem->Load("libANALYSISalice.so")
2c0cf367 26// gSystem->Load("libTRDqaRec.so")
b94feda9 27// gSystem->Load("libPWG1.so");
e15179be 28// gSystem->Load("libNetx.so") ;
29// gSystem->Load("libRAliEn.so");
2c0cf367 30//
77203477 31// Authors:
32// Alex Bercuci (A.Bercuci@gsi.de)
33// Markus Fasel (m.Fasel@gsi.de)
34
819f5b0f 35#ifndef __CINT__
8cc0ed91 36#include <Riostream.h>
37
819f5b0f 38#include "TStopwatch.h"
39#include "TMemStat.h"
40#include "TMemStatViewerGUI.h"
41
42#include "TROOT.h"
b94feda9 43#include "TClass.h"
819f5b0f 44#include "TSystem.h"
8cc0ed91 45#include "TError.h"
819f5b0f 46#include "TChain.h"
e15179be 47#include "TGrid.h"
48#include "TAlienCollection.h"
49#include "TGridCollection.h"
50#include "TGridResult.h"
af735a05 51#include "TGeoGlobalMagField.h"
819f5b0f 52
f7a1cc68 53#include "AliMagF.h"
8cc0ed91 54#include "AliTracker.h"
819f5b0f 55#include "AliLog.h"
56#include "AliCDBManager.h"
e15179be 57#include "AliGeomManager.h"
819f5b0f 58#include "AliAnalysisManager.h"
59#include "AliAnalysisDataContainer.h"
8cc0ed91 60#include "AliMCEventHandler.h"
61#include "AliESDInputHandler.h"
819f5b0f 62
8cc0ed91 63#include "TRD/AliTRDtrackerV1.h"
64#include "TRD/AliTRDcalibDB.h"
6da3eee3 65
66#include "TRD/qaRec/macros/AddTRDcheckESD.C"
67#include "TRD/qaRec/macros/AddTRDinfoGen.C"
68#include "TRD/qaRec/macros/AddTRDcheckDET.C"
69#include "TRD/qaRec/macros/AddTRDefficiency.C"
70#include "TRD/qaRec/macros/AddTRDresolution.C"
71#include "TRD/qaRec/macros/AddTRDcheckPID.C"
72
d66c0772 73#include "../../PWG1/macros/AddPerformanceTask.C"
819f5b0f 74#endif
75
6da3eee3 76#include "macros/AliTRDperformanceTrain.h"
d66c0772 77#include "../../PWG1/macros/AddPerformanceTask.h"
6da3eee3 78
3d86166d 79
819f5b0f 80Bool_t MEM = kFALSE;
b94feda9 81Bool_t fHasMCdata = kTRUE;
82Bool_t fHasFriends = kTRUE;
8cc0ed91 83
e15179be 84TChain* MakeChainLST(const char* filename = 0x0);
85TChain* MakeChainXML(const char* filename = 0x0);
b94feda9 86void run(Char_t *trd="ALL", Char_t *tpc="ALL", const Char_t *files=0x0, Long64_t nev=1234567890, Long64_t first = 0)
77203477 87{
819f5b0f 88 TMemStat *mem = 0x0;
8cc0ed91 89 if(MEM){
90 gSystem->Load("libMemStat.so");
91 gSystem->Load("libMemStatGui.so");
92 mem = new TMemStat("new, gnubuildin");
93 mem->AddStamp("Start");
94 }
814ecea4 95 TStopwatch timer;
96 timer.Start();
814ecea4 97
873458ab 98
99
100 // VERY GENERAL SETTINGS
b94feda9 101 AliLog::SetGlobalLogLevel(AliLog::kError);
107fde80 102 if(gSystem->Load("libANALYSIS.so")<0) return;
873458ab 103 if(gSystem->Load("libANALYSISalice.so")<0) return;
104
6da3eee3 105/* } else if(s.CompareTo("NOFR") == 0){
106 fHasFriends = kFALSE;
107 } else if(s.CompareTo("NOMC") == 0){
108 fHasMCdata = kFALSE;
109*/
77203477 110
873458ab 111 // INITIALIZATION OF RUNNING ENVIRONMENT
af735a05 112 //TODO We should use the GRP if available similar to AliReconstruction::InitGRP()!
6bc4a8f4 113 // initialize OCDB manager
114 AliCDBManager *cdbManager = AliCDBManager::Instance();
162637e4 115 cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB");
6bc4a8f4 116 cdbManager->SetRun(0);
117 cdbManager->SetCacheFlag(kFALSE);
af735a05 118 // initialize magnetic field.
6da3eee3 119 if(!TGeoGlobalMagField::Instance()->GetField()){
120 TGeoGlobalMagField::Instance()->SetField(
121 new AliMagF("Maps","Maps", 2, 1., 10., AliMagF::k5kG)
122 //AliMagF("Maps","Maps", 2, 0., 10., AliMagF::k2kG);
123 );
124 AliGeomManager::LoadGeometry();
125 }
5198d8c6 126
8cc0ed91 127
e15179be 128 // DEFINE DATA CHAIN
129 TChain *chain = 0x0;
130 if(!files) chain = MakeChainLST();
131 else{
132 TString fn(files);
133 if(fn.EndsWith("xml")) chain = MakeChainXML(files);
134 else chain = MakeChainLST(files);
135 }
136 if(!chain) return;
814ecea4 137 chain->SetBranchStatus("*FMD*",0);
138 chain->SetBranchStatus("*Calo*",0);
139 chain->SetBranchStatus("Tracks", 1);
140 chain->SetBranchStatus("ESDfriend*",1);
141 chain->Lookup();
142 chain->GetListOfFiles()->Print();
143 printf("\n ----> CHAIN HAS %d ENTRIES <----\n\n", (Int_t)chain->GetEntries());
814ecea4 144
873458ab 145
146 // BUILD ANALYSIS MANAGER
b94feda9 147 AliAnalysisManager *mgr = new AliAnalysisManager("Post Reconstruction Calibration/QA");
8cc0ed91 148 AliVEventHandler *esdH = 0x0, *mcH = 0x0;
149 mgr->SetInputEventHandler(esdH = new AliESDInputHandler);
150 if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler());
814ecea4 151 //mgr->SetDebugLevel(10);
152
b94feda9 153
873458ab 154
b94feda9 155///////////////////////////////////////////////////////////
156/////////////// TRD ///////////
157///////////////////////////////////////////////////////////
873458ab 158 // TRD specific library
159 if(gSystem->Load("libTRDqaRec.so")<0) return;
873458ab 160 // TRD data containers
161 AliAnalysisDataContainer *ci[] = {0x0, 0x0};
873458ab 162
873458ab 163
6da3eee3 164 // initialize TRD settings
165 AliTRDcalibDB *cal = AliTRDcalibDB::Instance();
166 AliTRDtrackerV1::SetNTimeBins(cal->GetNumberOfTimeBins());
167
168 // plug (set of) TRD wagons in the train
169 if(trd){
170 for(Int_t it=0; it<NTRDQATASKS; it++){
171 if(gROOT->LoadMacro(Form("$ALICE_ROOT/TRD/qaRec/macros/Add%s.C+", TString(fgkTRDtaskClassName[it])(3,20).Data()))) {
172 Error("run.C", Form("Error loading %s task.", fgkTRDtaskClassName[it]));
173 return;
174 }
175
176 switch(it){
177 case kCheckESD:
178 AddTRDcheckESD(mgr); break;
179 case kInfoGen:
180 AddTRDinfoGen(mgr, trd, 0x0, ci); break;
181 case kCheckDET:
182 AddTRDcheckDET(mgr, trd, ci); break;
183 case kEfficiency:
184 AddTRDefficiency(mgr, trd, ci); break;
185 case kResolution:
186 AddTRDresolution(mgr, trd, ci); break;
187 case kCheckPID:
188 AddTRDcheckPID(mgr, trd, ci); break;
189 default:
190 Warning("run.C", Form("No performance task registered at slot %d.", it));
191 }
e15179be 192 }
2b468513 193 }
b94feda9 194
873458ab 195///////////////////////////////////////////////////////////
196/////////////// TPC ///////////
197///////////////////////////////////////////////////////////
b94feda9 198 if(gSystem->Load("libPWG1.so")<0) return;
b94feda9 199
873458ab 200 // BUILD STEERING TASK FOR TPC
6da3eee3 201 if(tpc){
873458ab 202 if(gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddPerformanceTask.C+")) {
203 Error("run.C", "Error loading AliPerformanceTask task.");
204 return;
205 }
6da3eee3 206 AddPerformanceTask(mgr, tpc);
b94feda9 207 }
208
b94feda9 209 if (!mgr->InitAnalysis()) return;
873458ab 210 // verbosity
211 printf("\n\tRUNNING TRAIN FOR TASKS:\n");
212 mgr->GetTasks()->ls();
d85cd79c 213 //mgr->PrintStatus();
819f5b0f 214
b94feda9 215 mgr->StartAnalysis("local", chain, nev, first);
814ecea4 216
217 timer.Stop();
819f5b0f 218 timer.Print();
219
2c0cf367 220 cal->Terminate();
af735a05 221 TGeoGlobalMagField::Instance()->SetField(NULL);
8cc0ed91 222 delete cdbManager;
d12237d6 223
873458ab 224 // verbosity
225 printf("\n\tCLEANING UP TRAIN:\n");
226 mgr->GetTasks()->Delete();
b94feda9 227
8cc0ed91 228 if(mcH) delete mcH;
229 delete esdH;
230 delete mgr;
231 delete chain;
819f5b0f 232 if(MEM) delete mem;
233 if(MEM) TMemStatViewerGUI::ShowGUI();
814ecea4 234}
8cc0ed91 235
e15179be 236//____________________________________________
237TChain* MakeChainLST(const char* filename)
8cc0ed91 238{
239 // Create the chain
240 TChain* chain = new TChain("esdTree");
241
242 if(!filename){
243 chain->Add(Form("%s/AliESDs.root", gSystem->pwd()));
244 return chain;
245 }
246
247
248 // read ESD files from the input list.
249 ifstream in;
250 in.open(filename);
251 TString esdfile;
e15179be 252 while(in.good()) {
8cc0ed91 253 in >> esdfile;
254 if (!esdfile.Contains("root")) continue; // protection
255 chain->Add(esdfile.Data());
256 }
257
258 in.close();
259
260 return chain;
261}
e15179be 262
263//____________________________________________
264TChain* MakeChainXML(const char* xmlfile)
265{
266 if (!TFile::Open(xmlfile)) {
267 Error("MakeChainXML", Form("No file %s was found", xmlfile));
268 return 0x0;
269 }
270
271 if(gSystem->Load("libNetx.so")<0) return 0x0;
272 if(gSystem->Load("libRAliEn.so")<0) return 0x0;
273 TGrid::Connect("alien://") ;
274
275 TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile);
276 if (!collection) {
277 Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ;
278 return 0x0;
279 }
280 //collection->CheckIfOnline();
281
282 TGridResult* result = collection->GetGridResult("",0 ,0);
283 if(!result->GetEntries()){
284 Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ;
285 return 0x0;
286 }
287 // Makes the ESD chain
288 TChain* chain = new TChain("esdTree");
289 for (Int_t idx = 0; idx < result->GetEntries(); idx++) {
290 chain->Add(result->GetKey(idx, "turl"));
291 }
292 return chain;
293}