]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - STEER/AliReconstruction.cxx
Just set some variables properly.
[u/mrichter/AliRoot.git] / STEER / AliReconstruction.cxx
... / ...
CommitLineData
1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
15
16/* $Id$ */
17
18///////////////////////////////////////////////////////////////////////////////
19// //
20// class for running the reconstruction //
21// //
22// Clusters and tracks are created for all detectors and all events by //
23// typing: //
24// //
25// AliReconstruction rec; //
26// rec.Run(); //
27// //
28// The Run method returns kTRUE in case of successful execution. //
29// //
30// If the input to the reconstruction are not simulated digits but raw data, //
31// this can be specified by an argument of the Run method or by the method //
32// //
33// rec.SetInput("..."); //
34// //
35// The input formats and the corresponding argument are: //
36// - DDL raw data files: directory name, ends with "/" //
37// - raw data root file: root file name, extension ".root" //
38// - raw data DATE file: DATE file name, any other non-empty string //
39// - MC root files : empty string, default //
40// //
41// By default all events are reconstructed. The reconstruction can be //
42// limited to a range of events by giving the index of the first and the //
43// last event as an argument to the Run method or by calling //
44// //
45// rec.SetEventRange(..., ...); //
46// //
47// The index -1 (default) can be used for the last event to indicate no //
48// upper limit of the event range. //
49// //
50// In case of raw-data reconstruction the user can modify the default //
51// number of events per digits/clusters/tracks file. In case the option //
52// is not used the number is set 1. In case the user provides 0, than //
53// the number of events is equal to the number of events inside the //
54// raw-data file (i.e. one digits/clusters/tracks file): //
55// //
56// rec.SetNumberOfEventsPerFile(...); //
57// //
58// //
59// The name of the galice file can be changed from the default //
60// "galice.root" by passing it as argument to the AliReconstruction //
61// constructor or by //
62// //
63// rec.SetGAliceFile("..."); //
64// //
65// The local reconstruction can be switched on or off for individual //
66// detectors by //
67// //
68// rec.SetRunLocalReconstruction("..."); //
69// //
70// The argument is a (case sensitive) string with the names of the //
71// detectors separated by a space. The special string "ALL" selects all //
72// available detectors. This is the default. //
73// //
74// The reconstruction of the primary vertex position can be switched off by //
75// //
76// rec.SetRunVertexFinder(kFALSE); //
77// //
78// The tracking and the creation of ESD tracks can be switched on for //
79// selected detectors by //
80// //
81// rec.SetRunTracking("..."); //
82// //
83// Uniform/nonuniform field tracking switches (default: uniform field) //
84// //
85// rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
86// //
87// The filling of additional ESD information can be steered by //
88// //
89// rec.SetFillESD("..."); //
90// //
91// Again, for both methods the string specifies the list of detectors. //
92// The default is "ALL". //
93// //
94// The call of the shortcut method //
95// //
96// rec.SetRunReconstruction("..."); //
97// //
98// is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99// SetFillESD with the same detector selecting string as argument. //
100// //
101// The reconstruction requires digits or raw data as input. For the creation //
102// of digits and raw data have a look at the class AliSimulation. //
103// //
104// The input data of a detector can be replaced by the corresponding HLT //
105// data by calling (usual detector string) //
106// SetUseHLTData("..."); //
107// //
108// //
109///////////////////////////////////////////////////////////////////////////////
110
111#include <TArrayF.h>
112#include <TFile.h>
113#include <TList.h>
114#include <TSystem.h>
115#include <TROOT.h>
116#include <TPluginManager.h>
117#include <TGeoManager.h>
118#include <TLorentzVector.h>
119#include <TArrayS.h>
120#include <TArrayD.h>
121#include <TObjArray.h>
122#include <TMap.h>
123#include <TChain.h>
124#include <TProof.h>
125#include <TProofOutputFile.h>
126#include <TParameter.h>
127
128#include "AliReconstruction.h"
129#include "AliCodeTimer.h"
130#include "AliReconstructor.h"
131#include "AliLog.h"
132#include "AliRunLoader.h"
133#include "AliRun.h"
134#include "AliRawReaderFile.h"
135#include "AliRawReaderDate.h"
136#include "AliRawReaderRoot.h"
137#include "AliRawEventHeaderBase.h"
138#include "AliRawEvent.h"
139#include "AliESDEvent.h"
140#include "AliESDMuonTrack.h"
141#include "AliESDfriend.h"
142#include "AliESDVertex.h"
143#include "AliESDcascade.h"
144#include "AliESDkink.h"
145#include "AliESDtrack.h"
146#include "AliESDCaloCluster.h"
147#include "AliESDCaloCells.h"
148#include "AliMultiplicity.h"
149#include "AliTracker.h"
150#include "AliVertexer.h"
151#include "AliVertexerTracks.h"
152#include "AliV0vertexer.h"
153#include "AliCascadeVertexer.h"
154#include "AliHeader.h"
155#include "AliGenEventHeader.h"
156#include "AliPID.h"
157#include "AliESDpid.h"
158#include "AliESDtrack.h"
159#include "AliESDPmdTrack.h"
160
161#include "AliESDTagCreator.h"
162
163#include "AliGeomManager.h"
164#include "AliTrackPointArray.h"
165#include "AliCDBManager.h"
166#include "AliCDBStorage.h"
167#include "AliCDBEntry.h"
168#include "AliAlignObj.h"
169
170#include "AliCentralTrigger.h"
171#include "AliTriggerConfiguration.h"
172#include "AliTriggerClass.h"
173#include "AliTriggerCluster.h"
174#include "AliCTPRawStream.h"
175
176#include "AliQADataMakerRec.h"
177#include "AliGlobalQADataMaker.h"
178#include "AliQA.h"
179#include "AliQADataMakerSteer.h"
180
181#include "AliPlaneEff.h"
182
183#include "AliSysInfo.h" // memory snapshots
184#include "AliRawHLTManager.h"
185
186#include "AliMagWrapCheb.h"
187
188#include "AliDetectorRecoParam.h"
189#include "AliRunInfo.h"
190#include "AliEventInfo.h"
191
192#include "AliDAQ.h"
193
194ClassImp(AliReconstruction)
195
196//_____________________________________________________________________________
197const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
198
199//_____________________________________________________________________________
200AliReconstruction::AliReconstruction(const char* gAliceFilename) :
201 TSelector(),
202 fUniformField(kFALSE),
203 fForcedFieldMap(NULL),
204 fRunVertexFinder(kTRUE),
205 fRunVertexFinderTracks(kTRUE),
206 fRunHLTTracking(kFALSE),
207 fRunMuonTracking(kFALSE),
208 fRunV0Finder(kTRUE),
209 fRunCascadeFinder(kTRUE),
210 fStopOnError(kFALSE),
211 fWriteAlignmentData(kFALSE),
212 fWriteESDfriend(kFALSE),
213 fFillTriggerESD(kTRUE),
214
215 fCleanESD(kTRUE),
216 fV0DCAmax(3.),
217 fV0CsPmin(0.),
218 fDmax(50.),
219 fZmax(50.),
220
221 fRunLocalReconstruction("ALL"),
222 fRunTracking("ALL"),
223 fFillESD("ALL"),
224 fLoadCDB(""),
225 fUseTrackingErrorsForAlignment(""),
226 fGAliceFileName(gAliceFilename),
227 fRawInput(""),
228 fEquipIdMap(""),
229 fFirstEvent(0),
230 fLastEvent(-1),
231 fNumberOfEventsPerFile(1),
232 fOptions(),
233 fLoadAlignFromCDB(kTRUE),
234 fLoadAlignData("ALL"),
235 fESDPar(""),
236 fUseHLTData(),
237 fRunInfo(NULL),
238 fEventInfo(),
239
240 fRunLoader(NULL),
241 fRawReader(NULL),
242 fParentRawReader(NULL),
243
244 fRecoParam(),
245
246 fVertexer(NULL),
247 fDiamondProfile(NULL),
248 fDiamondProfileTPC(NULL),
249 fMeanVertexConstraint(kTRUE),
250
251 fGRPData(NULL),
252
253 fAlignObjArray(NULL),
254 fCDBUri(),
255 fSpecCDBUri(),
256 fInitCDBCalled(kFALSE),
257 fSetRunNumberFromDataCalled(kFALSE),
258 fQADetectors("ALL"),
259 fQASteer(NULL),
260 fQATasks("ALL"),
261 fRunQA(kTRUE),
262 fRunGlobalQA(kTRUE),
263 fSameQACycle(kFALSE),
264
265 fRunPlaneEff(kFALSE),
266
267 fesd(NULL),
268 fhltesd(NULL),
269 fesdf(NULL),
270 ffile(NULL),
271 ftree(NULL),
272 fhlttree(NULL),
273 ftVertexer(NULL),
274 fIsNewRunLoader(kFALSE),
275 fRunAliEVE(kFALSE),
276 fChain(NULL)
277{
278// create reconstruction object with default parameters
279 gGeoManager = NULL;
280
281 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
282 fReconstructor[iDet] = NULL;
283 fLoader[iDet] = NULL;
284 fTracker[iDet] = NULL;
285 }
286 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
287 fQACycles[iDet] = 999999 ;
288 fQAWriteExpert[iDet] = kFALSE ;
289 }
290
291 AliPID pid;
292}
293
294//_____________________________________________________________________________
295AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
296 TSelector(),
297 fUniformField(rec.fUniformField),
298 fForcedFieldMap(NULL),
299 fRunVertexFinder(rec.fRunVertexFinder),
300 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
301 fRunHLTTracking(rec.fRunHLTTracking),
302 fRunMuonTracking(rec.fRunMuonTracking),
303 fRunV0Finder(rec.fRunV0Finder),
304 fRunCascadeFinder(rec.fRunCascadeFinder),
305 fStopOnError(rec.fStopOnError),
306 fWriteAlignmentData(rec.fWriteAlignmentData),
307 fWriteESDfriend(rec.fWriteESDfriend),
308 fFillTriggerESD(rec.fFillTriggerESD),
309
310 fCleanESD(rec.fCleanESD),
311 fV0DCAmax(rec.fV0DCAmax),
312 fV0CsPmin(rec.fV0CsPmin),
313 fDmax(rec.fDmax),
314 fZmax(rec.fZmax),
315
316 fRunLocalReconstruction(rec.fRunLocalReconstruction),
317 fRunTracking(rec.fRunTracking),
318 fFillESD(rec.fFillESD),
319 fLoadCDB(rec.fLoadCDB),
320 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
321 fGAliceFileName(rec.fGAliceFileName),
322 fRawInput(rec.fRawInput),
323 fEquipIdMap(rec.fEquipIdMap),
324 fFirstEvent(rec.fFirstEvent),
325 fLastEvent(rec.fLastEvent),
326 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
327 fOptions(),
328 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
329 fLoadAlignData(rec.fLoadAlignData),
330 fESDPar(rec.fESDPar),
331 fUseHLTData(rec.fUseHLTData),
332 fRunInfo(NULL),
333 fEventInfo(),
334
335 fRunLoader(NULL),
336 fRawReader(NULL),
337 fParentRawReader(NULL),
338
339 fRecoParam(rec.fRecoParam),
340
341 fVertexer(NULL),
342 fDiamondProfile(rec.fDiamondProfile),
343 fDiamondProfileTPC(rec.fDiamondProfileTPC),
344 fMeanVertexConstraint(rec.fMeanVertexConstraint),
345
346 fGRPData(NULL),
347
348 fAlignObjArray(rec.fAlignObjArray),
349 fCDBUri(rec.fCDBUri),
350 fSpecCDBUri(),
351 fInitCDBCalled(rec.fInitCDBCalled),
352 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
353 fQADetectors(rec.fQADetectors),
354 fQASteer(NULL),
355 fQATasks(rec.fQATasks),
356 fRunQA(rec.fRunQA),
357 fRunGlobalQA(rec.fRunGlobalQA),
358 fSameQACycle(rec.fSameQACycle),
359 fRunPlaneEff(rec.fRunPlaneEff),
360
361 fesd(NULL),
362 fhltesd(NULL),
363 fesdf(NULL),
364 ffile(NULL),
365 ftree(NULL),
366 fhlttree(NULL),
367 ftVertexer(NULL),
368 fIsNewRunLoader(rec.fIsNewRunLoader),
369 fRunAliEVE(kFALSE),
370 fChain(NULL)
371{
372// copy constructor
373
374 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
375 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
376 }
377 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
378 fReconstructor[iDet] = NULL;
379 fLoader[iDet] = NULL;
380 fTracker[iDet] = NULL;
381 }
382
383 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
384 fQACycles[iDet] = rec.fQACycles[iDet];
385 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
386 }
387
388 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
389 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
390 }
391}
392
393//_____________________________________________________________________________
394AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
395{
396// assignment operator
397// Used in PROOF mode
398// Be very careful while modifing it!
399// Simple rules to follow:
400// for persistent data members - use their assignment operators
401// for non-persistent ones - do nothing or take the default values from constructor
402// TSelector members should not be touched
403 if(&rec == this) return *this;
404
405 fUniformField = rec.fUniformField;
406 fForcedFieldMap = NULL;
407 fRunVertexFinder = rec.fRunVertexFinder;
408 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
409 fRunHLTTracking = rec.fRunHLTTracking;
410 fRunMuonTracking = rec.fRunMuonTracking;
411 fRunV0Finder = rec.fRunV0Finder;
412 fRunCascadeFinder = rec.fRunCascadeFinder;
413 fStopOnError = rec.fStopOnError;
414 fWriteAlignmentData = rec.fWriteAlignmentData;
415 fWriteESDfriend = rec.fWriteESDfriend;
416 fFillTriggerESD = rec.fFillTriggerESD;
417
418 fCleanESD = rec.fCleanESD;
419 fV0DCAmax = rec.fV0DCAmax;
420 fV0CsPmin = rec.fV0CsPmin;
421 fDmax = rec.fDmax;
422 fZmax = rec.fZmax;
423
424 fRunLocalReconstruction = rec.fRunLocalReconstruction;
425 fRunTracking = rec.fRunTracking;
426 fFillESD = rec.fFillESD;
427 fLoadCDB = rec.fLoadCDB;
428 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
429 fGAliceFileName = rec.fGAliceFileName;
430 fRawInput = rec.fRawInput;
431 fEquipIdMap = rec.fEquipIdMap;
432 fFirstEvent = rec.fFirstEvent;
433 fLastEvent = rec.fLastEvent;
434 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
435
436 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
437 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
438 }
439
440 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
441 fLoadAlignData = rec.fLoadAlignData;
442 fESDPar = rec.fESDPar;
443 fUseHLTData = rec.fUseHLTData;
444
445 delete fRunInfo; fRunInfo = NULL;
446 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
447
448 fEventInfo = rec.fEventInfo;
449
450 fRunLoader = NULL;
451 fRawReader = NULL;
452 fParentRawReader = NULL;
453
454 fRecoParam = rec.fRecoParam;
455
456 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
457 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
458 delete fLoader[iDet]; fLoader[iDet] = NULL;
459 delete fTracker[iDet]; fTracker[iDet] = NULL;
460 }
461
462 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
463 fQACycles[iDet] = rec.fQACycles[iDet];
464 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
465 }
466
467 fVertexer = NULL;
468 delete fDiamondProfile; fDiamondProfile = NULL;
469 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
470 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
471 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
472 fMeanVertexConstraint = rec.fMeanVertexConstraint;
473
474 delete fGRPData; fGRPData = NULL;
475 if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
476
477 delete fAlignObjArray; fAlignObjArray = NULL;
478
479 fCDBUri = "";
480 fSpecCDBUri.Delete();
481 fInitCDBCalled = rec.fInitCDBCalled;
482 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
483 fQADetectors = rec.fQADetectors;
484 fQASteer = NULL;
485 fQATasks = rec.fQATasks;
486 fRunQA = rec.fRunQA;
487 fRunGlobalQA = rec.fRunGlobalQA;
488 fSameQACycle = rec.fSameQACycle;
489 fRunPlaneEff = rec.fRunPlaneEff;
490
491 fesd = NULL;
492 fhltesd = NULL;
493 fesdf = NULL;
494 ffile = NULL;
495 ftree = NULL;
496 fhlttree = NULL;
497 ftVertexer = NULL;
498 fIsNewRunLoader = rec.fIsNewRunLoader;
499 fRunAliEVE = kFALSE;
500 fChain = NULL;
501
502 return *this;
503}
504
505//_____________________________________________________________________________
506AliReconstruction::~AliReconstruction()
507{
508// clean up
509
510 CleanUp();
511 delete fForcedFieldMap;
512 fOptions.Delete();
513 if (fAlignObjArray) {
514 fAlignObjArray->Delete();
515 delete fAlignObjArray;
516 }
517 fSpecCDBUri.Delete();
518 delete fQASteer;
519 AliCodeTimer::Instance()->Print();
520}
521
522//_____________________________________________________________________________
523void AliReconstruction::InitCDB()
524{
525// activate a default CDB storage
526// First check if we have any CDB storage set, because it is used
527// to retrieve the calibration and alignment constants
528 AliCodeTimerAuto("");
529
530 if (fInitCDBCalled) return;
531 fInitCDBCalled = kTRUE;
532
533 AliCDBManager* man = AliCDBManager::Instance();
534 if (man->IsDefaultStorageSet())
535 {
536 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
537 AliWarning("Default CDB storage has been already set !");
538 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
539 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
540 fCDBUri = man->GetDefaultStorage()->GetURI();
541 }
542 else {
543 if (fCDBUri.Length() > 0)
544 {
545 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
546 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
547 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
548 } else {
549 fCDBUri="local://$ALICE_ROOT";
550 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
551 AliWarning("Default CDB storage not yet set !!!!");
552 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
553 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
554
555 }
556 man->SetDefaultStorage(fCDBUri);
557 }
558
559 // Now activate the detector specific CDB storage locations
560 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
561 TObject* obj = fSpecCDBUri[i];
562 if (!obj) continue;
563 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
564 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
565 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
566 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
567 }
568 AliSysInfo::AddStamp("InitCDB");
569}
570
571//_____________________________________________________________________________
572void AliReconstruction::SetDefaultStorage(const char* uri) {
573// Store the desired default CDB storage location
574// Activate it later within the Run() method
575
576 fCDBUri = uri;
577
578}
579
580//_____________________________________________________________________________
581void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
582// Store a detector-specific CDB storage location
583// Activate it later within the Run() method
584
585 AliCDBPath aPath(calibType);
586 if(!aPath.IsValid()){
587 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
588 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
589 if(!strcmp(calibType, fgkDetectorName[iDet])) {
590 aPath.SetPath(Form("%s/*", calibType));
591 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
592 break;
593 }
594 }
595 if(!aPath.IsValid()){
596 AliError(Form("Not a valid path or detector: %s", calibType));
597 return;
598 }
599 }
600
601// // check that calibType refers to a "valid" detector name
602// Bool_t isDetector = kFALSE;
603// for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
604// TString detName = fgkDetectorName[iDet];
605// if(aPath.GetLevel0() == detName) {
606// isDetector = kTRUE;
607// break;
608// }
609// }
610//
611// if(!isDetector) {
612// AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
613// return;
614// }
615
616 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
617 if (obj) fSpecCDBUri.Remove(obj);
618 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
619
620}
621
622//_____________________________________________________________________________
623Bool_t AliReconstruction::SetRunNumberFromData()
624{
625 // The method is called in Run() in order
626 // to set a correct run number.
627 // In case of raw data reconstruction the
628 // run number is taken from the raw data header
629
630 if (fSetRunNumberFromDataCalled) return kTRUE;
631 fSetRunNumberFromDataCalled = kTRUE;
632
633 AliCDBManager* man = AliCDBManager::Instance();
634
635 if(fRawReader) {
636 if(fRawReader->NextEvent()) {
637 if(man->GetRun() > 0) {
638 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
639 }
640 man->SetRun(fRawReader->GetRunNumber());
641 fRawReader->RewindEvents();
642 }
643 else {
644 if(man->GetRun() > 0) {
645 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
646 }
647 else {
648 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
649 return kFALSE;
650 }
651 }
652 }
653 else {
654 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
655 if (!rl) {
656 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
657 return kFALSE;
658 }
659 else {
660 rl->LoadHeader();
661 // read run number from gAlice
662 if(rl->GetHeader()) {
663 man->SetRun(rl->GetHeader()->GetRun());
664 rl->UnloadHeader();
665 delete rl;
666 }
667 else {
668 AliError("Neither run-loader header nor RawReader objects are found !");
669 delete rl;
670 return kFALSE;
671 }
672 }
673 }
674
675 man->Print();
676
677 return kTRUE;
678}
679
680//_____________________________________________________________________________
681void AliReconstruction::SetCDBLock() {
682 // Set CDB lock: from now on it is forbidden to reset the run number
683 // or the default storage or to activate any further storage!
684
685 AliCDBManager::Instance()->SetLock(1);
686}
687
688//_____________________________________________________________________________
689Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
690{
691 // Read the alignment objects from CDB.
692 // Each detector is supposed to have the
693 // alignment objects in DET/Align/Data CDB path.
694 // All the detector objects are then collected,
695 // sorted by geometry level (starting from ALIC) and
696 // then applied to the TGeo geometry.
697 // Finally an overlaps check is performed.
698
699 // Load alignment data from CDB and fill fAlignObjArray
700 if(fLoadAlignFromCDB){
701
702 TString detStr = detectors;
703 TString loadAlObjsListOfDets = "";
704
705 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
706 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
707 loadAlObjsListOfDets += fgkDetectorName[iDet];
708 loadAlObjsListOfDets += " ";
709 } // end loop over detectors
710 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
711 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
712 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
713 }else{
714 // Check if the array with alignment objects was
715 // provided by the user. If yes, apply the objects
716 // to the present TGeo geometry
717 if (fAlignObjArray) {
718 if (gGeoManager && gGeoManager->IsClosed()) {
719 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
720 AliError("The misalignment of one or more volumes failed!"
721 "Compare the list of simulated detectors and the list of detector alignment data!");
722 return kFALSE;
723 }
724 }
725 else {
726 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
727 return kFALSE;
728 }
729 }
730 }
731
732 if (fAlignObjArray) {
733 fAlignObjArray->Delete();
734 delete fAlignObjArray; fAlignObjArray=NULL;
735 }
736
737 return kTRUE;
738}
739
740//_____________________________________________________________________________
741void AliReconstruction::SetGAliceFile(const char* fileName)
742{
743// set the name of the galice file
744
745 fGAliceFileName = fileName;
746}
747
748//_____________________________________________________________________________
749void AliReconstruction::SetInput(const char* input)
750{
751 // In case the input string starts with 'mem://', we run in an online mode
752 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
753 // file is assumed. One can give as an input:
754 // mem://: - events taken from DAQ monitoring libs online
755 // or
756 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
757 if (input) fRawInput = input;
758}
759
760//_____________________________________________________________________________
761void AliReconstruction::SetOption(const char* detector, const char* option)
762{
763// set options for the reconstruction of a detector
764
765 TObject* obj = fOptions.FindObject(detector);
766 if (obj) fOptions.Remove(obj);
767 fOptions.Add(new TNamed(detector, option));
768}
769
770//_____________________________________________________________________________
771void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
772{
773 // Set custom reconstruction parameters for a given detector
774 // Single set of parameters for all the events
775 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
776 if(!strcmp(detector, fgkDetectorName[iDet])) {
777 par->SetAsDefault();
778 fRecoParam.AddDetRecoParam(iDet,par);
779 break;
780 }
781 }
782
783}
784
785//_____________________________________________________________________________
786Bool_t AliReconstruction::SetFieldMap(Float_t l3Current, Float_t diCurrent, Float_t factor, const char *path) {
787 //------------------------------------------------
788 // The magnetic field map, defined externally...
789 // L3 current 30000 A -> 0.5 T
790 // L3 current 12000 A -> 0.2 T
791 // dipole current 6000 A
792 // The polarities must be the same
793 //------------------------------------------------
794 const Float_t l3NominalCurrent1=30000.; // (A)
795 const Float_t l3NominalCurrent2=12000.; // (A)
796 const Float_t diNominalCurrent =6000. ; // (A)
797
798 const Float_t tolerance=0.03; // relative current tolerance
799 const Float_t zero=77.; // "zero" current (A)
800
801 Int_t map=0;
802 Bool_t dipoleON=kFALSE;
803
804 TString s=(factor < 0) ? "L3: -" : "L3: +";
805
806 l3Current = TMath::Abs(l3Current);
807 if (TMath::Abs(l3Current-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
808 map=AliMagWrapCheb::k5kG;
809 s+="0.5 T; ";
810 } else
811 if (TMath::Abs(l3Current-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
812 map=AliMagWrapCheb::k2kG;
813 s+="0.2 T; ";
814 } else
815 if (l3Current < zero) {
816 map=AliMagWrapCheb::k2kG;
817 s+="0.0 T; ";
818 factor=0.; // in fact, this is a global factor...
819 fUniformField=kTRUE; // track with the uniform (zero) B field
820 } else {
821 AliError(Form("Wrong L3 current (%f A)!",l3Current));
822 return kFALSE;
823 }
824
825 diCurrent = TMath::Abs(diCurrent);
826 if (TMath::Abs(diCurrent-diNominalCurrent)/diNominalCurrent < tolerance) {
827 // 3% current tolerance...
828 dipoleON=kTRUE;
829 s+="Dipole ON";
830 } else
831 if (diCurrent < zero) { // some small current..
832 dipoleON=kFALSE;
833 s+="Dipole OFF";
834 } else {
835 AliError(Form("Wrong dipole current (%f A)!",diCurrent));
836 return kFALSE;
837 }
838
839 delete fForcedFieldMap;
840 fForcedFieldMap=
841 new AliMagWrapCheb("B field map ",s,2,factor,10.,map,dipoleON,path);
842
843 fForcedFieldMap->Print();
844
845 AliTracker::SetFieldMap(fForcedFieldMap,fUniformField);
846
847 return kTRUE;
848}
849
850
851Bool_t AliReconstruction::InitGRP() {
852 //------------------------------------
853 // Initialization of the GRP entry
854 //------------------------------------
855 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
856
857 if (entry) {
858 fGRPData = dynamic_cast<TMap*>(entry->GetObject());
859 entry->SetOwner(0);
860 AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
861 }
862
863 if (!fGRPData) {
864 AliError("No GRP entry found in OCDB!");
865 return kFALSE;
866 }
867
868 TObjString *lhcState=
869 dynamic_cast<TObjString*>(fGRPData->GetValue("fLHCState"));
870 if (!lhcState) {
871 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
872 }
873
874 TObjString *beamType=
875 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamType"));
876 if (!beamType) {
877 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
878 }
879
880 TObjString *beamEnergyStr=
881 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamEnergy"));
882 if (!beamEnergyStr) {
883 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
884 }
885
886 TObjString *runType=
887 dynamic_cast<TObjString*>(fGRPData->GetValue("fRunType"));
888 if (!runType) {
889 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
890 }
891
892 TObjString *activeDetectors=
893 dynamic_cast<TObjString*>(fGRPData->GetValue("fDetectorMask"));
894 if (!activeDetectors) {
895 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
896 }
897
898 fRunInfo = new AliRunInfo(lhcState ? lhcState->GetString().Data() : "UNKNOWN",
899 beamType ? beamType->GetString().Data() : "UNKNOWN",
900 beamEnergyStr ? beamEnergyStr->GetString().Atof() : 0,
901 runType ? runType->GetString().Data() : "UNKNOWN",
902 activeDetectors ? activeDetectors->GetString().Atoi() : 1074790399);
903
904 // Process the list of active detectors
905 if (activeDetectors && activeDetectors->GetString().IsDigit()) {
906 UInt_t detMask = activeDetectors->GetString().Atoi();
907 fLoadCDB.Form("%s %s %s %s",
908 fRunLocalReconstruction.Data(),
909 fRunTracking.Data(),
910 fFillESD.Data(),
911 fQADetectors.Data());
912 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
913 fRunTracking = MatchDetectorList(fRunTracking,detMask);
914 fFillESD = MatchDetectorList(fFillESD,detMask);
915 fQADetectors = MatchDetectorList(fQADetectors,detMask);
916 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
917 }
918
919 AliInfo("===================================================================================");
920 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
921 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
922 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
923 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
924 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
925 AliInfo("===================================================================================");
926
927 //*** Dealing with the magnetic field map
928 if (AliTracker::GetFieldMap()) {
929 AliInfo("Running with the externally set B field !");
930 } else {
931 // Construct the field map out of the information retrieved from GRP.
932
933 Bool_t ok = kTRUE;
934
935 // L3
936 TObjString *l3Current=
937 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
938 if (!l3Current) {
939 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
940 ok = kFALSE;
941 }
942 TObjString *l3Polarity=
943 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
944 if (!l3Polarity) {
945 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
946 ok = kFALSE;
947 }
948
949 // Dipole
950 TObjString *diCurrent=
951 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
952 if (!diCurrent) {
953 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
954 ok = kFALSE;
955 }
956 TObjString *diPolarity=
957 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
958 if (!diPolarity) {
959 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
960 ok = kFALSE;
961 }
962
963 if (ok) {
964 Float_t l3Cur=TMath::Abs(atof(l3Current->GetName()));
965 Float_t diCur=TMath::Abs(atof(diCurrent->GetName()));
966 Float_t l3Pol=atof(l3Polarity->GetName());
967 Float_t factor=1.;
968 if (l3Pol != 0.) factor=-1.;
969
970
971 if (!SetFieldMap(l3Cur, diCur, factor)) {
972 AliFatal("Failed to creat a B field map ! Exiting...");
973 }
974 AliInfo("Running with the B field constructed out of GRP !");
975 }
976 else {
977 AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
978 }
979
980 }
981
982 //*** Get the diamond profile from OCDB
983 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
984 if (entry) {
985 if (fMeanVertexConstraint)
986 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
987 } else {
988 AliError("No diamond profile found in OCDB!");
989 }
990
991 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
992 if (entry) {
993 if (fMeanVertexConstraint)
994 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
995 } else {
996 AliError("No diamond profile found in OCDB!");
997 }
998
999 return kTRUE;
1000}
1001
1002//_____________________________________________________________________________
1003Bool_t AliReconstruction::LoadCDB()
1004{
1005 AliCodeTimerAuto("");
1006
1007 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1008
1009 TString detStr = fLoadCDB;
1010 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1011 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1012 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1013 }
1014 return kTRUE;
1015}
1016
1017//_____________________________________________________________________________
1018Bool_t AliReconstruction::Run(const char* input)
1019{
1020 // Run Run Run
1021 AliCodeTimerAuto("");
1022
1023 InitRun(input);
1024 if (GetAbort() != TSelector::kContinue) return kFALSE;
1025
1026 TChain *chain = NULL;
1027 if (fRawReader && (chain = fRawReader->GetChain())) {
1028 // Proof mode
1029 if (gProof) {
1030 gProof->AddInput(this);
1031 TUrl outputFile;
1032 outputFile.SetProtocol("root",kTRUE);
1033 outputFile.SetHost(gSystem->HostName());
1034 outputFile.SetFile(Form("%s/AliESDs.root",gSystem->pwd()));
1035 AliInfo(Form("Output file with ESDs is %s",outputFile.GetUrl()));
1036 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.GetUrl()));
1037 chain->SetProof();
1038 chain->Process("AliReconstruction");
1039 }
1040 else {
1041 chain->Process(this);
1042 }
1043 }
1044 else {
1045 Begin(NULL);
1046 if (GetAbort() != TSelector::kContinue) return kFALSE;
1047 SlaveBegin(NULL);
1048 if (GetAbort() != TSelector::kContinue) return kFALSE;
1049 //******* The loop over events
1050 Int_t iEvent = 0;
1051 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1052 (fRawReader && fRawReader->NextEvent())) {
1053 if (!ProcessEvent(iEvent)) {
1054 Abort("ProcessEvent",TSelector::kAbortFile);
1055 return kFALSE;
1056 }
1057 iEvent++;
1058 }
1059 SlaveTerminate();
1060 if (GetAbort() != TSelector::kContinue) return kFALSE;
1061 Terminate();
1062 if (GetAbort() != TSelector::kContinue) return kFALSE;
1063 }
1064
1065 return kTRUE;
1066}
1067
1068//_____________________________________________________________________________
1069void AliReconstruction::InitRawReader(const char* input)
1070{
1071 AliCodeTimerAuto("");
1072
1073 // Init raw-reader and
1074 // set the input in case of raw data
1075 if (input) fRawInput = input;
1076 fRawReader = AliRawReader::Create(fRawInput.Data());
1077 if (!fRawReader)
1078 AliInfo("Reconstruction will run over digits");
1079
1080 if (!fEquipIdMap.IsNull() && fRawReader)
1081 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1082
1083 if (!fUseHLTData.IsNull()) {
1084 // create the RawReaderHLT which performs redirection of HLT input data for
1085 // the specified detectors
1086 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1087 if (pRawReader) {
1088 fParentRawReader=fRawReader;
1089 fRawReader=pRawReader;
1090 } else {
1091 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1092 }
1093 }
1094 AliSysInfo::AddStamp("CreateRawReader");
1095}
1096
1097//_____________________________________________________________________________
1098void AliReconstruction::InitRun(const char* input)
1099{
1100 // Initialization of raw-reader,
1101 // run number, CDB etc.
1102 AliCodeTimerAuto("");
1103 AliSysInfo::AddStamp("Start");
1104
1105 // Initialize raw-reader if any
1106 InitRawReader(input);
1107
1108 // Initialize the CDB storage
1109 InitCDB();
1110
1111 // Set run number in CDBManager (if it is not already set by the user)
1112 if (!SetRunNumberFromData()) {
1113 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1114 return;
1115 }
1116
1117 // Set CDB lock: from now on it is forbidden to reset the run number
1118 // or the default storage or to activate any further storage!
1119 SetCDBLock();
1120
1121}
1122
1123//_____________________________________________________________________________
1124void AliReconstruction::Begin(TTree *)
1125{
1126 // Initialize AlReconstruction before
1127 // going into the event loop
1128 // Should follow the TSelector convention
1129 // i.e. initialize only the object on the client side
1130 AliCodeTimerAuto("");
1131
1132 AliReconstruction *reco = NULL;
1133 if (fInput) {
1134 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1135 *this = *reco;
1136 }
1137 AliSysInfo::AddStamp("ReadInputInBegin");
1138 }
1139
1140 // Import ideal TGeo geometry and apply misalignment
1141 if (!gGeoManager) {
1142 TString geom(gSystem->DirName(fGAliceFileName));
1143 geom += "/geometry.root";
1144 AliGeomManager::LoadGeometry(geom.Data());
1145 if (!gGeoManager) {
1146 Abort("LoadGeometry", TSelector::kAbortProcess);
1147 return;
1148 }
1149 AliSysInfo::AddStamp("LoadGeom");
1150 TString detsToCheck=fRunLocalReconstruction;
1151 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1152 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1153 return;
1154 }
1155 AliSysInfo::AddStamp("CheckGeom");
1156 }
1157
1158 if (!MisalignGeometry(fLoadAlignData)) {
1159 Abort("MisalignGeometry", TSelector::kAbortProcess);
1160 return;
1161 }
1162 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1163 AliSysInfo::AddStamp("MisalignGeom");
1164
1165 if (!InitGRP()) {
1166 Abort("InitGRP", TSelector::kAbortProcess);
1167 return;
1168 }
1169 AliSysInfo::AddStamp("InitGRP");
1170
1171 if (!LoadCDB()) {
1172 Abort("LoadCDB", TSelector::kAbortProcess);
1173 return;
1174 }
1175 AliSysInfo::AddStamp("LoadCDB");
1176
1177 // Read the reconstruction parameters from OCDB
1178 if (!InitRecoParams()) {
1179 AliWarning("Not all detectors have correct RecoParam objects initialized");
1180 }
1181 AliSysInfo::AddStamp("InitRecoParams");
1182
1183 if (fInput) {
1184 if (reco) *reco = *this;
1185 fInput->Add(gGeoManager);
1186 gGeoManager = NULL;
1187 fInput->Add(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()));
1188 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1189 AliMagF *magFieldMap = (AliMagF*)AliTracker::GetFieldMap();
1190 magFieldMap->SetName("MagneticFieldMap");
1191 fInput->Add(magFieldMap);
1192 }
1193
1194}
1195
1196//_____________________________________________________________________________
1197void AliReconstruction::SlaveBegin(TTree*)
1198{
1199 // Initialization related to run-loader,
1200 // vertexer, trackers, recontructors
1201 // In proof mode it is executed on the slave
1202 AliCodeTimerAuto("");
1203
1204 TProofOutputFile *outProofFile = NULL;
1205 if (fInput) {
1206 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1207 *this = *reco;
1208 }
1209 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1210 gGeoManager = tgeo;
1211 AliGeomManager::SetGeometry(tgeo);
1212 }
1213 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1214 Int_t runNumber = -1;
1215 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1216 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1217 man->SetCacheFlag(kTRUE);
1218 man->SetLock(kTRUE);
1219 man->Print();
1220 }
1221 }
1222 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1223 AliTracker::SetFieldMap(map,fUniformField);
1224 }
1225 if (TNamed *outputFileName = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE")) {
1226 outProofFile = new TProofOutputFile(gSystem->BaseName(TUrl(outputFileName->GetTitle()).GetFile()));
1227 outProofFile->SetOutputFileName(outputFileName->GetTitle());
1228 fOutput->Add(outProofFile);
1229 }
1230 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1231 }
1232
1233 // get the run loader
1234 if (!InitRunLoader()) {
1235 Abort("InitRunLoader", TSelector::kAbortProcess);
1236 return;
1237 }
1238 AliSysInfo::AddStamp("LoadLoader");
1239
1240 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1241 if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile);
1242
1243 // get vertexer
1244 if (fRunVertexFinder && !CreateVertexer()) {
1245 Abort("CreateVertexer", TSelector::kAbortProcess);
1246 return;
1247 }
1248 AliSysInfo::AddStamp("CreateVertexer");
1249
1250 // get trackers
1251 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1252 Abort("CreateTrackers", TSelector::kAbortProcess);
1253 return;
1254 }
1255 AliSysInfo::AddStamp("CreateTrackers");
1256
1257 // create the ESD output file and tree
1258 if (!outProofFile) {
1259 ffile = TFile::Open("AliESDs.root", "RECREATE");
1260 ffile->SetCompressionLevel(2);
1261 if (!ffile->IsOpen()) {
1262 Abort("OpenESDFile", TSelector::kAbortProcess);
1263 return;
1264 }
1265 }
1266 else {
1267 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1268 Abort(Form("Problems opening output PROOF file: %s/%s",
1269 outProofFile->GetDir(), outProofFile->GetFileName()),
1270 TSelector::kAbortProcess);
1271 return;
1272 }
1273 }
1274
1275 ftree = new TTree("esdTree", "Tree with ESD objects");
1276 fesd = new AliESDEvent();
1277 fesd->CreateStdContent();
1278 fesd->WriteToTree(ftree);
1279
1280 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1281 fhltesd = new AliESDEvent();
1282 fhltesd->CreateStdContent();
1283 fhltesd->WriteToTree(fhlttree);
1284
1285
1286 if (fWriteESDfriend) {
1287 fesdf = new AliESDfriend();
1288 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1289 br->SetFile("AliESDfriends.root");
1290 fesd->AddObject(fesdf);
1291 }
1292
1293 ProcInfo_t ProcInfo;
1294 gSystem->GetProcInfo(&ProcInfo);
1295 AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1296
1297 //QA
1298 //Initialize the QA and start of cycle
1299 if (fRunQA) {
1300 fQASteer = new AliQADataMakerSteer("rec") ;
1301 fQASteer->SetActiveDetectors(fQADetectors) ;
1302 for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
1303 fQASteer->SetCycleLength(AliQA::DETECTORINDEX_t(det), fQACycles[det]) ;
1304 if (fQAWriteExpert[det])
1305 fQASteer->SetWriteExpert(AliQA::DETECTORINDEX_t(det)) ;
1306 }
1307
1308 if (!fRawReader && fQATasks.Contains(AliQA::kRAWS))
1309 fQATasks.ReplaceAll(Form("%d",AliQA::kRAWS), "") ;
1310 fQASteer->SetTasks(fQATasks) ;
1311 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam) ;
1312 }
1313
1314 if (fRunGlobalQA) {
1315 Bool_t sameCycle = kFALSE ;
1316 if (!fQASteer) fQASteer = new AliQADataMakerSteer("rec") ;
1317 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1318 AliInfo(Form("Initializing the global QA data maker"));
1319 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1320 qadm->StartOfCycle(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1321 TObjArray *arr=qadm->Init(AliQA::kRECPOINTS);
1322 AliTracker::SetResidualsArray(arr);
1323 sameCycle = kTRUE ;
1324 }
1325 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1326 qadm->StartOfCycle(AliQA::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1327 qadm->Init(AliQA::kESDS);
1328 }
1329 }
1330
1331 //Initialize the Plane Efficiency framework
1332 if (fRunPlaneEff && !InitPlaneEff()) {
1333 Abort("InitPlaneEff", TSelector::kAbortProcess);
1334 return;
1335 }
1336
1337 if (strcmp(gProgName,"alieve") == 0)
1338 fRunAliEVE = InitAliEVE();
1339
1340 return;
1341}
1342
1343//_____________________________________________________________________________
1344Bool_t AliReconstruction::Process(Long64_t entry)
1345{
1346 // run the reconstruction over a single entry
1347 // from the chain with raw data
1348 AliCodeTimerAuto("");
1349
1350 TTree *currTree = fChain->GetTree();
1351 AliRawEvent *event = new AliRawEvent;
1352 currTree->SetBranchAddress("rawevent",&event);
1353 currTree->GetEntry(entry);
1354 fRawReader = new AliRawReaderRoot(event);
1355 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1356 delete fRawReader;
1357 fRawReader = NULL;
1358 delete event;
1359
1360 return fStatus;
1361}
1362
1363//_____________________________________________________________________________
1364void AliReconstruction::Init(TTree *tree)
1365{
1366 if (tree == 0) {
1367 AliError("The input tree is not found!");
1368 return;
1369 }
1370 fChain = tree;
1371}
1372
1373//_____________________________________________________________________________
1374Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1375{
1376 // run the reconstruction over a single event
1377 // The event loop is steered in Run method
1378
1379 AliCodeTimerAuto("");
1380
1381 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1382 fRunLoader->SetEventNumber(iEvent);
1383 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1384 iEvent, iEvent);
1385 fRunLoader->TreeE()->Fill();
1386 if (fRawReader && fRawReader->UseAutoSaveESD())
1387 fRunLoader->TreeE()->AutoSave("SaveSelf");
1388 }
1389
1390 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1391 return kTRUE;
1392 }
1393
1394 AliInfo(Form("processing event %d", iEvent));
1395
1396 // Fill Event-info object
1397 GetEventInfo();
1398 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1399
1400 fRunLoader->GetEvent(iEvent);
1401
1402 // QA on single raw
1403 if (fRunQA)
1404 fQASteer->RunOneEvent(fRawReader) ;
1405
1406 // local single event reconstruction
1407 if (!fRunLocalReconstruction.IsNull()) {
1408 TString detectors=fRunLocalReconstruction;
1409 // run HLT event reconstruction first
1410 // ;-( IsSelected changes the string
1411 if (IsSelected("HLT", detectors) &&
1412 !RunLocalEventReconstruction("HLT")) {
1413 if (fStopOnError) {CleanUp(); return kFALSE;}
1414 }
1415 detectors=fRunLocalReconstruction;
1416 detectors.ReplaceAll("HLT", "");
1417 if (!RunLocalEventReconstruction(detectors)) {
1418 if (fStopOnError) {CleanUp(); return kFALSE;}
1419 }
1420 }
1421
1422 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1423 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1424 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1425 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1426
1427 // Set magnetic field from the tracker
1428 fesd->SetMagneticField(AliTracker::GetBz());
1429 fhltesd->SetMagneticField(AliTracker::GetBz());
1430
1431
1432
1433 // Fill raw-data error log into the ESD
1434 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1435
1436 // vertex finder
1437 if (fRunVertexFinder) {
1438 if (!RunVertexFinder(fesd)) {
1439 if (fStopOnError) {CleanUp(); return kFALSE;}
1440 }
1441 }
1442
1443 // Muon tracking
1444 if (!fRunTracking.IsNull()) {
1445 if (fRunMuonTracking) {
1446 if (!RunMuonTracking(fesd)) {
1447 if (fStopOnError) {CleanUp(); return kFALSE;}
1448 }
1449 }
1450 }
1451
1452 // barrel tracking
1453 if (!fRunTracking.IsNull()) {
1454 if (!RunTracking(fesd)) {
1455 if (fStopOnError) {CleanUp(); return kFALSE;}
1456 }
1457 }
1458
1459 // fill ESD
1460 if (!fFillESD.IsNull()) {
1461 TString detectors=fFillESD;
1462 // run HLT first and on hltesd
1463 // ;-( IsSelected changes the string
1464 if (IsSelected("HLT", detectors) &&
1465 !FillESD(fhltesd, "HLT")) {
1466 if (fStopOnError) {CleanUp(); return kFALSE;}
1467 }
1468 detectors=fFillESD;
1469 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1470 if (detectors.Contains("ALL")) {
1471 detectors="";
1472 for (Int_t idet=0; idet<fgkNDetectors; ++idet){
1473 detectors += fgkDetectorName[idet];
1474 detectors += " ";
1475 }
1476 }
1477 detectors.ReplaceAll("HLT", "");
1478 if (!FillESD(fesd, detectors)) {
1479 if (fStopOnError) {CleanUp(); return kFALSE;}
1480 }
1481 }
1482
1483 // fill Event header information from the RawEventHeader
1484 if (fRawReader){FillRawEventHeaderESD(fesd);}
1485
1486 // combined PID
1487 AliESDpid::MakePID(fesd);
1488
1489 if (fFillTriggerESD) {
1490 if (!FillTriggerESD(fesd)) {
1491 if (fStopOnError) {CleanUp(); return kFALSE;}
1492 }
1493 }
1494
1495 ffile->cd();
1496
1497 //
1498 // Propagate track to the beam pipe (if not already done by ITS)
1499 //
1500 const Int_t ntracks = fesd->GetNumberOfTracks();
1501 const Double_t kBz = fesd->GetMagneticField();
1502 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1503
1504 TObjArray trkArray;
1505 UShort_t *selectedIdx=new UShort_t[ntracks];
1506
1507 for (Int_t itrack=0; itrack<ntracks; itrack++){
1508 const Double_t kMaxStep = 5; //max step over the material
1509 Bool_t ok;
1510
1511 AliESDtrack *track = fesd->GetTrack(itrack);
1512 if (!track) continue;
1513
1514 AliExternalTrackParam *tpcTrack =
1515 (AliExternalTrackParam *)track->GetTPCInnerParam();
1516 ok = kFALSE;
1517 if (tpcTrack)
1518 ok = AliTracker::
1519 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE);
1520
1521 if (ok) {
1522 Int_t n=trkArray.GetEntriesFast();
1523 selectedIdx[n]=track->GetID();
1524 trkArray.AddLast(tpcTrack);
1525 }
1526
1527 //Tracks refitted by ITS should already be at the SPD vertex
1528 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1529
1530 AliTracker::
1531 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE);
1532 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1533
1534 }
1535
1536 //
1537 // Improve the reconstructed primary vertex position using the tracks
1538 //
1539 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1540 if(fesd->GetPrimaryVertexSPD()) {
1541 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1542 if(vtitle.Contains("cosmics")) {
1543 runVertexFinderTracks=kFALSE;
1544 }
1545 }
1546 if (runVertexFinderTracks) {
1547 // TPC + ITS primary vertex
1548 ftVertexer->SetITSMode();
1549 if(fDiamondProfile && fMeanVertexConstraint) {
1550 ftVertexer->SetVtxStart(fDiamondProfile);
1551 } else {
1552 ftVertexer->SetConstraintOff();
1553 }
1554 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1555 if (pvtx) {
1556 if (pvtx->GetStatus()) {
1557 fesd->SetPrimaryVertex(pvtx);
1558 for (Int_t i=0; i<ntracks; i++) {
1559 AliESDtrack *t = fesd->GetTrack(i);
1560 t->RelateToVertex(pvtx, kBz, kVeryBig);
1561 }
1562 }
1563 }
1564
1565 // TPC-only primary vertex
1566 ftVertexer->SetTPCMode();
1567 if(fDiamondProfileTPC && fMeanVertexConstraint) {
1568 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1569 } else {
1570 ftVertexer->SetConstraintOff();
1571 }
1572 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1573 if (pvtx) {
1574 if (pvtx->GetStatus()) {
1575 fesd->SetPrimaryVertexTPC(pvtx);
1576 for (Int_t i=0; i<ntracks; i++) {
1577 AliESDtrack *t = fesd->GetTrack(i);
1578 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1579 }
1580 }
1581 }
1582
1583 }
1584 delete[] selectedIdx;
1585
1586 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1587
1588
1589 if (fRunV0Finder) {
1590 // V0 finding
1591 AliV0vertexer vtxer;
1592 vtxer.Tracks2V0vertices(fesd);
1593
1594 if (fRunCascadeFinder) {
1595 // Cascade finding
1596 AliCascadeVertexer cvtxer;
1597 cvtxer.V0sTracks2CascadeVertices(fesd);
1598 }
1599 }
1600
1601 // write ESD
1602 if (fCleanESD) CleanESD(fesd);
1603
1604 if (fRunQA)
1605 fQASteer->RunOneEvent(fesd) ;
1606
1607 if (fRunGlobalQA) {
1608 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1609 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1610 qadm->Exec(AliQA::kESDS, fesd);
1611 }
1612
1613 if (fWriteESDfriend) {
1614 fesdf->~AliESDfriend();
1615 new (fesdf) AliESDfriend(); // Reset...
1616 fesd->GetESDfriend(fesdf);
1617 }
1618 ftree->Fill();
1619
1620 // Auto-save the ESD tree in case of prompt reco @P2
1621 if (fRawReader && fRawReader->UseAutoSaveESD()) {
1622 ftree->AutoSave("SaveSelf");
1623 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1624 if (friendfile) friendfile->Save();
1625 }
1626
1627 // write HLT ESD
1628 fhlttree->Fill();
1629
1630 // call AliEVE
1631 if (fRunAliEVE) RunAliEVE();
1632
1633 fesd->Reset();
1634 fhltesd->Reset();
1635 if (fWriteESDfriend) {
1636 fesdf->~AliESDfriend();
1637 new (fesdf) AliESDfriend(); // Reset...
1638 }
1639
1640 ProcInfo_t ProcInfo;
1641 gSystem->GetProcInfo(&ProcInfo);
1642 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1643
1644 fEventInfo.Reset();
1645 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1646 if (fReconstructor[iDet])
1647 fReconstructor[iDet]->SetRecoParam(NULL);
1648 }
1649
1650 fQASteer->Increment() ;
1651 return kTRUE;
1652}
1653
1654//_____________________________________________________________________________
1655void AliReconstruction::SlaveTerminate()
1656{
1657 // Finalize the run on the slave side
1658 // Called after the exit
1659 // from the event loop
1660 AliCodeTimerAuto("");
1661
1662 if (fIsNewRunLoader) { // galice.root didn't exist
1663 fRunLoader->WriteHeader("OVERWRITE");
1664 fRunLoader->CdGAFile();
1665 fRunLoader->Write(0, TObject::kOverwrite);
1666 }
1667
1668 ftree->GetUserInfo()->Add(fesd);
1669 fhlttree->GetUserInfo()->Add(fhltesd);
1670
1671 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1672 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1673
1674 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1675 cdbMapCopy->SetOwner(1);
1676 cdbMapCopy->SetName("cdbMap");
1677 TIter iter(cdbMap->GetTable());
1678
1679 TPair* pair = 0;
1680 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1681 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1682 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1683 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1684 }
1685
1686 TList *cdbListCopy = new TList();
1687 cdbListCopy->SetOwner(1);
1688 cdbListCopy->SetName("cdbList");
1689
1690 TIter iter2(cdbList);
1691
1692 AliCDBId* id=0;
1693 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1694 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1695 }
1696
1697 ftree->GetUserInfo()->Add(cdbMapCopy);
1698 ftree->GetUserInfo()->Add(cdbListCopy);
1699
1700
1701 if(fESDPar.Contains("ESD.par")){
1702 AliInfo("Attaching ESD.par to Tree");
1703 TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
1704 ftree->GetUserInfo()->Add(fn);
1705 }
1706
1707
1708 ffile->cd();
1709
1710 if (fWriteESDfriend)
1711 ftree->SetBranchStatus("ESDfriend*",0);
1712 // we want to have only one tree version number
1713 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1714 fhlttree->Write();
1715
1716// Finish with Plane Efficiency evaluation: before of CleanUp !!!
1717 if (fRunPlaneEff && !FinishPlaneEff()) {
1718 AliWarning("Finish PlaneEff evaluation failed");
1719 }
1720
1721 // End of cycle for the in-loop
1722 if (fRunQA) {
1723 fQASteer->EndOfCycle() ;
1724 }
1725 if (fRunGlobalQA) {
1726 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1727 if (qadm) {
1728 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1729 qadm->EndOfCycle(AliQA::kRECPOINTS);
1730 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1731 qadm->EndOfCycle(AliQA::kESDS);
1732 qadm->Finish();
1733 }
1734 }
1735 gROOT->cd();
1736 CleanUp();
1737}
1738
1739//_____________________________________________________________________________
1740void AliReconstruction::Terminate()
1741{
1742 // Create tags for the events in the ESD tree (the ESD tree is always present)
1743 // In case of empty events the tags will contain dummy values
1744 AliCodeTimerAuto("");
1745
1746 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1747 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData);
1748
1749 // Cleanup of CDB manager: cache and active storages!
1750 AliCDBManager::Instance()->ClearCache();
1751}
1752
1753//_____________________________________________________________________________
1754Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1755{
1756// run the local reconstruction
1757
1758 static Int_t eventNr=0;
1759 AliCodeTimerAuto("")
1760
1761 TString detStr = detectors;
1762 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1763 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1764 AliReconstructor* reconstructor = GetReconstructor(iDet);
1765 if (!reconstructor) continue;
1766 AliLoader* loader = fLoader[iDet];
1767 // Matthias April 2008: temporary fix to run HLT reconstruction
1768 // although the HLT loader is missing
1769 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1770 if (fRawReader) {
1771 reconstructor->Reconstruct(fRawReader, NULL);
1772 } else {
1773 TTree* dummy=NULL;
1774 reconstructor->Reconstruct(dummy, NULL);
1775 }
1776 continue;
1777 }
1778 if (!loader) {
1779 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1780 continue;
1781 }
1782 // conversion of digits
1783 if (fRawReader && reconstructor->HasDigitConversion()) {
1784 AliInfo(Form("converting raw data digits into root objects for %s",
1785 fgkDetectorName[iDet]));
1786// AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1787// fgkDetectorName[iDet]));
1788 loader->LoadDigits("update");
1789 loader->CleanDigits();
1790 loader->MakeDigitsContainer();
1791 TTree* digitsTree = loader->TreeD();
1792 reconstructor->ConvertDigits(fRawReader, digitsTree);
1793 loader->WriteDigits("OVERWRITE");
1794 loader->UnloadDigits();
1795 }
1796 // local reconstruction
1797 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1798 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1799 loader->LoadRecPoints("update");
1800 loader->CleanRecPoints();
1801 loader->MakeRecPointsContainer();
1802 TTree* clustersTree = loader->TreeR();
1803 if (fRawReader && !reconstructor->HasDigitConversion()) {
1804 reconstructor->Reconstruct(fRawReader, clustersTree);
1805 } else {
1806 loader->LoadDigits("read");
1807 TTree* digitsTree = loader->TreeD();
1808 if (!digitsTree) {
1809 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1810 if (fStopOnError) return kFALSE;
1811 } else {
1812 reconstructor->Reconstruct(digitsTree, clustersTree);
1813 }
1814 loader->UnloadDigits();
1815 }
1816
1817 TString detQAStr(fQADetectors) ;
1818 if (fRunQA)
1819 fQASteer->RunOneEventInOneDetector(iDet, clustersTree) ;
1820
1821 loader->WriteRecPoints("OVERWRITE");
1822 loader->UnloadRecPoints();
1823 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1824 }
1825 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1826 AliError(Form("the following detectors were not found: %s",
1827 detStr.Data()));
1828 if (fStopOnError) return kFALSE;
1829 }
1830 eventNr++;
1831 return kTRUE;
1832}
1833
1834//_____________________________________________________________________________
1835Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
1836{
1837// run the barrel tracking
1838
1839 AliCodeTimerAuto("")
1840
1841 AliESDVertex* vertex = NULL;
1842 Double_t vtxPos[3] = {0, 0, 0};
1843 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
1844 TArrayF mcVertex(3);
1845 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
1846 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
1847 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
1848 }
1849
1850 if (fVertexer) {
1851 AliInfo("running the ITS vertex finder");
1852 if (fLoader[0]) {
1853 fLoader[0]->LoadRecPoints();
1854 TTree* cltree = fLoader[0]->TreeR();
1855 if (cltree) {
1856 if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile);
1857 vertex = fVertexer->FindVertexForCurrentEvent(cltree);
1858 }
1859 else {
1860 AliError("Can't get the ITS cluster tree");
1861 }
1862 fLoader[0]->UnloadRecPoints();
1863 }
1864 else {
1865 AliError("Can't get the ITS loader");
1866 }
1867 if(!vertex){
1868 AliWarning("Vertex not found");
1869 vertex = new AliESDVertex();
1870 vertex->SetName("default");
1871 }
1872 else {
1873 vertex->SetName("reconstructed");
1874 }
1875
1876 } else {
1877 AliInfo("getting the primary vertex from MC");
1878 vertex = new AliESDVertex(vtxPos, vtxErr);
1879 }
1880
1881 if (vertex) {
1882 vertex->GetXYZ(vtxPos);
1883 vertex->GetSigmaXYZ(vtxErr);
1884 } else {
1885 AliWarning("no vertex reconstructed");
1886 vertex = new AliESDVertex(vtxPos, vtxErr);
1887 }
1888 esd->SetPrimaryVertexSPD(vertex);
1889 // if SPD multiplicity has been determined, it is stored in the ESD
1890 AliMultiplicity *mult = fVertexer->GetMultiplicity();
1891 if(mult)esd->SetMultiplicity(mult);
1892
1893 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1894 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
1895 }
1896 delete vertex;
1897
1898 return kTRUE;
1899}
1900
1901//_____________________________________________________________________________
1902Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1903{
1904// run the HLT barrel tracking
1905
1906 AliCodeTimerAuto("")
1907
1908 if (!fRunLoader) {
1909 AliError("Missing runLoader!");
1910 return kFALSE;
1911 }
1912
1913 AliInfo("running HLT tracking");
1914
1915 // Get a pointer to the HLT reconstructor
1916 AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1);
1917 if (!reconstructor) return kFALSE;
1918
1919 // TPC + ITS
1920 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1921 TString detName = fgkDetectorName[iDet];
1922 AliDebug(1, Form("%s HLT tracking", detName.Data()));
1923 reconstructor->SetOption(detName.Data());
1924 AliTracker *tracker = reconstructor->CreateTracker();
1925 if (!tracker) {
1926 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
1927 if (fStopOnError) return kFALSE;
1928 continue;
1929 }
1930 Double_t vtxPos[3];
1931 Double_t vtxErr[3]={0.005,0.005,0.010};
1932 const AliESDVertex *vertex = esd->GetVertex();
1933 vertex->GetXYZ(vtxPos);
1934 tracker->SetVertex(vtxPos,vtxErr);
1935 if(iDet != 1) {
1936 fLoader[iDet]->LoadRecPoints("read");
1937 TTree* tree = fLoader[iDet]->TreeR();
1938 if (!tree) {
1939 AliError(Form("Can't get the %s cluster tree", detName.Data()));
1940 return kFALSE;
1941 }
1942 tracker->LoadClusters(tree);
1943 }
1944 if (tracker->Clusters2Tracks(esd) != 0) {
1945 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
1946 return kFALSE;
1947 }
1948 if(iDet != 1) {
1949 tracker->UnloadClusters();
1950 }
1951 delete tracker;
1952 }
1953
1954 return kTRUE;
1955}
1956
1957//_____________________________________________________________________________
1958Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
1959{
1960// run the muon spectrometer tracking
1961
1962 AliCodeTimerAuto("")
1963
1964 if (!fRunLoader) {
1965 AliError("Missing runLoader!");
1966 return kFALSE;
1967 }
1968 Int_t iDet = 7; // for MUON
1969
1970 AliInfo("is running...");
1971
1972 // Get a pointer to the MUON reconstructor
1973 AliReconstructor *reconstructor = GetReconstructor(iDet);
1974 if (!reconstructor) return kFALSE;
1975
1976
1977 TString detName = fgkDetectorName[iDet];
1978 AliDebug(1, Form("%s tracking", detName.Data()));
1979 AliTracker *tracker = reconstructor->CreateTracker();
1980 if (!tracker) {
1981 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
1982 return kFALSE;
1983 }
1984
1985 // read RecPoints
1986 fLoader[iDet]->LoadRecPoints("read");
1987
1988 tracker->LoadClusters(fLoader[iDet]->TreeR());
1989
1990 Int_t rv = tracker->Clusters2Tracks(esd);
1991
1992 if ( rv )
1993 {
1994 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
1995 return kFALSE;
1996 }
1997
1998 fLoader[iDet]->UnloadRecPoints();
1999
2000 tracker->UnloadClusters();
2001
2002 delete tracker;
2003
2004 return kTRUE;
2005}
2006
2007
2008//_____________________________________________________________________________
2009Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
2010{
2011// run the barrel tracking
2012 static Int_t eventNr=0;
2013 AliCodeTimerAuto("")
2014
2015 AliInfo("running tracking");
2016
2017 //Fill the ESD with the T0 info (will be used by the TOF)
2018 if (fReconstructor[11] && fLoader[11]) {
2019 fLoader[11]->LoadRecPoints("READ");
2020 TTree *treeR = fLoader[11]->TreeR();
2021 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2022 }
2023
2024 // pass 1: TPC + ITS inwards
2025 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2026 if (!fTracker[iDet]) continue;
2027 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2028
2029 // load clusters
2030 fLoader[iDet]->LoadRecPoints("read");
2031 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2032 TTree* tree = fLoader[iDet]->TreeR();
2033 if (!tree) {
2034 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2035 return kFALSE;
2036 }
2037 fTracker[iDet]->LoadClusters(tree);
2038 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2039 // run tracking
2040 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2041 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2042 return kFALSE;
2043 }
2044 // preliminary PID in TPC needed by the ITS tracker
2045 if (iDet == 1) {
2046 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2047 AliESDpid::MakePID(esd);
2048 }
2049 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2050 }
2051
2052 // pass 2: ALL backwards
2053
2054 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2055 if (!fTracker[iDet]) continue;
2056 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2057
2058 // load clusters
2059 if (iDet > 1) { // all except ITS, TPC
2060 TTree* tree = NULL;
2061 fLoader[iDet]->LoadRecPoints("read");
2062 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2063 tree = fLoader[iDet]->TreeR();
2064 if (!tree) {
2065 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2066 return kFALSE;
2067 }
2068 fTracker[iDet]->LoadClusters(tree);
2069 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2070 }
2071
2072 // run tracking
2073 if (iDet>1) // start filling residuals for the "outer" detectors
2074 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2075
2076 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2077 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
2078 // return kFALSE;
2079 }
2080
2081 // unload clusters
2082 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
2083 fTracker[iDet]->UnloadClusters();
2084 fLoader[iDet]->UnloadRecPoints();
2085 }
2086 // updated PID in TPC needed by the ITS tracker -MI
2087 if (iDet == 1) {
2088 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2089 AliESDpid::MakePID(esd);
2090 }
2091 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2092 }
2093 //stop filling residuals for the "outer" detectors
2094 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2095
2096 // pass 3: TRD + TPC + ITS refit inwards
2097
2098 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2099 if (!fTracker[iDet]) continue;
2100 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
2101
2102 // run tracking
2103 if (iDet<2) // start filling residuals for TPC and ITS
2104 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2105
2106 if (fTracker[iDet]->RefitInward(esd) != 0) {
2107 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
2108 // return kFALSE;
2109 }
2110 // run postprocessing
2111 if (fTracker[iDet]->PostProcess(esd) != 0) {
2112 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2113 // return kFALSE;
2114 }
2115 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2116 }
2117
2118 // write space-points to the ESD in case alignment data output
2119 // is switched on
2120 if (fWriteAlignmentData)
2121 WriteAlignmentData(esd);
2122
2123 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2124 if (!fTracker[iDet]) continue;
2125 // unload clusters
2126 fTracker[iDet]->UnloadClusters();
2127 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
2128 fLoader[iDet]->UnloadRecPoints();
2129 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
2130 }
2131 // stop filling residuals for TPC and ITS
2132 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2133
2134 eventNr++;
2135 return kTRUE;
2136}
2137
2138//_____________________________________________________________________________
2139Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2140 //
2141 // Remove the data which are not needed for the physics analysis.
2142 //
2143
2144 Int_t nTracks=esd->GetNumberOfTracks();
2145 Int_t nV0s=esd->GetNumberOfV0s();
2146 AliInfo
2147 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
2148
2149 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2150 Bool_t rc=esd->Clean(cleanPars);
2151
2152 nTracks=esd->GetNumberOfTracks();
2153 nV0s=esd->GetNumberOfV0s();
2154 AliInfo
2155 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2156
2157 return rc;
2158}
2159
2160//_____________________________________________________________________________
2161Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2162{
2163// fill the event summary data
2164
2165 AliCodeTimerAuto("")
2166 static Int_t eventNr=0;
2167 TString detStr = detectors;
2168
2169 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2170 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2171 AliReconstructor* reconstructor = GetReconstructor(iDet);
2172 if (!reconstructor) continue;
2173 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2174 TTree* clustersTree = NULL;
2175 if (fLoader[iDet]) {
2176 fLoader[iDet]->LoadRecPoints("read");
2177 clustersTree = fLoader[iDet]->TreeR();
2178 if (!clustersTree) {
2179 AliError(Form("Can't get the %s clusters tree",
2180 fgkDetectorName[iDet]));
2181 if (fStopOnError) return kFALSE;
2182 }
2183 }
2184 if (fRawReader && !reconstructor->HasDigitConversion()) {
2185 reconstructor->FillESD(fRawReader, clustersTree, esd);
2186 } else {
2187 TTree* digitsTree = NULL;
2188 if (fLoader[iDet]) {
2189 fLoader[iDet]->LoadDigits("read");
2190 digitsTree = fLoader[iDet]->TreeD();
2191 if (!digitsTree) {
2192 AliError(Form("Can't get the %s digits tree",
2193 fgkDetectorName[iDet]));
2194 if (fStopOnError) return kFALSE;
2195 }
2196 }
2197 reconstructor->FillESD(digitsTree, clustersTree, esd);
2198 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2199 }
2200 if (fLoader[iDet]) {
2201 fLoader[iDet]->UnloadRecPoints();
2202 }
2203 }
2204
2205 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2206 AliError(Form("the following detectors were not found: %s",
2207 detStr.Data()));
2208 if (fStopOnError) return kFALSE;
2209 }
2210 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2211 eventNr++;
2212 return kTRUE;
2213}
2214
2215//_____________________________________________________________________________
2216Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2217{
2218 // Reads the trigger decision which is
2219 // stored in Trigger.root file and fills
2220 // the corresponding esd entries
2221
2222 AliCodeTimerAuto("")
2223
2224 AliInfo("Filling trigger information into the ESD");
2225
2226 if (fRawReader) {
2227 AliCTPRawStream input(fRawReader);
2228 if (!input.Next()) {
2229 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2230 }
2231 else {
2232 if (esd->GetTriggerMask() != input.GetClassMask())
2233 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2234 input.GetClassMask(),esd->GetTriggerMask()));
2235 if (esd->GetOrbitNumber() != input.GetOrbitID())
2236 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2237 input.GetOrbitID(),esd->GetOrbitNumber()));
2238 if (esd->GetBunchCrossNumber() != input.GetBCID())
2239 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2240 input.GetBCID(),esd->GetBunchCrossNumber()));
2241 }
2242
2243 // Here one has to add the filling of trigger inputs and
2244 // interaction records
2245 // ...
2246 }
2247 return kTRUE;
2248}
2249
2250
2251
2252
2253
2254//_____________________________________________________________________________
2255Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2256{
2257 //
2258 // Filling information from RawReader Header
2259 //
2260
2261 if (!fRawReader) return kFALSE;
2262
2263 AliInfo("Filling information from RawReader Header");
2264
2265 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2266 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2267 esd->SetPeriodNumber(fRawReader->GetPeriod());
2268
2269 esd->SetTimeStamp(fRawReader->GetTimestamp());
2270 esd->SetEventType(fRawReader->GetType());
2271
2272 return kTRUE;
2273}
2274
2275
2276//_____________________________________________________________________________
2277Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2278{
2279// check whether detName is contained in detectors
2280// if yes, it is removed from detectors
2281
2282 // check if all detectors are selected
2283 if ((detectors.CompareTo("ALL") == 0) ||
2284 detectors.BeginsWith("ALL ") ||
2285 detectors.EndsWith(" ALL") ||
2286 detectors.Contains(" ALL ")) {
2287 detectors = "ALL";
2288 return kTRUE;
2289 }
2290
2291 // search for the given detector
2292 Bool_t result = kFALSE;
2293 if ((detectors.CompareTo(detName) == 0) ||
2294 detectors.BeginsWith(detName+" ") ||
2295 detectors.EndsWith(" "+detName) ||
2296 detectors.Contains(" "+detName+" ")) {
2297 detectors.ReplaceAll(detName, "");
2298 result = kTRUE;
2299 }
2300
2301 // clean up the detectors string
2302 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2303 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2304 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2305
2306 return result;
2307}
2308
2309//_____________________________________________________________________________
2310Bool_t AliReconstruction::InitRunLoader()
2311{
2312// get or create the run loader
2313
2314 if (gAlice) delete gAlice;
2315 gAlice = NULL;
2316
2317 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2318 // load all base libraries to get the loader classes
2319 TString libs = gSystem->GetLibraries();
2320 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2321 TString detName = fgkDetectorName[iDet];
2322 if (detName == "HLT") continue;
2323 if (libs.Contains("lib" + detName + "base.so")) continue;
2324 gSystem->Load("lib" + detName + "base.so");
2325 }
2326 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2327 if (!fRunLoader) {
2328 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2329 CleanUp();
2330 return kFALSE;
2331 }
2332
2333 fRunLoader->CdGAFile();
2334 fRunLoader->LoadgAlice();
2335
2336 //PH This is a temporary fix to give access to the kinematics
2337 //PH that is needed for the labels of ITS clusters
2338 fRunLoader->LoadHeader();
2339 fRunLoader->LoadKinematics();
2340
2341 } else { // galice.root does not exist
2342 if (!fRawReader) {
2343 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2344 }
2345 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2346 AliConfig::GetDefaultEventFolderName(),
2347 "recreate");
2348 if (!fRunLoader) {
2349 AliError(Form("could not create run loader in file %s",
2350 fGAliceFileName.Data()));
2351 CleanUp();
2352 return kFALSE;
2353 }
2354 fIsNewRunLoader = kTRUE;
2355 fRunLoader->MakeTree("E");
2356
2357 if (fNumberOfEventsPerFile > 0)
2358 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2359 else
2360 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2361 }
2362
2363 return kTRUE;
2364}
2365
2366//_____________________________________________________________________________
2367AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2368{
2369// get the reconstructor object and the loader for a detector
2370
2371 if (fReconstructor[iDet]) {
2372 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2373 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2374 fReconstructor[iDet]->SetRecoParam(par);
2375 }
2376 return fReconstructor[iDet];
2377 }
2378
2379 // load the reconstructor object
2380 TPluginManager* pluginManager = gROOT->GetPluginManager();
2381 TString detName = fgkDetectorName[iDet];
2382 TString recName = "Ali" + detName + "Reconstructor";
2383
2384 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2385
2386 AliReconstructor* reconstructor = NULL;
2387 // first check if a plugin is defined for the reconstructor
2388 TPluginHandler* pluginHandler =
2389 pluginManager->FindHandler("AliReconstructor", detName);
2390 // if not, add a plugin for it
2391 if (!pluginHandler) {
2392 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2393 TString libs = gSystem->GetLibraries();
2394 if (libs.Contains("lib" + detName + "base.so") ||
2395 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2396 pluginManager->AddHandler("AliReconstructor", detName,
2397 recName, detName + "rec", recName + "()");
2398 } else {
2399 pluginManager->AddHandler("AliReconstructor", detName,
2400 recName, detName, recName + "()");
2401 }
2402 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2403 }
2404 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2405 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2406 }
2407 if (reconstructor) {
2408 TObject* obj = fOptions.FindObject(detName.Data());
2409 if (obj) reconstructor->SetOption(obj->GetTitle());
2410 reconstructor->Init();
2411 fReconstructor[iDet] = reconstructor;
2412 }
2413
2414 // get or create the loader
2415 if (detName != "HLT") {
2416 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2417 if (!fLoader[iDet]) {
2418 AliConfig::Instance()
2419 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2420 detName, detName);
2421 // first check if a plugin is defined for the loader
2422 pluginHandler =
2423 pluginManager->FindHandler("AliLoader", detName);
2424 // if not, add a plugin for it
2425 if (!pluginHandler) {
2426 TString loaderName = "Ali" + detName + "Loader";
2427 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2428 pluginManager->AddHandler("AliLoader", detName,
2429 loaderName, detName + "base",
2430 loaderName + "(const char*, TFolder*)");
2431 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2432 }
2433 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2434 fLoader[iDet] =
2435 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2436 fRunLoader->GetEventFolder());
2437 }
2438 if (!fLoader[iDet]) { // use default loader
2439 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2440 }
2441 if (!fLoader[iDet]) {
2442 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2443 if (fStopOnError) return NULL;
2444 } else {
2445 fRunLoader->AddLoader(fLoader[iDet]);
2446 fRunLoader->CdGAFile();
2447 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2448 fRunLoader->Write(0, TObject::kOverwrite);
2449 }
2450 }
2451 }
2452
2453 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2454 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2455 reconstructor->SetRecoParam(par);
2456 }
2457 return reconstructor;
2458}
2459
2460//_____________________________________________________________________________
2461Bool_t AliReconstruction::CreateVertexer()
2462{
2463// create the vertexer
2464
2465 fVertexer = NULL;
2466 AliReconstructor* itsReconstructor = GetReconstructor(0);
2467 if (itsReconstructor) {
2468 fVertexer = itsReconstructor->CreateVertexer();
2469 }
2470 if (!fVertexer) {
2471 AliWarning("couldn't create a vertexer for ITS");
2472 if (fStopOnError) return kFALSE;
2473 }
2474
2475 return kTRUE;
2476}
2477
2478//_____________________________________________________________________________
2479Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2480{
2481// create the trackers
2482
2483 TString detStr = detectors;
2484 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2485 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2486 AliReconstructor* reconstructor = GetReconstructor(iDet);
2487 if (!reconstructor) continue;
2488 TString detName = fgkDetectorName[iDet];
2489 if (detName == "HLT") {
2490 fRunHLTTracking = kTRUE;
2491 continue;
2492 }
2493 if (detName == "MUON") {
2494 fRunMuonTracking = kTRUE;
2495 continue;
2496 }
2497
2498
2499 fTracker[iDet] = reconstructor->CreateTracker();
2500 if (!fTracker[iDet] && (iDet < 7)) {
2501 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2502 if (fStopOnError) return kFALSE;
2503 }
2504 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2505 }
2506
2507 return kTRUE;
2508}
2509
2510//_____________________________________________________________________________
2511void AliReconstruction::CleanUp()
2512{
2513// delete trackers and the run loader and close and delete the file
2514
2515 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2516 delete fReconstructor[iDet];
2517 fReconstructor[iDet] = NULL;
2518 fLoader[iDet] = NULL;
2519 delete fTracker[iDet];
2520 fTracker[iDet] = NULL;
2521 }
2522 delete fRunInfo;
2523 fRunInfo = NULL;
2524
2525 delete fVertexer;
2526 fVertexer = NULL;
2527
2528 delete ftVertexer;
2529 ftVertexer = NULL;
2530
2531 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2532 delete fDiamondProfile;
2533 fDiamondProfile = NULL;
2534 delete fDiamondProfileTPC;
2535 fDiamondProfileTPC = NULL;
2536 }
2537 delete fGRPData;
2538 fGRPData = NULL;
2539
2540 delete fRunLoader;
2541 fRunLoader = NULL;
2542 delete fRawReader;
2543 fRawReader = NULL;
2544 delete fParentRawReader;
2545 fParentRawReader=NULL;
2546
2547 if (ffile) {
2548 ffile->Close();
2549 delete ffile;
2550 ffile = NULL;
2551 }
2552}
2553
2554void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2555{
2556 // Write space-points which are then used in the alignment procedures
2557 // For the moment only ITS, TPC, TRD and TOF
2558
2559 Int_t ntracks = esd->GetNumberOfTracks();
2560 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2561 {
2562 AliESDtrack *track = esd->GetTrack(itrack);
2563 Int_t nsp = 0;
2564 Int_t idx[200];
2565 for (Int_t iDet = 3; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2566 nsp += track->GetNcls(iDet);
2567
2568 if (iDet==0) { // ITS "extra" clusters
2569 track->GetClusters(iDet,idx);
2570 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2571 }
2572 }
2573
2574 if (nsp) {
2575 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2576 track->SetTrackPointArray(sp);
2577 Int_t isptrack = 0;
2578 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2579 AliTracker *tracker = fTracker[iDet];
2580 if (!tracker) continue;
2581 Int_t nspdet = track->GetClusters(iDet,idx);
2582
2583 if (iDet==0) // ITS "extra" clusters
2584 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2585
2586 if (nspdet <= 0) continue;
2587 AliTrackPoint p;
2588 Int_t isp = 0;
2589 Int_t isp2 = 0;
2590 while (isp2 < nspdet) {
2591 Bool_t isvalid=kTRUE;
2592
2593 Int_t index=idx[isp++];
2594 if (index < 0) continue;
2595
2596 TString dets = fgkDetectorName[iDet];
2597 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2598 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2599 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2600 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2601 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2602 } else {
2603 isvalid = tracker->GetTrackPoint(index,p);
2604 }
2605 isp2++;
2606 if (!isvalid) continue;
2607 sp->AddPoint(isptrack,&p); isptrack++;
2608 }
2609 }
2610 }
2611 }
2612}
2613
2614//_____________________________________________________________________________
2615void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2616{
2617 // The method reads the raw-data error log
2618 // accumulated within the rawReader.
2619 // It extracts the raw-data errors related to
2620 // the current event and stores them into
2621 // a TClonesArray inside the esd object.
2622
2623 if (!fRawReader) return;
2624
2625 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2626
2627 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2628 if (!log) continue;
2629 if (iEvent != log->GetEventNumber()) continue;
2630
2631 esd->AddRawDataErrorLog(log);
2632 }
2633
2634}
2635
2636TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){
2637 // Dump a file content into a char in TNamed
2638 ifstream in;
2639 in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
2640 Int_t kBytes = (Int_t)in.tellg();
2641 printf("Size: %d \n",kBytes);
2642 TNamed *fn = 0;
2643 if(in.good()){
2644 char* memblock = new char [kBytes];
2645 in.seekg (0, ios::beg);
2646 in.read (memblock, kBytes);
2647 in.close();
2648 TString fData(memblock,kBytes);
2649 fn = new TNamed(pName,fData);
2650 printf("fData Size: %d \n",fData.Sizeof());
2651 printf("pName Size: %d \n",pName.Sizeof());
2652 printf("fn Size: %d \n",fn->Sizeof());
2653 delete[] memblock;
2654 }
2655 else{
2656 AliInfo(Form("Could not Open %s\n",fPath.Data()));
2657 }
2658
2659 return fn;
2660}
2661
2662void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){
2663 // This is not really needed in AliReconstruction at the moment
2664 // but can serve as a template
2665
2666 TList *fList = fTree->GetUserInfo();
2667 TNamed *fn = (TNamed*)fList->FindObject(pName.Data());
2668 printf("fn Size: %d \n",fn->Sizeof());
2669
2670 TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works
2671 const char* cdata = fn->GetTitle();
2672 printf("fTmp Size %d\n",fTmp.Sizeof());
2673
2674 int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
2675 printf("calculated size %d\n",size);
2676 ofstream out(pName.Data(),ios::out | ios::binary);
2677 out.write(cdata,size);
2678 out.close();
2679
2680}
2681
2682//_____________________________________________________________________________
2683void AliReconstruction::CheckQA()
2684{
2685// check the QA of SIM for this run and remove the detectors
2686// with status Fatal
2687
2688 TString newRunLocalReconstruction ;
2689 TString newRunTracking ;
2690 TString newFillESD ;
2691
2692 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2693 TString detName(AliQA::GetDetName(iDet)) ;
2694 AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2695 if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) {
2696 AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ;
2697 } else {
2698 if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2699 fRunLocalReconstruction.Contains("ALL") ) {
2700 newRunLocalReconstruction += detName ;
2701 newRunLocalReconstruction += " " ;
2702 }
2703 if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2704 fRunTracking.Contains("ALL") ) {
2705 newRunTracking += detName ;
2706 newRunTracking += " " ;
2707 }
2708 if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2709 fFillESD.Contains("ALL") ) {
2710 newFillESD += detName ;
2711 newFillESD += " " ;
2712 }
2713 }
2714 }
2715 fRunLocalReconstruction = newRunLocalReconstruction ;
2716 fRunTracking = newRunTracking ;
2717 fFillESD = newFillESD ;
2718}
2719
2720//_____________________________________________________________________________
2721Int_t AliReconstruction::GetDetIndex(const char* detector)
2722{
2723 // return the detector index corresponding to detector
2724 Int_t index = -1 ;
2725 for (index = 0; index < fgkNDetectors ; index++) {
2726 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2727 break ;
2728 }
2729 return index ;
2730}
2731//_____________________________________________________________________________
2732Bool_t AliReconstruction::FinishPlaneEff() {
2733 //
2734 // Here execute all the necessary operationis, at the end of the tracking phase,
2735 // in case that evaluation of PlaneEfficiencies was required for some detector.
2736 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2737 //
2738 // This Preliminary version works only FOR ITS !!!!!
2739 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2740 //
2741 // Input: none
2742 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2743 //
2744 Bool_t ret=kFALSE;
2745 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2746 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2747 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2748 if(fTracker[iDet]) {
2749 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2750 TString name=planeeff->GetName();
2751 name+=".root";
2752 TFile* pefile = TFile::Open(name, "RECREATE");
2753 ret=(Bool_t)planeeff->Write();
2754 pefile->Close();
2755 if(planeeff->GetCreateHistos()) {
2756 TString hname=planeeff->GetName();
2757 hname+="Histo.root";
2758 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2759 }
2760 }
2761 }
2762 return ret;
2763}
2764//_____________________________________________________________________________
2765Bool_t AliReconstruction::InitPlaneEff() {
2766//
2767 // Here execute all the necessary operations, before of the tracking phase,
2768 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2769 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2770 // which should be updated/recalculated.
2771 //
2772 // This Preliminary version will work only FOR ITS !!!!!
2773 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2774 //
2775 // Input: none
2776 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2777 //
2778 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2779 return kTRUE;
2780}
2781
2782//_____________________________________________________________________________
2783Bool_t AliReconstruction::InitAliEVE()
2784{
2785 // This method should be called only in case
2786 // AliReconstruction is run
2787 // within the alieve environment.
2788 // It will initialize AliEVE in a way
2789 // so that it can visualize event processed
2790 // by AliReconstruction.
2791 // The return flag shows whenever the
2792 // AliEVE initialization was successful or not.
2793
2794 TString macroStr;
2795 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2796 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2797 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2798
2799 gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};");
2800 gROOT->ProcessLine("alieve_online_init()");
2801
2802 return kTRUE;
2803}
2804
2805//_____________________________________________________________________________
2806void AliReconstruction::RunAliEVE()
2807{
2808 // Runs AliEVE visualisation of
2809 // the current event.
2810 // Should be executed only after
2811 // successful initialization of AliEVE.
2812
2813 AliInfo("Running AliEVE...");
2814 gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd));
2815 gSystem->Run();
2816}
2817
2818//_____________________________________________________________________________
2819Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2820{
2821 // Allows to run QA for a selected set of detectors
2822 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2823 // all selected detectors run the same selected tasks
2824
2825 if (!detAndAction.Contains(":")) {
2826 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2827 fRunQA = kFALSE ;
2828 return kFALSE ;
2829 }
2830 Int_t colon = detAndAction.Index(":") ;
2831 fQADetectors = detAndAction(0, colon) ;
2832 if (fQADetectors.Contains("ALL") )
2833 fQADetectors = fFillESD ;
2834 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2835 if (fQATasks.Contains("ALL") ) {
2836 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2837 } else {
2838 fQATasks.ToUpper() ;
2839 TString tempo("") ;
2840 if ( fQATasks.Contains("RAW") )
2841 tempo = Form("%d ", AliQA::kRAWS) ;
2842 if ( fQATasks.Contains("RECPOINT") )
2843 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2844 if ( fQATasks.Contains("ESD") )
2845 tempo += Form("%d ", AliQA::kESDS) ;
2846 fQATasks = tempo ;
2847 if (fQATasks.IsNull()) {
2848 AliInfo("No QA requested\n") ;
2849 fRunQA = kFALSE ;
2850 return kTRUE ;
2851 }
2852 }
2853 TString tempo(fQATasks) ;
2854 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2855 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2856 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2857 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2858 fRunQA = kTRUE ;
2859 return kTRUE;
2860}
2861
2862//_____________________________________________________________________________
2863Bool_t AliReconstruction::InitRecoParams()
2864{
2865 // The method accesses OCDB and retrieves all
2866 // the available reco-param objects from there.
2867
2868 Bool_t isOK = kTRUE;
2869
2870 TString detStr = fLoadCDB;
2871 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2872
2873 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2874
2875 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2876 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2877 continue;
2878 }
2879
2880 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
2881
2882 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2883 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
2884 if(!entry){
2885 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
2886 isOK = kFALSE;
2887 }
2888 else {
2889 TObject *recoParamObj = entry->GetObject();
2890 if (dynamic_cast<TObjArray*>(recoParamObj)) {
2891 // The detector has a normal TobjArray of AliDetectorRecoParam objects
2892 // Registering them in AliRecoParam
2893 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
2894 }
2895 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
2896 // The detector has only onse set of reco parameters
2897 // Registering it in AliRecoParam
2898 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
2899 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
2900 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
2901 }
2902 else {
2903 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
2904 isOK = kFALSE;
2905 }
2906 entry->SetOwner(0);
2907 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
2908 }
2909 }
2910
2911 if (AliDebugLevel() > 0) fRecoParam.Print();
2912
2913 return isOK;
2914}
2915
2916//_____________________________________________________________________________
2917Bool_t AliReconstruction::GetEventInfo()
2918{
2919 // Fill the event info object
2920 // ...
2921 AliCodeTimerAuto("")
2922
2923 AliCentralTrigger *aCTP = NULL;
2924 if (fRawReader) {
2925 fEventInfo.SetEventType(fRawReader->GetType());
2926
2927 ULong64_t mask = fRawReader->GetClassMask();
2928 fEventInfo.SetTriggerMask(mask);
2929 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
2930 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
2931
2932 aCTP = new AliCentralTrigger();
2933 TString configstr("");
2934 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
2935 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
2936 delete aCTP;
2937 return kFALSE;
2938 }
2939 aCTP->SetClassMask(mask);
2940 aCTP->SetClusterMask(clmask);
2941 }
2942 else {
2943 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
2944
2945 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
2946 aCTP = fRunLoader->GetTrigger();
2947 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
2948 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
2949 }
2950 else {
2951 AliWarning("No trigger can be loaded! The trigger information will not be used!");
2952 return kFALSE;
2953 }
2954 }
2955
2956 AliTriggerConfiguration *config = aCTP->GetConfiguration();
2957 if (!config) {
2958 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
2959 if (fRawReader) delete aCTP;
2960 return kFALSE;
2961 }
2962
2963 UChar_t clustmask = 0;
2964 TString trclasses;
2965 ULong64_t trmask = fEventInfo.GetTriggerMask();
2966 const TObjArray& classesArray = config->GetClasses();
2967 Int_t nclasses = classesArray.GetEntriesFast();
2968 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
2969 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
2970 if (trclass) {
2971 Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask());
2972 fesd->SetTriggerClass(trclass->GetName(),trindex);
2973 if (trmask & (1 << trindex)) {
2974 trclasses += " ";
2975 trclasses += trclass->GetName();
2976 trclasses += " ";
2977 clustmask |= trclass->GetCluster()->GetClusterMask();
2978 }
2979 }
2980 }
2981 fEventInfo.SetTriggerClasses(trclasses);
2982
2983 // Set the information in ESD
2984 fesd->SetTriggerMask(trmask);
2985 fesd->SetTriggerCluster(clustmask);
2986
2987 if (!aCTP->CheckTriggeredDetectors()) {
2988 if (fRawReader) delete aCTP;
2989 return kFALSE;
2990 }
2991
2992 if (fRawReader) delete aCTP;
2993
2994 // We have to fill also the HLT decision here!!
2995 // ...
2996
2997 return kTRUE;
2998}
2999
3000const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3001{
3002 // Match the detector list found in the rec.C or the default 'ALL'
3003 // to the list found in the GRP (stored there by the shuttle PP which
3004 // gets the information from ECS)
3005 static TString resultList;
3006 TString detList = detectorList;
3007
3008 resultList = "";
3009
3010 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3011 if ((detectorMask >> iDet) & 0x1) {
3012 TString det = AliDAQ::OfflineModuleName(iDet);
3013 if ((detList.CompareTo("ALL") == 0) ||
3014 detList.BeginsWith("ALL ") ||
3015 detList.EndsWith(" ALL") ||
3016 detList.Contains(" ALL ") ||
3017 (detList.CompareTo(det) == 0) ||
3018 detList.BeginsWith(det) ||
3019 detList.EndsWith(det) ||
3020 detList.Contains( " "+det+" " )) {
3021 if (!resultList.EndsWith(det + " ")) {
3022 resultList += det;
3023 resultList += " ";
3024 }
3025 }
3026 }
3027 }
3028
3029 // HLT
3030 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3031 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3032 if ((detList.CompareTo("ALL") == 0) ||
3033 detList.BeginsWith("ALL ") ||
3034 detList.EndsWith(" ALL") ||
3035 detList.Contains(" ALL ") ||
3036 (detList.CompareTo(hltDet) == 0) ||
3037 detList.BeginsWith(hltDet) ||
3038 detList.EndsWith(hltDet) ||
3039 detList.Contains( " "+hltDet+" " )) {
3040 resultList += hltDet;
3041 }
3042 }
3043
3044 return resultList.Data();
3045
3046}
3047
3048//______________________________________________________________________________
3049void AliReconstruction::Abort(const char *method, EAbort what)
3050{
3051 // Abort processing. If what = kAbortProcess, the Process() loop will be
3052 // aborted. If what = kAbortFile, the current file in a chain will be
3053 // aborted and the processing will continue with the next file, if there
3054 // is no next file then Process() will be aborted. Abort() can also be
3055 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3056 // the SlaveTerminate() and Terminate() are always called. The abort flag
3057 // can be checked in these methods using GetAbort().
3058 //
3059 // The method is overwritten in AliReconstruction for better handling of
3060 // reco specific errors
3061
3062 if (!fStopOnError) return;
3063
3064 CleanUp();
3065
3066 TString whyMess = method;
3067 whyMess += " failed! Aborting...";
3068
3069 AliError(whyMess.Data());
3070
3071 fAbort = what;
3072 TString mess = "Abort";
3073 if (fAbort == kAbortProcess)
3074 mess = "AbortProcess";
3075 else if (fAbort == kAbortFile)
3076 mess = "AbortFile";
3077
3078 Info(mess, whyMess.Data());
3079}
3080