1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the reconstruction //
22 // Clusters and tracks are created for all detectors and all events by //
25 // AliReconstruction rec; //
28 // The Run method returns kTRUE in case of successful execution. //
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 //
33 // rec.SetInput("..."); //
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 //
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 //
45 // rec.SetEventRange(..., ...); //
47 // The index -1 (default) can be used for the last event to indicate no //
48 // upper limit of the event range. //
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): //
56 // rec.SetNumberOfEventsPerFile(...); //
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 //
63 // rec.SetGAliceFile("..."); //
65 // The local reconstruction can be switched on or off for individual //
68 // rec.SetRunLocalReconstruction("..."); //
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. //
74 // The reconstruction of the primary vertex position can be switched off by //
76 // rec.SetRunVertexFinder(kFALSE); //
78 // The tracking and the creation of ESD tracks can be switched on for //
79 // selected detectors by //
81 // rec.SetRunTracking("..."); //
83 // Uniform/nonuniform field tracking switches (default: uniform field) //
85 // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
87 // The filling of additional ESD information can be steered by //
89 // rec.SetFillESD("..."); //
91 // Again, for both methods the string specifies the list of detectors. //
92 // The default is "ALL". //
94 // The call of the shortcut method //
96 // rec.SetRunReconstruction("..."); //
98 // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99 // SetFillESD with the same detector selecting string as argument. //
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. //
104 // The input data of a detector can be replaced by the corresponding HLT //
105 // data by calling (usual detector string) //
106 // SetUseHLTData("..."); //
109 ///////////////////////////////////////////////////////////////////////////////
116 #include <TGeoGlobalMagField.h>
117 #include <TGeoManager.h>
119 #include <TLorentzVector.h>
121 #include <TObjArray.h>
122 #include <TPRegexp.h>
123 #include <TParameter.h>
124 #include <TPluginManager.h>
126 #include <TProofOutputFile.h>
130 #include "AliAlignObj.h"
131 #include "AliCDBEntry.h"
132 #include "AliCDBManager.h"
133 #include "AliCDBStorage.h"
134 #include "AliCTPRawStream.h"
135 #include "AliCascadeVertexer.h"
136 #include "AliCentralTrigger.h"
137 #include "AliCodeTimer.h"
139 #include "AliDetectorRecoParam.h"
140 #include "AliESDCaloCells.h"
141 #include "AliESDCaloCluster.h"
142 #include "AliESDEvent.h"
143 #include "AliESDMuonTrack.h"
144 #include "AliESDPmdTrack.h"
145 #include "AliESDTagCreator.h"
146 #include "AliESDVertex.h"
147 #include "AliESDcascade.h"
148 #include "AliESDfriend.h"
149 #include "AliESDkink.h"
150 #include "AliESDpid.h"
151 #include "AliESDtrack.h"
152 #include "AliESDtrack.h"
153 #include "AliEventInfo.h"
154 #include "AliGRPObject.h"
155 #include "AliGRPRecoParam.h"
156 #include "AliGenEventHeader.h"
157 #include "AliGeomManager.h"
158 #include "AliGlobalQADataMaker.h"
159 #include "AliHeader.h"
162 #include "AliMultiplicity.h"
164 #include "AliPlaneEff.h"
166 #include "AliQADataMakerRec.h"
167 #include "AliQAManager.h"
168 #include "AliRawEvent.h"
169 #include "AliRawEventHeaderBase.h"
170 #include "AliRawHLTManager.h"
171 #include "AliRawReaderDate.h"
172 #include "AliRawReaderFile.h"
173 #include "AliRawReaderRoot.h"
174 #include "AliReconstruction.h"
175 #include "AliReconstructor.h"
177 #include "AliRunInfo.h"
178 #include "AliRunLoader.h"
179 #include "AliSysInfo.h" // memory snapshots
180 #include "AliTrackPointArray.h"
181 #include "AliTracker.h"
182 #include "AliTriggerClass.h"
183 #include "AliTriggerCluster.h"
184 #include "AliTriggerConfiguration.h"
185 #include "AliV0vertexer.h"
186 #include "AliVertexer.h"
187 #include "AliVertexerTracks.h"
189 ClassImp(AliReconstruction)
191 //_____________________________________________________________________________
192 const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
194 //_____________________________________________________________________________
195 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
197 fUniformField(kFALSE),
198 fRunVertexFinder(kTRUE),
199 fRunVertexFinderTracks(kTRUE),
200 fRunHLTTracking(kFALSE),
201 fRunMuonTracking(kFALSE),
203 fRunCascadeFinder(kTRUE),
204 fStopOnError(kFALSE),
205 fWriteAlignmentData(kFALSE),
206 fWriteESDfriend(kFALSE),
207 fFillTriggerESD(kTRUE),
215 fRunLocalReconstruction("ALL"),
219 fUseTrackingErrorsForAlignment(""),
220 fGAliceFileName(gAliceFilename),
225 fNumberOfEventsPerFile((UInt_t)-1),
227 fLoadAlignFromCDB(kTRUE),
228 fLoadAlignData("ALL"),
235 fParentRawReader(NULL),
239 fDiamondProfileSPD(NULL),
240 fDiamondProfile(NULL),
241 fDiamondProfileTPC(NULL),
245 fAlignObjArray(NULL),
249 fInitCDBCalled(kFALSE),
250 fSetRunNumberFromDataCalled(kFALSE),
256 fSameQACycle(kFALSE),
257 fInitQACalled(kFALSE),
258 fRunPlaneEff(kFALSE),
267 fIsNewRunLoader(kFALSE),
271 // create reconstruction object with default parameters
274 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
275 fReconstructor[iDet] = NULL;
276 fLoader[iDet] = NULL;
277 fTracker[iDet] = NULL;
279 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
280 fQACycles[iDet] = 999999 ;
281 fQAWriteExpert[iDet] = kFALSE ;
287 //_____________________________________________________________________________
288 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
290 fUniformField(rec.fUniformField),
291 fRunVertexFinder(rec.fRunVertexFinder),
292 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
293 fRunHLTTracking(rec.fRunHLTTracking),
294 fRunMuonTracking(rec.fRunMuonTracking),
295 fRunV0Finder(rec.fRunV0Finder),
296 fRunCascadeFinder(rec.fRunCascadeFinder),
297 fStopOnError(rec.fStopOnError),
298 fWriteAlignmentData(rec.fWriteAlignmentData),
299 fWriteESDfriend(rec.fWriteESDfriend),
300 fFillTriggerESD(rec.fFillTriggerESD),
302 fCleanESD(rec.fCleanESD),
303 fV0DCAmax(rec.fV0DCAmax),
304 fV0CsPmin(rec.fV0CsPmin),
308 fRunLocalReconstruction(rec.fRunLocalReconstruction),
309 fRunTracking(rec.fRunTracking),
310 fFillESD(rec.fFillESD),
311 fLoadCDB(rec.fLoadCDB),
312 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
313 fGAliceFileName(rec.fGAliceFileName),
314 fRawInput(rec.fRawInput),
315 fEquipIdMap(rec.fEquipIdMap),
316 fFirstEvent(rec.fFirstEvent),
317 fLastEvent(rec.fLastEvent),
318 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
320 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
321 fLoadAlignData(rec.fLoadAlignData),
322 fUseHLTData(rec.fUseHLTData),
328 fParentRawReader(NULL),
330 fRecoParam(rec.fRecoParam),
332 fDiamondProfileSPD(rec.fDiamondProfileSPD),
333 fDiamondProfile(rec.fDiamondProfile),
334 fDiamondProfileTPC(rec.fDiamondProfileTPC),
338 fAlignObjArray(rec.fAlignObjArray),
339 fCDBUri(rec.fCDBUri),
340 fQARefUri(rec.fQARefUri),
342 fInitCDBCalled(rec.fInitCDBCalled),
343 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
344 fQADetectors(rec.fQADetectors),
346 fQATasks(rec.fQATasks),
348 fRunGlobalQA(rec.fRunGlobalQA),
349 fSameQACycle(rec.fSameQACycle),
350 fInitQACalled(rec.fInitQACalled),
351 fRunPlaneEff(rec.fRunPlaneEff),
360 fIsNewRunLoader(rec.fIsNewRunLoader),
366 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
367 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
369 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
370 fReconstructor[iDet] = NULL;
371 fLoader[iDet] = NULL;
372 fTracker[iDet] = NULL;
375 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
376 fQACycles[iDet] = rec.fQACycles[iDet];
377 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
380 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
381 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
385 //_____________________________________________________________________________
386 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
388 // assignment operator
389 // Used in PROOF mode
390 // Be very careful while modifing it!
391 // Simple rules to follow:
392 // for persistent data members - use their assignment operators
393 // for non-persistent ones - do nothing or take the default values from constructor
394 // TSelector members should not be touched
395 if(&rec == this) return *this;
397 fUniformField = rec.fUniformField;
398 fRunVertexFinder = rec.fRunVertexFinder;
399 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
400 fRunHLTTracking = rec.fRunHLTTracking;
401 fRunMuonTracking = rec.fRunMuonTracking;
402 fRunV0Finder = rec.fRunV0Finder;
403 fRunCascadeFinder = rec.fRunCascadeFinder;
404 fStopOnError = rec.fStopOnError;
405 fWriteAlignmentData = rec.fWriteAlignmentData;
406 fWriteESDfriend = rec.fWriteESDfriend;
407 fFillTriggerESD = rec.fFillTriggerESD;
409 fCleanESD = rec.fCleanESD;
410 fV0DCAmax = rec.fV0DCAmax;
411 fV0CsPmin = rec.fV0CsPmin;
415 fRunLocalReconstruction = rec.fRunLocalReconstruction;
416 fRunTracking = rec.fRunTracking;
417 fFillESD = rec.fFillESD;
418 fLoadCDB = rec.fLoadCDB;
419 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
420 fGAliceFileName = rec.fGAliceFileName;
421 fRawInput = rec.fRawInput;
422 fEquipIdMap = rec.fEquipIdMap;
423 fFirstEvent = rec.fFirstEvent;
424 fLastEvent = rec.fLastEvent;
425 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
427 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
428 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
431 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
432 fLoadAlignData = rec.fLoadAlignData;
433 fUseHLTData = rec.fUseHLTData;
435 delete fRunInfo; fRunInfo = NULL;
436 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
438 fEventInfo = rec.fEventInfo;
442 fParentRawReader = NULL;
444 fRecoParam = rec.fRecoParam;
446 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
447 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
448 delete fLoader[iDet]; fLoader[iDet] = NULL;
449 delete fTracker[iDet]; fTracker[iDet] = NULL;
452 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
453 fQACycles[iDet] = rec.fQACycles[iDet];
454 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
457 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
458 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
459 delete fDiamondProfile; fDiamondProfile = NULL;
460 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
461 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
462 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
464 delete fGRPData; fGRPData = NULL;
465 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
466 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
468 delete fAlignObjArray; fAlignObjArray = NULL;
471 fQARefUri = rec.fQARefUri;
472 fSpecCDBUri.Delete();
473 fInitCDBCalled = rec.fInitCDBCalled;
474 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
475 fQADetectors = rec.fQADetectors;
477 fQATasks = rec.fQATasks;
479 fRunGlobalQA = rec.fRunGlobalQA;
480 fSameQACycle = rec.fSameQACycle;
481 fInitQACalled = rec.fInitQACalled;
482 fRunPlaneEff = rec.fRunPlaneEff;
491 fIsNewRunLoader = rec.fIsNewRunLoader;
498 //_____________________________________________________________________________
499 AliReconstruction::~AliReconstruction()
506 if (fAlignObjArray) {
507 fAlignObjArray->Delete();
508 delete fAlignObjArray;
510 fSpecCDBUri.Delete();
512 AliCodeTimer::Instance()->Print();
515 //_____________________________________________________________________________
516 void AliReconstruction::InitQA()
518 //Initialize the QA and start of cycle
519 AliCodeTimerAuto("");
521 if (fInitQACalled) return;
522 fInitQACalled = kTRUE;
524 fQAManager = AliQAManager::QAManager("rec") ;
525 if (fQAManager->IsDefaultStorageSet()) {
526 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
527 AliWarning("Default QA reference storage has been already set !");
528 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
529 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
530 fQARefUri = fQAManager->GetDefaultStorage()->GetURI();
532 if (fQARefUri.Length() > 0) {
533 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
534 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
535 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
537 fQARefUri="local://$ALICE_ROOT/QAref";
538 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
539 AliWarning("Default QA refeference storage not yet set !!!!");
540 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
541 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
544 fQAManager->SetDefaultStorage(fQARefUri);
548 fQAManager->SetActiveDetectors(fQADetectors) ;
549 for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
550 fQAManager->SetCycleLength(AliQA::DETECTORINDEX_t(det), fQACycles[det]) ;
551 fQAManager->SetWriteExpert(AliQA::DETECTORINDEX_t(det)) ;
553 if (!fRawReader && fQATasks.Contains(AliQA::kRAWS))
554 fQATasks.ReplaceAll(Form("%d",AliQA::kRAWS), "") ;
555 fQAManager->SetTasks(fQATasks) ;
556 fQAManager->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
559 Bool_t sameCycle = kFALSE ;
560 AliQADataMaker *qadm = fQAManager->GetQADataMaker(AliQA::kGLOBAL);
561 AliInfo(Form("Initializing the global QA data maker"));
562 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
563 qadm->StartOfCycle(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
564 TObjArray **arr=qadm->Init(AliQA::kRECPOINTS);
565 AliTracker::SetResidualsArray(arr);
568 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
569 qadm->StartOfCycle(AliQA::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
570 qadm->Init(AliQA::kESDS);
572 AliSysInfo::AddStamp("InitQA");
576 //_____________________________________________________________________________
577 void AliReconstruction::InitCDB()
579 // activate a default CDB storage
580 // First check if we have any CDB storage set, because it is used
581 // to retrieve the calibration and alignment constants
582 AliCodeTimerAuto("");
584 if (fInitCDBCalled) return;
585 fInitCDBCalled = kTRUE;
587 AliCDBManager* man = AliCDBManager::Instance();
588 if (man->IsDefaultStorageSet())
590 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
591 AliWarning("Default CDB storage has been already set !");
592 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
593 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
594 fCDBUri = man->GetDefaultStorage()->GetURI();
597 if (fCDBUri.Length() > 0)
599 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
600 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
601 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
603 fCDBUri="local://$ALICE_ROOT/OCDB";
604 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
605 AliWarning("Default CDB storage not yet set !!!!");
606 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
607 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
610 man->SetDefaultStorage(fCDBUri);
613 // Now activate the detector specific CDB storage locations
614 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
615 TObject* obj = fSpecCDBUri[i];
617 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
618 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
619 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
620 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
622 AliSysInfo::AddStamp("InitCDB");
625 //_____________________________________________________________________________
626 void AliReconstruction::SetDefaultStorage(const char* uri) {
627 // Store the desired default CDB storage location
628 // Activate it later within the Run() method
634 //_____________________________________________________________________________
635 void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
636 // Store the desired default CDB storage location
637 // Activate it later within the Run() method
640 AliQA::SetQARefStorage(fQARefUri.Data()) ;
643 //_____________________________________________________________________________
644 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
645 // Store a detector-specific CDB storage location
646 // Activate it later within the Run() method
648 AliCDBPath aPath(calibType);
649 if(!aPath.IsValid()){
650 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
651 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
652 if(!strcmp(calibType, fgkDetectorName[iDet])) {
653 aPath.SetPath(Form("%s/*", calibType));
654 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
658 if(!aPath.IsValid()){
659 AliError(Form("Not a valid path or detector: %s", calibType));
664 // // check that calibType refers to a "valid" detector name
665 // Bool_t isDetector = kFALSE;
666 // for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
667 // TString detName = fgkDetectorName[iDet];
668 // if(aPath.GetLevel0() == detName) {
669 // isDetector = kTRUE;
675 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
679 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
680 if (obj) fSpecCDBUri.Remove(obj);
681 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
685 //_____________________________________________________________________________
686 Bool_t AliReconstruction::SetRunNumberFromData()
688 // The method is called in Run() in order
689 // to set a correct run number.
690 // In case of raw data reconstruction the
691 // run number is taken from the raw data header
693 if (fSetRunNumberFromDataCalled) return kTRUE;
694 fSetRunNumberFromDataCalled = kTRUE;
696 AliCDBManager* man = AliCDBManager::Instance();
699 if(fRawReader->NextEvent()) {
700 if(man->GetRun() > 0) {
701 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
703 man->SetRun(fRawReader->GetRunNumber());
704 fRawReader->RewindEvents();
707 if(man->GetRun() > 0) {
708 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
711 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
717 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
719 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
724 // read run number from gAlice
725 if(rl->GetHeader()) {
726 man->SetRun(rl->GetHeader()->GetRun());
731 AliError("Neither run-loader header nor RawReader objects are found !");
743 //_____________________________________________________________________________
744 void AliReconstruction::SetCDBLock() {
745 // Set CDB lock: from now on it is forbidden to reset the run number
746 // or the default storage or to activate any further storage!
748 AliCDBManager::Instance()->SetLock(1);
751 //_____________________________________________________________________________
752 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
754 // Read the alignment objects from CDB.
755 // Each detector is supposed to have the
756 // alignment objects in DET/Align/Data CDB path.
757 // All the detector objects are then collected,
758 // sorted by geometry level (starting from ALIC) and
759 // then applied to the TGeo geometry.
760 // Finally an overlaps check is performed.
762 // Load alignment data from CDB and fill fAlignObjArray
763 if(fLoadAlignFromCDB){
765 TString detStr = detectors;
766 TString loadAlObjsListOfDets = "";
768 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
769 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
770 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
772 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
774 loadAlObjsListOfDets += fgkDetectorName[iDet];
775 loadAlObjsListOfDets += " ";
777 } // end loop over detectors
779 if(AliGeomManager::GetNalignable("GRP") != 0)
780 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
781 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
782 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
784 // Check if the array with alignment objects was
785 // provided by the user. If yes, apply the objects
786 // to the present TGeo geometry
787 if (fAlignObjArray) {
788 if (gGeoManager && gGeoManager->IsClosed()) {
789 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
790 AliError("The misalignment of one or more volumes failed!"
791 "Compare the list of simulated detectors and the list of detector alignment data!");
796 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
802 if (fAlignObjArray) {
803 fAlignObjArray->Delete();
804 delete fAlignObjArray; fAlignObjArray=NULL;
810 //_____________________________________________________________________________
811 void AliReconstruction::SetGAliceFile(const char* fileName)
813 // set the name of the galice file
815 fGAliceFileName = fileName;
818 //_____________________________________________________________________________
819 void AliReconstruction::SetInput(const char* input)
821 // In case the input string starts with 'mem://', we run in an online mode
822 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
823 // file is assumed. One can give as an input:
824 // mem://: - events taken from DAQ monitoring libs online
826 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
827 if (input) fRawInput = input;
830 //_____________________________________________________________________________
831 void AliReconstruction::SetOption(const char* detector, const char* option)
833 // set options for the reconstruction of a detector
835 TObject* obj = fOptions.FindObject(detector);
836 if (obj) fOptions.Remove(obj);
837 fOptions.Add(new TNamed(detector, option));
840 //_____________________________________________________________________________
841 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
843 // Set custom reconstruction parameters for a given detector
844 // Single set of parameters for all the events
846 // First check if the reco-params are global
847 if(!strcmp(detector, "GRP")) {
849 fRecoParam.AddDetRecoParam(kNDetectors,par);
853 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
854 if(!strcmp(detector, fgkDetectorName[iDet])) {
856 fRecoParam.AddDetRecoParam(iDet,par);
863 //_____________________________________________________________________________
864 Bool_t AliReconstruction::SetFieldMap(Float_t l3Cur, Float_t diCur, Float_t l3Pol,
865 Float_t diPol, Float_t beamenergy,
866 const Char_t *beamtype, const Char_t *path)
868 //------------------------------------------------
869 // The magnetic field map, defined externally...
870 // L3 current 30000 A -> 0.5 T
871 // L3 current 12000 A -> 0.2 T
872 // dipole current 6000 A
873 // The polarities must be the same
874 //------------------------------------------------
875 const Float_t l3NominalCurrent1=30000.; // (A)
876 const Float_t l3NominalCurrent2=12000.; // (A)
877 const Float_t diNominalCurrent =6000. ; // (A)
879 const Float_t tolerance=0.03; // relative current tolerance
880 const Float_t zero=77.; // "zero" current (A)
882 TString s=(l3Pol < 0) ? "L3: -" : "L3: +";
884 AliMagF::BMap_t map = AliMagF::k5kG;
888 l3Cur = TMath::Abs(l3Cur);
889 if (TMath::Abs(l3Cur-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
890 fcL3 = l3Cur/l3NominalCurrent1;
893 } else if (TMath::Abs(l3Cur-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
894 fcL3 = l3Cur/l3NominalCurrent2;
897 } else if (l3Cur <= zero) {
899 map = AliMagF::k5kGUniform;
901 fUniformField=kTRUE; // track with the uniform (zero) B field
903 AliError(Form("Wrong L3 current (%f A)!",l3Cur));
907 diCur = TMath::Abs(diCur);
908 if (TMath::Abs(diCur-diNominalCurrent)/diNominalCurrent < tolerance) {
909 // 3% current tolerance...
910 fcDip = diCur/diNominalCurrent;
912 } else if (diCur <= zero) { // some small current..
916 AliError(Form("Wrong dipole current (%f A)!",diCur));
920 if (l3Pol!=diPol && (map==AliMagF::k5kG || map==AliMagF::k2kG) && fcDip!=0) {
921 AliError("L3 and Dipole polarities must be the same");
925 if (l3Pol<0) fcL3 = -fcL3;
926 if (diPol<0) fcDip = -fcDip;
928 AliMagF::BeamType_t btype = AliMagF::kNoBeamField;
929 TString btypestr = beamtype;
931 TPRegexp protonBeam("(proton|p)\\s*-?\\s*\\1");
932 TPRegexp ionBeam("(lead|pb|ion|a)\\s*-?\\s*\\1");
933 if (btypestr.Contains(ionBeam)) btype = AliMagF::kBeamTypeAA;
934 else if (btypestr.Contains(protonBeam)) btype = AliMagF::kBeamTypepp;
936 AliInfo(Form("Cannot determine the beam type from %s, assume no LHC magnet field",beamtype));
939 AliMagF* fld = new AliMagF("MagneticFieldMap", s.Data(), 2, fcL3, fcDip, 10., map, path,
941 TGeoGlobalMagField::Instance()->SetField( fld );
942 TGeoGlobalMagField::Instance()->Lock();
948 Bool_t AliReconstruction::InitGRP() {
949 //------------------------------------
950 // Initialization of the GRP entry
951 //------------------------------------
952 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
956 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
959 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
961 fGRPData = new AliGRPObject();
962 fGRPData->ReadValuesFromMap(m);
966 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
967 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
971 AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
975 AliError("No GRP entry found in OCDB!");
979 TString lhcState = fGRPData->GetLHCState();
980 if (lhcState==AliGRPObject::GetInvalidString()) {
981 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
982 lhcState = "UNKNOWN";
985 TString beamType = fGRPData->GetBeamType();
986 if (beamType==AliGRPObject::GetInvalidString()) {
987 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
988 beamType = "UNKNOWN";
991 Float_t beamEnergy = fGRPData->GetBeamEnergy();
992 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
993 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
996 // energy is provided in MeV*120
999 TString runType = fGRPData->GetRunType();
1000 if (runType==AliGRPObject::GetInvalidString()) {
1001 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
1002 runType = "UNKNOWN";
1005 Int_t activeDetectors = fGRPData->GetDetectorMask();
1006 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
1007 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
1008 activeDetectors = 1074790399;
1011 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
1015 // Process the list of active detectors
1016 if (activeDetectors) {
1017 UInt_t detMask = activeDetectors;
1018 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
1019 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1020 fFillESD = MatchDetectorList(fFillESD,detMask);
1021 fQADetectors = MatchDetectorList(fQADetectors,detMask);
1022 fLoadCDB.Form("%s %s %s %s",
1023 fRunLocalReconstruction.Data(),
1024 fRunTracking.Data(),
1026 fQADetectors.Data());
1027 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
1028 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1)) {
1029 // switch off the vertexer
1030 AliInfo("SPD is not in the list of active detectors. Vertexer switched off.");
1031 fRunVertexFinder = kFALSE;
1033 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1034 // switch off the reading of CTP raw-data payload
1035 if (fFillTriggerESD) {
1036 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1037 fFillTriggerESD = kFALSE;
1042 AliInfo("===================================================================================");
1043 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1044 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1045 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
1046 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
1047 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
1048 AliInfo("===================================================================================");
1050 //*** Dealing with the magnetic field map
1051 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {AliInfo("Running with the externally locked B field !");}
1053 // Construct the field map out of the information retrieved from GRP.
1056 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1057 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1058 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1062 Char_t l3Polarity = fGRPData->GetL3Polarity();
1063 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1064 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1069 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1070 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1071 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1075 Char_t diPolarity = fGRPData->GetDipolePolarity();
1076 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1077 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1082 TObjString *l3Current=
1083 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
1085 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1088 TObjString *l3Polarity=
1089 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
1091 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1096 TObjString *diCurrent=
1097 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
1099 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1102 TObjString *diPolarity=
1103 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
1105 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1111 if ( !SetFieldMap(l3Current, diCurrent, l3Polarity ? -1:1, diPolarity ? -1:1) )
1112 AliFatal("Failed to creat a B field map ! Exiting...");
1113 AliInfo("Running with the B field constructed out of GRP !");
1115 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1119 //*** Get the diamond profiles from OCDB
1120 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1122 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1124 AliError("No SPD diamond profile found in OCDB!");
1127 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1129 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1131 AliError("No diamond profile found in OCDB!");
1134 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1136 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1138 AliError("No TPC diamond profile found in OCDB!");
1144 //_____________________________________________________________________________
1145 Bool_t AliReconstruction::LoadCDB()
1147 AliCodeTimerAuto("");
1149 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1151 TString detStr = fLoadCDB;
1152 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1153 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1154 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1159 //_____________________________________________________________________________
1160 Bool_t AliReconstruction::Run(const char* input)
1163 AliCodeTimerAuto("");
1166 if (GetAbort() != TSelector::kContinue) return kFALSE;
1168 TChain *chain = NULL;
1169 if (fRawReader && (chain = fRawReader->GetChain())) {
1172 gProof->AddInput(this);
1174 outputFile.SetProtocol("root",kTRUE);
1175 outputFile.SetHost(gSystem->HostName());
1176 outputFile.SetFile(Form("%s/AliESDs.root",gSystem->pwd()));
1177 AliInfo(Form("Output file with ESDs is %s",outputFile.GetUrl()));
1178 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.GetUrl()));
1180 chain->Process("AliReconstruction");
1183 chain->Process(this);
1188 if (GetAbort() != TSelector::kContinue) return kFALSE;
1190 if (GetAbort() != TSelector::kContinue) return kFALSE;
1191 //******* The loop over events
1192 AliInfo("Starting looping over events");
1194 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1195 (fRawReader && fRawReader->NextEvent())) {
1196 if (!ProcessEvent(iEvent)) {
1197 Abort("ProcessEvent",TSelector::kAbortFile);
1203 if (GetAbort() != TSelector::kContinue) return kFALSE;
1205 if (GetAbort() != TSelector::kContinue) return kFALSE;
1211 //_____________________________________________________________________________
1212 void AliReconstruction::InitRawReader(const char* input)
1214 AliCodeTimerAuto("");
1216 // Init raw-reader and
1217 // set the input in case of raw data
1218 if (input) fRawInput = input;
1219 fRawReader = AliRawReader::Create(fRawInput.Data());
1221 AliInfo("Reconstruction will run over digits");
1223 if (!fEquipIdMap.IsNull() && fRawReader)
1224 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1226 if (!fUseHLTData.IsNull()) {
1227 // create the RawReaderHLT which performs redirection of HLT input data for
1228 // the specified detectors
1229 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1231 fParentRawReader=fRawReader;
1232 fRawReader=pRawReader;
1234 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1237 AliSysInfo::AddStamp("CreateRawReader");
1240 //_____________________________________________________________________________
1241 void AliReconstruction::InitRun(const char* input)
1243 // Initialization of raw-reader,
1244 // run number, CDB etc.
1245 AliCodeTimerAuto("");
1246 AliSysInfo::AddStamp("Start");
1248 // Initialize raw-reader if any
1249 InitRawReader(input);
1251 // Initialize the CDB storage
1254 // Set run number in CDBManager (if it is not already set by the user)
1255 if (!SetRunNumberFromData()) {
1256 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1260 // Set CDB lock: from now on it is forbidden to reset the run number
1261 // or the default storage or to activate any further storage!
1266 //_____________________________________________________________________________
1267 void AliReconstruction::Begin(TTree *)
1269 // Initialize AlReconstruction before
1270 // going into the event loop
1271 // Should follow the TSelector convention
1272 // i.e. initialize only the object on the client side
1273 AliCodeTimerAuto("");
1275 AliReconstruction *reco = NULL;
1277 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1280 AliSysInfo::AddStamp("ReadInputInBegin");
1283 // Import ideal TGeo geometry and apply misalignment
1285 TString geom(gSystem->DirName(fGAliceFileName));
1286 geom += "/geometry.root";
1287 AliGeomManager::LoadGeometry(geom.Data());
1289 Abort("LoadGeometry", TSelector::kAbortProcess);
1292 AliSysInfo::AddStamp("LoadGeom");
1293 TString detsToCheck=fRunLocalReconstruction;
1294 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1295 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1298 AliSysInfo::AddStamp("CheckGeom");
1301 if (!MisalignGeometry(fLoadAlignData)) {
1302 Abort("MisalignGeometry", TSelector::kAbortProcess);
1305 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1306 AliSysInfo::AddStamp("MisalignGeom");
1309 Abort("InitGRP", TSelector::kAbortProcess);
1312 AliSysInfo::AddStamp("InitGRP");
1315 Abort("LoadCDB", TSelector::kAbortProcess);
1318 AliSysInfo::AddStamp("LoadCDB");
1320 // Read the reconstruction parameters from OCDB
1321 if (!InitRecoParams()) {
1322 AliWarning("Not all detectors have correct RecoParam objects initialized");
1324 AliSysInfo::AddStamp("InitRecoParams");
1326 if (fInput && gProof) {
1327 if (reco) *reco = *this;
1329 gProof->AddInputData(gGeoManager,kTRUE);
1331 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
1332 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1333 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1334 magFieldMap->SetName("MagneticFieldMap");
1335 gProof->AddInputData(magFieldMap,kTRUE);
1340 //_____________________________________________________________________________
1341 void AliReconstruction::SlaveBegin(TTree*)
1343 // Initialization related to run-loader,
1344 // vertexer, trackers, recontructors
1345 // In proof mode it is executed on the slave
1346 AliCodeTimerAuto("");
1348 TProofOutputFile *outProofFile = NULL;
1350 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1353 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1355 AliGeomManager::SetGeometry(tgeo);
1357 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1358 Int_t runNumber = -1;
1359 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1360 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1361 man->SetCacheFlag(kTRUE);
1362 man->SetLock(kTRUE);
1366 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1367 TGeoGlobalMagField::Instance()->SetField(map);
1369 if (TNamed *outputFileName = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE")) {
1370 outProofFile = new TProofOutputFile(gSystem->BaseName(TUrl(outputFileName->GetTitle()).GetFile()));
1371 outProofFile->SetOutputFileName(outputFileName->GetTitle());
1372 fOutput->Add(outProofFile);
1374 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1377 // get the run loader
1378 if (!InitRunLoader()) {
1379 Abort("InitRunLoader", TSelector::kAbortProcess);
1382 AliSysInfo::AddStamp("LoadLoader");
1384 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1387 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1388 Abort("CreateTrackers", TSelector::kAbortProcess);
1391 AliSysInfo::AddStamp("CreateTrackers");
1393 // create the ESD output file and tree
1394 if (!outProofFile) {
1395 ffile = TFile::Open("AliESDs.root", "RECREATE");
1396 ffile->SetCompressionLevel(2);
1397 if (!ffile->IsOpen()) {
1398 Abort("OpenESDFile", TSelector::kAbortProcess);
1403 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1404 Abort(Form("Problems opening output PROOF file: %s/%s",
1405 outProofFile->GetDir(), outProofFile->GetFileName()),
1406 TSelector::kAbortProcess);
1411 ftree = new TTree("esdTree", "Tree with ESD objects");
1412 fesd = new AliESDEvent();
1413 fesd->CreateStdContent();
1415 fesd->WriteToTree(ftree);
1416 if (fWriteESDfriend) {
1418 // Since we add the branch manually we must
1419 // book and add it after WriteToTree
1420 // otherwise it is created twice,
1421 // once via writetotree and once here.
1422 // The case for AliESDfriend is now
1423 // caught also in AlIESDEvent::WriteToTree but
1424 // be careful when changing the name (AliESDfriend is not
1425 // a TNamed so we had to hardwire it)
1426 fesdf = new AliESDfriend();
1427 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1428 br->SetFile("AliESDfriends.root");
1429 fesd->AddObject(fesdf);
1431 ftree->GetUserInfo()->Add(fesd);
1433 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1434 fhltesd = new AliESDEvent();
1435 fhltesd->CreateStdContent();
1437 // read the ESD template from CDB
1438 // HLT is allowed to put non-std content to its ESD, the non-std
1439 // objects need to be created before invocation of WriteToTree in
1440 // order to create all branches. Initialization is done from an
1441 // ESD layout template in CDB
1442 AliCDBManager* man = AliCDBManager::Instance();
1443 AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
1444 AliCDBEntry* hltESDConfig=NULL;
1445 if (man->GetId(hltESDConfigPath)!=NULL &&
1446 (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
1447 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1449 // init all internal variables from the list of objects
1450 pESDLayout->GetStdContent();
1452 // copy content and create non-std objects
1453 *fhltesd=*pESDLayout;
1456 AliError(Form("error setting hltEsd layout from %s: invalid object type",
1457 hltESDConfigPath.GetPath().Data()));
1461 fhltesd->WriteToTree(fhlttree);
1462 fhlttree->GetUserInfo()->Add(fhltesd);
1464 ProcInfo_t procInfo;
1465 gSystem->GetProcInfo(&procInfo);
1466 AliInfo(Form("Current memory usage %d %d", procInfo.fMemResident, procInfo.fMemVirtual));
1469 //Initialize the QA and start of cycle
1470 if (fRunQA || fRunGlobalQA)
1473 //Initialize the Plane Efficiency framework
1474 if (fRunPlaneEff && !InitPlaneEff()) {
1475 Abort("InitPlaneEff", TSelector::kAbortProcess);
1479 if (strcmp(gProgName,"alieve") == 0)
1480 fRunAliEVE = InitAliEVE();
1485 //_____________________________________________________________________________
1486 Bool_t AliReconstruction::Process(Long64_t entry)
1488 // run the reconstruction over a single entry
1489 // from the chain with raw data
1490 AliCodeTimerAuto("");
1492 TTree *currTree = fChain->GetTree();
1493 AliRawEvent *event = new AliRawEvent;
1494 currTree->SetBranchAddress("rawevent",&event);
1495 currTree->GetEntry(entry);
1496 fRawReader = new AliRawReaderRoot(event);
1497 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1505 //_____________________________________________________________________________
1506 void AliReconstruction::Init(TTree *tree)
1509 AliError("The input tree is not found!");
1515 //_____________________________________________________________________________
1516 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1518 // run the reconstruction over a single event
1519 // The event loop is steered in Run method
1521 AliCodeTimerAuto("");
1523 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1524 fRunLoader->SetEventNumber(iEvent);
1525 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1527 fRunLoader->TreeE()->Fill();
1528 if (fRawReader && fRawReader->UseAutoSaveESD())
1529 fRunLoader->TreeE()->AutoSave("SaveSelf");
1532 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1536 AliInfo(Form("processing event %d", iEvent));
1538 fRunLoader->GetEvent(iEvent);
1540 // Fill Event-info object
1542 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1543 AliInfo(Form("Current event specie: %s",fRecoParam.PrintEventSpecie()));
1545 // Set the reco-params
1547 TString detStr = fLoadCDB;
1548 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1549 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1550 AliReconstructor *reconstructor = GetReconstructor(iDet);
1551 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1552 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1553 reconstructor->SetRecoParam(par);
1555 fQAManager->SetRecoParam(iDet, par) ;
1563 fQAManager->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1564 fQAManager->RunOneEvent(fRawReader) ;
1566 // local single event reconstruction
1567 if (!fRunLocalReconstruction.IsNull()) {
1568 TString detectors=fRunLocalReconstruction;
1569 // run HLT event reconstruction first
1570 // ;-( IsSelected changes the string
1571 if (IsSelected("HLT", detectors) &&
1572 !RunLocalEventReconstruction("HLT")) {
1573 if (fStopOnError) {CleanUp(); return kFALSE;}
1575 detectors=fRunLocalReconstruction;
1576 detectors.ReplaceAll("HLT", "");
1577 if (!RunLocalEventReconstruction(detectors)) {
1578 if (fStopOnError) {CleanUp(); return kFALSE;}
1582 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1583 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1584 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1585 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1587 // Set magnetic field from the tracker
1588 fesd->SetMagneticField(AliTracker::GetBz());
1589 fhltesd->SetMagneticField(AliTracker::GetBz());
1591 // Set most probable pt, for B=0 tracking
1592 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
1593 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
1594 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
1596 // Fill raw-data error log into the ESD
1597 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1600 if (fRunVertexFinder) {
1601 if (!RunVertexFinder(fesd)) {
1602 if (fStopOnError) {CleanUp(); return kFALSE;}
1607 if (!fRunTracking.IsNull()) {
1608 if (fRunMuonTracking) {
1609 if (!RunMuonTracking(fesd)) {
1610 if (fStopOnError) {CleanUp(); return kFALSE;}
1616 if (!fRunTracking.IsNull()) {
1617 if (!RunTracking(fesd)) {
1618 if (fStopOnError) {CleanUp(); return kFALSE;}
1623 if (!fFillESD.IsNull()) {
1624 TString detectors=fFillESD;
1625 // run HLT first and on hltesd
1626 // ;-( IsSelected changes the string
1627 if (IsSelected("HLT", detectors) &&
1628 !FillESD(fhltesd, "HLT")) {
1629 if (fStopOnError) {CleanUp(); return kFALSE;}
1632 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1633 if (detectors.Contains("ALL")) {
1635 for (Int_t idet=0; idet<kNDetectors; ++idet){
1636 detectors += fgkDetectorName[idet];
1640 detectors.ReplaceAll("HLT", "");
1641 if (!FillESD(fesd, detectors)) {
1642 if (fStopOnError) {CleanUp(); return kFALSE;}
1646 // fill Event header information from the RawEventHeader
1647 if (fRawReader){FillRawEventHeaderESD(fesd);}
1650 AliESDpid::MakePID(fesd);
1652 if (fFillTriggerESD) {
1653 if (!FillTriggerESD(fesd)) {
1654 if (fStopOnError) {CleanUp(); return kFALSE;}
1661 // Propagate track to the beam pipe (if not already done by ITS)
1663 const Int_t ntracks = fesd->GetNumberOfTracks();
1664 const Double_t kBz = fesd->GetMagneticField();
1665 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1668 UShort_t *selectedIdx=new UShort_t[ntracks];
1670 for (Int_t itrack=0; itrack<ntracks; itrack++){
1671 const Double_t kMaxStep = 1; //max step over the material
1674 AliESDtrack *track = fesd->GetTrack(itrack);
1675 if (!track) continue;
1677 AliExternalTrackParam *tpcTrack =
1678 (AliExternalTrackParam *)track->GetTPCInnerParam();
1682 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
1685 Int_t n=trkArray.GetEntriesFast();
1686 selectedIdx[n]=track->GetID();
1687 trkArray.AddLast(tpcTrack);
1690 //Tracks refitted by ITS should already be at the SPD vertex
1691 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1694 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
1695 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1700 // Improve the reconstructed primary vertex position using the tracks
1702 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1703 if(fesd->GetPrimaryVertexSPD()) {
1704 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1705 if(vtitle.Contains("cosmics")) {
1706 runVertexFinderTracks=kFALSE;
1710 if (runVertexFinderTracks) {
1711 // TPC + ITS primary vertex
1712 ftVertexer->SetITSMode();
1713 ftVertexer->SetConstraintOff();
1714 // get cuts for vertexer from AliGRPRecoParam
1716 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1717 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1718 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
1719 ftVertexer->SetCuts(cutsVertexer);
1720 delete [] cutsVertexer; cutsVertexer = NULL;
1721 if(fDiamondProfile && grpRecoParam->GetVertexerTracksConstraintITS())
1722 ftVertexer->SetVtxStart(fDiamondProfile);
1724 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1726 if (pvtx->GetStatus()) {
1727 fesd->SetPrimaryVertexTracks(pvtx);
1728 for (Int_t i=0; i<ntracks; i++) {
1729 AliESDtrack *t = fesd->GetTrack(i);
1730 t->RelateToVertex(pvtx, kBz, kVeryBig);
1735 // TPC-only primary vertex
1736 ftVertexer->SetTPCMode();
1737 ftVertexer->SetConstraintOff();
1738 // get cuts for vertexer from AliGRPRecoParam
1740 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1741 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1742 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
1743 ftVertexer->SetCuts(cutsVertexer);
1744 delete [] cutsVertexer; cutsVertexer = NULL;
1745 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC())
1746 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1748 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1750 if (pvtx->GetStatus()) {
1751 fesd->SetPrimaryVertexTPC(pvtx);
1752 for (Int_t i=0; i<ntracks; i++) {
1753 AliESDtrack *t = fesd->GetTrack(i);
1754 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1760 delete[] selectedIdx;
1762 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1767 AliV0vertexer vtxer;
1768 vtxer.Tracks2V0vertices(fesd);
1770 if (fRunCascadeFinder) {
1772 AliCascadeVertexer cvtxer;
1773 cvtxer.V0sTracks2CascadeVertices(fesd);
1778 if (fCleanESD) CleanESD(fesd);
1781 fQAManager->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1782 fQAManager->RunOneEvent(fesd) ;
1785 AliQADataMaker *qadm = fQAManager->GetQADataMaker(AliQA::kGLOBAL);
1786 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1787 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1788 qadm->Exec(AliQA::kESDS, fesd);
1791 if (fWriteESDfriend) {
1792 // fesdf->~AliESDfriend();
1793 // new (fesdf) AliESDfriend(); // Reset...
1794 fesd->GetESDfriend(fesdf);
1798 // Auto-save the ESD tree in case of prompt reco @P2
1799 if (fRawReader && fRawReader->UseAutoSaveESD()) {
1800 ftree->AutoSave("SaveSelf");
1801 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1802 if (friendfile) friendfile->Save();
1809 if (fRunAliEVE) RunAliEVE();
1813 if (fWriteESDfriend) {
1814 fesdf->~AliESDfriend();
1815 new (fesdf) AliESDfriend(); // Reset...
1818 ProcInfo_t procInfo;
1819 gSystem->GetProcInfo(&procInfo);
1820 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, procInfo.fMemResident, procInfo.fMemVirtual));
1823 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1824 if (fReconstructor[iDet])
1825 fReconstructor[iDet]->SetRecoParam(NULL);
1828 if (fRunQA || fRunGlobalQA)
1829 fQAManager->Increment() ;
1834 //_____________________________________________________________________________
1835 void AliReconstruction::SlaveTerminate()
1837 // Finalize the run on the slave side
1838 // Called after the exit
1839 // from the event loop
1840 AliCodeTimerAuto("");
1842 if (fIsNewRunLoader) { // galice.root didn't exist
1843 fRunLoader->WriteHeader("OVERWRITE");
1844 fRunLoader->CdGAFile();
1845 fRunLoader->Write(0, TObject::kOverwrite);
1848 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1849 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1851 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1852 cdbMapCopy->SetOwner(1);
1853 cdbMapCopy->SetName("cdbMap");
1854 TIter iter(cdbMap->GetTable());
1857 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1858 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1859 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1860 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1863 TList *cdbListCopy = new TList();
1864 cdbListCopy->SetOwner(1);
1865 cdbListCopy->SetName("cdbList");
1867 TIter iter2(cdbList);
1870 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1871 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1874 ftree->GetUserInfo()->Add(cdbMapCopy);
1875 ftree->GetUserInfo()->Add(cdbListCopy);
1880 if (fWriteESDfriend)
1881 ftree->SetBranchStatus("ESDfriend*",0);
1882 // we want to have only one tree version number
1883 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1886 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
1887 if (fRunPlaneEff && !FinishPlaneEff()) {
1888 AliWarning("Finish PlaneEff evaluation failed");
1891 // End of cycle for the in-loop
1893 fQAManager->EndOfCycle() ;
1896 AliQADataMaker *qadm = fQAManager->GetQADataMaker(AliQA::kGLOBAL);
1898 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1899 qadm->EndOfCycle(AliQA::kRECPOINTS);
1900 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1901 qadm->EndOfCycle(AliQA::kESDS);
1909 //_____________________________________________________________________________
1910 void AliReconstruction::Terminate()
1912 // Create tags for the events in the ESD tree (the ESD tree is always present)
1913 // In case of empty events the tags will contain dummy values
1914 AliCodeTimerAuto("");
1916 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1917 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQA::Instance()->GetQA(), AliQA::Instance()->GetEventSpecies(), AliQA::kNDET, AliRecoParam::kNSpecies);
1919 // Cleanup of CDB manager: cache and active storages!
1920 AliCDBManager::Instance()->ClearCache();
1923 //_____________________________________________________________________________
1924 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1926 // run the local reconstruction
1928 static Int_t eventNr=0;
1929 AliCodeTimerAuto("")
1931 TString detStr = detectors;
1932 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1933 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1934 AliReconstructor* reconstructor = GetReconstructor(iDet);
1935 if (!reconstructor) continue;
1936 AliLoader* loader = fLoader[iDet];
1937 // Matthias April 2008: temporary fix to run HLT reconstruction
1938 // although the HLT loader is missing
1939 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1941 reconstructor->Reconstruct(fRawReader, NULL);
1944 reconstructor->Reconstruct(dummy, NULL);
1949 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1952 // conversion of digits
1953 if (fRawReader && reconstructor->HasDigitConversion()) {
1954 AliInfo(Form("converting raw data digits into root objects for %s",
1955 fgkDetectorName[iDet]));
1956 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1957 // fgkDetectorName[iDet]));
1958 loader->LoadDigits("update");
1959 loader->CleanDigits();
1960 loader->MakeDigitsContainer();
1961 TTree* digitsTree = loader->TreeD();
1962 reconstructor->ConvertDigits(fRawReader, digitsTree);
1963 loader->WriteDigits("OVERWRITE");
1964 loader->UnloadDigits();
1966 // local reconstruction
1967 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1968 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1969 loader->LoadRecPoints("update");
1970 loader->CleanRecPoints();
1971 loader->MakeRecPointsContainer();
1972 TTree* clustersTree = loader->TreeR();
1973 if (fRawReader && !reconstructor->HasDigitConversion()) {
1974 reconstructor->Reconstruct(fRawReader, clustersTree);
1976 loader->LoadDigits("read");
1977 TTree* digitsTree = loader->TreeD();
1979 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1980 if (fStopOnError) return kFALSE;
1982 reconstructor->Reconstruct(digitsTree, clustersTree);
1984 loader->UnloadDigits();
1987 TString detQAStr(fQADetectors) ;
1989 fQAManager->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1990 fQAManager->RunOneEventInOneDetector(iDet, clustersTree) ;
1992 loader->WriteRecPoints("OVERWRITE");
1993 loader->UnloadRecPoints();
1994 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1996 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1997 AliError(Form("the following detectors were not found: %s",
1999 if (fStopOnError) return kFALSE;
2005 //_____________________________________________________________________________
2006 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
2008 // run the barrel tracking
2010 AliCodeTimerAuto("")
2012 AliVertexer *vertexer = CreateVertexer();
2013 if (!vertexer) return kFALSE;
2015 AliInfo("running the ITS vertex finder");
2016 AliESDVertex* vertex = NULL;
2018 fLoader[0]->LoadRecPoints();
2019 TTree* cltree = fLoader[0]->TreeR();
2021 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2022 vertex = vertexer->FindVertexForCurrentEvent(cltree);
2025 AliError("Can't get the ITS cluster tree");
2027 fLoader[0]->UnloadRecPoints();
2030 AliError("Can't get the ITS loader");
2033 AliWarning("Vertex not found");
2034 vertex = new AliESDVertex();
2035 vertex->SetName("default");
2038 vertex->SetName("reconstructed");
2043 vertex->GetXYZ(vtxPos);
2044 vertex->GetSigmaXYZ(vtxErr);
2046 esd->SetPrimaryVertexSPD(vertex);
2047 // if SPD multiplicity has been determined, it is stored in the ESD
2048 AliMultiplicity *mult = vertexer->GetMultiplicity();
2049 if(mult)esd->SetMultiplicity(mult);
2051 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2052 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2061 //_____________________________________________________________________________
2062 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
2064 // run the HLT barrel tracking
2066 AliCodeTimerAuto("")
2069 AliError("Missing runLoader!");
2073 AliInfo("running HLT tracking");
2075 // Get a pointer to the HLT reconstructor
2076 AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
2077 if (!reconstructor) return kFALSE;
2080 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2081 TString detName = fgkDetectorName[iDet];
2082 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2083 reconstructor->SetOption(detName.Data());
2084 AliTracker *tracker = reconstructor->CreateTracker();
2086 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2087 if (fStopOnError) return kFALSE;
2091 Double_t vtxErr[3]={0.005,0.005,0.010};
2092 const AliESDVertex *vertex = esd->GetVertex();
2093 vertex->GetXYZ(vtxPos);
2094 tracker->SetVertex(vtxPos,vtxErr);
2096 fLoader[iDet]->LoadRecPoints("read");
2097 TTree* tree = fLoader[iDet]->TreeR();
2099 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2102 tracker->LoadClusters(tree);
2104 if (tracker->Clusters2Tracks(esd) != 0) {
2105 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2109 tracker->UnloadClusters();
2117 //_____________________________________________________________________________
2118 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2120 // run the muon spectrometer tracking
2122 AliCodeTimerAuto("")
2125 AliError("Missing runLoader!");
2128 Int_t iDet = 7; // for MUON
2130 AliInfo("is running...");
2132 // Get a pointer to the MUON reconstructor
2133 AliReconstructor *reconstructor = GetReconstructor(iDet);
2134 if (!reconstructor) return kFALSE;
2137 TString detName = fgkDetectorName[iDet];
2138 AliDebug(1, Form("%s tracking", detName.Data()));
2139 AliTracker *tracker = reconstructor->CreateTracker();
2141 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2146 fLoader[iDet]->LoadRecPoints("read");
2148 tracker->LoadClusters(fLoader[iDet]->TreeR());
2150 Int_t rv = tracker->Clusters2Tracks(esd);
2154 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2158 fLoader[iDet]->UnloadRecPoints();
2160 tracker->UnloadClusters();
2168 //_____________________________________________________________________________
2169 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
2171 // run the barrel tracking
2172 static Int_t eventNr=0;
2173 AliCodeTimerAuto("")
2175 AliInfo("running tracking");
2177 //Fill the ESD with the T0 info (will be used by the TOF)
2178 if (fReconstructor[11] && fLoader[11]) {
2179 fLoader[11]->LoadRecPoints("READ");
2180 TTree *treeR = fLoader[11]->TreeR();
2182 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2186 // pass 1: TPC + ITS inwards
2187 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2188 if (!fTracker[iDet]) continue;
2189 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2192 fLoader[iDet]->LoadRecPoints("read");
2193 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2194 TTree* tree = fLoader[iDet]->TreeR();
2196 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2199 fTracker[iDet]->LoadClusters(tree);
2200 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2202 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2203 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2206 // preliminary PID in TPC needed by the ITS tracker
2208 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2209 AliESDpid::MakePID(esd);
2211 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2214 // pass 2: ALL backwards
2216 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2217 if (!fTracker[iDet]) continue;
2218 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2221 if (iDet > 1) { // all except ITS, TPC
2223 fLoader[iDet]->LoadRecPoints("read");
2224 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2225 tree = fLoader[iDet]->TreeR();
2227 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2230 fTracker[iDet]->LoadClusters(tree);
2231 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2235 if (iDet>1) // start filling residuals for the "outer" detectors
2236 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2238 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2239 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
2244 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
2245 fTracker[iDet]->UnloadClusters();
2246 fLoader[iDet]->UnloadRecPoints();
2248 // updated PID in TPC needed by the ITS tracker -MI
2250 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2251 AliESDpid::MakePID(esd);
2253 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2255 //stop filling residuals for the "outer" detectors
2256 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
2258 // pass 3: TRD + TPC + ITS refit inwards
2260 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2261 if (!fTracker[iDet]) continue;
2262 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
2265 if (iDet<2) // start filling residuals for TPC and ITS
2266 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2268 if (fTracker[iDet]->RefitInward(esd) != 0) {
2269 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
2272 // run postprocessing
2273 if (fTracker[iDet]->PostProcess(esd) != 0) {
2274 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2277 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2280 // write space-points to the ESD in case alignment data output
2282 if (fWriteAlignmentData)
2283 WriteAlignmentData(esd);
2285 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2286 if (!fTracker[iDet]) continue;
2288 fTracker[iDet]->UnloadClusters();
2289 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
2290 fLoader[iDet]->UnloadRecPoints();
2291 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
2293 // stop filling residuals for TPC and ITS
2294 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
2300 //_____________________________________________________________________________
2301 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2303 // Remove the data which are not needed for the physics analysis.
2306 Int_t nTracks=esd->GetNumberOfTracks();
2307 Int_t nV0s=esd->GetNumberOfV0s();
2309 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
2311 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2312 Bool_t rc=esd->Clean(cleanPars);
2314 nTracks=esd->GetNumberOfTracks();
2315 nV0s=esd->GetNumberOfV0s();
2317 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2322 //_____________________________________________________________________________
2323 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2325 // fill the event summary data
2327 AliCodeTimerAuto("")
2328 static Int_t eventNr=0;
2329 TString detStr = detectors;
2331 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2332 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2333 AliReconstructor* reconstructor = GetReconstructor(iDet);
2334 if (!reconstructor) continue;
2335 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2336 TTree* clustersTree = NULL;
2337 if (fLoader[iDet]) {
2338 fLoader[iDet]->LoadRecPoints("read");
2339 clustersTree = fLoader[iDet]->TreeR();
2340 if (!clustersTree) {
2341 AliError(Form("Can't get the %s clusters tree",
2342 fgkDetectorName[iDet]));
2343 if (fStopOnError) return kFALSE;
2346 if (fRawReader && !reconstructor->HasDigitConversion()) {
2347 reconstructor->FillESD(fRawReader, clustersTree, esd);
2349 TTree* digitsTree = NULL;
2350 if (fLoader[iDet]) {
2351 fLoader[iDet]->LoadDigits("read");
2352 digitsTree = fLoader[iDet]->TreeD();
2354 AliError(Form("Can't get the %s digits tree",
2355 fgkDetectorName[iDet]));
2356 if (fStopOnError) return kFALSE;
2359 reconstructor->FillESD(digitsTree, clustersTree, esd);
2360 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2362 if (fLoader[iDet]) {
2363 fLoader[iDet]->UnloadRecPoints();
2367 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2368 AliError(Form("the following detectors were not found: %s",
2370 if (fStopOnError) return kFALSE;
2372 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2377 //_____________________________________________________________________________
2378 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2380 // Reads the trigger decision which is
2381 // stored in Trigger.root file and fills
2382 // the corresponding esd entries
2384 AliCodeTimerAuto("")
2386 AliInfo("Filling trigger information into the ESD");
2389 AliCTPRawStream input(fRawReader);
2390 if (!input.Next()) {
2391 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2394 if (esd->GetTriggerMask() != input.GetClassMask())
2395 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2396 input.GetClassMask(),esd->GetTriggerMask()));
2397 if (esd->GetOrbitNumber() != input.GetOrbitID())
2398 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2399 input.GetOrbitID(),esd->GetOrbitNumber()));
2400 if (esd->GetBunchCrossNumber() != input.GetBCID())
2401 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2402 input.GetBCID(),esd->GetBunchCrossNumber()));
2405 // Here one has to add the filling of trigger inputs and
2406 // interaction records
2416 //_____________________________________________________________________________
2417 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2420 // Filling information from RawReader Header
2423 if (!fRawReader) return kFALSE;
2425 AliInfo("Filling information from RawReader Header");
2427 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2428 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2429 esd->SetPeriodNumber(fRawReader->GetPeriod());
2431 esd->SetTimeStamp(fRawReader->GetTimestamp());
2432 esd->SetEventType(fRawReader->GetType());
2438 //_____________________________________________________________________________
2439 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2441 // check whether detName is contained in detectors
2442 // if yes, it is removed from detectors
2444 // check if all detectors are selected
2445 if ((detectors.CompareTo("ALL") == 0) ||
2446 detectors.BeginsWith("ALL ") ||
2447 detectors.EndsWith(" ALL") ||
2448 detectors.Contains(" ALL ")) {
2453 // search for the given detector
2454 Bool_t result = kFALSE;
2455 if ((detectors.CompareTo(detName) == 0) ||
2456 detectors.BeginsWith(detName+" ") ||
2457 detectors.EndsWith(" "+detName) ||
2458 detectors.Contains(" "+detName+" ")) {
2459 detectors.ReplaceAll(detName, "");
2463 // clean up the detectors string
2464 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2465 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2466 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2471 //_____________________________________________________________________________
2472 Bool_t AliReconstruction::InitRunLoader()
2474 // get or create the run loader
2476 if (gAlice) delete gAlice;
2479 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2480 // load all base libraries to get the loader classes
2481 TString libs = gSystem->GetLibraries();
2482 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2483 TString detName = fgkDetectorName[iDet];
2484 if (detName == "HLT") continue;
2485 if (libs.Contains("lib" + detName + "base.so")) continue;
2486 gSystem->Load("lib" + detName + "base.so");
2488 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2490 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2495 fRunLoader->CdGAFile();
2496 fRunLoader->LoadgAlice();
2498 //PH This is a temporary fix to give access to the kinematics
2499 //PH that is needed for the labels of ITS clusters
2500 fRunLoader->LoadHeader();
2501 fRunLoader->LoadKinematics();
2503 } else { // galice.root does not exist
2505 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2507 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2508 AliConfig::GetDefaultEventFolderName(),
2511 AliError(Form("could not create run loader in file %s",
2512 fGAliceFileName.Data()));
2516 fIsNewRunLoader = kTRUE;
2517 fRunLoader->MakeTree("E");
2519 if (fNumberOfEventsPerFile > 0)
2520 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2522 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2528 //_____________________________________________________________________________
2529 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2531 // get the reconstructor object and the loader for a detector
2533 if (fReconstructor[iDet]) {
2534 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2535 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2536 fReconstructor[iDet]->SetRecoParam(par);
2538 return fReconstructor[iDet];
2541 // load the reconstructor object
2542 TPluginManager* pluginManager = gROOT->GetPluginManager();
2543 TString detName = fgkDetectorName[iDet];
2544 TString recName = "Ali" + detName + "Reconstructor";
2546 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2548 AliReconstructor* reconstructor = NULL;
2549 // first check if a plugin is defined for the reconstructor
2550 TPluginHandler* pluginHandler =
2551 pluginManager->FindHandler("AliReconstructor", detName);
2552 // if not, add a plugin for it
2553 if (!pluginHandler) {
2554 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2555 TString libs = gSystem->GetLibraries();
2556 if (libs.Contains("lib" + detName + "base.so") ||
2557 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2558 pluginManager->AddHandler("AliReconstructor", detName,
2559 recName, detName + "rec", recName + "()");
2561 pluginManager->AddHandler("AliReconstructor", detName,
2562 recName, detName, recName + "()");
2564 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2566 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2567 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2569 if (reconstructor) {
2570 TObject* obj = fOptions.FindObject(detName.Data());
2571 if (obj) reconstructor->SetOption(obj->GetTitle());
2572 reconstructor->Init();
2573 fReconstructor[iDet] = reconstructor;
2576 // get or create the loader
2577 if (detName != "HLT") {
2578 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2579 if (!fLoader[iDet]) {
2580 AliConfig::Instance()
2581 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2583 // first check if a plugin is defined for the loader
2585 pluginManager->FindHandler("AliLoader", detName);
2586 // if not, add a plugin for it
2587 if (!pluginHandler) {
2588 TString loaderName = "Ali" + detName + "Loader";
2589 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2590 pluginManager->AddHandler("AliLoader", detName,
2591 loaderName, detName + "base",
2592 loaderName + "(const char*, TFolder*)");
2593 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2595 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2597 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2598 fRunLoader->GetEventFolder());
2600 if (!fLoader[iDet]) { // use default loader
2601 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2603 if (!fLoader[iDet]) {
2604 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2605 if (fStopOnError) return NULL;
2607 fRunLoader->AddLoader(fLoader[iDet]);
2608 fRunLoader->CdGAFile();
2609 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2610 fRunLoader->Write(0, TObject::kOverwrite);
2615 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2616 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2617 reconstructor->SetRecoParam(par);
2619 return reconstructor;
2622 //_____________________________________________________________________________
2623 AliVertexer* AliReconstruction::CreateVertexer()
2625 // create the vertexer
2626 // Please note that the caller is the owner of the
2629 AliVertexer* vertexer = NULL;
2630 AliReconstructor* itsReconstructor = GetReconstructor(0);
2631 if (itsReconstructor) {
2632 vertexer = itsReconstructor->CreateVertexer();
2635 AliWarning("couldn't create a vertexer for ITS");
2641 //_____________________________________________________________________________
2642 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2644 // create the trackers
2645 AliInfo("Creating trackers");
2647 TString detStr = detectors;
2648 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2649 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2650 AliReconstructor* reconstructor = GetReconstructor(iDet);
2651 if (!reconstructor) continue;
2652 TString detName = fgkDetectorName[iDet];
2653 if (detName == "HLT") {
2654 fRunHLTTracking = kTRUE;
2657 if (detName == "MUON") {
2658 fRunMuonTracking = kTRUE;
2663 fTracker[iDet] = reconstructor->CreateTracker();
2664 if (!fTracker[iDet] && (iDet < 7)) {
2665 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2666 if (fStopOnError) return kFALSE;
2668 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2674 //_____________________________________________________________________________
2675 void AliReconstruction::CleanUp()
2677 // delete trackers and the run loader and close and delete the file
2679 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2680 delete fReconstructor[iDet];
2681 fReconstructor[iDet] = NULL;
2682 fLoader[iDet] = NULL;
2683 delete fTracker[iDet];
2684 fTracker[iDet] = NULL;
2692 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2693 delete fDiamondProfileSPD;
2694 fDiamondProfileSPD = NULL;
2695 delete fDiamondProfile;
2696 fDiamondProfile = NULL;
2697 delete fDiamondProfileTPC;
2698 fDiamondProfileTPC = NULL;
2704 delete fParentRawReader;
2705 fParentRawReader=NULL;
2714 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2716 // Write space-points which are then used in the alignment procedures
2717 // For the moment only ITS, TPC, TRD and TOF
2719 Int_t ntracks = esd->GetNumberOfTracks();
2720 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2722 AliESDtrack *track = esd->GetTrack(itrack);
2725 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2726 nsp += track->GetNcls(iDet);
2728 if (iDet==0) { // ITS "extra" clusters
2729 track->GetClusters(iDet,idx);
2730 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2735 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2736 track->SetTrackPointArray(sp);
2738 for (Int_t iDet = 5; iDet >= 0; iDet--) {
2739 AliTracker *tracker = fTracker[iDet];
2740 if (!tracker) continue;
2741 Int_t nspdet = track->GetClusters(iDet,idx);
2743 if (iDet==0) // ITS "extra" clusters
2744 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2746 if (nspdet <= 0) continue;
2750 while (isp2 < nspdet) {
2751 Bool_t isvalid=kTRUE;
2753 Int_t index=idx[isp++];
2754 if (index < 0) continue;
2756 TString dets = fgkDetectorName[iDet];
2757 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2758 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2759 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2760 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2761 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2763 isvalid = tracker->GetTrackPoint(index,p);
2766 if (!isvalid) continue;
2767 if (iDet==0 && (isp-1)>=6) p.SetExtra();
2768 sp->AddPoint(isptrack,&p); isptrack++;
2775 //_____________________________________________________________________________
2776 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2778 // The method reads the raw-data error log
2779 // accumulated within the rawReader.
2780 // It extracts the raw-data errors related to
2781 // the current event and stores them into
2782 // a TClonesArray inside the esd object.
2784 if (!fRawReader) return;
2786 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2788 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2790 if (iEvent != log->GetEventNumber()) continue;
2792 esd->AddRawDataErrorLog(log);
2797 //_____________________________________________________________________________
2798 void AliReconstruction::CheckQA()
2800 // check the QA of SIM for this run and remove the detectors
2801 // with status Fatal
2803 // TString newRunLocalReconstruction ;
2804 // TString newRunTracking ;
2805 // TString newFillESD ;
2807 // for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2808 // TString detName(AliQA::GetDetName(iDet)) ;
2809 // AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2810 // if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, specie, AliQA::kFATAL)) {
2811 // AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
2812 // detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
2814 // if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2815 // fRunLocalReconstruction.Contains("ALL") ) {
2816 // newRunLocalReconstruction += detName ;
2817 // newRunLocalReconstruction += " " ;
2819 // if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2820 // fRunTracking.Contains("ALL") ) {
2821 // newRunTracking += detName ;
2822 // newRunTracking += " " ;
2824 // if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2825 // fFillESD.Contains("ALL") ) {
2826 // newFillESD += detName ;
2827 // newFillESD += " " ;
2831 // fRunLocalReconstruction = newRunLocalReconstruction ;
2832 // fRunTracking = newRunTracking ;
2833 // fFillESD = newFillESD ;
2836 //_____________________________________________________________________________
2837 Int_t AliReconstruction::GetDetIndex(const char* detector)
2839 // return the detector index corresponding to detector
2841 for (index = 0; index < kNDetectors ; index++) {
2842 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2847 //_____________________________________________________________________________
2848 Bool_t AliReconstruction::FinishPlaneEff() {
2850 // Here execute all the necessary operationis, at the end of the tracking phase,
2851 // in case that evaluation of PlaneEfficiencies was required for some detector.
2852 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2854 // This Preliminary version works only FOR ITS !!!!!
2855 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2858 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2861 //for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2862 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2863 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2864 if(fTracker[iDet]) {
2865 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2866 TString name=planeeff->GetName();
2868 TFile* pefile = TFile::Open(name, "RECREATE");
2869 ret=(Bool_t)planeeff->Write();
2871 if(planeeff->GetCreateHistos()) {
2872 TString hname=planeeff->GetName();
2873 hname+="Histo.root";
2874 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2880 //_____________________________________________________________________________
2881 Bool_t AliReconstruction::InitPlaneEff() {
2883 // Here execute all the necessary operations, before of the tracking phase,
2884 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2885 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2886 // which should be updated/recalculated.
2888 // This Preliminary version will work only FOR ITS !!!!!
2889 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2892 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2894 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2898 //_____________________________________________________________________________
2899 Bool_t AliReconstruction::InitAliEVE()
2901 // This method should be called only in case
2902 // AliReconstruction is run
2903 // within the alieve environment.
2904 // It will initialize AliEVE in a way
2905 // so that it can visualize event processed
2906 // by AliReconstruction.
2907 // The return flag shows whenever the
2908 // AliEVE initialization was successful or not.
2911 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2912 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2913 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2915 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
2916 gROOT->ProcessLine("alieve_online_init()");
2921 //_____________________________________________________________________________
2922 void AliReconstruction::RunAliEVE()
2924 // Runs AliEVE visualisation of
2925 // the current event.
2926 // Should be executed only after
2927 // successful initialization of AliEVE.
2929 AliInfo("Running AliEVE...");
2930 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)0x%lx,(AliRawReader*)0x%lx,(AliESDEvent*)0x%lx,(AliESDfriend*)0x%lx);",fRunLoader,fRawReader,fesd,fesdf));
2934 //_____________________________________________________________________________
2935 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2937 // Allows to run QA for a selected set of detectors
2938 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2939 // all selected detectors run the same selected tasks
2941 if (!detAndAction.Contains(":")) {
2942 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2946 Int_t colon = detAndAction.Index(":") ;
2947 fQADetectors = detAndAction(0, colon) ;
2948 if (fQADetectors.Contains("ALL") )
2949 fQADetectors = fFillESD ;
2950 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2951 if (fQATasks.Contains("ALL") ) {
2952 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2954 fQATasks.ToUpper() ;
2956 if ( fQATasks.Contains("RAW") )
2957 tempo = Form("%d ", AliQA::kRAWS) ;
2958 if ( fQATasks.Contains("RECPOINT") )
2959 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2960 if ( fQATasks.Contains("ESD") )
2961 tempo += Form("%d ", AliQA::kESDS) ;
2963 if (fQATasks.IsNull()) {
2964 AliInfo("No QA requested\n") ;
2969 TString tempo(fQATasks) ;
2970 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2971 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2972 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2973 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2978 //_____________________________________________________________________________
2979 Bool_t AliReconstruction::InitRecoParams()
2981 // The method accesses OCDB and retrieves all
2982 // the available reco-param objects from there.
2984 Bool_t isOK = kTRUE;
2986 TString detStr = fLoadCDB;
2987 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2989 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2991 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2992 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2996 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
2998 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2999 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3001 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
3005 TObject *recoParamObj = entry->GetObject();
3006 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3007 // The detector has a normal TobjArray of AliDetectorRecoParam objects
3008 // Registering them in AliRecoParam
3009 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
3011 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3012 // The detector has only onse set of reco parameters
3013 // Registering it in AliRecoParam
3014 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
3015 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3016 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3019 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
3023 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
3027 if (AliDebugLevel() > 0) fRecoParam.Print();
3032 //_____________________________________________________________________________
3033 Bool_t AliReconstruction::GetEventInfo()
3035 // Fill the event info object
3037 AliCodeTimerAuto("")
3039 AliCentralTrigger *aCTP = NULL;
3041 fEventInfo.SetEventType(fRawReader->GetType());
3043 ULong64_t mask = fRawReader->GetClassMask();
3044 fEventInfo.SetTriggerMask(mask);
3045 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
3046 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
3048 aCTP = new AliCentralTrigger();
3049 TString configstr("");
3050 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
3051 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
3055 aCTP->SetClassMask(mask);
3056 aCTP->SetClusterMask(clmask);
3059 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
3061 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
3062 aCTP = fRunLoader->GetTrigger();
3063 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
3064 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
3067 AliWarning("No trigger can be loaded! The trigger information will not be used!");
3072 AliTriggerConfiguration *config = aCTP->GetConfiguration();
3074 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
3075 if (fRawReader) delete aCTP;
3079 UChar_t clustmask = 0;
3081 ULong64_t trmask = fEventInfo.GetTriggerMask();
3082 const TObjArray& classesArray = config->GetClasses();
3083 Int_t nclasses = classesArray.GetEntriesFast();
3084 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
3085 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
3087 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
3088 fesd->SetTriggerClass(trclass->GetName(),trindex);
3089 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
3090 if (trmask & (1 << trindex)) {
3092 trclasses += trclass->GetName();
3094 clustmask |= trclass->GetCluster()->GetClusterMask();
3098 fEventInfo.SetTriggerClasses(trclasses);
3100 // Set the information in ESD
3101 fesd->SetTriggerMask(trmask);
3102 fesd->SetTriggerCluster(clustmask);
3104 if (!aCTP->CheckTriggeredDetectors()) {
3105 if (fRawReader) delete aCTP;
3109 if (fRawReader) delete aCTP;
3111 // We have to fill also the HLT decision here!!
3117 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3119 // Match the detector list found in the rec.C or the default 'ALL'
3120 // to the list found in the GRP (stored there by the shuttle PP which
3121 // gets the information from ECS)
3122 static TString resultList;
3123 TString detList = detectorList;
3127 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3128 if ((detectorMask >> iDet) & 0x1) {
3129 TString det = AliDAQ::OfflineModuleName(iDet);
3130 if ((detList.CompareTo("ALL") == 0) ||
3131 ((detList.BeginsWith("ALL ") ||
3132 detList.EndsWith(" ALL") ||
3133 detList.Contains(" ALL ")) &&
3134 !(detList.BeginsWith("-"+det+" ") ||
3135 detList.EndsWith(" -"+det) ||
3136 detList.Contains(" -"+det+" "))) ||
3137 (detList.CompareTo(det) == 0) ||
3138 detList.BeginsWith(det+" ") ||
3139 detList.EndsWith(" "+det) ||
3140 detList.Contains( " "+det+" " )) {
3141 if (!resultList.EndsWith(det + " ")) {
3150 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3151 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3152 if ((detList.CompareTo("ALL") == 0) ||
3153 ((detList.BeginsWith("ALL ") ||
3154 detList.EndsWith(" ALL") ||
3155 detList.Contains(" ALL ")) &&
3156 !(detList.BeginsWith("-"+hltDet+" ") ||
3157 detList.EndsWith(" -"+hltDet) ||
3158 detList.Contains(" -"+hltDet+" "))) ||
3159 (detList.CompareTo(hltDet) == 0) ||
3160 detList.BeginsWith(hltDet+" ") ||
3161 detList.EndsWith(" "+hltDet) ||
3162 detList.Contains( " "+hltDet+" " )) {
3163 resultList += hltDet;
3167 return resultList.Data();
3171 //______________________________________________________________________________
3172 void AliReconstruction::Abort(const char *method, EAbort what)
3174 // Abort processing. If what = kAbortProcess, the Process() loop will be
3175 // aborted. If what = kAbortFile, the current file in a chain will be
3176 // aborted and the processing will continue with the next file, if there
3177 // is no next file then Process() will be aborted. Abort() can also be
3178 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3179 // the SlaveTerminate() and Terminate() are always called. The abort flag
3180 // can be checked in these methods using GetAbort().
3182 // The method is overwritten in AliReconstruction for better handling of
3183 // reco specific errors
3185 if (!fStopOnError) return;
3189 TString whyMess = method;
3190 whyMess += " failed! Aborting...";
3192 AliError(whyMess.Data());
3195 TString mess = "Abort";
3196 if (fAbort == kAbortProcess)
3197 mess = "AbortProcess";
3198 else if (fAbort == kAbortFile)
3201 Info(mess, whyMess.Data());