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 <TPluginManager.h>
117 #include <TGeoManager.h>
118 #include <TLorentzVector.h>
121 #include <TObjArray.h>
125 #include <TProofOutputFile.h>
126 #include <TParameter.h>
128 #include "AliReconstruction.h"
129 #include "AliCodeTimer.h"
130 #include "AliReconstructor.h"
132 #include "AliRunLoader.h"
134 #include "AliRawReaderFile.h"
135 #include "AliRawReaderDate.h"
136 #include "AliRawReaderRoot.h"
137 #include "AliRawEventHeaderBase.h"
138 #include "AliRawEvent.h"
139 #include "AliESDEvent.h"
140 #include "AliESDMuonTrack.h"
141 #include "AliESDfriend.h"
142 #include "AliESDVertex.h"
143 #include "AliESDcascade.h"
144 #include "AliESDkink.h"
145 #include "AliESDtrack.h"
146 #include "AliESDCaloCluster.h"
147 #include "AliESDCaloCells.h"
148 #include "AliMultiplicity.h"
149 #include "AliTracker.h"
150 #include "AliVertexer.h"
151 #include "AliVertexerTracks.h"
152 #include "AliV0vertexer.h"
153 #include "AliCascadeVertexer.h"
154 #include "AliHeader.h"
155 #include "AliGenEventHeader.h"
157 #include "AliESDpid.h"
158 #include "AliESDtrack.h"
159 #include "AliESDPmdTrack.h"
161 #include "AliESDTagCreator.h"
163 #include "AliGeomManager.h"
164 #include "AliTrackPointArray.h"
165 #include "AliCDBManager.h"
166 #include "AliCDBStorage.h"
167 #include "AliCDBEntry.h"
168 #include "AliAlignObj.h"
170 #include "AliCentralTrigger.h"
171 #include "AliTriggerConfiguration.h"
172 #include "AliTriggerClass.h"
173 #include "AliTriggerCluster.h"
174 #include "AliCTPRawStream.h"
176 #include "AliQADataMakerRec.h"
177 #include "AliGlobalQADataMaker.h"
179 #include "AliQADataMakerSteer.h"
181 #include "AliPlaneEff.h"
183 #include "AliSysInfo.h" // memory snapshots
184 #include "AliRawHLTManager.h"
186 #include "AliMagWrapCheb.h"
188 #include "AliDetectorRecoParam.h"
189 #include "AliGRPRecoParam.h"
190 #include "AliRunInfo.h"
191 #include "AliEventInfo.h"
195 #include "AliGRPObject.h"
197 ClassImp(AliReconstruction)
199 //_____________________________________________________________________________
200 const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
202 //_____________________________________________________________________________
203 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
205 fUniformField(kFALSE),
206 fForcedFieldMap(NULL),
207 fRunVertexFinder(kTRUE),
208 fRunVertexFinderTracks(kTRUE),
209 fRunHLTTracking(kFALSE),
210 fRunMuonTracking(kFALSE),
212 fRunCascadeFinder(kTRUE),
213 fStopOnError(kFALSE),
214 fWriteAlignmentData(kFALSE),
215 fWriteESDfriend(kFALSE),
216 fFillTriggerESD(kTRUE),
224 fRunLocalReconstruction("ALL"),
228 fUseTrackingErrorsForAlignment(""),
229 fGAliceFileName(gAliceFilename),
234 fNumberOfEventsPerFile(1),
236 fLoadAlignFromCDB(kTRUE),
237 fLoadAlignData("ALL"),
245 fParentRawReader(NULL),
250 fDiamondProfileSPD(NULL),
251 fDiamondProfile(NULL),
252 fDiamondProfileTPC(NULL),
256 fAlignObjArray(NULL),
259 fInitCDBCalled(kFALSE),
260 fSetRunNumberFromDataCalled(kFALSE),
266 fSameQACycle(kFALSE),
268 fRunPlaneEff(kFALSE),
277 fIsNewRunLoader(kFALSE),
281 // create reconstruction object with default parameters
284 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
285 fReconstructor[iDet] = NULL;
286 fLoader[iDet] = NULL;
287 fTracker[iDet] = NULL;
289 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
290 fQACycles[iDet] = 999999 ;
291 fQAWriteExpert[iDet] = kFALSE ;
297 //_____________________________________________________________________________
298 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
300 fUniformField(rec.fUniformField),
301 fForcedFieldMap(NULL),
302 fRunVertexFinder(rec.fRunVertexFinder),
303 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
304 fRunHLTTracking(rec.fRunHLTTracking),
305 fRunMuonTracking(rec.fRunMuonTracking),
306 fRunV0Finder(rec.fRunV0Finder),
307 fRunCascadeFinder(rec.fRunCascadeFinder),
308 fStopOnError(rec.fStopOnError),
309 fWriteAlignmentData(rec.fWriteAlignmentData),
310 fWriteESDfriend(rec.fWriteESDfriend),
311 fFillTriggerESD(rec.fFillTriggerESD),
313 fCleanESD(rec.fCleanESD),
314 fV0DCAmax(rec.fV0DCAmax),
315 fV0CsPmin(rec.fV0CsPmin),
319 fRunLocalReconstruction(rec.fRunLocalReconstruction),
320 fRunTracking(rec.fRunTracking),
321 fFillESD(rec.fFillESD),
322 fLoadCDB(rec.fLoadCDB),
323 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
324 fGAliceFileName(rec.fGAliceFileName),
325 fRawInput(rec.fRawInput),
326 fEquipIdMap(rec.fEquipIdMap),
327 fFirstEvent(rec.fFirstEvent),
328 fLastEvent(rec.fLastEvent),
329 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
331 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
332 fLoadAlignData(rec.fLoadAlignData),
333 fESDPar(rec.fESDPar),
334 fUseHLTData(rec.fUseHLTData),
340 fParentRawReader(NULL),
342 fRecoParam(rec.fRecoParam),
345 fDiamondProfileSPD(rec.fDiamondProfileSPD),
346 fDiamondProfile(rec.fDiamondProfile),
347 fDiamondProfileTPC(rec.fDiamondProfileTPC),
351 fAlignObjArray(rec.fAlignObjArray),
352 fCDBUri(rec.fCDBUri),
354 fInitCDBCalled(rec.fInitCDBCalled),
355 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
356 fQADetectors(rec.fQADetectors),
358 fQATasks(rec.fQATasks),
360 fRunGlobalQA(rec.fRunGlobalQA),
361 fSameQACycle(rec.fSameQACycle),
362 fRunPlaneEff(rec.fRunPlaneEff),
371 fIsNewRunLoader(rec.fIsNewRunLoader),
377 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
378 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
380 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
381 fReconstructor[iDet] = NULL;
382 fLoader[iDet] = NULL;
383 fTracker[iDet] = NULL;
386 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
387 fQACycles[iDet] = rec.fQACycles[iDet];
388 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
391 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
392 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
396 //_____________________________________________________________________________
397 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
399 // assignment operator
400 // Used in PROOF mode
401 // Be very careful while modifing it!
402 // Simple rules to follow:
403 // for persistent data members - use their assignment operators
404 // for non-persistent ones - do nothing or take the default values from constructor
405 // TSelector members should not be touched
406 if(&rec == this) return *this;
408 fUniformField = rec.fUniformField;
409 fForcedFieldMap = NULL;
410 fRunVertexFinder = rec.fRunVertexFinder;
411 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
412 fRunHLTTracking = rec.fRunHLTTracking;
413 fRunMuonTracking = rec.fRunMuonTracking;
414 fRunV0Finder = rec.fRunV0Finder;
415 fRunCascadeFinder = rec.fRunCascadeFinder;
416 fStopOnError = rec.fStopOnError;
417 fWriteAlignmentData = rec.fWriteAlignmentData;
418 fWriteESDfriend = rec.fWriteESDfriend;
419 fFillTriggerESD = rec.fFillTriggerESD;
421 fCleanESD = rec.fCleanESD;
422 fV0DCAmax = rec.fV0DCAmax;
423 fV0CsPmin = rec.fV0CsPmin;
427 fRunLocalReconstruction = rec.fRunLocalReconstruction;
428 fRunTracking = rec.fRunTracking;
429 fFillESD = rec.fFillESD;
430 fLoadCDB = rec.fLoadCDB;
431 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
432 fGAliceFileName = rec.fGAliceFileName;
433 fRawInput = rec.fRawInput;
434 fEquipIdMap = rec.fEquipIdMap;
435 fFirstEvent = rec.fFirstEvent;
436 fLastEvent = rec.fLastEvent;
437 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
439 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
440 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
443 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
444 fLoadAlignData = rec.fLoadAlignData;
445 fESDPar = rec.fESDPar;
446 fUseHLTData = rec.fUseHLTData;
448 delete fRunInfo; fRunInfo = NULL;
449 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
451 fEventInfo = rec.fEventInfo;
455 fParentRawReader = NULL;
457 fRecoParam = rec.fRecoParam;
459 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
460 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
461 delete fLoader[iDet]; fLoader[iDet] = NULL;
462 delete fTracker[iDet]; fTracker[iDet] = NULL;
465 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
466 fQACycles[iDet] = rec.fQACycles[iDet];
467 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
471 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
472 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
473 delete fDiamondProfile; fDiamondProfile = NULL;
474 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
475 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
476 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
478 delete fGRPData; fGRPData = NULL;
479 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
480 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
482 delete fAlignObjArray; fAlignObjArray = NULL;
485 fSpecCDBUri.Delete();
486 fInitCDBCalled = rec.fInitCDBCalled;
487 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
488 fQADetectors = rec.fQADetectors;
490 fQATasks = rec.fQATasks;
492 fRunGlobalQA = rec.fRunGlobalQA;
493 fSameQACycle = rec.fSameQACycle;
494 fRunPlaneEff = rec.fRunPlaneEff;
503 fIsNewRunLoader = rec.fIsNewRunLoader;
510 //_____________________________________________________________________________
511 AliReconstruction::~AliReconstruction()
517 delete fForcedFieldMap;
519 if (fAlignObjArray) {
520 fAlignObjArray->Delete();
521 delete fAlignObjArray;
523 fSpecCDBUri.Delete();
525 AliCodeTimer::Instance()->Print();
528 //_____________________________________________________________________________
529 void AliReconstruction::InitCDB()
531 // activate a default CDB storage
532 // First check if we have any CDB storage set, because it is used
533 // to retrieve the calibration and alignment constants
534 AliCodeTimerAuto("");
536 if (fInitCDBCalled) return;
537 fInitCDBCalled = kTRUE;
539 AliCDBManager* man = AliCDBManager::Instance();
540 if (man->IsDefaultStorageSet())
542 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
543 AliWarning("Default CDB storage has been already set !");
544 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
545 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
546 fCDBUri = man->GetDefaultStorage()->GetURI();
549 if (fCDBUri.Length() > 0)
551 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
552 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
553 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
555 fCDBUri="local://$ALICE_ROOT";
556 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
557 AliWarning("Default CDB storage not yet set !!!!");
558 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
559 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
562 man->SetDefaultStorage(fCDBUri);
565 // Now activate the detector specific CDB storage locations
566 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
567 TObject* obj = fSpecCDBUri[i];
569 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
570 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
571 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
572 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
574 AliSysInfo::AddStamp("InitCDB");
577 //_____________________________________________________________________________
578 void AliReconstruction::SetDefaultStorage(const char* uri) {
579 // Store the desired default CDB storage location
580 // Activate it later within the Run() method
586 //_____________________________________________________________________________
587 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
588 // Store a detector-specific CDB storage location
589 // Activate it later within the Run() method
591 AliCDBPath aPath(calibType);
592 if(!aPath.IsValid()){
593 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
594 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
595 if(!strcmp(calibType, fgkDetectorName[iDet])) {
596 aPath.SetPath(Form("%s/*", calibType));
597 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
601 if(!aPath.IsValid()){
602 AliError(Form("Not a valid path or detector: %s", calibType));
607 // // check that calibType refers to a "valid" detector name
608 // Bool_t isDetector = kFALSE;
609 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
610 // TString detName = fgkDetectorName[iDet];
611 // if(aPath.GetLevel0() == detName) {
612 // isDetector = kTRUE;
618 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
622 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
623 if (obj) fSpecCDBUri.Remove(obj);
624 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
628 //_____________________________________________________________________________
629 Bool_t AliReconstruction::SetRunNumberFromData()
631 // The method is called in Run() in order
632 // to set a correct run number.
633 // In case of raw data reconstruction the
634 // run number is taken from the raw data header
636 if (fSetRunNumberFromDataCalled) return kTRUE;
637 fSetRunNumberFromDataCalled = kTRUE;
639 AliCDBManager* man = AliCDBManager::Instance();
642 if(fRawReader->NextEvent()) {
643 if(man->GetRun() > 0) {
644 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
646 man->SetRun(fRawReader->GetRunNumber());
647 fRawReader->RewindEvents();
650 if(man->GetRun() > 0) {
651 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
654 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
660 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
662 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
667 // read run number from gAlice
668 if(rl->GetHeader()) {
669 man->SetRun(rl->GetHeader()->GetRun());
674 AliError("Neither run-loader header nor RawReader objects are found !");
686 //_____________________________________________________________________________
687 void AliReconstruction::SetCDBLock() {
688 // Set CDB lock: from now on it is forbidden to reset the run number
689 // or the default storage or to activate any further storage!
691 AliCDBManager::Instance()->SetLock(1);
694 //_____________________________________________________________________________
695 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
697 // Read the alignment objects from CDB.
698 // Each detector is supposed to have the
699 // alignment objects in DET/Align/Data CDB path.
700 // All the detector objects are then collected,
701 // sorted by geometry level (starting from ALIC) and
702 // then applied to the TGeo geometry.
703 // Finally an overlaps check is performed.
705 // Load alignment data from CDB and fill fAlignObjArray
706 if(fLoadAlignFromCDB){
708 TString detStr = detectors;
709 TString loadAlObjsListOfDets = "";
711 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
712 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
713 if(fgkDetectorName[iDet]=="HLT") continue;
714 if(AliGeomManager::IsModuleInGeom(fgkDetectorName[iDet]))
716 loadAlObjsListOfDets += fgkDetectorName[iDet];
717 loadAlObjsListOfDets += " ";
719 } // end loop over detectors
720 if(AliGeomManager::IsModuleInGeom("FRAME"))
721 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
722 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
723 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
725 // Check if the array with alignment objects was
726 // provided by the user. If yes, apply the objects
727 // to the present TGeo geometry
728 if (fAlignObjArray) {
729 if (gGeoManager && gGeoManager->IsClosed()) {
730 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
731 AliError("The misalignment of one or more volumes failed!"
732 "Compare the list of simulated detectors and the list of detector alignment data!");
737 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
743 if (fAlignObjArray) {
744 fAlignObjArray->Delete();
745 delete fAlignObjArray; fAlignObjArray=NULL;
751 //_____________________________________________________________________________
752 void AliReconstruction::SetGAliceFile(const char* fileName)
754 // set the name of the galice file
756 fGAliceFileName = fileName;
759 //_____________________________________________________________________________
760 void AliReconstruction::SetInput(const char* input)
762 // In case the input string starts with 'mem://', we run in an online mode
763 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
764 // file is assumed. One can give as an input:
765 // mem://: - events taken from DAQ monitoring libs online
767 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
768 if (input) fRawInput = input;
771 //_____________________________________________________________________________
772 void AliReconstruction::SetOption(const char* detector, const char* option)
774 // set options for the reconstruction of a detector
776 TObject* obj = fOptions.FindObject(detector);
777 if (obj) fOptions.Remove(obj);
778 fOptions.Add(new TNamed(detector, option));
781 //_____________________________________________________________________________
782 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
784 // Set custom reconstruction parameters for a given detector
785 // Single set of parameters for all the events
787 // First check if the reco-params are global
788 if(!strcmp(detector, "GRP")) {
790 fRecoParam.AddDetRecoParam(fgkNDetectors,par);
794 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
795 if(!strcmp(detector, fgkDetectorName[iDet])) {
797 fRecoParam.AddDetRecoParam(iDet,par);
804 //_____________________________________________________________________________
805 Bool_t AliReconstruction::SetFieldMap(Float_t l3Current, Float_t diCurrent, Float_t factor, const char *path) {
806 //------------------------------------------------
807 // The magnetic field map, defined externally...
808 // L3 current 30000 A -> 0.5 T
809 // L3 current 12000 A -> 0.2 T
810 // dipole current 6000 A
811 // The polarities must be the same
812 //------------------------------------------------
813 const Float_t l3NominalCurrent1=30000.; // (A)
814 const Float_t l3NominalCurrent2=12000.; // (A)
815 const Float_t diNominalCurrent =6000. ; // (A)
817 const Float_t tolerance=0.03; // relative current tolerance
818 const Float_t zero=77.; // "zero" current (A)
821 Bool_t dipoleON=kFALSE;
823 TString s=(factor < 0) ? "L3: -" : "L3: +";
825 l3Current = TMath::Abs(l3Current);
826 if (TMath::Abs(l3Current-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
827 map=AliMagWrapCheb::k5kG;
830 if (TMath::Abs(l3Current-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
831 map=AliMagWrapCheb::k2kG;
834 if (l3Current < zero) {
835 map=AliMagWrapCheb::k2kG;
837 factor=0.; // in fact, this is a global factor...
838 fUniformField=kTRUE; // track with the uniform (zero) B field
840 AliError(Form("Wrong L3 current (%f A)!",l3Current));
844 diCurrent = TMath::Abs(diCurrent);
845 if (TMath::Abs(diCurrent-diNominalCurrent)/diNominalCurrent < tolerance) {
846 // 3% current tolerance...
850 if (diCurrent < zero) { // some small current..
854 AliError(Form("Wrong dipole current (%f A)!",diCurrent));
858 delete fForcedFieldMap;
860 new AliMagWrapCheb("B field map ",s,2,factor,10.,map,dipoleON,path);
862 fForcedFieldMap->Print();
864 AliTracker::SetFieldMap(fForcedFieldMap,fUniformField);
870 Bool_t AliReconstruction::InitGRP() {
871 //------------------------------------
872 // Initialization of the GRP entry
873 //------------------------------------
874 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
878 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
881 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
883 fGRPData = new AliGRPObject();
884 fGRPData->ReadValuesFromMap(m);
888 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
889 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
893 AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
897 AliError("No GRP entry found in OCDB!");
901 TString lhcState = fGRPData->GetLHCState();
902 if (lhcState==AliGRPObject::GetInvalidString()) {
903 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
904 lhcState = "UNKNOWN";
907 TString beamType = fGRPData->GetBeamType();
908 if (beamType==AliGRPObject::GetInvalidString()) {
909 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
910 beamType = "UNKNOWN";
913 Float_t beamEnergy = fGRPData->GetBeamEnergy();
914 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
915 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
919 TString runType = fGRPData->GetRunType();
920 if (runType==AliGRPObject::GetInvalidString()) {
921 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
925 Int_t activeDetectors = fGRPData->GetDetectorMask();
926 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
927 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
928 activeDetectors = 1074790399;
931 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
936 // Process the list of active detectors
937 if (activeDetectors) {
938 UInt_t detMask = activeDetectors;
939 fLoadCDB.Form("%s %s %s %s",
940 fRunLocalReconstruction.Data(),
943 fQADetectors.Data());
944 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
945 fRunTracking = MatchDetectorList(fRunTracking,detMask);
946 fFillESD = MatchDetectorList(fFillESD,detMask);
947 fQADetectors = MatchDetectorList(fQADetectors,detMask);
948 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
949 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1)) {
950 // switch off the vertexer
951 AliInfo("SPD is not in the list of active detectors. Vertexer switched off.");
952 fRunVertexFinder = kFALSE;
956 AliInfo("===================================================================================");
957 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
958 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
959 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
960 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
961 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
962 AliInfo("===================================================================================");
964 //*** Dealing with the magnetic field map
965 if (AliTracker::GetFieldMap()) {
966 AliInfo("Running with the externally set B field !");
968 // Construct the field map out of the information retrieved from GRP.
973 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
974 if (l3Current == AliGRPObject::GetInvalidFloat()) {
975 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
979 Char_t l3Polarity = fGRPData->GetL3Polarity();
980 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
981 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
986 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
987 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
988 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
992 Char_t diPolarity = fGRPData->GetDipolePolarity();
993 if (diPolarity == AliGRPObject::GetInvalidChar()) {
994 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
999 TObjString *l3Current=
1000 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
1002 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1005 TObjString *l3Polarity=
1006 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
1008 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1013 TObjString *diCurrent=
1014 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
1016 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1019 TObjString *diPolarity=
1020 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
1022 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1028 Float_t l3Cur=TMath::Abs(l3Current);
1029 Float_t diCur=TMath::Abs(diCurrent);
1030 Float_t l3Pol=l3Polarity;
1031 // Float_t l3Cur=TMath::Abs(atof(l3Current->GetName()));
1032 //Float_t diCur=TMath::Abs(atof(diCurrent->GetName()));
1033 //Float_t l3Pol=atof(l3Polarity->GetName());
1035 if (l3Pol != 0.) factor=-1.;
1038 if (!SetFieldMap(l3Cur, diCur, factor)) {
1039 AliFatal("Failed to creat a B field map ! Exiting...");
1041 AliInfo("Running with the B field constructed out of GRP !");
1044 AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1049 //*** Get the diamond profiles from OCDB
1050 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1052 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1054 AliError("No SPD diamond profile found in OCDB!");
1057 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1059 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1061 AliError("No diamond profile found in OCDB!");
1064 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1066 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1068 AliError("No TPC diamond profile found in OCDB!");
1074 //_____________________________________________________________________________
1075 Bool_t AliReconstruction::LoadCDB()
1077 AliCodeTimerAuto("");
1079 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1081 TString detStr = fLoadCDB;
1082 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1083 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1084 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1089 //_____________________________________________________________________________
1090 Bool_t AliReconstruction::Run(const char* input)
1093 AliCodeTimerAuto("");
1096 if (GetAbort() != TSelector::kContinue) return kFALSE;
1098 TChain *chain = NULL;
1099 if (fRawReader && (chain = fRawReader->GetChain())) {
1102 gProof->AddInput(this);
1104 outputFile.SetProtocol("root",kTRUE);
1105 outputFile.SetHost(gSystem->HostName());
1106 outputFile.SetFile(Form("%s/AliESDs.root",gSystem->pwd()));
1107 AliInfo(Form("Output file with ESDs is %s",outputFile.GetUrl()));
1108 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.GetUrl()));
1110 chain->Process("AliReconstruction");
1113 chain->Process(this);
1118 if (GetAbort() != TSelector::kContinue) return kFALSE;
1120 if (GetAbort() != TSelector::kContinue) return kFALSE;
1121 //******* The loop over events
1122 AliInfo("Starting looping over events");
1124 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1125 (fRawReader && fRawReader->NextEvent())) {
1126 if (!ProcessEvent(iEvent)) {
1127 Abort("ProcessEvent",TSelector::kAbortFile);
1133 if (GetAbort() != TSelector::kContinue) return kFALSE;
1135 if (GetAbort() != TSelector::kContinue) return kFALSE;
1141 //_____________________________________________________________________________
1142 void AliReconstruction::InitRawReader(const char* input)
1144 AliCodeTimerAuto("");
1146 // Init raw-reader and
1147 // set the input in case of raw data
1148 if (input) fRawInput = input;
1149 fRawReader = AliRawReader::Create(fRawInput.Data());
1151 AliInfo("Reconstruction will run over digits");
1153 if (!fEquipIdMap.IsNull() && fRawReader)
1154 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1156 if (!fUseHLTData.IsNull()) {
1157 // create the RawReaderHLT which performs redirection of HLT input data for
1158 // the specified detectors
1159 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1161 fParentRawReader=fRawReader;
1162 fRawReader=pRawReader;
1164 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1167 AliSysInfo::AddStamp("CreateRawReader");
1170 //_____________________________________________________________________________
1171 void AliReconstruction::InitRun(const char* input)
1173 // Initialization of raw-reader,
1174 // run number, CDB etc.
1175 AliCodeTimerAuto("");
1176 AliSysInfo::AddStamp("Start");
1178 // Initialize raw-reader if any
1179 InitRawReader(input);
1181 // Initialize the CDB storage
1184 // Set run number in CDBManager (if it is not already set by the user)
1185 if (!SetRunNumberFromData()) {
1186 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1190 // Set CDB lock: from now on it is forbidden to reset the run number
1191 // or the default storage or to activate any further storage!
1196 //_____________________________________________________________________________
1197 void AliReconstruction::Begin(TTree *)
1199 // Initialize AlReconstruction before
1200 // going into the event loop
1201 // Should follow the TSelector convention
1202 // i.e. initialize only the object on the client side
1203 AliCodeTimerAuto("");
1205 AliReconstruction *reco = NULL;
1207 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1210 AliSysInfo::AddStamp("ReadInputInBegin");
1213 // Import ideal TGeo geometry and apply misalignment
1215 TString geom(gSystem->DirName(fGAliceFileName));
1216 geom += "/geometry.root";
1217 AliGeomManager::LoadGeometry(geom.Data());
1219 Abort("LoadGeometry", TSelector::kAbortProcess);
1222 AliSysInfo::AddStamp("LoadGeom");
1223 TString detsToCheck=fRunLocalReconstruction;
1224 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1225 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1228 AliSysInfo::AddStamp("CheckGeom");
1231 if (!MisalignGeometry(fLoadAlignData)) {
1232 Abort("MisalignGeometry", TSelector::kAbortProcess);
1235 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1236 AliSysInfo::AddStamp("MisalignGeom");
1239 Abort("InitGRP", TSelector::kAbortProcess);
1242 AliSysInfo::AddStamp("InitGRP");
1245 Abort("LoadCDB", TSelector::kAbortProcess);
1248 AliSysInfo::AddStamp("LoadCDB");
1250 // Read the reconstruction parameters from OCDB
1251 if (!InitRecoParams()) {
1252 AliWarning("Not all detectors have correct RecoParam objects initialized");
1254 AliSysInfo::AddStamp("InitRecoParams");
1257 if (reco) *reco = *this;
1258 fInput->Add(gGeoManager);
1260 fInput->Add(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()));
1261 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1262 AliMagF *magFieldMap = (AliMagF*)AliTracker::GetFieldMap();
1263 magFieldMap->SetName("MagneticFieldMap");
1264 fInput->Add(magFieldMap);
1269 //_____________________________________________________________________________
1270 void AliReconstruction::SlaveBegin(TTree*)
1272 // Initialization related to run-loader,
1273 // vertexer, trackers, recontructors
1274 // In proof mode it is executed on the slave
1275 AliCodeTimerAuto("");
1277 TProofOutputFile *outProofFile = NULL;
1279 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1282 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1284 AliGeomManager::SetGeometry(tgeo);
1286 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1287 Int_t runNumber = -1;
1288 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1289 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1290 man->SetCacheFlag(kTRUE);
1291 man->SetLock(kTRUE);
1295 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1296 AliTracker::SetFieldMap(map,fUniformField);
1298 if (TNamed *outputFileName = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE")) {
1299 outProofFile = new TProofOutputFile(gSystem->BaseName(TUrl(outputFileName->GetTitle()).GetFile()));
1300 outProofFile->SetOutputFileName(outputFileName->GetTitle());
1301 fOutput->Add(outProofFile);
1303 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1306 // get the run loader
1307 if (!InitRunLoader()) {
1308 Abort("InitRunLoader", TSelector::kAbortProcess);
1311 AliSysInfo::AddStamp("LoadLoader");
1313 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1316 if (fRunVertexFinder && !CreateVertexer()) {
1317 Abort("CreateVertexer", TSelector::kAbortProcess);
1320 AliSysInfo::AddStamp("CreateVertexer");
1323 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1324 Abort("CreateTrackers", TSelector::kAbortProcess);
1327 AliSysInfo::AddStamp("CreateTrackers");
1329 // create the ESD output file and tree
1330 if (!outProofFile) {
1331 ffile = TFile::Open("AliESDs.root", "RECREATE");
1332 ffile->SetCompressionLevel(2);
1333 if (!ffile->IsOpen()) {
1334 Abort("OpenESDFile", TSelector::kAbortProcess);
1339 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1340 Abort(Form("Problems opening output PROOF file: %s/%s",
1341 outProofFile->GetDir(), outProofFile->GetFileName()),
1342 TSelector::kAbortProcess);
1347 ftree = new TTree("esdTree", "Tree with ESD objects");
1348 fesd = new AliESDEvent();
1349 fesd->CreateStdContent();
1350 if (fWriteESDfriend) {
1351 fesdf = new AliESDfriend();
1352 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1353 br->SetFile("AliESDfriends.root");
1354 fesd->AddObject(fesdf);
1356 fesd->WriteToTree(ftree);
1357 ftree->GetUserInfo()->Add(fesd);
1359 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1360 fhltesd = new AliESDEvent();
1361 fhltesd->CreateStdContent();
1362 fhltesd->WriteToTree(fhlttree);
1363 fhlttree->GetUserInfo()->Add(fhltesd);
1365 ProcInfo_t ProcInfo;
1366 gSystem->GetProcInfo(&ProcInfo);
1367 AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1370 //Initialize the QA and start of cycle
1372 fQASteer = new AliQADataMakerSteer("rec") ;
1373 fQASteer->SetActiveDetectors(fQADetectors) ;
1374 for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
1375 fQASteer->SetCycleLength(AliQA::DETECTORINDEX_t(det), fQACycles[det]) ;
1376 if (fQAWriteExpert[det])
1377 fQASteer->SetWriteExpert(AliQA::DETECTORINDEX_t(det)) ;
1380 if (!fRawReader && fQATasks.Contains(AliQA::kRAWS))
1381 fQATasks.ReplaceAll(Form("%d",AliQA::kRAWS), "") ;
1382 fQASteer->SetTasks(fQATasks) ;
1383 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam) ;
1387 Bool_t sameCycle = kFALSE ;
1388 if (!fQASteer) fQASteer = new AliQADataMakerSteer("rec") ;
1389 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1390 AliInfo(Form("Initializing the global QA data maker"));
1391 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1392 qadm->StartOfCycle(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1393 TObjArray *arr=qadm->Init(AliQA::kRECPOINTS);
1394 AliTracker::SetResidualsArray(arr);
1397 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1398 qadm->StartOfCycle(AliQA::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1399 qadm->Init(AliQA::kESDS);
1403 //Initialize the Plane Efficiency framework
1404 if (fRunPlaneEff && !InitPlaneEff()) {
1405 Abort("InitPlaneEff", TSelector::kAbortProcess);
1409 if (strcmp(gProgName,"alieve") == 0)
1410 fRunAliEVE = InitAliEVE();
1415 //_____________________________________________________________________________
1416 Bool_t AliReconstruction::Process(Long64_t entry)
1418 // run the reconstruction over a single entry
1419 // from the chain with raw data
1420 AliCodeTimerAuto("");
1422 TTree *currTree = fChain->GetTree();
1423 AliRawEvent *event = new AliRawEvent;
1424 currTree->SetBranchAddress("rawevent",&event);
1425 currTree->GetEntry(entry);
1426 fRawReader = new AliRawReaderRoot(event);
1427 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1435 //_____________________________________________________________________________
1436 void AliReconstruction::Init(TTree *tree)
1439 AliError("The input tree is not found!");
1445 //_____________________________________________________________________________
1446 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1448 // run the reconstruction over a single event
1449 // The event loop is steered in Run method
1451 AliCodeTimerAuto("");
1453 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1454 fRunLoader->SetEventNumber(iEvent);
1455 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1457 fRunLoader->TreeE()->Fill();
1458 if (fRawReader && fRawReader->UseAutoSaveESD())
1459 fRunLoader->TreeE()->AutoSave("SaveSelf");
1462 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1466 AliInfo(Form("processing event %d", iEvent));
1468 // Fill Event-info object
1470 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1472 // Set the reco-params
1474 TString detStr = fLoadCDB;
1475 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1476 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1477 AliReconstructor *reconstructor = GetReconstructor(iDet);
1478 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1479 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1480 reconstructor->SetRecoParam(par);
1485 fRunLoader->GetEvent(iEvent);
1489 fQASteer->RunOneEvent(fRawReader) ;
1491 // local single event reconstruction
1492 if (!fRunLocalReconstruction.IsNull()) {
1493 TString detectors=fRunLocalReconstruction;
1494 // run HLT event reconstruction first
1495 // ;-( IsSelected changes the string
1496 if (IsSelected("HLT", detectors) &&
1497 !RunLocalEventReconstruction("HLT")) {
1498 if (fStopOnError) {CleanUp(); return kFALSE;}
1500 detectors=fRunLocalReconstruction;
1501 detectors.ReplaceAll("HLT", "");
1502 if (!RunLocalEventReconstruction(detectors)) {
1503 if (fStopOnError) {CleanUp(); return kFALSE;}
1507 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1508 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1509 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1510 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1512 // Set magnetic field from the tracker
1513 fesd->SetMagneticField(AliTracker::GetBz());
1514 fhltesd->SetMagneticField(AliTracker::GetBz());
1516 // Set most probable pt, for B=0 tracking
1517 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
1518 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(fgkNDetectors));
1519 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
1521 // Fill raw-data error log into the ESD
1522 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1525 if (fRunVertexFinder) {
1526 if (!RunVertexFinder(fesd)) {
1527 if (fStopOnError) {CleanUp(); return kFALSE;}
1532 if (!fRunTracking.IsNull()) {
1533 if (fRunMuonTracking) {
1534 if (!RunMuonTracking(fesd)) {
1535 if (fStopOnError) {CleanUp(); return kFALSE;}
1541 if (!fRunTracking.IsNull()) {
1542 if (!RunTracking(fesd)) {
1543 if (fStopOnError) {CleanUp(); return kFALSE;}
1548 if (!fFillESD.IsNull()) {
1549 TString detectors=fFillESD;
1550 // run HLT first and on hltesd
1551 // ;-( IsSelected changes the string
1552 if (IsSelected("HLT", detectors) &&
1553 !FillESD(fhltesd, "HLT")) {
1554 if (fStopOnError) {CleanUp(); return kFALSE;}
1557 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1558 if (detectors.Contains("ALL")) {
1560 for (Int_t idet=0; idet<fgkNDetectors; ++idet){
1561 detectors += fgkDetectorName[idet];
1565 detectors.ReplaceAll("HLT", "");
1566 if (!FillESD(fesd, detectors)) {
1567 if (fStopOnError) {CleanUp(); return kFALSE;}
1571 // fill Event header information from the RawEventHeader
1572 if (fRawReader){FillRawEventHeaderESD(fesd);}
1575 AliESDpid::MakePID(fesd);
1577 if (fFillTriggerESD) {
1578 if (!FillTriggerESD(fesd)) {
1579 if (fStopOnError) {CleanUp(); return kFALSE;}
1586 // Propagate track to the beam pipe (if not already done by ITS)
1588 const Int_t ntracks = fesd->GetNumberOfTracks();
1589 const Double_t kBz = fesd->GetMagneticField();
1590 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1593 UShort_t *selectedIdx=new UShort_t[ntracks];
1595 for (Int_t itrack=0; itrack<ntracks; itrack++){
1596 const Double_t kMaxStep = 5; //max step over the material
1599 AliESDtrack *track = fesd->GetTrack(itrack);
1600 if (!track) continue;
1602 AliExternalTrackParam *tpcTrack =
1603 (AliExternalTrackParam *)track->GetTPCInnerParam();
1607 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE);
1610 Int_t n=trkArray.GetEntriesFast();
1611 selectedIdx[n]=track->GetID();
1612 trkArray.AddLast(tpcTrack);
1615 //Tracks refitted by ITS should already be at the SPD vertex
1616 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1619 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE);
1620 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1625 // Improve the reconstructed primary vertex position using the tracks
1627 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1628 if(fesd->GetPrimaryVertexSPD()) {
1629 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1630 if(vtitle.Contains("cosmics")) {
1631 runVertexFinderTracks=kFALSE;
1635 if (runVertexFinderTracks) {
1636 // TPC + ITS primary vertex
1637 ftVertexer->SetITSMode();
1638 ftVertexer->SetConstraintOff();
1639 // get cuts for vertexer from AliGRPRecoParam
1641 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1642 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1643 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
1644 ftVertexer->SetCuts(cutsVertexer);
1645 delete [] cutsVertexer; cutsVertexer = NULL;
1646 if(fDiamondProfile && grpRecoParam->GetVertexerTracksConstraintITS())
1647 ftVertexer->SetVtxStart(fDiamondProfile);
1649 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1651 if (pvtx->GetStatus()) {
1652 fesd->SetPrimaryVertex(pvtx);
1653 for (Int_t i=0; i<ntracks; i++) {
1654 AliESDtrack *t = fesd->GetTrack(i);
1655 t->RelateToVertex(pvtx, kBz, kVeryBig);
1660 // TPC-only primary vertex
1661 ftVertexer->SetTPCMode();
1662 ftVertexer->SetConstraintOff();
1663 // get cuts for vertexer from AliGRPRecoParam
1665 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1666 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1667 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
1668 ftVertexer->SetCuts(cutsVertexer);
1669 delete [] cutsVertexer; cutsVertexer = NULL;
1670 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC())
1671 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1673 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1675 if (pvtx->GetStatus()) {
1676 fesd->SetPrimaryVertexTPC(pvtx);
1677 for (Int_t i=0; i<ntracks; i++) {
1678 AliESDtrack *t = fesd->GetTrack(i);
1679 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1685 delete[] selectedIdx;
1687 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1692 AliV0vertexer vtxer;
1693 vtxer.Tracks2V0vertices(fesd);
1695 if (fRunCascadeFinder) {
1697 AliCascadeVertexer cvtxer;
1698 cvtxer.V0sTracks2CascadeVertices(fesd);
1703 if (fCleanESD) CleanESD(fesd);
1706 fQASteer->RunOneEvent(fesd) ;
1709 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1710 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1711 qadm->Exec(AliQA::kESDS, fesd);
1714 if (fWriteESDfriend) {
1715 // fesdf->~AliESDfriend();
1716 // new (fesdf) AliESDfriend(); // Reset...
1717 fesd->GetESDfriend(fesdf);
1721 // Auto-save the ESD tree in case of prompt reco @P2
1722 if (fRawReader && fRawReader->UseAutoSaveESD()) {
1723 ftree->AutoSave("SaveSelf");
1724 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1725 if (friendfile) friendfile->Save();
1732 if (fRunAliEVE) RunAliEVE();
1736 if (fWriteESDfriend) {
1737 fesdf->~AliESDfriend();
1738 new (fesdf) AliESDfriend(); // Reset...
1741 ProcInfo_t ProcInfo;
1742 gSystem->GetProcInfo(&ProcInfo);
1743 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1746 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1747 if (fReconstructor[iDet])
1748 fReconstructor[iDet]->SetRecoParam(NULL);
1751 if (fRunQA || fRunGlobalQA)
1752 fQASteer->Increment() ;
1757 //_____________________________________________________________________________
1758 void AliReconstruction::SlaveTerminate()
1760 // Finalize the run on the slave side
1761 // Called after the exit
1762 // from the event loop
1763 AliCodeTimerAuto("");
1765 if (fIsNewRunLoader) { // galice.root didn't exist
1766 fRunLoader->WriteHeader("OVERWRITE");
1767 fRunLoader->CdGAFile();
1768 fRunLoader->Write(0, TObject::kOverwrite);
1771 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1772 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1774 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1775 cdbMapCopy->SetOwner(1);
1776 cdbMapCopy->SetName("cdbMap");
1777 TIter iter(cdbMap->GetTable());
1780 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1781 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1782 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1783 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1786 TList *cdbListCopy = new TList();
1787 cdbListCopy->SetOwner(1);
1788 cdbListCopy->SetName("cdbList");
1790 TIter iter2(cdbList);
1793 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1794 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1797 ftree->GetUserInfo()->Add(cdbMapCopy);
1798 ftree->GetUserInfo()->Add(cdbListCopy);
1801 if(fESDPar.Contains("ESD.par")){
1802 AliInfo("Attaching ESD.par to Tree");
1803 TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
1804 ftree->GetUserInfo()->Add(fn);
1810 if (fWriteESDfriend)
1811 ftree->SetBranchStatus("ESDfriend*",0);
1812 // we want to have only one tree version number
1813 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1816 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
1817 if (fRunPlaneEff && !FinishPlaneEff()) {
1818 AliWarning("Finish PlaneEff evaluation failed");
1821 // End of cycle for the in-loop
1823 fQASteer->EndOfCycle() ;
1826 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1828 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1829 qadm->EndOfCycle(AliQA::kRECPOINTS);
1830 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1831 qadm->EndOfCycle(AliQA::kESDS);
1839 //_____________________________________________________________________________
1840 void AliReconstruction::Terminate()
1842 // Create tags for the events in the ESD tree (the ESD tree is always present)
1843 // In case of empty events the tags will contain dummy values
1844 AliCodeTimerAuto("");
1846 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1847 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData);
1849 // Cleanup of CDB manager: cache and active storages!
1850 AliCDBManager::Instance()->ClearCache();
1853 //_____________________________________________________________________________
1854 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1856 // run the local reconstruction
1858 static Int_t eventNr=0;
1859 AliCodeTimerAuto("")
1861 TString detStr = detectors;
1862 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1863 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1864 AliReconstructor* reconstructor = GetReconstructor(iDet);
1865 if (!reconstructor) continue;
1866 AliLoader* loader = fLoader[iDet];
1867 // Matthias April 2008: temporary fix to run HLT reconstruction
1868 // although the HLT loader is missing
1869 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1871 reconstructor->Reconstruct(fRawReader, NULL);
1874 reconstructor->Reconstruct(dummy, NULL);
1879 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1882 // conversion of digits
1883 if (fRawReader && reconstructor->HasDigitConversion()) {
1884 AliInfo(Form("converting raw data digits into root objects for %s",
1885 fgkDetectorName[iDet]));
1886 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1887 // fgkDetectorName[iDet]));
1888 loader->LoadDigits("update");
1889 loader->CleanDigits();
1890 loader->MakeDigitsContainer();
1891 TTree* digitsTree = loader->TreeD();
1892 reconstructor->ConvertDigits(fRawReader, digitsTree);
1893 loader->WriteDigits("OVERWRITE");
1894 loader->UnloadDigits();
1896 // local reconstruction
1897 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1898 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1899 loader->LoadRecPoints("update");
1900 loader->CleanRecPoints();
1901 loader->MakeRecPointsContainer();
1902 TTree* clustersTree = loader->TreeR();
1903 if (fRawReader && !reconstructor->HasDigitConversion()) {
1904 reconstructor->Reconstruct(fRawReader, clustersTree);
1906 loader->LoadDigits("read");
1907 TTree* digitsTree = loader->TreeD();
1909 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1910 if (fStopOnError) return kFALSE;
1912 reconstructor->Reconstruct(digitsTree, clustersTree);
1914 loader->UnloadDigits();
1917 TString detQAStr(fQADetectors) ;
1919 fQASteer->RunOneEventInOneDetector(iDet, clustersTree) ;
1921 loader->WriteRecPoints("OVERWRITE");
1922 loader->UnloadRecPoints();
1923 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1925 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1926 AliError(Form("the following detectors were not found: %s",
1928 if (fStopOnError) return kFALSE;
1934 //_____________________________________________________________________________
1935 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
1937 // run the barrel tracking
1939 AliCodeTimerAuto("")
1941 AliESDVertex* vertex = NULL;
1942 Double_t vtxPos[3] = {0, 0, 0};
1943 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
1944 TArrayF mcVertex(3);
1945 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
1946 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
1947 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
1951 AliInfo("running the ITS vertex finder");
1953 fLoader[0]->LoadRecPoints();
1954 TTree* cltree = fLoader[0]->TreeR();
1956 if(fDiamondProfileSPD) fVertexer->SetVtxStart(fDiamondProfileSPD);
1957 vertex = fVertexer->FindVertexForCurrentEvent(cltree);
1960 AliError("Can't get the ITS cluster tree");
1962 fLoader[0]->UnloadRecPoints();
1965 AliError("Can't get the ITS loader");
1968 AliWarning("Vertex not found");
1969 vertex = new AliESDVertex();
1970 vertex->SetName("default");
1973 vertex->SetName("reconstructed");
1977 AliInfo("getting the primary vertex from MC");
1978 vertex = new AliESDVertex(vtxPos, vtxErr);
1982 vertex->GetXYZ(vtxPos);
1983 vertex->GetSigmaXYZ(vtxErr);
1985 AliWarning("no vertex reconstructed");
1986 vertex = new AliESDVertex(vtxPos, vtxErr);
1988 esd->SetPrimaryVertexSPD(vertex);
1989 // if SPD multiplicity has been determined, it is stored in the ESD
1990 AliMultiplicity *mult = fVertexer->GetMultiplicity();
1991 if(mult)esd->SetMultiplicity(mult);
1993 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1994 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2001 //_____________________________________________________________________________
2002 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
2004 // run the HLT barrel tracking
2006 AliCodeTimerAuto("")
2009 AliError("Missing runLoader!");
2013 AliInfo("running HLT tracking");
2015 // Get a pointer to the HLT reconstructor
2016 AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1);
2017 if (!reconstructor) return kFALSE;
2020 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2021 TString detName = fgkDetectorName[iDet];
2022 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2023 reconstructor->SetOption(detName.Data());
2024 AliTracker *tracker = reconstructor->CreateTracker();
2026 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2027 if (fStopOnError) return kFALSE;
2031 Double_t vtxErr[3]={0.005,0.005,0.010};
2032 const AliESDVertex *vertex = esd->GetVertex();
2033 vertex->GetXYZ(vtxPos);
2034 tracker->SetVertex(vtxPos,vtxErr);
2036 fLoader[iDet]->LoadRecPoints("read");
2037 TTree* tree = fLoader[iDet]->TreeR();
2039 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2042 tracker->LoadClusters(tree);
2044 if (tracker->Clusters2Tracks(esd) != 0) {
2045 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2049 tracker->UnloadClusters();
2057 //_____________________________________________________________________________
2058 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2060 // run the muon spectrometer tracking
2062 AliCodeTimerAuto("")
2065 AliError("Missing runLoader!");
2068 Int_t iDet = 7; // for MUON
2070 AliInfo("is running...");
2072 // Get a pointer to the MUON reconstructor
2073 AliReconstructor *reconstructor = GetReconstructor(iDet);
2074 if (!reconstructor) return kFALSE;
2077 TString detName = fgkDetectorName[iDet];
2078 AliDebug(1, Form("%s tracking", detName.Data()));
2079 AliTracker *tracker = reconstructor->CreateTracker();
2081 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2086 fLoader[iDet]->LoadRecPoints("read");
2088 tracker->LoadClusters(fLoader[iDet]->TreeR());
2090 Int_t rv = tracker->Clusters2Tracks(esd);
2094 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2098 fLoader[iDet]->UnloadRecPoints();
2100 tracker->UnloadClusters();
2108 //_____________________________________________________________________________
2109 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
2111 // run the barrel tracking
2112 static Int_t eventNr=0;
2113 AliCodeTimerAuto("")
2115 AliInfo("running tracking");
2117 //Fill the ESD with the T0 info (will be used by the TOF)
2118 if (fReconstructor[11] && fLoader[11]) {
2119 fLoader[11]->LoadRecPoints("READ");
2120 TTree *treeR = fLoader[11]->TreeR();
2121 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2124 // pass 1: TPC + ITS inwards
2125 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2126 if (!fTracker[iDet]) continue;
2127 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2130 fLoader[iDet]->LoadRecPoints("read");
2131 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2132 TTree* tree = fLoader[iDet]->TreeR();
2134 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2137 fTracker[iDet]->LoadClusters(tree);
2138 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2140 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2141 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2144 // preliminary PID in TPC needed by the ITS tracker
2146 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2147 AliESDpid::MakePID(esd);
2149 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2152 // pass 2: ALL backwards
2154 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2155 if (!fTracker[iDet]) continue;
2156 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2159 if (iDet > 1) { // all except ITS, TPC
2161 fLoader[iDet]->LoadRecPoints("read");
2162 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2163 tree = fLoader[iDet]->TreeR();
2165 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2168 fTracker[iDet]->LoadClusters(tree);
2169 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2173 if (iDet>1) // start filling residuals for the "outer" detectors
2174 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2176 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2177 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
2182 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
2183 fTracker[iDet]->UnloadClusters();
2184 fLoader[iDet]->UnloadRecPoints();
2186 // updated PID in TPC needed by the ITS tracker -MI
2188 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2189 AliESDpid::MakePID(esd);
2191 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2193 //stop filling residuals for the "outer" detectors
2194 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2196 // pass 3: TRD + TPC + ITS refit inwards
2198 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2199 if (!fTracker[iDet]) continue;
2200 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
2203 if (iDet<2) // start filling residuals for TPC and ITS
2204 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2206 if (fTracker[iDet]->RefitInward(esd) != 0) {
2207 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
2210 // run postprocessing
2211 if (fTracker[iDet]->PostProcess(esd) != 0) {
2212 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2215 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2218 // write space-points to the ESD in case alignment data output
2220 if (fWriteAlignmentData)
2221 WriteAlignmentData(esd);
2223 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2224 if (!fTracker[iDet]) continue;
2226 fTracker[iDet]->UnloadClusters();
2227 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
2228 fLoader[iDet]->UnloadRecPoints();
2229 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
2231 // stop filling residuals for TPC and ITS
2232 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2238 //_____________________________________________________________________________
2239 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2241 // Remove the data which are not needed for the physics analysis.
2244 Int_t nTracks=esd->GetNumberOfTracks();
2245 Int_t nV0s=esd->GetNumberOfV0s();
2247 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
2249 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2250 Bool_t rc=esd->Clean(cleanPars);
2252 nTracks=esd->GetNumberOfTracks();
2253 nV0s=esd->GetNumberOfV0s();
2255 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2260 //_____________________________________________________________________________
2261 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2263 // fill the event summary data
2265 AliCodeTimerAuto("")
2266 static Int_t eventNr=0;
2267 TString detStr = detectors;
2269 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2270 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2271 AliReconstructor* reconstructor = GetReconstructor(iDet);
2272 if (!reconstructor) continue;
2273 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2274 TTree* clustersTree = NULL;
2275 if (fLoader[iDet]) {
2276 fLoader[iDet]->LoadRecPoints("read");
2277 clustersTree = fLoader[iDet]->TreeR();
2278 if (!clustersTree) {
2279 AliError(Form("Can't get the %s clusters tree",
2280 fgkDetectorName[iDet]));
2281 if (fStopOnError) return kFALSE;
2284 if (fRawReader && !reconstructor->HasDigitConversion()) {
2285 reconstructor->FillESD(fRawReader, clustersTree, esd);
2287 TTree* digitsTree = NULL;
2288 if (fLoader[iDet]) {
2289 fLoader[iDet]->LoadDigits("read");
2290 digitsTree = fLoader[iDet]->TreeD();
2292 AliError(Form("Can't get the %s digits tree",
2293 fgkDetectorName[iDet]));
2294 if (fStopOnError) return kFALSE;
2297 reconstructor->FillESD(digitsTree, clustersTree, esd);
2298 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2300 if (fLoader[iDet]) {
2301 fLoader[iDet]->UnloadRecPoints();
2305 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2306 AliError(Form("the following detectors were not found: %s",
2308 if (fStopOnError) return kFALSE;
2310 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2315 //_____________________________________________________________________________
2316 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2318 // Reads the trigger decision which is
2319 // stored in Trigger.root file and fills
2320 // the corresponding esd entries
2322 AliCodeTimerAuto("")
2324 AliInfo("Filling trigger information into the ESD");
2327 AliCTPRawStream input(fRawReader);
2328 if (!input.Next()) {
2329 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2332 if (esd->GetTriggerMask() != input.GetClassMask())
2333 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2334 input.GetClassMask(),esd->GetTriggerMask()));
2335 if (esd->GetOrbitNumber() != input.GetOrbitID())
2336 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2337 input.GetOrbitID(),esd->GetOrbitNumber()));
2338 if (esd->GetBunchCrossNumber() != input.GetBCID())
2339 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2340 input.GetBCID(),esd->GetBunchCrossNumber()));
2343 // Here one has to add the filling of trigger inputs and
2344 // interaction records
2354 //_____________________________________________________________________________
2355 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2358 // Filling information from RawReader Header
2361 if (!fRawReader) return kFALSE;
2363 AliInfo("Filling information from RawReader Header");
2365 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2366 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2367 esd->SetPeriodNumber(fRawReader->GetPeriod());
2369 esd->SetTimeStamp(fRawReader->GetTimestamp());
2370 esd->SetEventType(fRawReader->GetType());
2376 //_____________________________________________________________________________
2377 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2379 // check whether detName is contained in detectors
2380 // if yes, it is removed from detectors
2382 // check if all detectors are selected
2383 if ((detectors.CompareTo("ALL") == 0) ||
2384 detectors.BeginsWith("ALL ") ||
2385 detectors.EndsWith(" ALL") ||
2386 detectors.Contains(" ALL ")) {
2391 // search for the given detector
2392 Bool_t result = kFALSE;
2393 if ((detectors.CompareTo(detName) == 0) ||
2394 detectors.BeginsWith(detName+" ") ||
2395 detectors.EndsWith(" "+detName) ||
2396 detectors.Contains(" "+detName+" ")) {
2397 detectors.ReplaceAll(detName, "");
2401 // clean up the detectors string
2402 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2403 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2404 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2409 //_____________________________________________________________________________
2410 Bool_t AliReconstruction::InitRunLoader()
2412 // get or create the run loader
2414 if (gAlice) delete gAlice;
2417 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2418 // load all base libraries to get the loader classes
2419 TString libs = gSystem->GetLibraries();
2420 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2421 TString detName = fgkDetectorName[iDet];
2422 if (detName == "HLT") continue;
2423 if (libs.Contains("lib" + detName + "base.so")) continue;
2424 gSystem->Load("lib" + detName + "base.so");
2426 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2428 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2433 fRunLoader->CdGAFile();
2434 fRunLoader->LoadgAlice();
2436 //PH This is a temporary fix to give access to the kinematics
2437 //PH that is needed for the labels of ITS clusters
2438 fRunLoader->LoadHeader();
2439 fRunLoader->LoadKinematics();
2441 } else { // galice.root does not exist
2443 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2445 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2446 AliConfig::GetDefaultEventFolderName(),
2449 AliError(Form("could not create run loader in file %s",
2450 fGAliceFileName.Data()));
2454 fIsNewRunLoader = kTRUE;
2455 fRunLoader->MakeTree("E");
2457 if (fNumberOfEventsPerFile > 0)
2458 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2460 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2466 //_____________________________________________________________________________
2467 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2469 // get the reconstructor object and the loader for a detector
2471 if (fReconstructor[iDet]) {
2472 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2473 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2474 fReconstructor[iDet]->SetRecoParam(par);
2476 return fReconstructor[iDet];
2479 // load the reconstructor object
2480 TPluginManager* pluginManager = gROOT->GetPluginManager();
2481 TString detName = fgkDetectorName[iDet];
2482 TString recName = "Ali" + detName + "Reconstructor";
2484 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2486 AliReconstructor* reconstructor = NULL;
2487 // first check if a plugin is defined for the reconstructor
2488 TPluginHandler* pluginHandler =
2489 pluginManager->FindHandler("AliReconstructor", detName);
2490 // if not, add a plugin for it
2491 if (!pluginHandler) {
2492 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2493 TString libs = gSystem->GetLibraries();
2494 if (libs.Contains("lib" + detName + "base.so") ||
2495 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2496 pluginManager->AddHandler("AliReconstructor", detName,
2497 recName, detName + "rec", recName + "()");
2499 pluginManager->AddHandler("AliReconstructor", detName,
2500 recName, detName, recName + "()");
2502 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2504 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2505 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2507 if (reconstructor) {
2508 TObject* obj = fOptions.FindObject(detName.Data());
2509 if (obj) reconstructor->SetOption(obj->GetTitle());
2510 reconstructor->Init();
2511 fReconstructor[iDet] = reconstructor;
2514 // get or create the loader
2515 if (detName != "HLT") {
2516 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2517 if (!fLoader[iDet]) {
2518 AliConfig::Instance()
2519 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2521 // first check if a plugin is defined for the loader
2523 pluginManager->FindHandler("AliLoader", detName);
2524 // if not, add a plugin for it
2525 if (!pluginHandler) {
2526 TString loaderName = "Ali" + detName + "Loader";
2527 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2528 pluginManager->AddHandler("AliLoader", detName,
2529 loaderName, detName + "base",
2530 loaderName + "(const char*, TFolder*)");
2531 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2533 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2535 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2536 fRunLoader->GetEventFolder());
2538 if (!fLoader[iDet]) { // use default loader
2539 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2541 if (!fLoader[iDet]) {
2542 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2543 if (fStopOnError) return NULL;
2545 fRunLoader->AddLoader(fLoader[iDet]);
2546 fRunLoader->CdGAFile();
2547 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2548 fRunLoader->Write(0, TObject::kOverwrite);
2553 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2554 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2555 reconstructor->SetRecoParam(par);
2557 return reconstructor;
2560 //_____________________________________________________________________________
2561 Bool_t AliReconstruction::CreateVertexer()
2563 // create the vertexer
2566 AliReconstructor* itsReconstructor = GetReconstructor(0);
2567 if (itsReconstructor) {
2568 fVertexer = itsReconstructor->CreateVertexer();
2571 AliWarning("couldn't create a vertexer for ITS");
2572 if (fStopOnError) return kFALSE;
2578 //_____________________________________________________________________________
2579 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2581 // create the trackers
2582 AliInfo("Creating trackers");
2584 TString detStr = detectors;
2585 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2586 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2587 AliReconstructor* reconstructor = GetReconstructor(iDet);
2588 if (!reconstructor) continue;
2589 TString detName = fgkDetectorName[iDet];
2590 if (detName == "HLT") {
2591 fRunHLTTracking = kTRUE;
2594 if (detName == "MUON") {
2595 fRunMuonTracking = kTRUE;
2600 fTracker[iDet] = reconstructor->CreateTracker();
2601 if (!fTracker[iDet] && (iDet < 7)) {
2602 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2603 if (fStopOnError) return kFALSE;
2605 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2611 //_____________________________________________________________________________
2612 void AliReconstruction::CleanUp()
2614 // delete trackers and the run loader and close and delete the file
2616 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2617 delete fReconstructor[iDet];
2618 fReconstructor[iDet] = NULL;
2619 fLoader[iDet] = NULL;
2620 delete fTracker[iDet];
2621 fTracker[iDet] = NULL;
2632 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2633 delete fDiamondProfileSPD;
2634 fDiamondProfileSPD = NULL;
2635 delete fDiamondProfile;
2636 fDiamondProfile = NULL;
2637 delete fDiamondProfileTPC;
2638 fDiamondProfileTPC = NULL;
2644 delete fParentRawReader;
2645 fParentRawReader=NULL;
2654 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2656 // Write space-points which are then used in the alignment procedures
2657 // For the moment only ITS, TPC, TRD and TOF
2659 Int_t ntracks = esd->GetNumberOfTracks();
2660 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2662 AliESDtrack *track = esd->GetTrack(itrack);
2665 for (Int_t iDet = 3; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2666 nsp += track->GetNcls(iDet);
2668 if (iDet==0) { // ITS "extra" clusters
2669 track->GetClusters(iDet,idx);
2670 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2675 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2676 track->SetTrackPointArray(sp);
2678 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2679 AliTracker *tracker = fTracker[iDet];
2680 if (!tracker) continue;
2681 Int_t nspdet = track->GetClusters(iDet,idx);
2683 if (iDet==0) // ITS "extra" clusters
2684 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2686 if (nspdet <= 0) continue;
2690 while (isp2 < nspdet) {
2691 Bool_t isvalid=kTRUE;
2693 Int_t index=idx[isp++];
2694 if (index < 0) continue;
2696 TString dets = fgkDetectorName[iDet];
2697 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2698 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2699 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2700 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2701 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2703 isvalid = tracker->GetTrackPoint(index,p);
2706 if (!isvalid) continue;
2707 sp->AddPoint(isptrack,&p); isptrack++;
2714 //_____________________________________________________________________________
2715 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2717 // The method reads the raw-data error log
2718 // accumulated within the rawReader.
2719 // It extracts the raw-data errors related to
2720 // the current event and stores them into
2721 // a TClonesArray inside the esd object.
2723 if (!fRawReader) return;
2725 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2727 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2729 if (iEvent != log->GetEventNumber()) continue;
2731 esd->AddRawDataErrorLog(log);
2736 TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){
2737 // Dump a file content into a char in TNamed
2739 in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
2740 Int_t kBytes = (Int_t)in.tellg();
2741 printf("Size: %d \n",kBytes);
2744 char* memblock = new char [kBytes];
2745 in.seekg (0, ios::beg);
2746 in.read (memblock, kBytes);
2748 TString fData(memblock,kBytes);
2749 fn = new TNamed(pName,fData);
2750 printf("fData Size: %d \n",fData.Sizeof());
2751 printf("pName Size: %d \n",pName.Sizeof());
2752 printf("fn Size: %d \n",fn->Sizeof());
2756 AliInfo(Form("Could not Open %s\n",fPath.Data()));
2762 void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){
2763 // This is not really needed in AliReconstruction at the moment
2764 // but can serve as a template
2766 TList *fList = fTree->GetUserInfo();
2767 TNamed *fn = (TNamed*)fList->FindObject(pName.Data());
2768 printf("fn Size: %d \n",fn->Sizeof());
2770 TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works
2771 const char* cdata = fn->GetTitle();
2772 printf("fTmp Size %d\n",fTmp.Sizeof());
2774 int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
2775 printf("calculated size %d\n",size);
2776 ofstream out(pName.Data(),ios::out | ios::binary);
2777 out.write(cdata,size);
2782 //_____________________________________________________________________________
2783 void AliReconstruction::CheckQA()
2785 // check the QA of SIM for this run and remove the detectors
2786 // with status Fatal
2788 TString newRunLocalReconstruction ;
2789 TString newRunTracking ;
2790 TString newFillESD ;
2792 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2793 TString detName(AliQA::GetDetName(iDet)) ;
2794 AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2795 if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) {
2796 AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ;
2798 if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2799 fRunLocalReconstruction.Contains("ALL") ) {
2800 newRunLocalReconstruction += detName ;
2801 newRunLocalReconstruction += " " ;
2803 if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2804 fRunTracking.Contains("ALL") ) {
2805 newRunTracking += detName ;
2806 newRunTracking += " " ;
2808 if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2809 fFillESD.Contains("ALL") ) {
2810 newFillESD += detName ;
2815 fRunLocalReconstruction = newRunLocalReconstruction ;
2816 fRunTracking = newRunTracking ;
2817 fFillESD = newFillESD ;
2820 //_____________________________________________________________________________
2821 Int_t AliReconstruction::GetDetIndex(const char* detector)
2823 // return the detector index corresponding to detector
2825 for (index = 0; index < fgkNDetectors ; index++) {
2826 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2831 //_____________________________________________________________________________
2832 Bool_t AliReconstruction::FinishPlaneEff() {
2834 // Here execute all the necessary operationis, at the end of the tracking phase,
2835 // in case that evaluation of PlaneEfficiencies was required for some detector.
2836 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2838 // This Preliminary version works only FOR ITS !!!!!
2839 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2842 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2845 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2846 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2847 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2848 if(fTracker[iDet]) {
2849 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2850 TString name=planeeff->GetName();
2852 TFile* pefile = TFile::Open(name, "RECREATE");
2853 ret=(Bool_t)planeeff->Write();
2855 if(planeeff->GetCreateHistos()) {
2856 TString hname=planeeff->GetName();
2857 hname+="Histo.root";
2858 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2864 //_____________________________________________________________________________
2865 Bool_t AliReconstruction::InitPlaneEff() {
2867 // Here execute all the necessary operations, before of the tracking phase,
2868 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2869 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2870 // which should be updated/recalculated.
2872 // This Preliminary version will work only FOR ITS !!!!!
2873 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2876 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2878 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2882 //_____________________________________________________________________________
2883 Bool_t AliReconstruction::InitAliEVE()
2885 // This method should be called only in case
2886 // AliReconstruction is run
2887 // within the alieve environment.
2888 // It will initialize AliEVE in a way
2889 // so that it can visualize event processed
2890 // by AliReconstruction.
2891 // The return flag shows whenever the
2892 // AliEVE initialization was successful or not.
2895 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2896 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2897 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2899 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
2900 gROOT->ProcessLine("alieve_online_init()");
2905 //_____________________________________________________________________________
2906 void AliReconstruction::RunAliEVE()
2908 // Runs AliEVE visualisation of
2909 // the current event.
2910 // Should be executed only after
2911 // successful initialization of AliEVE.
2913 AliInfo("Running AliEVE...");
2914 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd));
2918 //_____________________________________________________________________________
2919 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2921 // Allows to run QA for a selected set of detectors
2922 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2923 // all selected detectors run the same selected tasks
2925 if (!detAndAction.Contains(":")) {
2926 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2930 Int_t colon = detAndAction.Index(":") ;
2931 fQADetectors = detAndAction(0, colon) ;
2932 if (fQADetectors.Contains("ALL") )
2933 fQADetectors = fFillESD ;
2934 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2935 if (fQATasks.Contains("ALL") ) {
2936 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2938 fQATasks.ToUpper() ;
2940 if ( fQATasks.Contains("RAW") )
2941 tempo = Form("%d ", AliQA::kRAWS) ;
2942 if ( fQATasks.Contains("RECPOINT") )
2943 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2944 if ( fQATasks.Contains("ESD") )
2945 tempo += Form("%d ", AliQA::kESDS) ;
2947 if (fQATasks.IsNull()) {
2948 AliInfo("No QA requested\n") ;
2953 TString tempo(fQATasks) ;
2954 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2955 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2956 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2957 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2962 //_____________________________________________________________________________
2963 Bool_t AliReconstruction::InitRecoParams()
2965 // The method accesses OCDB and retrieves all
2966 // the available reco-param objects from there.
2968 Bool_t isOK = kTRUE;
2970 TString detStr = fLoadCDB;
2971 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2973 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2975 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2976 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2980 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
2982 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2983 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
2985 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
2989 TObject *recoParamObj = entry->GetObject();
2990 if (dynamic_cast<TObjArray*>(recoParamObj)) {
2991 // The detector has a normal TobjArray of AliDetectorRecoParam objects
2992 // Registering them in AliRecoParam
2993 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
2995 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
2996 // The detector has only onse set of reco parameters
2997 // Registering it in AliRecoParam
2998 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
2999 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3000 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3003 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
3007 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
3011 if (AliDebugLevel() > 0) fRecoParam.Print();
3016 //_____________________________________________________________________________
3017 Bool_t AliReconstruction::GetEventInfo()
3019 // Fill the event info object
3021 AliCodeTimerAuto("")
3023 AliCentralTrigger *aCTP = NULL;
3025 fEventInfo.SetEventType(fRawReader->GetType());
3027 ULong64_t mask = fRawReader->GetClassMask();
3028 fEventInfo.SetTriggerMask(mask);
3029 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
3030 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
3032 aCTP = new AliCentralTrigger();
3033 TString configstr("");
3034 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
3035 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
3039 aCTP->SetClassMask(mask);
3040 aCTP->SetClusterMask(clmask);
3043 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
3045 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
3046 aCTP = fRunLoader->GetTrigger();
3047 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
3048 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
3051 AliWarning("No trigger can be loaded! The trigger information will not be used!");
3056 AliTriggerConfiguration *config = aCTP->GetConfiguration();
3058 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
3059 if (fRawReader) delete aCTP;
3063 UChar_t clustmask = 0;
3065 ULong64_t trmask = fEventInfo.GetTriggerMask();
3066 const TObjArray& classesArray = config->GetClasses();
3067 Int_t nclasses = classesArray.GetEntriesFast();
3068 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
3069 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
3071 Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask());
3072 fesd->SetTriggerClass(trclass->GetName(),trindex);
3073 if (trmask & (1 << trindex)) {
3075 trclasses += trclass->GetName();
3077 clustmask |= trclass->GetCluster()->GetClusterMask();
3081 fEventInfo.SetTriggerClasses(trclasses);
3083 // Set the information in ESD
3084 fesd->SetTriggerMask(trmask);
3085 fesd->SetTriggerCluster(clustmask);
3087 if (!aCTP->CheckTriggeredDetectors()) {
3088 if (fRawReader) delete aCTP;
3092 if (fRawReader) delete aCTP;
3094 // We have to fill also the HLT decision here!!
3100 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3102 // Match the detector list found in the rec.C or the default 'ALL'
3103 // to the list found in the GRP (stored there by the shuttle PP which
3104 // gets the information from ECS)
3105 static TString resultList;
3106 TString detList = detectorList;
3110 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3111 if ((detectorMask >> iDet) & 0x1) {
3112 TString det = AliDAQ::OfflineModuleName(iDet);
3113 if ((detList.CompareTo("ALL") == 0) ||
3114 detList.BeginsWith("ALL ") ||
3115 detList.EndsWith(" ALL") ||
3116 detList.Contains(" ALL ") ||
3117 (detList.CompareTo(det) == 0) ||
3118 detList.BeginsWith(det) ||
3119 detList.EndsWith(det) ||
3120 detList.Contains( " "+det+" " )) {
3121 if (!resultList.EndsWith(det + " ")) {
3130 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3131 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3132 if ((detList.CompareTo("ALL") == 0) ||
3133 detList.BeginsWith("ALL ") ||
3134 detList.EndsWith(" ALL") ||
3135 detList.Contains(" ALL ") ||
3136 (detList.CompareTo(hltDet) == 0) ||
3137 detList.BeginsWith(hltDet) ||
3138 detList.EndsWith(hltDet) ||
3139 detList.Contains( " "+hltDet+" " )) {
3140 resultList += hltDet;
3144 return resultList.Data();
3148 //______________________________________________________________________________
3149 void AliReconstruction::Abort(const char *method, EAbort what)
3151 // Abort processing. If what = kAbortProcess, the Process() loop will be
3152 // aborted. If what = kAbortFile, the current file in a chain will be
3153 // aborted and the processing will continue with the next file, if there
3154 // is no next file then Process() will be aborted. Abort() can also be
3155 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3156 // the SlaveTerminate() and Terminate() are always called. The abort flag
3157 // can be checked in these methods using GetAbort().
3159 // The method is overwritten in AliReconstruction for better handling of
3160 // reco specific errors
3162 if (!fStopOnError) return;
3166 TString whyMess = method;
3167 whyMess += " failed! Aborting...";
3169 AliError(whyMess.Data());
3172 TString mess = "Abort";
3173 if (fAbort == kAbortProcess)
3174 mess = "AbortProcess";
3175 else if (fAbort == kAbortFile)
3178 Info(mess, whyMess.Data());