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 ClassImp(AliReconstruction)
197 //_____________________________________________________________________________
198 const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
200 //_____________________________________________________________________________
201 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
203 fUniformField(kFALSE),
204 fForcedFieldMap(NULL),
205 fRunVertexFinder(kTRUE),
206 fRunVertexFinderTracks(kTRUE),
207 fRunHLTTracking(kFALSE),
208 fRunMuonTracking(kFALSE),
210 fRunCascadeFinder(kTRUE),
211 fStopOnError(kFALSE),
212 fWriteAlignmentData(kFALSE),
213 fWriteESDfriend(kFALSE),
214 fFillTriggerESD(kTRUE),
222 fRunLocalReconstruction("ALL"),
226 fUseTrackingErrorsForAlignment(""),
227 fGAliceFileName(gAliceFilename),
232 fNumberOfEventsPerFile(1),
234 fLoadAlignFromCDB(kTRUE),
235 fLoadAlignData("ALL"),
243 fParentRawReader(NULL),
248 fDiamondProfile(NULL),
249 fDiamondProfileTPC(NULL),
250 fMeanVertexConstraint(kTRUE),
254 fAlignObjArray(NULL),
257 fInitCDBCalled(kFALSE),
258 fSetRunNumberFromDataCalled(kFALSE),
264 fSameQACycle(kFALSE),
266 fRunPlaneEff(kFALSE),
275 fIsNewRunLoader(kFALSE),
279 // create reconstruction object with default parameters
282 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
283 fReconstructor[iDet] = NULL;
284 fLoader[iDet] = NULL;
285 fTracker[iDet] = NULL;
287 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
288 fQACycles[iDet] = 999999 ;
289 fQAWriteExpert[iDet] = kFALSE ;
295 //_____________________________________________________________________________
296 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
298 fUniformField(rec.fUniformField),
299 fForcedFieldMap(NULL),
300 fRunVertexFinder(rec.fRunVertexFinder),
301 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
302 fRunHLTTracking(rec.fRunHLTTracking),
303 fRunMuonTracking(rec.fRunMuonTracking),
304 fRunV0Finder(rec.fRunV0Finder),
305 fRunCascadeFinder(rec.fRunCascadeFinder),
306 fStopOnError(rec.fStopOnError),
307 fWriteAlignmentData(rec.fWriteAlignmentData),
308 fWriteESDfriend(rec.fWriteESDfriend),
309 fFillTriggerESD(rec.fFillTriggerESD),
311 fCleanESD(rec.fCleanESD),
312 fV0DCAmax(rec.fV0DCAmax),
313 fV0CsPmin(rec.fV0CsPmin),
317 fRunLocalReconstruction(rec.fRunLocalReconstruction),
318 fRunTracking(rec.fRunTracking),
319 fFillESD(rec.fFillESD),
320 fLoadCDB(rec.fLoadCDB),
321 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
322 fGAliceFileName(rec.fGAliceFileName),
323 fRawInput(rec.fRawInput),
324 fEquipIdMap(rec.fEquipIdMap),
325 fFirstEvent(rec.fFirstEvent),
326 fLastEvent(rec.fLastEvent),
327 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
329 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
330 fLoadAlignData(rec.fLoadAlignData),
331 fESDPar(rec.fESDPar),
332 fUseHLTData(rec.fUseHLTData),
338 fParentRawReader(NULL),
340 fRecoParam(rec.fRecoParam),
343 fDiamondProfile(rec.fDiamondProfile),
344 fDiamondProfileTPC(rec.fDiamondProfileTPC),
345 fMeanVertexConstraint(rec.fMeanVertexConstraint),
349 fAlignObjArray(rec.fAlignObjArray),
350 fCDBUri(rec.fCDBUri),
352 fInitCDBCalled(rec.fInitCDBCalled),
353 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
354 fQADetectors(rec.fQADetectors),
356 fQATasks(rec.fQATasks),
358 fRunGlobalQA(rec.fRunGlobalQA),
359 fSameQACycle(rec.fSameQACycle),
360 fRunPlaneEff(rec.fRunPlaneEff),
369 fIsNewRunLoader(rec.fIsNewRunLoader),
375 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
376 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
378 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
379 fReconstructor[iDet] = NULL;
380 fLoader[iDet] = NULL;
381 fTracker[iDet] = NULL;
384 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
385 fQACycles[iDet] = rec.fQACycles[iDet];
386 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
389 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
390 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
394 //_____________________________________________________________________________
395 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
397 // assignment operator
398 // Used in PROOF mode
399 // Be very careful while modifing it!
400 // Simple rules to follow:
401 // for persistent data members - use their assignment operators
402 // for non-persistent ones - do nothing or take the default values from constructor
403 // TSelector members should not be touched
404 if(&rec == this) return *this;
406 fUniformField = rec.fUniformField;
407 fForcedFieldMap = NULL;
408 fRunVertexFinder = rec.fRunVertexFinder;
409 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
410 fRunHLTTracking = rec.fRunHLTTracking;
411 fRunMuonTracking = rec.fRunMuonTracking;
412 fRunV0Finder = rec.fRunV0Finder;
413 fRunCascadeFinder = rec.fRunCascadeFinder;
414 fStopOnError = rec.fStopOnError;
415 fWriteAlignmentData = rec.fWriteAlignmentData;
416 fWriteESDfriend = rec.fWriteESDfriend;
417 fFillTriggerESD = rec.fFillTriggerESD;
419 fCleanESD = rec.fCleanESD;
420 fV0DCAmax = rec.fV0DCAmax;
421 fV0CsPmin = rec.fV0CsPmin;
425 fRunLocalReconstruction = rec.fRunLocalReconstruction;
426 fRunTracking = rec.fRunTracking;
427 fFillESD = rec.fFillESD;
428 fLoadCDB = rec.fLoadCDB;
429 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
430 fGAliceFileName = rec.fGAliceFileName;
431 fRawInput = rec.fRawInput;
432 fEquipIdMap = rec.fEquipIdMap;
433 fFirstEvent = rec.fFirstEvent;
434 fLastEvent = rec.fLastEvent;
435 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
437 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
438 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
441 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
442 fLoadAlignData = rec.fLoadAlignData;
443 fESDPar = rec.fESDPar;
444 fUseHLTData = rec.fUseHLTData;
446 delete fRunInfo; fRunInfo = NULL;
447 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
449 fEventInfo = rec.fEventInfo;
453 fParentRawReader = NULL;
455 fRecoParam = rec.fRecoParam;
457 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
458 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
459 delete fLoader[iDet]; fLoader[iDet] = NULL;
460 delete fTracker[iDet]; fTracker[iDet] = NULL;
463 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
464 fQACycles[iDet] = rec.fQACycles[iDet];
465 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
469 delete fDiamondProfile; fDiamondProfile = NULL;
470 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
471 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
472 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
473 fMeanVertexConstraint = rec.fMeanVertexConstraint;
475 delete fGRPData; fGRPData = NULL;
476 if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
478 delete fAlignObjArray; fAlignObjArray = NULL;
481 fSpecCDBUri.Delete();
482 fInitCDBCalled = rec.fInitCDBCalled;
483 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
484 fQADetectors = rec.fQADetectors;
486 fQATasks = rec.fQATasks;
488 fRunGlobalQA = rec.fRunGlobalQA;
489 fSameQACycle = rec.fSameQACycle;
490 fRunPlaneEff = rec.fRunPlaneEff;
499 fIsNewRunLoader = rec.fIsNewRunLoader;
506 //_____________________________________________________________________________
507 AliReconstruction::~AliReconstruction()
513 delete fForcedFieldMap;
515 if (fAlignObjArray) {
516 fAlignObjArray->Delete();
517 delete fAlignObjArray;
519 fSpecCDBUri.Delete();
521 AliCodeTimer::Instance()->Print();
524 //_____________________________________________________________________________
525 void AliReconstruction::InitCDB()
527 // activate a default CDB storage
528 // First check if we have any CDB storage set, because it is used
529 // to retrieve the calibration and alignment constants
530 AliCodeTimerAuto("");
532 if (fInitCDBCalled) return;
533 fInitCDBCalled = kTRUE;
535 AliCDBManager* man = AliCDBManager::Instance();
536 if (man->IsDefaultStorageSet())
538 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
539 AliWarning("Default CDB storage has been already set !");
540 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
541 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
542 fCDBUri = man->GetDefaultStorage()->GetURI();
545 if (fCDBUri.Length() > 0)
547 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
548 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
549 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
551 fCDBUri="local://$ALICE_ROOT";
552 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
553 AliWarning("Default CDB storage not yet set !!!!");
554 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
555 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
558 man->SetDefaultStorage(fCDBUri);
561 // Now activate the detector specific CDB storage locations
562 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
563 TObject* obj = fSpecCDBUri[i];
565 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
566 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
567 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
568 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
570 AliSysInfo::AddStamp("InitCDB");
573 //_____________________________________________________________________________
574 void AliReconstruction::SetDefaultStorage(const char* uri) {
575 // Store the desired default CDB storage location
576 // Activate it later within the Run() method
582 //_____________________________________________________________________________
583 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
584 // Store a detector-specific CDB storage location
585 // Activate it later within the Run() method
587 AliCDBPath aPath(calibType);
588 if(!aPath.IsValid()){
589 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
590 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
591 if(!strcmp(calibType, fgkDetectorName[iDet])) {
592 aPath.SetPath(Form("%s/*", calibType));
593 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
597 if(!aPath.IsValid()){
598 AliError(Form("Not a valid path or detector: %s", calibType));
603 // // check that calibType refers to a "valid" detector name
604 // Bool_t isDetector = kFALSE;
605 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
606 // TString detName = fgkDetectorName[iDet];
607 // if(aPath.GetLevel0() == detName) {
608 // isDetector = kTRUE;
614 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
618 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
619 if (obj) fSpecCDBUri.Remove(obj);
620 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
624 //_____________________________________________________________________________
625 Bool_t AliReconstruction::SetRunNumberFromData()
627 // The method is called in Run() in order
628 // to set a correct run number.
629 // In case of raw data reconstruction the
630 // run number is taken from the raw data header
632 if (fSetRunNumberFromDataCalled) return kTRUE;
633 fSetRunNumberFromDataCalled = kTRUE;
635 AliCDBManager* man = AliCDBManager::Instance();
638 if(fRawReader->NextEvent()) {
639 if(man->GetRun() > 0) {
640 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
642 man->SetRun(fRawReader->GetRunNumber());
643 fRawReader->RewindEvents();
646 if(man->GetRun() > 0) {
647 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
650 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
656 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
658 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
663 // read run number from gAlice
664 if(rl->GetHeader()) {
665 man->SetRun(rl->GetHeader()->GetRun());
670 AliError("Neither run-loader header nor RawReader objects are found !");
682 //_____________________________________________________________________________
683 void AliReconstruction::SetCDBLock() {
684 // Set CDB lock: from now on it is forbidden to reset the run number
685 // or the default storage or to activate any further storage!
687 AliCDBManager::Instance()->SetLock(1);
690 //_____________________________________________________________________________
691 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
693 // Read the alignment objects from CDB.
694 // Each detector is supposed to have the
695 // alignment objects in DET/Align/Data CDB path.
696 // All the detector objects are then collected,
697 // sorted by geometry level (starting from ALIC) and
698 // then applied to the TGeo geometry.
699 // Finally an overlaps check is performed.
701 // Load alignment data from CDB and fill fAlignObjArray
702 if(fLoadAlignFromCDB){
704 TString detStr = detectors;
705 TString loadAlObjsListOfDets = "";
707 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
708 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
709 if(fgkDetectorName[iDet]=="HLT") continue;
710 if(AliGeomManager::IsModuleInGeom(fgkDetectorName[iDet]))
712 loadAlObjsListOfDets += fgkDetectorName[iDet];
713 loadAlObjsListOfDets += " ";
715 } // end loop over detectors
716 if(AliGeomManager::IsModuleInGeom("FRAME"))
717 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
718 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
719 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
721 // Check if the array with alignment objects was
722 // provided by the user. If yes, apply the objects
723 // to the present TGeo geometry
724 if (fAlignObjArray) {
725 if (gGeoManager && gGeoManager->IsClosed()) {
726 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
727 AliError("The misalignment of one or more volumes failed!"
728 "Compare the list of simulated detectors and the list of detector alignment data!");
733 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
739 if (fAlignObjArray) {
740 fAlignObjArray->Delete();
741 delete fAlignObjArray; fAlignObjArray=NULL;
747 //_____________________________________________________________________________
748 void AliReconstruction::SetGAliceFile(const char* fileName)
750 // set the name of the galice file
752 fGAliceFileName = fileName;
755 //_____________________________________________________________________________
756 void AliReconstruction::SetInput(const char* input)
758 // In case the input string starts with 'mem://', we run in an online mode
759 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
760 // file is assumed. One can give as an input:
761 // mem://: - events taken from DAQ monitoring libs online
763 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
764 if (input) fRawInput = input;
767 //_____________________________________________________________________________
768 void AliReconstruction::SetOption(const char* detector, const char* option)
770 // set options for the reconstruction of a detector
772 TObject* obj = fOptions.FindObject(detector);
773 if (obj) fOptions.Remove(obj);
774 fOptions.Add(new TNamed(detector, option));
777 //_____________________________________________________________________________
778 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
780 // Set custom reconstruction parameters for a given detector
781 // Single set of parameters for all the events
783 // First check if the reco-params are global
784 if(!strcmp(detector, "GRP")) {
786 fRecoParam.AddDetRecoParam(fgkNDetectors,par);
790 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
791 if(!strcmp(detector, fgkDetectorName[iDet])) {
793 fRecoParam.AddDetRecoParam(iDet,par);
800 //_____________________________________________________________________________
801 Bool_t AliReconstruction::SetFieldMap(Float_t l3Current, Float_t diCurrent, Float_t factor, const char *path) {
802 //------------------------------------------------
803 // The magnetic field map, defined externally...
804 // L3 current 30000 A -> 0.5 T
805 // L3 current 12000 A -> 0.2 T
806 // dipole current 6000 A
807 // The polarities must be the same
808 //------------------------------------------------
809 const Float_t l3NominalCurrent1=30000.; // (A)
810 const Float_t l3NominalCurrent2=12000.; // (A)
811 const Float_t diNominalCurrent =6000. ; // (A)
813 const Float_t tolerance=0.03; // relative current tolerance
814 const Float_t zero=77.; // "zero" current (A)
817 Bool_t dipoleON=kFALSE;
819 TString s=(factor < 0) ? "L3: -" : "L3: +";
821 l3Current = TMath::Abs(l3Current);
822 if (TMath::Abs(l3Current-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
823 map=AliMagWrapCheb::k5kG;
826 if (TMath::Abs(l3Current-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
827 map=AliMagWrapCheb::k2kG;
830 if (l3Current < zero) {
831 map=AliMagWrapCheb::k2kG;
833 factor=0.; // in fact, this is a global factor...
834 fUniformField=kTRUE; // track with the uniform (zero) B field
836 AliError(Form("Wrong L3 current (%f A)!",l3Current));
840 diCurrent = TMath::Abs(diCurrent);
841 if (TMath::Abs(diCurrent-diNominalCurrent)/diNominalCurrent < tolerance) {
842 // 3% current tolerance...
846 if (diCurrent < zero) { // some small current..
850 AliError(Form("Wrong dipole current (%f A)!",diCurrent));
854 delete fForcedFieldMap;
856 new AliMagWrapCheb("B field map ",s,2,factor,10.,map,dipoleON,path);
858 fForcedFieldMap->Print();
860 AliTracker::SetFieldMap(fForcedFieldMap,fUniformField);
866 Bool_t AliReconstruction::InitGRP() {
867 //------------------------------------
868 // Initialization of the GRP entry
869 //------------------------------------
870 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
873 fGRPData = dynamic_cast<TMap*>(entry->GetObject());
875 AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
879 AliError("No GRP entry found in OCDB!");
883 TObjString *lhcState=
884 dynamic_cast<TObjString*>(fGRPData->GetValue("fLHCState"));
886 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
889 TObjString *beamType=
890 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamType"));
892 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
895 TObjString *beamEnergyStr=
896 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamEnergy"));
897 if (!beamEnergyStr) {
898 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
902 dynamic_cast<TObjString*>(fGRPData->GetValue("fRunType"));
904 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
907 TObjString *activeDetectors=
908 dynamic_cast<TObjString*>(fGRPData->GetValue("fDetectorMask"));
909 if (!activeDetectors) {
910 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
913 fRunInfo = new AliRunInfo(lhcState ? lhcState->GetString().Data() : "UNKNOWN",
914 beamType ? beamType->GetString().Data() : "UNKNOWN",
915 beamEnergyStr ? beamEnergyStr->GetString().Atof() : 0,
916 runType ? runType->GetString().Data() : "UNKNOWN",
917 activeDetectors ? activeDetectors->GetString().Atoi() : 1074790399);
919 // Process the list of active detectors
920 if (activeDetectors && activeDetectors->GetString().IsDigit()) {
921 UInt_t detMask = activeDetectors->GetString().Atoi();
922 fLoadCDB.Form("%s %s %s %s",
923 fRunLocalReconstruction.Data(),
926 fQADetectors.Data());
927 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
928 fRunTracking = MatchDetectorList(fRunTracking,detMask);
929 fFillESD = MatchDetectorList(fFillESD,detMask);
930 fQADetectors = MatchDetectorList(fQADetectors,detMask);
931 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
934 AliInfo("===================================================================================");
935 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
936 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
937 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
938 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
939 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
940 AliInfo("===================================================================================");
942 //*** Dealing with the magnetic field map
943 if (AliTracker::GetFieldMap()) {
944 AliInfo("Running with the externally set B field !");
946 // Construct the field map out of the information retrieved from GRP.
951 TObjString *l3Current=
952 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
954 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
957 TObjString *l3Polarity=
958 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
960 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
965 TObjString *diCurrent=
966 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
968 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
971 TObjString *diPolarity=
972 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
974 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
979 Float_t l3Cur=TMath::Abs(atof(l3Current->GetName()));
980 Float_t diCur=TMath::Abs(atof(diCurrent->GetName()));
981 Float_t l3Pol=atof(l3Polarity->GetName());
983 if (l3Pol != 0.) factor=-1.;
986 if (!SetFieldMap(l3Cur, diCur, factor)) {
987 AliFatal("Failed to creat a B field map ! Exiting...");
989 AliInfo("Running with the B field constructed out of GRP !");
992 AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
997 //*** Get the diamond profile from OCDB
998 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1000 if (fMeanVertexConstraint)
1001 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1003 AliError("No diamond profile found in OCDB!");
1006 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1008 if (fMeanVertexConstraint)
1009 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1011 AliError("No diamond profile found in OCDB!");
1017 //_____________________________________________________________________________
1018 Bool_t AliReconstruction::LoadCDB()
1020 AliCodeTimerAuto("");
1022 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1024 TString detStr = fLoadCDB;
1025 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1026 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1027 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1032 //_____________________________________________________________________________
1033 Bool_t AliReconstruction::Run(const char* input)
1036 AliCodeTimerAuto("");
1039 if (GetAbort() != TSelector::kContinue) return kFALSE;
1041 TChain *chain = NULL;
1042 if (fRawReader && (chain = fRawReader->GetChain())) {
1045 gProof->AddInput(this);
1047 outputFile.SetProtocol("root",kTRUE);
1048 outputFile.SetHost(gSystem->HostName());
1049 outputFile.SetFile(Form("%s/AliESDs.root",gSystem->pwd()));
1050 AliInfo(Form("Output file with ESDs is %s",outputFile.GetUrl()));
1051 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.GetUrl()));
1053 chain->Process("AliReconstruction");
1056 chain->Process(this);
1061 if (GetAbort() != TSelector::kContinue) return kFALSE;
1063 if (GetAbort() != TSelector::kContinue) return kFALSE;
1064 //******* The loop over events
1066 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1067 (fRawReader && fRawReader->NextEvent())) {
1068 if (!ProcessEvent(iEvent)) {
1069 Abort("ProcessEvent",TSelector::kAbortFile);
1075 if (GetAbort() != TSelector::kContinue) return kFALSE;
1077 if (GetAbort() != TSelector::kContinue) return kFALSE;
1083 //_____________________________________________________________________________
1084 void AliReconstruction::InitRawReader(const char* input)
1086 AliCodeTimerAuto("");
1088 // Init raw-reader and
1089 // set the input in case of raw data
1090 if (input) fRawInput = input;
1091 fRawReader = AliRawReader::Create(fRawInput.Data());
1093 AliInfo("Reconstruction will run over digits");
1095 if (!fEquipIdMap.IsNull() && fRawReader)
1096 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1098 if (!fUseHLTData.IsNull()) {
1099 // create the RawReaderHLT which performs redirection of HLT input data for
1100 // the specified detectors
1101 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1103 fParentRawReader=fRawReader;
1104 fRawReader=pRawReader;
1106 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1109 AliSysInfo::AddStamp("CreateRawReader");
1112 //_____________________________________________________________________________
1113 void AliReconstruction::InitRun(const char* input)
1115 // Initialization of raw-reader,
1116 // run number, CDB etc.
1117 AliCodeTimerAuto("");
1118 AliSysInfo::AddStamp("Start");
1120 // Initialize raw-reader if any
1121 InitRawReader(input);
1123 // Initialize the CDB storage
1126 // Set run number in CDBManager (if it is not already set by the user)
1127 if (!SetRunNumberFromData()) {
1128 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1132 // Set CDB lock: from now on it is forbidden to reset the run number
1133 // or the default storage or to activate any further storage!
1138 //_____________________________________________________________________________
1139 void AliReconstruction::Begin(TTree *)
1141 // Initialize AlReconstruction before
1142 // going into the event loop
1143 // Should follow the TSelector convention
1144 // i.e. initialize only the object on the client side
1145 AliCodeTimerAuto("");
1147 AliReconstruction *reco = NULL;
1149 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1152 AliSysInfo::AddStamp("ReadInputInBegin");
1155 // Import ideal TGeo geometry and apply misalignment
1157 TString geom(gSystem->DirName(fGAliceFileName));
1158 geom += "/geometry.root";
1159 AliGeomManager::LoadGeometry(geom.Data());
1161 Abort("LoadGeometry", TSelector::kAbortProcess);
1164 AliSysInfo::AddStamp("LoadGeom");
1165 TString detsToCheck=fRunLocalReconstruction;
1166 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1167 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1170 AliSysInfo::AddStamp("CheckGeom");
1173 if (!MisalignGeometry(fLoadAlignData)) {
1174 Abort("MisalignGeometry", TSelector::kAbortProcess);
1177 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1178 AliSysInfo::AddStamp("MisalignGeom");
1181 Abort("InitGRP", TSelector::kAbortProcess);
1184 AliSysInfo::AddStamp("InitGRP");
1187 Abort("LoadCDB", TSelector::kAbortProcess);
1190 AliSysInfo::AddStamp("LoadCDB");
1192 // Read the reconstruction parameters from OCDB
1193 if (!InitRecoParams()) {
1194 AliWarning("Not all detectors have correct RecoParam objects initialized");
1196 AliSysInfo::AddStamp("InitRecoParams");
1199 if (reco) *reco = *this;
1200 fInput->Add(gGeoManager);
1202 fInput->Add(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()));
1203 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1204 AliMagF *magFieldMap = (AliMagF*)AliTracker::GetFieldMap();
1205 magFieldMap->SetName("MagneticFieldMap");
1206 fInput->Add(magFieldMap);
1211 //_____________________________________________________________________________
1212 void AliReconstruction::SlaveBegin(TTree*)
1214 // Initialization related to run-loader,
1215 // vertexer, trackers, recontructors
1216 // In proof mode it is executed on the slave
1217 AliCodeTimerAuto("");
1219 TProofOutputFile *outProofFile = NULL;
1221 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1224 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1226 AliGeomManager::SetGeometry(tgeo);
1228 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1229 Int_t runNumber = -1;
1230 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1231 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1232 man->SetCacheFlag(kTRUE);
1233 man->SetLock(kTRUE);
1237 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1238 AliTracker::SetFieldMap(map,fUniformField);
1240 if (TNamed *outputFileName = (TNamed *) fInput->FindObject("PROOF_OUTPUTFILE")) {
1241 outProofFile = new TProofOutputFile(gSystem->BaseName(TUrl(outputFileName->GetTitle()).GetFile()));
1242 outProofFile->SetOutputFileName(outputFileName->GetTitle());
1243 fOutput->Add(outProofFile);
1245 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1248 // get the run loader
1249 if (!InitRunLoader()) {
1250 Abort("InitRunLoader", TSelector::kAbortProcess);
1253 AliSysInfo::AddStamp("LoadLoader");
1255 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1256 if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile);
1259 if (fRunVertexFinder && !CreateVertexer()) {
1260 Abort("CreateVertexer", TSelector::kAbortProcess);
1263 AliSysInfo::AddStamp("CreateVertexer");
1266 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1267 Abort("CreateTrackers", TSelector::kAbortProcess);
1270 AliSysInfo::AddStamp("CreateTrackers");
1272 // create the ESD output file and tree
1273 if (!outProofFile) {
1274 ffile = TFile::Open("AliESDs.root", "RECREATE");
1275 ffile->SetCompressionLevel(2);
1276 if (!ffile->IsOpen()) {
1277 Abort("OpenESDFile", TSelector::kAbortProcess);
1282 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1283 Abort(Form("Problems opening output PROOF file: %s/%s",
1284 outProofFile->GetDir(), outProofFile->GetFileName()),
1285 TSelector::kAbortProcess);
1290 ftree = new TTree("esdTree", "Tree with ESD objects");
1291 fesd = new AliESDEvent();
1292 fesd->CreateStdContent();
1293 fesd->WriteToTree(ftree);
1295 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1296 fhltesd = new AliESDEvent();
1297 fhltesd->CreateStdContent();
1298 fhltesd->WriteToTree(fhlttree);
1301 if (fWriteESDfriend) {
1302 fesdf = new AliESDfriend();
1303 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1304 br->SetFile("AliESDfriends.root");
1305 fesd->AddObject(fesdf);
1308 ProcInfo_t ProcInfo;
1309 gSystem->GetProcInfo(&ProcInfo);
1310 AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1313 //Initialize the QA and start of cycle
1315 fQASteer = new AliQADataMakerSteer("rec") ;
1316 fQASteer->SetActiveDetectors(fQADetectors) ;
1317 for (Int_t det = 0 ; det < AliQA::kNDET ; det++) {
1318 fQASteer->SetCycleLength(AliQA::DETECTORINDEX_t(det), fQACycles[det]) ;
1319 if (fQAWriteExpert[det])
1320 fQASteer->SetWriteExpert(AliQA::DETECTORINDEX_t(det)) ;
1323 if (!fRawReader && fQATasks.Contains(AliQA::kRAWS))
1324 fQATasks.ReplaceAll(Form("%d",AliQA::kRAWS), "") ;
1325 fQASteer->SetTasks(fQATasks) ;
1326 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam) ;
1330 Bool_t sameCycle = kFALSE ;
1331 if (!fQASteer) fQASteer = new AliQADataMakerSteer("rec") ;
1332 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1333 AliInfo(Form("Initializing the global QA data maker"));
1334 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1335 qadm->StartOfCycle(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1336 TObjArray *arr=qadm->Init(AliQA::kRECPOINTS);
1337 AliTracker::SetResidualsArray(arr);
1340 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1341 qadm->StartOfCycle(AliQA::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
1342 qadm->Init(AliQA::kESDS);
1346 //Initialize the Plane Efficiency framework
1347 if (fRunPlaneEff && !InitPlaneEff()) {
1348 Abort("InitPlaneEff", TSelector::kAbortProcess);
1352 if (strcmp(gProgName,"alieve") == 0)
1353 fRunAliEVE = InitAliEVE();
1358 //_____________________________________________________________________________
1359 Bool_t AliReconstruction::Process(Long64_t entry)
1361 // run the reconstruction over a single entry
1362 // from the chain with raw data
1363 AliCodeTimerAuto("");
1365 TTree *currTree = fChain->GetTree();
1366 AliRawEvent *event = new AliRawEvent;
1367 currTree->SetBranchAddress("rawevent",&event);
1368 currTree->GetEntry(entry);
1369 fRawReader = new AliRawReaderRoot(event);
1370 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1378 //_____________________________________________________________________________
1379 void AliReconstruction::Init(TTree *tree)
1382 AliError("The input tree is not found!");
1388 //_____________________________________________________________________________
1389 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1391 // run the reconstruction over a single event
1392 // The event loop is steered in Run method
1394 AliCodeTimerAuto("");
1396 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1397 fRunLoader->SetEventNumber(iEvent);
1398 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1400 fRunLoader->TreeE()->Fill();
1401 if (fRawReader && fRawReader->UseAutoSaveESD())
1402 fRunLoader->TreeE()->AutoSave("SaveSelf");
1405 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1409 AliInfo(Form("processing event %d", iEvent));
1411 // Fill Event-info object
1413 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1415 // Set the reco-params
1417 TString detStr = fLoadCDB;
1418 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1419 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1420 AliReconstructor *reconstructor = GetReconstructor(iDet);
1421 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1422 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1423 reconstructor->SetRecoParam(par);
1428 fRunLoader->GetEvent(iEvent);
1432 fQASteer->RunOneEvent(fRawReader) ;
1434 // local single event reconstruction
1435 if (!fRunLocalReconstruction.IsNull()) {
1436 TString detectors=fRunLocalReconstruction;
1437 // run HLT event reconstruction first
1438 // ;-( IsSelected changes the string
1439 if (IsSelected("HLT", detectors) &&
1440 !RunLocalEventReconstruction("HLT")) {
1441 if (fStopOnError) {CleanUp(); return kFALSE;}
1443 detectors=fRunLocalReconstruction;
1444 detectors.ReplaceAll("HLT", "");
1445 if (!RunLocalEventReconstruction(detectors)) {
1446 if (fStopOnError) {CleanUp(); return kFALSE;}
1450 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1451 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1452 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1453 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1455 // Set magnetic field from the tracker
1456 fesd->SetMagneticField(AliTracker::GetBz());
1457 fhltesd->SetMagneticField(AliTracker::GetBz());
1459 // Set most probable pt, for B=0 tracking
1460 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(fgkNDetectors));
1461 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
1463 // Fill raw-data error log into the ESD
1464 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1467 if (fRunVertexFinder) {
1468 if (!RunVertexFinder(fesd)) {
1469 if (fStopOnError) {CleanUp(); return kFALSE;}
1474 if (!fRunTracking.IsNull()) {
1475 if (fRunMuonTracking) {
1476 if (!RunMuonTracking(fesd)) {
1477 if (fStopOnError) {CleanUp(); return kFALSE;}
1483 if (!fRunTracking.IsNull()) {
1484 if (!RunTracking(fesd)) {
1485 if (fStopOnError) {CleanUp(); return kFALSE;}
1490 if (!fFillESD.IsNull()) {
1491 TString detectors=fFillESD;
1492 // run HLT first and on hltesd
1493 // ;-( IsSelected changes the string
1494 if (IsSelected("HLT", detectors) &&
1495 !FillESD(fhltesd, "HLT")) {
1496 if (fStopOnError) {CleanUp(); return kFALSE;}
1499 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1500 if (detectors.Contains("ALL")) {
1502 for (Int_t idet=0; idet<fgkNDetectors; ++idet){
1503 detectors += fgkDetectorName[idet];
1507 detectors.ReplaceAll("HLT", "");
1508 if (!FillESD(fesd, detectors)) {
1509 if (fStopOnError) {CleanUp(); return kFALSE;}
1513 // fill Event header information from the RawEventHeader
1514 if (fRawReader){FillRawEventHeaderESD(fesd);}
1517 AliESDpid::MakePID(fesd);
1519 if (fFillTriggerESD) {
1520 if (!FillTriggerESD(fesd)) {
1521 if (fStopOnError) {CleanUp(); return kFALSE;}
1528 // Propagate track to the beam pipe (if not already done by ITS)
1530 const Int_t ntracks = fesd->GetNumberOfTracks();
1531 const Double_t kBz = fesd->GetMagneticField();
1532 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1535 UShort_t *selectedIdx=new UShort_t[ntracks];
1537 for (Int_t itrack=0; itrack<ntracks; itrack++){
1538 const Double_t kMaxStep = 5; //max step over the material
1541 AliESDtrack *track = fesd->GetTrack(itrack);
1542 if (!track) continue;
1544 AliExternalTrackParam *tpcTrack =
1545 (AliExternalTrackParam *)track->GetTPCInnerParam();
1549 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE);
1552 Int_t n=trkArray.GetEntriesFast();
1553 selectedIdx[n]=track->GetID();
1554 trkArray.AddLast(tpcTrack);
1557 //Tracks refitted by ITS should already be at the SPD vertex
1558 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1561 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE);
1562 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1567 // Improve the reconstructed primary vertex position using the tracks
1569 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1570 if(fesd->GetPrimaryVertexSPD()) {
1571 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1572 if(vtitle.Contains("cosmics")) {
1573 runVertexFinderTracks=kFALSE;
1577 if (runVertexFinderTracks) {
1578 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
1579 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(fgkNDetectors));
1581 // TPC + ITS primary vertex
1582 ftVertexer->SetITSMode();
1583 // get cuts for vertexer from AliGRPRecoParam
1585 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1586 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1587 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
1588 ftVertexer->SetCuts(cutsVertexer);
1589 delete [] cutsVertexer; cutsVertexer = NULL;
1591 if(fDiamondProfile && fMeanVertexConstraint) {
1592 ftVertexer->SetVtxStart(fDiamondProfile);
1594 ftVertexer->SetConstraintOff();
1596 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1598 if (pvtx->GetStatus()) {
1599 fesd->SetPrimaryVertex(pvtx);
1600 for (Int_t i=0; i<ntracks; i++) {
1601 AliESDtrack *t = fesd->GetTrack(i);
1602 t->RelateToVertex(pvtx, kBz, kVeryBig);
1607 // TPC-only primary vertex
1608 ftVertexer->SetTPCMode();
1609 // get cuts for vertexer from AliGRPRecoParam
1611 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1612 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1613 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
1614 ftVertexer->SetCuts(cutsVertexer);
1615 delete [] cutsVertexer; cutsVertexer = NULL;
1617 if(fDiamondProfileTPC && fMeanVertexConstraint) {
1618 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1620 ftVertexer->SetConstraintOff();
1622 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1624 if (pvtx->GetStatus()) {
1625 fesd->SetPrimaryVertexTPC(pvtx);
1626 for (Int_t i=0; i<ntracks; i++) {
1627 AliESDtrack *t = fesd->GetTrack(i);
1628 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1634 delete[] selectedIdx;
1636 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1641 AliV0vertexer vtxer;
1642 vtxer.Tracks2V0vertices(fesd);
1644 if (fRunCascadeFinder) {
1646 AliCascadeVertexer cvtxer;
1647 cvtxer.V0sTracks2CascadeVertices(fesd);
1652 if (fCleanESD) CleanESD(fesd);
1655 fQASteer->RunOneEvent(fesd) ;
1658 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1659 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1660 qadm->Exec(AliQA::kESDS, fesd);
1663 if (fWriteESDfriend) {
1664 // fesdf->~AliESDfriend();
1665 // new (fesdf) AliESDfriend(); // Reset...
1666 fesd->GetESDfriend(fesdf);
1670 // Auto-save the ESD tree in case of prompt reco @P2
1671 if (fRawReader && fRawReader->UseAutoSaveESD()) {
1672 ftree->AutoSave("SaveSelf");
1673 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1674 if (friendfile) friendfile->Save();
1681 if (fRunAliEVE) RunAliEVE();
1685 if (fWriteESDfriend) {
1686 fesdf->~AliESDfriend();
1687 new (fesdf) AliESDfriend(); // Reset...
1690 ProcInfo_t ProcInfo;
1691 gSystem->GetProcInfo(&ProcInfo);
1692 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1695 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1696 if (fReconstructor[iDet])
1697 fReconstructor[iDet]->SetRecoParam(NULL);
1700 if (fRunQA || fRunGlobalQA)
1701 fQASteer->Increment() ;
1706 //_____________________________________________________________________________
1707 void AliReconstruction::SlaveTerminate()
1709 // Finalize the run on the slave side
1710 // Called after the exit
1711 // from the event loop
1712 AliCodeTimerAuto("");
1714 if (fIsNewRunLoader) { // galice.root didn't exist
1715 fRunLoader->WriteHeader("OVERWRITE");
1716 fRunLoader->CdGAFile();
1717 fRunLoader->Write(0, TObject::kOverwrite);
1720 ftree->GetUserInfo()->Add(fesd);
1721 fhlttree->GetUserInfo()->Add(fhltesd);
1723 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1724 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1726 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1727 cdbMapCopy->SetOwner(1);
1728 cdbMapCopy->SetName("cdbMap");
1729 TIter iter(cdbMap->GetTable());
1732 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1733 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1734 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1735 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1738 TList *cdbListCopy = new TList();
1739 cdbListCopy->SetOwner(1);
1740 cdbListCopy->SetName("cdbList");
1742 TIter iter2(cdbList);
1745 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1746 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1749 ftree->GetUserInfo()->Add(cdbMapCopy);
1750 ftree->GetUserInfo()->Add(cdbListCopy);
1753 if(fESDPar.Contains("ESD.par")){
1754 AliInfo("Attaching ESD.par to Tree");
1755 TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
1756 ftree->GetUserInfo()->Add(fn);
1762 if (fWriteESDfriend)
1763 ftree->SetBranchStatus("ESDfriend*",0);
1764 // we want to have only one tree version number
1765 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1768 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
1769 if (fRunPlaneEff && !FinishPlaneEff()) {
1770 AliWarning("Finish PlaneEff evaluation failed");
1773 // End of cycle for the in-loop
1775 fQASteer->EndOfCycle() ;
1778 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1780 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1781 qadm->EndOfCycle(AliQA::kRECPOINTS);
1782 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1783 qadm->EndOfCycle(AliQA::kESDS);
1791 //_____________________________________________________________________________
1792 void AliReconstruction::Terminate()
1794 // Create tags for the events in the ESD tree (the ESD tree is always present)
1795 // In case of empty events the tags will contain dummy values
1796 AliCodeTimerAuto("");
1798 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1799 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData);
1801 // Cleanup of CDB manager: cache and active storages!
1802 AliCDBManager::Instance()->ClearCache();
1805 //_____________________________________________________________________________
1806 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1808 // run the local reconstruction
1810 static Int_t eventNr=0;
1811 AliCodeTimerAuto("")
1813 TString detStr = detectors;
1814 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1815 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1816 AliReconstructor* reconstructor = GetReconstructor(iDet);
1817 if (!reconstructor) continue;
1818 AliLoader* loader = fLoader[iDet];
1819 // Matthias April 2008: temporary fix to run HLT reconstruction
1820 // although the HLT loader is missing
1821 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1823 reconstructor->Reconstruct(fRawReader, NULL);
1826 reconstructor->Reconstruct(dummy, NULL);
1831 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1834 // conversion of digits
1835 if (fRawReader && reconstructor->HasDigitConversion()) {
1836 AliInfo(Form("converting raw data digits into root objects for %s",
1837 fgkDetectorName[iDet]));
1838 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1839 // fgkDetectorName[iDet]));
1840 loader->LoadDigits("update");
1841 loader->CleanDigits();
1842 loader->MakeDigitsContainer();
1843 TTree* digitsTree = loader->TreeD();
1844 reconstructor->ConvertDigits(fRawReader, digitsTree);
1845 loader->WriteDigits("OVERWRITE");
1846 loader->UnloadDigits();
1848 // local reconstruction
1849 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1850 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1851 loader->LoadRecPoints("update");
1852 loader->CleanRecPoints();
1853 loader->MakeRecPointsContainer();
1854 TTree* clustersTree = loader->TreeR();
1855 if (fRawReader && !reconstructor->HasDigitConversion()) {
1856 reconstructor->Reconstruct(fRawReader, clustersTree);
1858 loader->LoadDigits("read");
1859 TTree* digitsTree = loader->TreeD();
1861 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1862 if (fStopOnError) return kFALSE;
1864 reconstructor->Reconstruct(digitsTree, clustersTree);
1866 loader->UnloadDigits();
1869 TString detQAStr(fQADetectors) ;
1871 fQASteer->RunOneEventInOneDetector(iDet, clustersTree) ;
1873 loader->WriteRecPoints("OVERWRITE");
1874 loader->UnloadRecPoints();
1875 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1877 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1878 AliError(Form("the following detectors were not found: %s",
1880 if (fStopOnError) return kFALSE;
1886 //_____________________________________________________________________________
1887 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
1889 // run the barrel tracking
1891 AliCodeTimerAuto("")
1893 AliESDVertex* vertex = NULL;
1894 Double_t vtxPos[3] = {0, 0, 0};
1895 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
1896 TArrayF mcVertex(3);
1897 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
1898 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
1899 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
1903 AliInfo("running the ITS vertex finder");
1905 fLoader[0]->LoadRecPoints();
1906 TTree* cltree = fLoader[0]->TreeR();
1908 if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile);
1909 vertex = fVertexer->FindVertexForCurrentEvent(cltree);
1912 AliError("Can't get the ITS cluster tree");
1914 fLoader[0]->UnloadRecPoints();
1917 AliError("Can't get the ITS loader");
1920 AliWarning("Vertex not found");
1921 vertex = new AliESDVertex();
1922 vertex->SetName("default");
1925 vertex->SetName("reconstructed");
1929 AliInfo("getting the primary vertex from MC");
1930 vertex = new AliESDVertex(vtxPos, vtxErr);
1934 vertex->GetXYZ(vtxPos);
1935 vertex->GetSigmaXYZ(vtxErr);
1937 AliWarning("no vertex reconstructed");
1938 vertex = new AliESDVertex(vtxPos, vtxErr);
1940 esd->SetPrimaryVertexSPD(vertex);
1941 // if SPD multiplicity has been determined, it is stored in the ESD
1942 AliMultiplicity *mult = fVertexer->GetMultiplicity();
1943 if(mult)esd->SetMultiplicity(mult);
1945 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1946 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
1953 //_____________________________________________________________________________
1954 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1956 // run the HLT barrel tracking
1958 AliCodeTimerAuto("")
1961 AliError("Missing runLoader!");
1965 AliInfo("running HLT tracking");
1967 // Get a pointer to the HLT reconstructor
1968 AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1);
1969 if (!reconstructor) return kFALSE;
1972 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1973 TString detName = fgkDetectorName[iDet];
1974 AliDebug(1, Form("%s HLT tracking", detName.Data()));
1975 reconstructor->SetOption(detName.Data());
1976 AliTracker *tracker = reconstructor->CreateTracker();
1978 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
1979 if (fStopOnError) return kFALSE;
1983 Double_t vtxErr[3]={0.005,0.005,0.010};
1984 const AliESDVertex *vertex = esd->GetVertex();
1985 vertex->GetXYZ(vtxPos);
1986 tracker->SetVertex(vtxPos,vtxErr);
1988 fLoader[iDet]->LoadRecPoints("read");
1989 TTree* tree = fLoader[iDet]->TreeR();
1991 AliError(Form("Can't get the %s cluster tree", detName.Data()));
1994 tracker->LoadClusters(tree);
1996 if (tracker->Clusters2Tracks(esd) != 0) {
1997 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2001 tracker->UnloadClusters();
2009 //_____________________________________________________________________________
2010 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2012 // run the muon spectrometer tracking
2014 AliCodeTimerAuto("")
2017 AliError("Missing runLoader!");
2020 Int_t iDet = 7; // for MUON
2022 AliInfo("is running...");
2024 // Get a pointer to the MUON reconstructor
2025 AliReconstructor *reconstructor = GetReconstructor(iDet);
2026 if (!reconstructor) return kFALSE;
2029 TString detName = fgkDetectorName[iDet];
2030 AliDebug(1, Form("%s tracking", detName.Data()));
2031 AliTracker *tracker = reconstructor->CreateTracker();
2033 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2038 fLoader[iDet]->LoadRecPoints("read");
2040 tracker->LoadClusters(fLoader[iDet]->TreeR());
2042 Int_t rv = tracker->Clusters2Tracks(esd);
2046 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2050 fLoader[iDet]->UnloadRecPoints();
2052 tracker->UnloadClusters();
2060 //_____________________________________________________________________________
2061 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
2063 // run the barrel tracking
2064 static Int_t eventNr=0;
2065 AliCodeTimerAuto("")
2067 AliInfo("running tracking");
2069 //Fill the ESD with the T0 info (will be used by the TOF)
2070 if (fReconstructor[11] && fLoader[11]) {
2071 fLoader[11]->LoadRecPoints("READ");
2072 TTree *treeR = fLoader[11]->TreeR();
2073 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2076 // pass 1: TPC + ITS inwards
2077 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2078 if (!fTracker[iDet]) continue;
2079 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2082 fLoader[iDet]->LoadRecPoints("read");
2083 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2084 TTree* tree = fLoader[iDet]->TreeR();
2086 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2089 fTracker[iDet]->LoadClusters(tree);
2090 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2092 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2093 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2096 // preliminary PID in TPC needed by the ITS tracker
2098 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2099 AliESDpid::MakePID(esd);
2101 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2104 // pass 2: ALL backwards
2106 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2107 if (!fTracker[iDet]) continue;
2108 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2111 if (iDet > 1) { // all except ITS, TPC
2113 fLoader[iDet]->LoadRecPoints("read");
2114 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2115 tree = fLoader[iDet]->TreeR();
2117 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2120 fTracker[iDet]->LoadClusters(tree);
2121 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2125 if (iDet>1) // start filling residuals for the "outer" detectors
2126 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2128 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2129 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
2134 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
2135 fTracker[iDet]->UnloadClusters();
2136 fLoader[iDet]->UnloadRecPoints();
2138 // updated PID in TPC needed by the ITS tracker -MI
2140 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2141 AliESDpid::MakePID(esd);
2143 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2145 //stop filling residuals for the "outer" detectors
2146 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2148 // pass 3: TRD + TPC + ITS refit inwards
2150 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2151 if (!fTracker[iDet]) continue;
2152 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
2155 if (iDet<2) // start filling residuals for TPC and ITS
2156 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
2158 if (fTracker[iDet]->RefitInward(esd) != 0) {
2159 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
2162 // run postprocessing
2163 if (fTracker[iDet]->PostProcess(esd) != 0) {
2164 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2167 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2170 // write space-points to the ESD in case alignment data output
2172 if (fWriteAlignmentData)
2173 WriteAlignmentData(esd);
2175 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2176 if (!fTracker[iDet]) continue;
2178 fTracker[iDet]->UnloadClusters();
2179 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
2180 fLoader[iDet]->UnloadRecPoints();
2181 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
2183 // stop filling residuals for TPC and ITS
2184 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
2190 //_____________________________________________________________________________
2191 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2193 // Remove the data which are not needed for the physics analysis.
2196 Int_t nTracks=esd->GetNumberOfTracks();
2197 Int_t nV0s=esd->GetNumberOfV0s();
2199 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
2201 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2202 Bool_t rc=esd->Clean(cleanPars);
2204 nTracks=esd->GetNumberOfTracks();
2205 nV0s=esd->GetNumberOfV0s();
2207 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2212 //_____________________________________________________________________________
2213 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2215 // fill the event summary data
2217 AliCodeTimerAuto("")
2218 static Int_t eventNr=0;
2219 TString detStr = detectors;
2221 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2222 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2223 AliReconstructor* reconstructor = GetReconstructor(iDet);
2224 if (!reconstructor) continue;
2225 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2226 TTree* clustersTree = NULL;
2227 if (fLoader[iDet]) {
2228 fLoader[iDet]->LoadRecPoints("read");
2229 clustersTree = fLoader[iDet]->TreeR();
2230 if (!clustersTree) {
2231 AliError(Form("Can't get the %s clusters tree",
2232 fgkDetectorName[iDet]));
2233 if (fStopOnError) return kFALSE;
2236 if (fRawReader && !reconstructor->HasDigitConversion()) {
2237 reconstructor->FillESD(fRawReader, clustersTree, esd);
2239 TTree* digitsTree = NULL;
2240 if (fLoader[iDet]) {
2241 fLoader[iDet]->LoadDigits("read");
2242 digitsTree = fLoader[iDet]->TreeD();
2244 AliError(Form("Can't get the %s digits tree",
2245 fgkDetectorName[iDet]));
2246 if (fStopOnError) return kFALSE;
2249 reconstructor->FillESD(digitsTree, clustersTree, esd);
2250 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2252 if (fLoader[iDet]) {
2253 fLoader[iDet]->UnloadRecPoints();
2257 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2258 AliError(Form("the following detectors were not found: %s",
2260 if (fStopOnError) return kFALSE;
2262 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2267 //_____________________________________________________________________________
2268 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2270 // Reads the trigger decision which is
2271 // stored in Trigger.root file and fills
2272 // the corresponding esd entries
2274 AliCodeTimerAuto("")
2276 AliInfo("Filling trigger information into the ESD");
2279 AliCTPRawStream input(fRawReader);
2280 if (!input.Next()) {
2281 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2284 if (esd->GetTriggerMask() != input.GetClassMask())
2285 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2286 input.GetClassMask(),esd->GetTriggerMask()));
2287 if (esd->GetOrbitNumber() != input.GetOrbitID())
2288 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2289 input.GetOrbitID(),esd->GetOrbitNumber()));
2290 if (esd->GetBunchCrossNumber() != input.GetBCID())
2291 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2292 input.GetBCID(),esd->GetBunchCrossNumber()));
2295 // Here one has to add the filling of trigger inputs and
2296 // interaction records
2306 //_____________________________________________________________________________
2307 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2310 // Filling information from RawReader Header
2313 if (!fRawReader) return kFALSE;
2315 AliInfo("Filling information from RawReader Header");
2317 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2318 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2319 esd->SetPeriodNumber(fRawReader->GetPeriod());
2321 esd->SetTimeStamp(fRawReader->GetTimestamp());
2322 esd->SetEventType(fRawReader->GetType());
2328 //_____________________________________________________________________________
2329 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2331 // check whether detName is contained in detectors
2332 // if yes, it is removed from detectors
2334 // check if all detectors are selected
2335 if ((detectors.CompareTo("ALL") == 0) ||
2336 detectors.BeginsWith("ALL ") ||
2337 detectors.EndsWith(" ALL") ||
2338 detectors.Contains(" ALL ")) {
2343 // search for the given detector
2344 Bool_t result = kFALSE;
2345 if ((detectors.CompareTo(detName) == 0) ||
2346 detectors.BeginsWith(detName+" ") ||
2347 detectors.EndsWith(" "+detName) ||
2348 detectors.Contains(" "+detName+" ")) {
2349 detectors.ReplaceAll(detName, "");
2353 // clean up the detectors string
2354 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2355 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2356 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2361 //_____________________________________________________________________________
2362 Bool_t AliReconstruction::InitRunLoader()
2364 // get or create the run loader
2366 if (gAlice) delete gAlice;
2369 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2370 // load all base libraries to get the loader classes
2371 TString libs = gSystem->GetLibraries();
2372 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2373 TString detName = fgkDetectorName[iDet];
2374 if (detName == "HLT") continue;
2375 if (libs.Contains("lib" + detName + "base.so")) continue;
2376 gSystem->Load("lib" + detName + "base.so");
2378 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2380 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2385 fRunLoader->CdGAFile();
2386 fRunLoader->LoadgAlice();
2388 //PH This is a temporary fix to give access to the kinematics
2389 //PH that is needed for the labels of ITS clusters
2390 fRunLoader->LoadHeader();
2391 fRunLoader->LoadKinematics();
2393 } else { // galice.root does not exist
2395 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2397 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2398 AliConfig::GetDefaultEventFolderName(),
2401 AliError(Form("could not create run loader in file %s",
2402 fGAliceFileName.Data()));
2406 fIsNewRunLoader = kTRUE;
2407 fRunLoader->MakeTree("E");
2409 if (fNumberOfEventsPerFile > 0)
2410 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2412 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2418 //_____________________________________________________________________________
2419 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2421 // get the reconstructor object and the loader for a detector
2423 if (fReconstructor[iDet]) {
2424 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2425 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2426 fReconstructor[iDet]->SetRecoParam(par);
2428 return fReconstructor[iDet];
2431 // load the reconstructor object
2432 TPluginManager* pluginManager = gROOT->GetPluginManager();
2433 TString detName = fgkDetectorName[iDet];
2434 TString recName = "Ali" + detName + "Reconstructor";
2436 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2438 AliReconstructor* reconstructor = NULL;
2439 // first check if a plugin is defined for the reconstructor
2440 TPluginHandler* pluginHandler =
2441 pluginManager->FindHandler("AliReconstructor", detName);
2442 // if not, add a plugin for it
2443 if (!pluginHandler) {
2444 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2445 TString libs = gSystem->GetLibraries();
2446 if (libs.Contains("lib" + detName + "base.so") ||
2447 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2448 pluginManager->AddHandler("AliReconstructor", detName,
2449 recName, detName + "rec", recName + "()");
2451 pluginManager->AddHandler("AliReconstructor", detName,
2452 recName, detName, recName + "()");
2454 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2456 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2457 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2459 if (reconstructor) {
2460 TObject* obj = fOptions.FindObject(detName.Data());
2461 if (obj) reconstructor->SetOption(obj->GetTitle());
2462 reconstructor->Init();
2463 fReconstructor[iDet] = reconstructor;
2466 // get or create the loader
2467 if (detName != "HLT") {
2468 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2469 if (!fLoader[iDet]) {
2470 AliConfig::Instance()
2471 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2473 // first check if a plugin is defined for the loader
2475 pluginManager->FindHandler("AliLoader", detName);
2476 // if not, add a plugin for it
2477 if (!pluginHandler) {
2478 TString loaderName = "Ali" + detName + "Loader";
2479 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2480 pluginManager->AddHandler("AliLoader", detName,
2481 loaderName, detName + "base",
2482 loaderName + "(const char*, TFolder*)");
2483 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2485 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2487 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2488 fRunLoader->GetEventFolder());
2490 if (!fLoader[iDet]) { // use default loader
2491 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2493 if (!fLoader[iDet]) {
2494 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2495 if (fStopOnError) return NULL;
2497 fRunLoader->AddLoader(fLoader[iDet]);
2498 fRunLoader->CdGAFile();
2499 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2500 fRunLoader->Write(0, TObject::kOverwrite);
2505 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2506 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2507 reconstructor->SetRecoParam(par);
2509 return reconstructor;
2512 //_____________________________________________________________________________
2513 Bool_t AliReconstruction::CreateVertexer()
2515 // create the vertexer
2518 AliReconstructor* itsReconstructor = GetReconstructor(0);
2519 if (itsReconstructor) {
2520 fVertexer = itsReconstructor->CreateVertexer();
2523 AliWarning("couldn't create a vertexer for ITS");
2524 if (fStopOnError) return kFALSE;
2530 //_____________________________________________________________________________
2531 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2533 // create the trackers
2535 TString detStr = detectors;
2536 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2537 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2538 AliReconstructor* reconstructor = GetReconstructor(iDet);
2539 if (!reconstructor) continue;
2540 TString detName = fgkDetectorName[iDet];
2541 if (detName == "HLT") {
2542 fRunHLTTracking = kTRUE;
2545 if (detName == "MUON") {
2546 fRunMuonTracking = kTRUE;
2551 fTracker[iDet] = reconstructor->CreateTracker();
2552 if (!fTracker[iDet] && (iDet < 7)) {
2553 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2554 if (fStopOnError) return kFALSE;
2556 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2562 //_____________________________________________________________________________
2563 void AliReconstruction::CleanUp()
2565 // delete trackers and the run loader and close and delete the file
2567 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2568 delete fReconstructor[iDet];
2569 fReconstructor[iDet] = NULL;
2570 fLoader[iDet] = NULL;
2571 delete fTracker[iDet];
2572 fTracker[iDet] = NULL;
2583 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2584 delete fDiamondProfile;
2585 fDiamondProfile = NULL;
2586 delete fDiamondProfileTPC;
2587 fDiamondProfileTPC = NULL;
2593 delete fParentRawReader;
2594 fParentRawReader=NULL;
2603 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2605 // Write space-points which are then used in the alignment procedures
2606 // For the moment only ITS, TPC, TRD and TOF
2608 Int_t ntracks = esd->GetNumberOfTracks();
2609 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2611 AliESDtrack *track = esd->GetTrack(itrack);
2614 for (Int_t iDet = 3; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2615 nsp += track->GetNcls(iDet);
2617 if (iDet==0) { // ITS "extra" clusters
2618 track->GetClusters(iDet,idx);
2619 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2624 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2625 track->SetTrackPointArray(sp);
2627 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2628 AliTracker *tracker = fTracker[iDet];
2629 if (!tracker) continue;
2630 Int_t nspdet = track->GetClusters(iDet,idx);
2632 if (iDet==0) // ITS "extra" clusters
2633 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2635 if (nspdet <= 0) continue;
2639 while (isp2 < nspdet) {
2640 Bool_t isvalid=kTRUE;
2642 Int_t index=idx[isp++];
2643 if (index < 0) continue;
2645 TString dets = fgkDetectorName[iDet];
2646 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2647 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2648 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2649 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2650 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2652 isvalid = tracker->GetTrackPoint(index,p);
2655 if (!isvalid) continue;
2656 sp->AddPoint(isptrack,&p); isptrack++;
2663 //_____________________________________________________________________________
2664 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2666 // The method reads the raw-data error log
2667 // accumulated within the rawReader.
2668 // It extracts the raw-data errors related to
2669 // the current event and stores them into
2670 // a TClonesArray inside the esd object.
2672 if (!fRawReader) return;
2674 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2676 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2678 if (iEvent != log->GetEventNumber()) continue;
2680 esd->AddRawDataErrorLog(log);
2685 TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){
2686 // Dump a file content into a char in TNamed
2688 in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
2689 Int_t kBytes = (Int_t)in.tellg();
2690 printf("Size: %d \n",kBytes);
2693 char* memblock = new char [kBytes];
2694 in.seekg (0, ios::beg);
2695 in.read (memblock, kBytes);
2697 TString fData(memblock,kBytes);
2698 fn = new TNamed(pName,fData);
2699 printf("fData Size: %d \n",fData.Sizeof());
2700 printf("pName Size: %d \n",pName.Sizeof());
2701 printf("fn Size: %d \n",fn->Sizeof());
2705 AliInfo(Form("Could not Open %s\n",fPath.Data()));
2711 void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){
2712 // This is not really needed in AliReconstruction at the moment
2713 // but can serve as a template
2715 TList *fList = fTree->GetUserInfo();
2716 TNamed *fn = (TNamed*)fList->FindObject(pName.Data());
2717 printf("fn Size: %d \n",fn->Sizeof());
2719 TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works
2720 const char* cdata = fn->GetTitle();
2721 printf("fTmp Size %d\n",fTmp.Sizeof());
2723 int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
2724 printf("calculated size %d\n",size);
2725 ofstream out(pName.Data(),ios::out | ios::binary);
2726 out.write(cdata,size);
2731 //_____________________________________________________________________________
2732 void AliReconstruction::CheckQA()
2734 // check the QA of SIM for this run and remove the detectors
2735 // with status Fatal
2737 TString newRunLocalReconstruction ;
2738 TString newRunTracking ;
2739 TString newFillESD ;
2741 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2742 TString detName(AliQA::GetDetName(iDet)) ;
2743 AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2744 if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) {
2745 AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ;
2747 if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2748 fRunLocalReconstruction.Contains("ALL") ) {
2749 newRunLocalReconstruction += detName ;
2750 newRunLocalReconstruction += " " ;
2752 if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2753 fRunTracking.Contains("ALL") ) {
2754 newRunTracking += detName ;
2755 newRunTracking += " " ;
2757 if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2758 fFillESD.Contains("ALL") ) {
2759 newFillESD += detName ;
2764 fRunLocalReconstruction = newRunLocalReconstruction ;
2765 fRunTracking = newRunTracking ;
2766 fFillESD = newFillESD ;
2769 //_____________________________________________________________________________
2770 Int_t AliReconstruction::GetDetIndex(const char* detector)
2772 // return the detector index corresponding to detector
2774 for (index = 0; index < fgkNDetectors ; index++) {
2775 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2780 //_____________________________________________________________________________
2781 Bool_t AliReconstruction::FinishPlaneEff() {
2783 // Here execute all the necessary operationis, at the end of the tracking phase,
2784 // in case that evaluation of PlaneEfficiencies was required for some detector.
2785 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2787 // This Preliminary version works only FOR ITS !!!!!
2788 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2791 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2794 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2795 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2796 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2797 if(fTracker[iDet]) {
2798 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2799 TString name=planeeff->GetName();
2801 TFile* pefile = TFile::Open(name, "RECREATE");
2802 ret=(Bool_t)planeeff->Write();
2804 if(planeeff->GetCreateHistos()) {
2805 TString hname=planeeff->GetName();
2806 hname+="Histo.root";
2807 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2813 //_____________________________________________________________________________
2814 Bool_t AliReconstruction::InitPlaneEff() {
2816 // Here execute all the necessary operations, before of the tracking phase,
2817 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2818 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2819 // which should be updated/recalculated.
2821 // This Preliminary version will work only FOR ITS !!!!!
2822 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2825 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2827 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2831 //_____________________________________________________________________________
2832 Bool_t AliReconstruction::InitAliEVE()
2834 // This method should be called only in case
2835 // AliReconstruction is run
2836 // within the alieve environment.
2837 // It will initialize AliEVE in a way
2838 // so that it can visualize event processed
2839 // by AliReconstruction.
2840 // The return flag shows whenever the
2841 // AliEVE initialization was successful or not.
2844 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2845 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2846 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2848 gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};");
2849 gROOT->ProcessLine("alieve_online_init()");
2854 //_____________________________________________________________________________
2855 void AliReconstruction::RunAliEVE()
2857 // Runs AliEVE visualisation of
2858 // the current event.
2859 // Should be executed only after
2860 // successful initialization of AliEVE.
2862 AliInfo("Running AliEVE...");
2863 gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd));
2867 //_____________________________________________________________________________
2868 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2870 // Allows to run QA for a selected set of detectors
2871 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2872 // all selected detectors run the same selected tasks
2874 if (!detAndAction.Contains(":")) {
2875 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2879 Int_t colon = detAndAction.Index(":") ;
2880 fQADetectors = detAndAction(0, colon) ;
2881 if (fQADetectors.Contains("ALL") )
2882 fQADetectors = fFillESD ;
2883 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2884 if (fQATasks.Contains("ALL") ) {
2885 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2887 fQATasks.ToUpper() ;
2889 if ( fQATasks.Contains("RAW") )
2890 tempo = Form("%d ", AliQA::kRAWS) ;
2891 if ( fQATasks.Contains("RECPOINT") )
2892 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2893 if ( fQATasks.Contains("ESD") )
2894 tempo += Form("%d ", AliQA::kESDS) ;
2896 if (fQATasks.IsNull()) {
2897 AliInfo("No QA requested\n") ;
2902 TString tempo(fQATasks) ;
2903 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2904 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2905 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2906 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2911 //_____________________________________________________________________________
2912 Bool_t AliReconstruction::InitRecoParams()
2914 // The method accesses OCDB and retrieves all
2915 // the available reco-param objects from there.
2917 Bool_t isOK = kTRUE;
2919 TString detStr = fLoadCDB;
2920 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2922 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2924 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2925 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2929 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
2931 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2932 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
2934 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
2938 TObject *recoParamObj = entry->GetObject();
2939 if (dynamic_cast<TObjArray*>(recoParamObj)) {
2940 // The detector has a normal TobjArray of AliDetectorRecoParam objects
2941 // Registering them in AliRecoParam
2942 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
2944 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
2945 // The detector has only onse set of reco parameters
2946 // Registering it in AliRecoParam
2947 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
2948 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
2949 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
2952 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
2956 AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
2960 if (AliDebugLevel() > 0) fRecoParam.Print();
2965 //_____________________________________________________________________________
2966 Bool_t AliReconstruction::GetEventInfo()
2968 // Fill the event info object
2970 AliCodeTimerAuto("")
2972 AliCentralTrigger *aCTP = NULL;
2974 fEventInfo.SetEventType(fRawReader->GetType());
2976 ULong64_t mask = fRawReader->GetClassMask();
2977 fEventInfo.SetTriggerMask(mask);
2978 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
2979 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
2981 aCTP = new AliCentralTrigger();
2982 TString configstr("");
2983 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
2984 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
2988 aCTP->SetClassMask(mask);
2989 aCTP->SetClusterMask(clmask);
2992 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
2994 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
2995 aCTP = fRunLoader->GetTrigger();
2996 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
2997 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
3000 AliWarning("No trigger can be loaded! The trigger information will not be used!");
3005 AliTriggerConfiguration *config = aCTP->GetConfiguration();
3007 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
3008 if (fRawReader) delete aCTP;
3012 UChar_t clustmask = 0;
3014 ULong64_t trmask = fEventInfo.GetTriggerMask();
3015 const TObjArray& classesArray = config->GetClasses();
3016 Int_t nclasses = classesArray.GetEntriesFast();
3017 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
3018 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
3020 Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask());
3021 fesd->SetTriggerClass(trclass->GetName(),trindex);
3022 if (trmask & (1 << trindex)) {
3024 trclasses += trclass->GetName();
3026 clustmask |= trclass->GetCluster()->GetClusterMask();
3030 fEventInfo.SetTriggerClasses(trclasses);
3032 // Set the information in ESD
3033 fesd->SetTriggerMask(trmask);
3034 fesd->SetTriggerCluster(clustmask);
3036 if (!aCTP->CheckTriggeredDetectors()) {
3037 if (fRawReader) delete aCTP;
3041 if (fRawReader) delete aCTP;
3043 // We have to fill also the HLT decision here!!
3049 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3051 // Match the detector list found in the rec.C or the default 'ALL'
3052 // to the list found in the GRP (stored there by the shuttle PP which
3053 // gets the information from ECS)
3054 static TString resultList;
3055 TString detList = detectorList;
3059 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3060 if ((detectorMask >> iDet) & 0x1) {
3061 TString det = AliDAQ::OfflineModuleName(iDet);
3062 if ((detList.CompareTo("ALL") == 0) ||
3063 detList.BeginsWith("ALL ") ||
3064 detList.EndsWith(" ALL") ||
3065 detList.Contains(" ALL ") ||
3066 (detList.CompareTo(det) == 0) ||
3067 detList.BeginsWith(det) ||
3068 detList.EndsWith(det) ||
3069 detList.Contains( " "+det+" " )) {
3070 if (!resultList.EndsWith(det + " ")) {
3079 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3080 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3081 if ((detList.CompareTo("ALL") == 0) ||
3082 detList.BeginsWith("ALL ") ||
3083 detList.EndsWith(" ALL") ||
3084 detList.Contains(" ALL ") ||
3085 (detList.CompareTo(hltDet) == 0) ||
3086 detList.BeginsWith(hltDet) ||
3087 detList.EndsWith(hltDet) ||
3088 detList.Contains( " "+hltDet+" " )) {
3089 resultList += hltDet;
3093 return resultList.Data();
3097 //______________________________________________________________________________
3098 void AliReconstruction::Abort(const char *method, EAbort what)
3100 // Abort processing. If what = kAbortProcess, the Process() loop will be
3101 // aborted. If what = kAbortFile, the current file in a chain will be
3102 // aborted and the processing will continue with the next file, if there
3103 // is no next file then Process() will be aborted. Abort() can also be
3104 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3105 // the SlaveTerminate() and Terminate() are always called. The abort flag
3106 // can be checked in these methods using GetAbort().
3108 // The method is overwritten in AliReconstruction for better handling of
3109 // reco specific errors
3111 if (!fStopOnError) return;
3115 TString whyMess = method;
3116 whyMess += " failed! Aborting...";
3118 AliError(whyMess.Data());
3121 TString mess = "Abort";
3122 if (fAbort == kAbortProcess)
3123 mess = "AbortProcess";
3124 else if (fAbort == kAbortFile)
3127 Info(mess, whyMess.Data());