]>
Commit | Line | Data |
---|---|---|
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" | |
873458ab | 65 | #include "TRD/qaRec/info/AliTRDeventInfo.h" |
9a281e83 | 66 | #include "TRD/qaRec/AliTRDcheckESD.h" |
873458ab | 67 | #include "TRD/qaRec/AliTRDinfoGen.h" |
68 | #include "TRD/qaRec/AliTRDefficiency.h" | |
69 | #include "TRD/qaRec/AliTRDefficiencyMC.h" | |
e3cf3d02 | 70 | #include "TRD/qaRec/AliTRDresolution.h" |
8cc0ed91 | 71 | #include "TRD/qaRec/AliTRDcalibration.h" |
e15179be | 72 | #include "TRD/qaRec/AliTRDalignmentTask.h" |
3d86166d | 73 | #include "TRD/qaRec/AliTRDpidChecker.h" |
28efdace | 74 | #include "TRD/qaRec/AliTRDpidRefMaker.h" |
2b468513 | 75 | #include "TRD/qaRec/AliTRDcheckDetector.h" |
5198d8c6 | 76 | #include "TRD/qaRec/AliTRDclusterResolution.h" |
c792ca2e | 77 | #include "TRD/qaRec/AliTRDmultiplicity.h" |
b94feda9 | 78 | |
79 | ||
80 | #include "PWG1/AliPerformanceTask.h" | |
81 | #include "PWG1/AliPerformanceEff.h" | |
873458ab | 82 | #include "PWG1/AliPerformanceDEdx.h" |
83 | #include "PWG1/AliPerformanceTPC.h" | |
84 | #include "PWG1/AliPerformanceDCA.h" | |
85 | #include "PWG1/AliPerformanceRes.h" | |
b94feda9 | 86 | #include "PWG1/AliMCInfoCuts.h" |
87 | #include "PWG1/AliRecInfoCuts.h" | |
819f5b0f | 88 | #endif |
89 | ||
3d86166d | 90 | #include "run.h" |
91 | ||
819f5b0f | 92 | Bool_t MEM = kFALSE; |
b94feda9 | 93 | Bool_t fHasMCdata = kTRUE; |
94 | Bool_t fHasFriends = kTRUE; | |
95 | const Int_t kTPCmode = 0; // | |
96 | const Int_t kTPChpt = 0; // | |
8cc0ed91 | 97 | |
e15179be | 98 | TChain* MakeChainLST(const char* filename = 0x0); |
99 | TChain* MakeChainXML(const char* filename = 0x0); | |
b94feda9 | 100 | Int_t ParseTRD(Char_t *opt); |
101 | Int_t ParseTPC(Char_t *opt); | |
102 | void run(Char_t *trd="ALL", Char_t *tpc="ALL", const Char_t *files=0x0, Long64_t nev=1234567890, Long64_t first = 0) | |
77203477 | 103 | { |
819f5b0f | 104 | TMemStat *mem = 0x0; |
8cc0ed91 | 105 | if(MEM){ |
106 | gSystem->Load("libMemStat.so"); | |
107 | gSystem->Load("libMemStatGui.so"); | |
108 | mem = new TMemStat("new, gnubuildin"); | |
109 | mem->AddStamp("Start"); | |
110 | } | |
814ecea4 | 111 | TStopwatch timer; |
112 | timer.Start(); | |
814ecea4 | 113 | |
873458ab | 114 | |
115 | ||
116 | // VERY GENERAL SETTINGS | |
b94feda9 | 117 | AliLog::SetGlobalLogLevel(AliLog::kError); |
107fde80 | 118 | if(gSystem->Load("libANALYSIS.so")<0) return; |
873458ab | 119 | if(gSystem->Load("libANALYSISalice.so")<0) return; |
120 | ||
121 | ||
77203477 | 122 | |
873458ab | 123 | // INITIALIZATION OF RUNNING ENVIRONMENT |
af735a05 | 124 | //TODO We should use the GRP if available similar to AliReconstruction::InitGRP()! |
6bc4a8f4 | 125 | // initialize OCDB manager |
126 | AliCDBManager *cdbManager = AliCDBManager::Instance(); | |
162637e4 | 127 | cdbManager->SetDefaultStorage("local://$ALICE_ROOT/OCDB"); |
6bc4a8f4 | 128 | cdbManager->SetRun(0); |
129 | cdbManager->SetCacheFlag(kFALSE); | |
af735a05 | 130 | // initialize magnetic field. |
131 | AliMagF *field = 0x0; | |
132 | field = new AliMagF("Maps","Maps", 2, 1., 10., AliMagF::k5kG); | |
133 | //field = new AliMagF("Maps","Maps", 2, 0., 10., AliMagF::k2kG); | |
134 | TGeoGlobalMagField::Instance()->SetField(field); | |
6fc46cba | 135 | |
6bc4a8f4 | 136 | // initialize TRD settings |
137 | AliTRDcalibDB *cal = AliTRDcalibDB::Instance(); | |
138 | AliTRDtrackerV1::SetNTimeBins(cal->GetNumberOfTimeBins()); | |
139 | AliGeomManager::LoadGeometry(); | |
140 | ||
28efdace | 141 | |
5198d8c6 | 142 | |
8cc0ed91 | 143 | |
e15179be | 144 | // DEFINE DATA CHAIN |
145 | TChain *chain = 0x0; | |
146 | if(!files) chain = MakeChainLST(); | |
147 | else{ | |
148 | TString fn(files); | |
149 | if(fn.EndsWith("xml")) chain = MakeChainXML(files); | |
150 | else chain = MakeChainLST(files); | |
151 | } | |
152 | if(!chain) return; | |
814ecea4 | 153 | chain->SetBranchStatus("*FMD*",0); |
154 | chain->SetBranchStatus("*Calo*",0); | |
155 | chain->SetBranchStatus("Tracks", 1); | |
156 | chain->SetBranchStatus("ESDfriend*",1); | |
157 | chain->Lookup(); | |
158 | chain->GetListOfFiles()->Print(); | |
159 | printf("\n ----> CHAIN HAS %d ENTRIES <----\n\n", (Int_t)chain->GetEntries()); | |
160 | ||
814ecea4 | 161 | |
873458ab | 162 | |
163 | // BUILD ANALYSIS MANAGER | |
b94feda9 | 164 | AliAnalysisManager *mgr = new AliAnalysisManager("Post Reconstruction Calibration/QA"); |
8cc0ed91 | 165 | AliVEventHandler *esdH = 0x0, *mcH = 0x0; |
166 | mgr->SetInputEventHandler(esdH = new AliESDInputHandler); | |
167 | if(fHasMCdata) mgr->SetMCtruthEventHandler(mcH = new AliMCEventHandler()); | |
814ecea4 | 168 | //mgr->SetDebugLevel(10); |
169 | ||
b94feda9 | 170 | |
873458ab | 171 | |
b94feda9 | 172 | /////////////////////////////////////////////////////////// |
173 | /////////////// TRD /////////// | |
174 | /////////////////////////////////////////////////////////// | |
873458ab | 175 | // TRD specific library |
176 | if(gSystem->Load("libTRDqaRec.so")<0) return; | |
177 | // Parse TRD options | |
178 | Int_t fSteerTRD = ParseTRD(trd); | |
179 | // TRD data containers | |
180 | AliAnalysisDataContainer *ci[] = {0x0, 0x0}; | |
181 | AliAnalysisDataContainer *co[] = {0x0, 0x0, 0x0, 0x0}; | |
182 | ||
183 | // plug (set of) TRD wagons in the train | |
184 | for(Int_t it=0; it<NQATASKS; it++){ | |
185 | if(!(TSTBIT(fSteerTRD, it))) continue; | |
186 | if(gROOT->LoadMacro(Form("$ALICE_ROOT/TRD/qaRec/macros/Add%s.C+", TString(fgkTRDtaskClassName[it])(3,20).Data()))) { | |
187 | Error("run.C", Form("Error loading %s task.", fgkTRDtaskClassName[it])); | |
188 | return; | |
189 | } | |
190 | ||
191 | switch(it){ | |
192 | case kCheckESD: | |
193 | AddTRDcheckESD(mgr); break; | |
194 | case kInfoGen: | |
195 | AddTRDinfoGen(mgr, 0x0, ci); break; | |
196 | case kCheckDetector: | |
197 | AddTRDcheckDetector(mgr, ci, co, fSteerTRD); break; | |
198 | case kEfficiency: | |
199 | AddTRDefficiency(mgr, ci, co, fSteerTRD); break; | |
200 | case kResolution: | |
201 | AddTRDresolution(mgr, ci, co, fSteerTRD); break; | |
202 | case kPID: | |
203 | AddTRDpidChecker(mgr, ci, co, fSteerTRD); break; | |
204 | default: | |
205 | Warning("run.C", Form("No performance task registered at slot %d.", it)); | |
e15179be | 206 | } |
2b468513 | 207 | } |
b94feda9 | 208 | |
209 | ||
873458ab | 210 | /////////////////////////////////////////////////////////// |
211 | /////////////// TPC /////////// | |
212 | /////////////////////////////////////////////////////////// | |
b94feda9 | 213 | if(gSystem->Load("libPWG1.so")<0) return; |
873458ab | 214 | // Parse TPC options |
215 | Int_t fSteerTPC = ParseTPC(tpc); | |
216 | // Create TPC-ESD track reconstruction cuts | |
b94feda9 | 217 | AliRecInfoCuts *pRecInfoCuts = new AliRecInfoCuts(); |
218 | pRecInfoCuts->SetPtRange(0.20,200.0); | |
219 | //pRecInfoCuts->SetEtaRange(-0.9,0.9); | |
220 | pRecInfoCuts->SetMaxDCAToVertexXY(3.0); | |
221 | pRecInfoCuts->SetMaxDCAToVertexZ(3.0); | |
222 | pRecInfoCuts->SetMinNClustersTPC(50); | |
223 | pRecInfoCuts->SetMinNClustersITS(2); | |
224 | pRecInfoCuts->SetMinTPCsignalN(50); | |
225 | pRecInfoCuts->SetHistogramsOn(kFALSE); | |
873458ab | 226 | // Create TPC-MC track reconstruction cuts |
b94feda9 | 227 | AliMCInfoCuts *pMCInfoCuts = new AliMCInfoCuts(); |
228 | pMCInfoCuts->SetMinRowsWithDigits(50); | |
229 | pMCInfoCuts->SetMaxR(0.025); // from diamond xy size (pp@10TeV) | |
230 | pMCInfoCuts->SetMaxVz(15.); // from diamond z size (pp@10TeV) | |
231 | pMCInfoCuts->SetRangeTPCSignal(0.5,1.4); | |
232 | pMCInfoCuts->SetMinTrackLength(70); | |
233 | ||
873458ab | 234 | // BUILD STEERING TASK FOR TPC |
235 | if(fSteerTPC){ | |
236 | if(gROOT->LoadMacro("$ALICE_ROOT/PWG1/macros/AddPerformanceTask.C+")) { | |
237 | Error("run.C", "Error loading AliPerformanceTask task."); | |
238 | return; | |
239 | } | |
240 | AliPerformanceTask *TPC = AddPerformanceTask(mgr); | |
241 | ||
242 | // plug (set of) TPC wagons in the train | |
243 | TClass ctask; AliPerformanceObject *perf = 0x0; | |
244 | for(Int_t icomp=1; icomp<NTPCTASKS; icomp++){ | |
245 | if(!(TSTBIT(fSteerTPC, icomp))) continue; | |
246 | new(&ctask) TClass(fgkTPCtaskClassName[icomp]); | |
247 | TPC->AddPerformanceObject((perf = (AliPerformanceObject*)ctask.New())); | |
248 | perf->SetAnalysisMode(kTPCmode); | |
249 | perf->SetHptGenerator(kTPChpt); | |
250 | perf->SetAliRecInfoCuts(pRecInfoCuts); | |
251 | perf->SetAliMCInfoCuts(pMCInfoCuts); | |
252 | } | |
b94feda9 | 253 | } |
254 | ||
b94feda9 | 255 | if (!mgr->InitAnalysis()) return; |
873458ab | 256 | // verbosity |
257 | printf("\n\tRUNNING TRAIN FOR TASKS:\n"); | |
258 | mgr->GetTasks()->ls(); | |
d85cd79c | 259 | //mgr->PrintStatus(); |
819f5b0f | 260 | |
b94feda9 | 261 | mgr->StartAnalysis("local", chain, nev, first); |
814ecea4 | 262 | |
263 | timer.Stop(); | |
819f5b0f | 264 | timer.Print(); |
265 | ||
2c0cf367 | 266 | cal->Terminate(); |
af735a05 | 267 | TGeoGlobalMagField::Instance()->SetField(NULL); |
8cc0ed91 | 268 | delete cdbManager; |
d12237d6 | 269 | |
873458ab | 270 | // verbosity |
271 | printf("\n\tCLEANING UP TRAIN:\n"); | |
272 | mgr->GetTasks()->Delete(); | |
273 | // for(Int_t it=tt->GetEntriesFast(); it--;){ | |
274 | // if(!(task = (AliAnalysisTask*)tt->At(it))) continue; | |
275 | // printf("Cleaning up %s [%s] ...\n", task->GetName(), task->GetTitle()); | |
276 | // delete task; | |
277 | // } | |
b94feda9 | 278 | |
8cc0ed91 | 279 | if(mcH) delete mcH; |
280 | delete esdH; | |
281 | delete mgr; | |
282 | delete chain; | |
819f5b0f | 283 | if(MEM) delete mem; |
284 | if(MEM) TMemStatViewerGUI::ShowGUI(); | |
814ecea4 | 285 | } |
8cc0ed91 | 286 | |
e15179be | 287 | //____________________________________________ |
288 | TChain* MakeChainLST(const char* filename) | |
8cc0ed91 | 289 | { |
290 | // Create the chain | |
291 | TChain* chain = new TChain("esdTree"); | |
292 | ||
293 | if(!filename){ | |
294 | chain->Add(Form("%s/AliESDs.root", gSystem->pwd())); | |
295 | return chain; | |
296 | } | |
297 | ||
298 | ||
299 | // read ESD files from the input list. | |
300 | ifstream in; | |
301 | in.open(filename); | |
302 | TString esdfile; | |
e15179be | 303 | while(in.good()) { |
8cc0ed91 | 304 | in >> esdfile; |
305 | if (!esdfile.Contains("root")) continue; // protection | |
306 | chain->Add(esdfile.Data()); | |
307 | } | |
308 | ||
309 | in.close(); | |
310 | ||
311 | return chain; | |
312 | } | |
e15179be | 313 | |
314 | //____________________________________________ | |
315 | TChain* MakeChainXML(const char* xmlfile) | |
316 | { | |
317 | if (!TFile::Open(xmlfile)) { | |
318 | Error("MakeChainXML", Form("No file %s was found", xmlfile)); | |
319 | return 0x0; | |
320 | } | |
321 | ||
322 | if(gSystem->Load("libNetx.so")<0) return 0x0; | |
323 | if(gSystem->Load("libRAliEn.so")<0) return 0x0; | |
324 | TGrid::Connect("alien://") ; | |
325 | ||
326 | TGridCollection *collection = (TGridCollection*) TAlienCollection::Open(xmlfile); | |
327 | if (!collection) { | |
328 | Error("MakeChainXML", Form("No collection found in %s", xmlfile)) ; | |
329 | return 0x0; | |
330 | } | |
331 | //collection->CheckIfOnline(); | |
332 | ||
333 | TGridResult* result = collection->GetGridResult("",0 ,0); | |
334 | if(!result->GetEntries()){ | |
335 | Error("MakeChainXML", Form("No entries found in %s", xmlfile)) ; | |
336 | return 0x0; | |
337 | } | |
338 | // Makes the ESD chain | |
339 | TChain* chain = new TChain("esdTree"); | |
340 | for (Int_t idx = 0; idx < result->GetEntries(); idx++) { | |
341 | chain->Add(result->GetKey(idx, "turl")); | |
342 | } | |
343 | return chain; | |
344 | } | |
b94feda9 | 345 | |
346 | ||
347 | //____________________________________________ | |
348 | Int_t ParseTRD(Char_t *trd) | |
349 | { | |
873458ab | 350 | Int_t fSteerTask = 1; |
b94feda9 | 351 | TObjArray *tasksArray = TString(trd).Tokenize(" "); |
352 | for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){ | |
353 | TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String(); | |
354 | if(s.CompareTo("ALL") == 0){ | |
355 | for(Int_t itask = 0; itask < NQATASKS; itask++) SETBIT(fSteerTask, itask); | |
356 | continue; | |
357 | } else if(s.CompareTo("NOFR") == 0){ | |
358 | fHasFriends = kFALSE; | |
359 | } else if(s.CompareTo("NOMC") == 0){ | |
360 | fHasMCdata = kFALSE; | |
361 | } else { | |
362 | Bool_t foundOpt = kFALSE; | |
363 | for(Int_t itask = 0; itask < NTRDTASKS; itask++){ | |
364 | if(s.CompareTo(fgkTRDtaskOpt[itask]) != 0) continue; | |
365 | SETBIT(fSteerTask, itask); SETBIT(fSteerTask, 0); | |
366 | foundOpt = kTRUE; | |
367 | break; | |
368 | } | |
369 | if(!foundOpt) Info("run.C", Form("TRD task %s not implemented (yet).", s.Data())); | |
370 | } | |
371 | } | |
372 | // extra rules for calibration tasks | |
873458ab | 373 | if(TSTBIT(fSteerTask, kCalibration)) SETBIT(fSteerTask, kCheckDetector); |
374 | if(TSTBIT(fSteerTask, kMultiplicity)) SETBIT(fSteerTask, kEfficiency); | |
375 | if(TSTBIT(fSteerTask, kEfficiencyMC)) SETBIT(fSteerTask, kEfficiency); | |
b94feda9 | 376 | if(TSTBIT(fSteerTask, kClErrParam)) SETBIT(fSteerTask, kResolution); |
377 | if(TSTBIT(fSteerTask, kAlignment)) SETBIT(fSteerTask, kResolution); | |
b94feda9 | 378 | if(TSTBIT(fSteerTask, kPIDRefMaker)) SETBIT(fSteerTask, kPIDChecker); |
379 | ||
380 | return fSteerTask; | |
381 | } | |
382 | ||
383 | ||
384 | ||
385 | //____________________________________________ | |
386 | Int_t ParseTPC(Char_t *tpc) | |
387 | { | |
388 | Int_t fSteerTask = 0; | |
389 | TObjArray *tasksArray = TString(tpc).Tokenize(" "); | |
390 | for(Int_t isel = 0; isel < tasksArray->GetEntriesFast(); isel++){ | |
391 | TString s = (dynamic_cast<TObjString *>(tasksArray->UncheckedAt(isel)))->String(); | |
392 | if(s.CompareTo("ALL") == 0){ | |
393 | for(Int_t itask = 0; itask < NTPCPERFORMANCE; itask++) SETBIT(fSteerTask, itask); | |
394 | continue; | |
395 | } else if(s.CompareTo("NOFR") == 0){ | |
396 | fHasFriends = kFALSE; | |
397 | } else if(s.CompareTo("NOMC") == 0){ | |
398 | fHasMCdata = kFALSE; | |
399 | } else { | |
400 | Bool_t foundOpt = kFALSE; | |
401 | for(Int_t itask = 0; itask < NTPCTASKS; itask++){ | |
402 | if(s.CompareTo(fgkTPCtaskOpt[itask]) != 0) continue; | |
403 | SETBIT(fSteerTask, itask); SETBIT(fSteerTask, 0); | |
404 | foundOpt = kTRUE; | |
405 | break; | |
406 | } | |
407 | if(!foundOpt) Info("run.C", Form("TPC task %s not implemented (yet).", s.Data())); | |
408 | } | |
409 | } | |
410 | return fSteerTask; | |
411 | } | |
412 | ||
413 |