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("..."); //
108 // For debug purposes the method SetCheckPointLevel can be used. If the //
109 // argument is greater than 0, files with ESD events will be written after //
110 // selected steps of the reconstruction for each event: //
111 // level 1: after tracking and after filling of ESD (final) //
112 // level 2: in addition after each tracking step //
113 // level 3: in addition after the filling of ESD for each detector //
114 // If a final check point file exists for an event, this event will be //
115 // skipped in the reconstruction. The tracking and the filling of ESD for //
116 // a detector will be skipped as well, if the corresponding check point //
117 // file exists. The ESD event will then be loaded from the file instead. //
119 ///////////////////////////////////////////////////////////////////////////////
126 #include <TPluginManager.h>
127 #include <TGeoManager.h>
128 #include <TLorentzVector.h>
131 #include <TObjArray.h>
134 #include "AliReconstruction.h"
135 #include "AliCodeTimer.h"
136 #include "AliReconstructor.h"
138 #include "AliRunLoader.h"
140 #include "AliRawReaderFile.h"
141 #include "AliRawReaderDate.h"
142 #include "AliRawReaderRoot.h"
143 #include "AliRawEventHeaderBase.h"
144 #include "AliESDEvent.h"
145 #include "AliESDMuonTrack.h"
146 #include "AliESDfriend.h"
147 #include "AliESDVertex.h"
148 #include "AliESDcascade.h"
149 #include "AliESDkink.h"
150 #include "AliESDtrack.h"
151 #include "AliESDCaloCluster.h"
152 #include "AliESDCaloCells.h"
153 #include "AliMultiplicity.h"
154 #include "AliTracker.h"
155 #include "AliVertexer.h"
156 #include "AliVertexerTracks.h"
157 #include "AliV0vertexer.h"
158 #include "AliCascadeVertexer.h"
159 #include "AliHeader.h"
160 #include "AliGenEventHeader.h"
162 #include "AliESDpid.h"
163 #include "AliESDtrack.h"
164 #include "AliESDPmdTrack.h"
166 #include "AliESDTagCreator.h"
167 #include "AliAODTagCreator.h"
169 #include "AliGeomManager.h"
170 #include "AliTrackPointArray.h"
171 #include "AliCDBManager.h"
172 #include "AliCDBStorage.h"
173 #include "AliCDBEntry.h"
174 #include "AliAlignObj.h"
176 #include "AliCentralTrigger.h"
177 #include "AliTriggerConfiguration.h"
178 #include "AliTriggerClass.h"
179 #include "AliCTPRawStream.h"
181 #include "AliQADataMakerRec.h"
182 #include "AliGlobalQADataMaker.h"
184 #include "AliQADataMakerSteer.h"
186 #include "AliPlaneEff.h"
188 #include "AliSysInfo.h" // memory snapshots
189 #include "AliRawHLTManager.h"
191 #include "AliMagWrapCheb.h"
193 #include "AliDetectorRecoParam.h"
194 #include "AliRunInfo.h"
195 #include "AliEventInfo.h"
199 ClassImp(AliReconstruction)
202 //_____________________________________________________________________________
203 const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
205 //_____________________________________________________________________________
206 AliReconstruction::AliReconstruction(const char* gAliceFilename,
207 const char* name, const char* title) :
210 fUniformField(kFALSE),
211 fForcedFieldMap(0x0),
212 fRunVertexFinder(kTRUE),
213 fRunVertexFinderTracks(kTRUE),
214 fRunHLTTracking(kFALSE),
215 fRunMuonTracking(kFALSE),
217 fRunCascadeFinder(kTRUE),
218 fStopOnError(kFALSE),
219 fWriteAlignmentData(kFALSE),
220 fWriteESDfriend(kFALSE),
222 fFillTriggerESD(kTRUE),
230 fRunLocalReconstruction("ALL"),
233 fUseTrackingErrorsForAlignment(""),
234 fGAliceFileName(gAliceFilename),
239 fNumberOfEventsPerFile(1),
242 fLoadAlignFromCDB(kTRUE),
243 fLoadAlignData("ALL"),
251 fParentRawReader(NULL),
256 fDiamondProfile(NULL),
257 fDiamondProfileTPC(NULL),
258 fMeanVertexConstraint(kTRUE),
262 fAlignObjArray(NULL),
265 fInitCDBCalled(kFALSE),
266 fSetRunNumberFromDataCalled(kFALSE),
273 fSameQACycle(kFALSE),
275 fRunPlaneEff(kFALSE),
287 fIsNewRunLoader(kFALSE),
290 // create reconstruction object with default parameters
292 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
293 fReconstructor[iDet] = NULL;
294 fLoader[iDet] = NULL;
295 fTracker[iDet] = NULL;
296 fQACycles[iDet] = 999999;
298 fQASteer = new AliQADataMakerSteer("rec") ;
299 fQASteer->SetActiveDetectors(fQADetectors) ;
300 fQASteer->SetTasks(fQATasks) ;
304 //_____________________________________________________________________________
305 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
308 fUniformField(rec.fUniformField),
309 fForcedFieldMap(0x0),
310 fRunVertexFinder(rec.fRunVertexFinder),
311 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
312 fRunHLTTracking(rec.fRunHLTTracking),
313 fRunMuonTracking(rec.fRunMuonTracking),
314 fRunV0Finder(rec.fRunV0Finder),
315 fRunCascadeFinder(rec.fRunCascadeFinder),
316 fStopOnError(rec.fStopOnError),
317 fWriteAlignmentData(rec.fWriteAlignmentData),
318 fWriteESDfriend(rec.fWriteESDfriend),
319 fWriteAOD(rec.fWriteAOD),
320 fFillTriggerESD(rec.fFillTriggerESD),
322 fCleanESD(rec.fCleanESD),
323 fV0DCAmax(rec.fV0DCAmax),
324 fV0CsPmin(rec.fV0CsPmin),
328 fRunLocalReconstruction(rec.fRunLocalReconstruction),
329 fRunTracking(rec.fRunTracking),
330 fFillESD(rec.fFillESD),
331 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
332 fGAliceFileName(rec.fGAliceFileName),
334 fEquipIdMap(rec.fEquipIdMap),
335 fFirstEvent(rec.fFirstEvent),
336 fLastEvent(rec.fLastEvent),
337 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
340 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
341 fLoadAlignData(rec.fLoadAlignData),
342 fESDPar(rec.fESDPar),
343 fUseHLTData(rec.fUseHLTData),
349 fParentRawReader(NULL),
354 fDiamondProfile(NULL),
355 fDiamondProfileTPC(NULL),
356 fMeanVertexConstraint(rec.fMeanVertexConstraint),
360 fAlignObjArray(rec.fAlignObjArray),
361 fCDBUri(rec.fCDBUri),
363 fInitCDBCalled(rec.fInitCDBCalled),
364 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
365 fQADetectors(rec.fQADetectors),
366 fQASteer(rec.fQASteer),
367 fQATasks(rec.fQATasks),
369 fRunGlobalQA(rec.fRunGlobalQA),
370 fInLoopQA(rec.fInLoopQA),
371 fSameQACycle(rec.fSameQACycle),
372 fRunPlaneEff(rec.fRunPlaneEff),
384 fIsNewRunLoader(rec.fIsNewRunLoader),
389 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
390 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
392 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
393 fReconstructor[iDet] = NULL;
394 fLoader[iDet] = NULL;
395 fTracker[iDet] = NULL;
396 fQACycles[iDet] = rec.fQACycles[iDet];
398 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
399 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
402 fForcedFieldMap=new AliMagWrapCheb(*((AliMagWrapCheb*)rec.fForcedFieldMap));
405 //_____________________________________________________________________________
406 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
408 // assignment operator
410 this->~AliReconstruction();
411 new(this) AliReconstruction(rec);
415 //_____________________________________________________________________________
416 AliReconstruction::~AliReconstruction()
422 fSpecCDBUri.Delete();
423 delete fForcedFieldMap;
425 AliCodeTimer::Instance()->Print();
428 //_____________________________________________________________________________
429 void AliReconstruction::InitCDB()
431 // activate a default CDB storage
432 // First check if we have any CDB storage set, because it is used
433 // to retrieve the calibration and alignment constants
435 if (fInitCDBCalled) return;
436 fInitCDBCalled = kTRUE;
438 AliCDBManager* man = AliCDBManager::Instance();
439 if (man->IsDefaultStorageSet())
441 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
442 AliWarning("Default CDB storage has been already set !");
443 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
444 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
445 fCDBUri = man->GetDefaultStorage()->GetURI();
448 if (fCDBUri.Length() > 0)
450 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
451 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
452 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
454 fCDBUri="local://$ALICE_ROOT";
455 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
456 AliWarning("Default CDB storage not yet set !!!!");
457 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
458 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
461 man->SetDefaultStorage(fCDBUri);
464 // Now activate the detector specific CDB storage locations
465 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
466 TObject* obj = fSpecCDBUri[i];
468 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
469 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
470 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
471 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
476 //_____________________________________________________________________________
477 void AliReconstruction::SetDefaultStorage(const char* uri) {
478 // Store the desired default CDB storage location
479 // Activate it later within the Run() method
485 //_____________________________________________________________________________
486 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
487 // Store a detector-specific CDB storage location
488 // Activate it later within the Run() method
490 AliCDBPath aPath(calibType);
491 if(!aPath.IsValid()){
492 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
493 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
494 if(!strcmp(calibType, fgkDetectorName[iDet])) {
495 aPath.SetPath(Form("%s/*", calibType));
496 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
500 if(!aPath.IsValid()){
501 AliError(Form("Not a valid path or detector: %s", calibType));
506 // // check that calibType refers to a "valid" detector name
507 // Bool_t isDetector = kFALSE;
508 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
509 // TString detName = fgkDetectorName[iDet];
510 // if(aPath.GetLevel0() == detName) {
511 // isDetector = kTRUE;
517 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
521 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
522 if (obj) fSpecCDBUri.Remove(obj);
523 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
527 //_____________________________________________________________________________
528 Bool_t AliReconstruction::SetRunNumberFromData()
530 // The method is called in Run() in order
531 // to set a correct run number.
532 // In case of raw data reconstruction the
533 // run number is taken from the raw data header
535 if (fSetRunNumberFromDataCalled) return kTRUE;
536 fSetRunNumberFromDataCalled = kTRUE;
538 AliCDBManager* man = AliCDBManager::Instance();
540 if(man->GetRun() > 0) {
541 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
545 AliError("No run loader is found !");
548 // read run number from gAlice
549 if(fRunLoader->GetAliRun())
550 AliCDBManager::Instance()->SetRun(fRunLoader->GetHeader()->GetRun());
553 if(fRawReader->NextEvent()) {
554 AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber());
555 fRawReader->RewindEvents();
558 if(man->GetRun() > 0) {
559 AliWarning("No raw events is found ! Using settings in AliCDBManager !");
564 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
570 AliError("Neither gAlice nor RawReader objects are found !");
580 //_____________________________________________________________________________
581 void AliReconstruction::SetCDBLock() {
582 // Set CDB lock: from now on it is forbidden to reset the run number
583 // or the default storage or to activate any further storage!
585 AliCDBManager::Instance()->SetLock(1);
588 //_____________________________________________________________________________
589 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
591 // Read the alignment objects from CDB.
592 // Each detector is supposed to have the
593 // alignment objects in DET/Align/Data CDB path.
594 // All the detector objects are then collected,
595 // sorted by geometry level (starting from ALIC) and
596 // then applied to the TGeo geometry.
597 // Finally an overlaps check is performed.
599 // Load alignment data from CDB and fill fAlignObjArray
600 if(fLoadAlignFromCDB){
602 TString detStr = detectors;
603 TString loadAlObjsListOfDets = "";
605 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
606 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
607 loadAlObjsListOfDets += fgkDetectorName[iDet];
608 loadAlObjsListOfDets += " ";
609 } // end loop over detectors
610 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
611 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
613 // Check if the array with alignment objects was
614 // provided by the user. If yes, apply the objects
615 // to the present TGeo geometry
616 if (fAlignObjArray) {
617 if (gGeoManager && gGeoManager->IsClosed()) {
618 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
619 AliError("The misalignment of one or more volumes failed!"
620 "Compare the list of simulated detectors and the list of detector alignment data!");
625 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
631 delete fAlignObjArray; fAlignObjArray=0;
636 //_____________________________________________________________________________
637 void AliReconstruction::SetGAliceFile(const char* fileName)
639 // set the name of the galice file
641 fGAliceFileName = fileName;
644 //_____________________________________________________________________________
645 void AliReconstruction::SetInput(const char* input)
647 // In case the input string starts with 'mem://', we run in an online mode
648 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
649 // file is assumed. One can give as an input:
650 // mem://: - events taken from DAQ monitoring libs online
652 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
656 //_____________________________________________________________________________
657 void AliReconstruction::SetOption(const char* detector, const char* option)
659 // set options for the reconstruction of a detector
661 TObject* obj = fOptions.FindObject(detector);
662 if (obj) fOptions.Remove(obj);
663 fOptions.Add(new TNamed(detector, option));
666 //_____________________________________________________________________________
667 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
669 // Set custom reconstruction parameters for a given detector
670 // Single set of parameters for all the events
671 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
672 if(!strcmp(detector, fgkDetectorName[iDet])) {
674 fRecoParam.AddDetRecoParam(iDet,par);
681 //_____________________________________________________________________________
682 Bool_t AliReconstruction::SetFieldMap(Float_t l3Current, Float_t diCurrent, Float_t factor, const char *path) {
683 //------------------------------------------------
684 // The magnetic field map, defined externally...
685 // L3 current 30000 A -> 0.5 T
686 // L3 current 12000 A -> 0.2 T
687 // dipole current 6000 A
688 // The polarities must be the same
689 //------------------------------------------------
690 const Float_t l3NominalCurrent1=30000.; // (A)
691 const Float_t l3NominalCurrent2=12000.; // (A)
692 const Float_t diNominalCurrent =6000. ; // (A)
694 const Float_t tolerance=0.03; // relative current tolerance
695 const Float_t zero=77.; // "zero" current (A)
698 Bool_t dipoleON=kFALSE;
700 TString s=(factor < 0) ? "L3: -" : "L3: +";
702 l3Current = TMath::Abs(l3Current);
703 if (TMath::Abs(l3Current-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
704 map=AliMagWrapCheb::k5kG;
707 if (TMath::Abs(l3Current-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
708 map=AliMagWrapCheb::k2kG;
711 if (l3Current < zero) {
712 map=AliMagWrapCheb::k2kG;
714 factor=0.; // in fact, this is a global factor...
715 fUniformField=kTRUE; // track with the uniform (zero) B field
717 AliError(Form("Wrong L3 current (%f A)!",l3Current));
721 diCurrent = TMath::Abs(diCurrent);
722 if (TMath::Abs(diCurrent-diNominalCurrent)/diNominalCurrent < tolerance) {
723 // 3% current tolerance...
727 if (diCurrent < zero) { // some small current..
731 AliError(Form("Wrong dipole current (%f A)!",diCurrent));
735 delete fForcedFieldMap;
737 new AliMagWrapCheb("B field map ",s,2,factor,10.,map,dipoleON,path);
739 fForcedFieldMap->Print();
741 AliTracker::SetFieldMap(fForcedFieldMap,fUniformField);
747 Bool_t AliReconstruction::InitGRP() {
748 //------------------------------------
749 // Initialization of the GRP entry
750 //------------------------------------
751 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
753 if (entry) fGRPData = dynamic_cast<TMap*>(entry->GetObject());
756 AliError("No GRP entry found in OCDB!");
760 TObjString *lhcState=
761 dynamic_cast<TObjString*>(fGRPData->GetValue("fLHCState"));
763 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
766 TObjString *beamType=
767 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamType"));
769 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
772 TObjString *beamEnergyStr=
773 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamEnergy"));
774 if (!beamEnergyStr) {
775 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
779 dynamic_cast<TObjString*>(fGRPData->GetValue("fRunType"));
781 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
784 TObjString *activeDetectors=
785 dynamic_cast<TObjString*>(fGRPData->GetValue("fDetectorMask"));
786 if (!activeDetectors) {
787 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
790 fRunInfo = new AliRunInfo(lhcState ? lhcState->GetString().Data() : "UNKNOWN",
791 beamType ? beamType->GetString().Data() : "UNKNOWN",
792 beamEnergyStr ? beamEnergyStr->GetString().Atof() : 0,
793 runType ? runType->GetString().Data() : "UNKNOWN",
794 activeDetectors ? activeDetectors->GetString().Atoi() : 1074790399);
796 // Process the list of active detectors
797 if (activeDetectors && activeDetectors->GetString().IsDigit()) {
798 UInt_t detMask = activeDetectors->GetString().Atoi();
799 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
800 fRunTracking = MatchDetectorList(fRunTracking,detMask);
801 fFillESD = MatchDetectorList(fFillESD,detMask);
802 fQADetectors = MatchDetectorList(fQADetectors,detMask);
803 fQASteer->SetActiveDetectors(fQADetectors) ;
806 AliInfo("===================================================================================");
807 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
808 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
809 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
810 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
811 AliInfo("===================================================================================");
813 //*** Dealing with the magnetic field map
814 if (AliTracker::GetFieldMap()) {
815 AliInfo("Running with the externally set B field !");
817 // Construct the field map out of the information retrieved from GRP.
822 TObjString *l3Current=
823 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
825 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
828 TObjString *l3Polarity=
829 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
831 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
836 TObjString *diCurrent=
837 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
839 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
842 TObjString *diPolarity=
843 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
845 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
850 Float_t l3Cur=TMath::Abs(atof(l3Current->GetName()));
851 Float_t diCur=TMath::Abs(atof(diCurrent->GetName()));
852 Float_t l3Pol=atof(l3Polarity->GetName());
854 if (l3Pol != 0.) factor=-1.;
857 if (!SetFieldMap(l3Cur, diCur, factor)) {
858 AliFatal("Failed to creat a B field map ! Exiting...");
860 AliInfo("Running with the B field constructed out of GRP !");
863 AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
869 //*** Get the diamond profile from OCDB
870 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
872 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
874 AliError("No diamond profile found in OCDB!");
877 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
879 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
881 AliError("No diamond profile found in OCDB!");
887 //_____________________________________________________________________________
888 Bool_t AliReconstruction::Run(const char* input)
891 AliCodeTimerAuto("");
893 if (!InitRun(input)) return kFALSE;
894 //******* The loop over events
896 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
897 (fRawReader && fRawReader->NextEvent())) {
898 if (!RunEvent(iEvent)) return kFALSE;
902 if (!FinishRun()) return kFALSE;
907 //_____________________________________________________________________________
908 Bool_t AliReconstruction::InitRun(const char* input)
910 // Initialize all the stuff before
911 // going into the event loop
912 // If the second argument is given, the first one is ignored and
913 // the reconstruction works in an online mode
914 AliCodeTimerAuto("");
916 // Overwrite the previous setting
917 if (input) fInput = input;
919 // set the input in case of raw data
920 fRawReader = AliRawReader::Create(fInput.Data());
922 AliInfo("Reconstruction will run over digits");
924 if (!fEquipIdMap.IsNull() && fRawReader)
925 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
927 if (!fUseHLTData.IsNull()) {
928 // create the RawReaderHLT which performs redirection of HLT input data for
929 // the specified detectors
930 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
932 fParentRawReader=fRawReader;
933 fRawReader=pRawReader;
935 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
939 AliSysInfo::AddStamp("Start");
940 // get the run loader
941 if (!InitRunLoader()) return kFALSE;
942 AliSysInfo::AddStamp("LoadLoader");
944 // Initialize the CDB storage
947 AliSysInfo::AddStamp("LoadCDB");
949 // Set run number in CDBManager (if it is not already set by the user)
950 if (!SetRunNumberFromData()) if (fStopOnError) return kFALSE;
952 // Set CDB lock: from now on it is forbidden to reset the run number
953 // or the default storage or to activate any further storage!
956 // Import ideal TGeo geometry and apply misalignment
958 TString geom(gSystem->DirName(fGAliceFileName));
959 geom += "/geometry.root";
960 AliGeomManager::LoadGeometry(geom.Data());
962 TString detsToCheck=fRunLocalReconstruction;
963 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data()))
964 AliFatalClass("Current loaded geometry differs in the definition of symbolic names!");
965 if (!gGeoManager) if (fStopOnError) return kFALSE;
968 if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE;
969 AliSysInfo::AddStamp("LoadGeom");
972 if (!InitGRP()) return kFALSE;
974 // Read the reconstruction parameters from OCDB
975 if (!InitRecoParams()) {
981 AliSysInfo::AddStamp("ReadRecoParam");
983 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
984 if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile);
987 if (fRunVertexFinder && !CreateVertexer()) {
993 AliSysInfo::AddStamp("Vertexer");
996 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1002 AliSysInfo::AddStamp("LoadTrackers");
1004 // get the possibly already existing ESD file and tree
1005 fesd = new AliESDEvent(); fhltesd = new AliESDEvent();
1006 if (!gSystem->AccessPathName("AliESDs.root")){
1007 gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE);
1008 ffileOld = TFile::Open("AliESDs.old.root");
1009 if (ffileOld && ffileOld->IsOpen()) {
1010 ftreeOld = (TTree*) ffileOld->Get("esdTree");
1011 if (ftreeOld)fesd->ReadFromTree(ftreeOld);
1012 fhlttreeOld = (TTree*) ffileOld->Get("HLTesdTree");
1013 if (fhlttreeOld) fhltesd->ReadFromTree(fhlttreeOld);
1017 // create the ESD output file and tree
1018 ffile = TFile::Open("AliESDs.root", "RECREATE");
1019 ffile->SetCompressionLevel(2);
1020 if (!ffile->IsOpen()) {
1021 AliError("opening AliESDs.root failed");
1022 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1025 ftree = new TTree("esdTree", "Tree with ESD objects");
1026 fesd = new AliESDEvent();
1027 fesd->CreateStdContent();
1028 fesd->WriteToTree(ftree);
1030 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1031 fhltesd = new AliESDEvent();
1032 fhltesd->CreateStdContent();
1033 fhltesd->WriteToTree(fhlttree);
1036 if (fWriteESDfriend) {
1037 fesdf = new AliESDfriend();
1038 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1039 br->SetFile("AliESDfriends.root");
1040 fesd->AddObject(fesdf);
1045 if (fRawReader) fRawReader->RewindEvents();
1047 ProcInfo_t ProcInfo;
1048 gSystem->GetProcInfo(&ProcInfo);
1049 AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1053 if (fRunQA && fRawReader && fQATasks.Contains(Form("%d", AliQA::kRAWS))) {
1054 fQASteer->Run(fQADetectors, fRawReader) ;
1055 fSameQACycle = kTRUE ;
1059 //Initialize the QA and start of cycle for out-of-loop QA
1061 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam, fSameQACycle, !fInLoopQA) ;
1065 fSameQACycle = kFALSE;
1066 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1067 AliInfo(Form("Initializing the global QA data maker"));
1068 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1069 TObjArray *arr=qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
1070 AliTracker::SetResidualsArray(arr);
1072 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
1073 fSameQACycle = kTRUE;
1076 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1077 qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
1079 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
1080 fSameQACycle = kTRUE;
1085 //Initialize the Plane Efficiency framework
1086 if (fRunPlaneEff && !InitPlaneEff()) {
1087 if(fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1090 if (strcmp(gProgName,"alieve") == 0)
1091 fRunAliEVE = InitAliEVE();
1096 //_____________________________________________________________________________
1097 Bool_t AliReconstruction::RunEvent(Int_t iEvent)
1099 // run the reconstruction over a single event
1100 // The event loop is steered in Run method
1102 AliCodeTimerAuto("");
1104 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1105 fRunLoader->SetEventNumber(iEvent);
1106 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1108 //?? fRunLoader->MakeTree("H");
1109 fRunLoader->TreeE()->Fill();
1112 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1113 // copy old ESD to the new one
1115 fesd->ReadFromTree(ftreeOld);
1116 ftreeOld->GetEntry(iEvent);
1120 fhltesd->ReadFromTree(fhlttreeOld);
1121 fhlttreeOld->GetEntry(iEvent);
1127 AliInfo(Form("processing event %d", iEvent));
1129 // Fill Event-info object
1131 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1133 //Start of cycle for the in-loop QA
1134 if (fInLoopQA && fRunQA) {
1135 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam, fSameQACycle, fInLoopQA) ;
1137 if (fInLoopQA && fRunGlobalQA) {
1138 fSameQACycle = kFALSE;
1139 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1140 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1141 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
1142 fSameQACycle = kTRUE;
1144 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1145 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
1146 fSameQACycle = kTRUE;
1150 fRunLoader->GetEvent(iEvent);
1152 char aFileName[256];
1153 sprintf(aFileName, "ESD_%d.%d_final.root",
1154 fRunLoader->GetHeader()->GetRun(),
1155 fRunLoader->GetHeader()->GetEventNrInRun());
1156 if (!gSystem->AccessPathName(aFileName)) return kTRUE;
1159 if (fInLoopQA && fRunQA)
1160 fQASteer->RunOneEvent(fRawReader) ;
1162 // local single event reconstruction
1163 if (!fRunLocalReconstruction.IsNull()) {
1164 TString detectors=fRunLocalReconstruction;
1165 // run HLT event reconstruction first
1166 // ;-( IsSelected changes the string
1167 if (IsSelected("HLT", detectors) &&
1168 !RunLocalEventReconstruction("HLT")) {
1169 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1171 detectors=fRunLocalReconstruction;
1172 detectors.ReplaceAll("HLT", "");
1173 if (!RunLocalEventReconstruction(detectors)) {
1174 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1178 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1179 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1180 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1181 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1183 // Set magnetic field from the tracker
1184 fesd->SetMagneticField(AliTracker::GetBz());
1185 fhltesd->SetMagneticField(AliTracker::GetBz());
1189 // Fill raw-data error log into the ESD
1190 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1193 if (fRunVertexFinder) {
1194 if (!ReadESD(fesd, "vertex")) {
1195 if (!RunVertexFinder(fesd)) {
1196 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1198 if (fCheckPointLevel > 0) WriteESD(fesd, "vertex");
1203 if (!fRunTracking.IsNull()) {
1204 if (fRunMuonTracking) {
1205 if (!RunMuonTracking(fesd)) {
1206 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1212 if (!fRunTracking.IsNull()) {
1213 if (!ReadESD(fesd, "tracking")) {
1214 if (!RunTracking(fesd)) {
1215 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1217 if (fCheckPointLevel > 0) WriteESD(fesd, "tracking");
1222 if (!fFillESD.IsNull()) {
1223 TString detectors=fFillESD;
1224 // run HLT first and on hltesd
1225 // ;-( IsSelected changes the string
1226 if (IsSelected("HLT", detectors) &&
1227 !FillESD(fhltesd, "HLT")) {
1228 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1231 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1232 if (detectors.Contains("ALL")) {
1234 for (Int_t idet=0; idet<fgkNDetectors; ++idet){
1235 detectors += fgkDetectorName[idet];
1239 detectors.ReplaceAll("HLT", "");
1240 if (!FillESD(fesd, detectors)) {
1241 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1245 // fill Event header information from the RawEventHeader
1246 if (fRawReader){FillRawEventHeaderESD(fesd);}
1249 AliESDpid::MakePID(fesd);
1250 if (fCheckPointLevel > 1) WriteESD(fesd, "PID");
1252 if (fFillTriggerESD) {
1253 if (!ReadESD(fesd, "trigger")) {
1254 if (!FillTriggerESD(fesd)) {
1255 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1257 if (fCheckPointLevel > 1) WriteESD(fesd, "trigger");
1264 // Propagate track to the beam pipe (if not already done by ITS)
1266 const Int_t ntracks = fesd->GetNumberOfTracks();
1267 const Double_t kBz = fesd->GetMagneticField();
1268 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1271 UShort_t *selectedIdx=new UShort_t[ntracks];
1273 for (Int_t itrack=0; itrack<ntracks; itrack++){
1274 const Double_t kMaxStep = 5; //max step over the material
1277 AliESDtrack *track = fesd->GetTrack(itrack);
1278 if (!track) continue;
1280 AliExternalTrackParam *tpcTrack =
1281 (AliExternalTrackParam *)track->GetTPCInnerParam();
1285 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE);
1288 Int_t n=trkArray.GetEntriesFast();
1289 selectedIdx[n]=track->GetID();
1290 trkArray.AddLast(tpcTrack);
1293 //Tracks refitted by ITS should already be at the SPD vertex
1294 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1297 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE);
1298 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1303 // Improve the reconstructed primary vertex position using the tracks
1305 TObject *obj = fOptions.FindObject("ITS");
1307 TString optITS = obj->GetTitle();
1308 if (optITS.Contains("cosmics") || optITS.Contains("COSMICS"))
1309 fRunVertexFinderTracks=kFALSE;
1311 if (fRunVertexFinderTracks) {
1312 // TPC + ITS primary vertex
1313 ftVertexer->SetITSrefitRequired();
1314 if(fDiamondProfile && fMeanVertexConstraint) {
1315 ftVertexer->SetVtxStart(fDiamondProfile);
1317 ftVertexer->SetConstraintOff();
1319 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1321 if (pvtx->GetStatus()) {
1322 fesd->SetPrimaryVertex(pvtx);
1323 for (Int_t i=0; i<ntracks; i++) {
1324 AliESDtrack *t = fesd->GetTrack(i);
1325 t->RelateToVertex(pvtx, kBz, kVeryBig);
1330 // TPC-only primary vertex
1331 ftVertexer->SetITSrefitNotRequired();
1332 if(fDiamondProfileTPC && fMeanVertexConstraint) {
1333 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1335 ftVertexer->SetConstraintOff();
1337 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1339 if (pvtx->GetStatus()) {
1340 fesd->SetPrimaryVertexTPC(pvtx);
1341 for (Int_t i=0; i<ntracks; i++) {
1342 AliESDtrack *t = fesd->GetTrack(i);
1343 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1349 delete[] selectedIdx;
1351 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1356 AliV0vertexer vtxer;
1357 vtxer.Tracks2V0vertices(fesd);
1359 if (fRunCascadeFinder) {
1361 AliCascadeVertexer cvtxer;
1362 cvtxer.V0sTracks2CascadeVertices(fesd);
1367 if (fCleanESD) CleanESD(fesd);
1371 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1372 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1373 qadm->Exec(AliQA::kESDS, fesd);
1377 if (fWriteESDfriend) {
1378 fesdf->~AliESDfriend();
1379 new (fesdf) AliESDfriend(); // Reset...
1380 fesd->GetESDfriend(fesdf);
1384 // Auto-save the ESD tree in case of prompt reco @P2
1385 if (fRawReader && fRawReader->UseAutoSaveESD())
1386 ftree->AutoSave("SaveSelf");
1392 if (fRunAliEVE) RunAliEVE();
1394 if (fCheckPointLevel > 0) WriteESD(fesd, "final");
1397 if (fWriteESDfriend) {
1398 fesdf->~AliESDfriend();
1399 new (fesdf) AliESDfriend(); // Reset...
1402 ProcInfo_t ProcInfo;
1403 gSystem->GetProcInfo(&ProcInfo);
1404 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1407 // End of cycle for the in-loop
1408 if (fInLoopQA && fRunQA) {
1409 fQASteer->RunOneEvent(fesd) ;
1410 fQASteer->EndOfCycle() ;
1413 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1415 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1416 qadm->EndOfCycle(AliQA::kRECPOINTS);
1417 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1418 qadm->EndOfCycle(AliQA::kESDS);
1424 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1425 if (fReconstructor[iDet])
1426 fReconstructor[iDet]->SetRecoParam(NULL);
1432 //_____________________________________________________________________________
1433 Bool_t AliReconstruction::FinishRun()
1436 // Called after the exit
1437 // from the event loop
1438 AliCodeTimerAuto("");
1440 if (fIsNewRunLoader) { // galice.root didn't exist
1441 fRunLoader->WriteHeader("OVERWRITE");
1442 fRunLoader->CdGAFile();
1443 fRunLoader->Write(0, TObject::kOverwrite);
1446 ftree->GetUserInfo()->Add(fesd);
1447 fhlttree->GetUserInfo()->Add(fhltesd);
1449 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1450 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1452 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1453 cdbMapCopy->SetOwner(1);
1454 cdbMapCopy->SetName("cdbMap");
1455 TIter iter(cdbMap->GetTable());
1458 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1459 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1460 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1461 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1464 TList *cdbListCopy = new TList();
1465 cdbListCopy->SetOwner(1);
1466 cdbListCopy->SetName("cdbList");
1468 TIter iter2(cdbList);
1471 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1472 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1475 ftree->GetUserInfo()->Add(cdbMapCopy);
1476 ftree->GetUserInfo()->Add(cdbListCopy);
1479 if(fESDPar.Contains("ESD.par")){
1480 AliInfo("Attaching ESD.par to Tree");
1481 TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
1482 ftree->GetUserInfo()->Add(fn);
1488 if (fWriteESDfriend)
1489 ftree->SetBranchStatus("ESDfriend*",0);
1490 // we want to have only one tree version number
1491 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1494 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
1495 if (fRunPlaneEff && !FinishPlaneEff()) {
1496 AliWarning("Finish PlaneEff evaluation failed");
1500 CleanUp(ffile, ffileOld);
1503 AliWarning("AOD creation not supported anymore during reconstruction. See ANALYSIS/AliAnalysisTaskESDfilter.cxx instead.");
1506 // Create tags for the events in the ESD tree (the ESD tree is always present)
1507 // In case of empty events the tags will contain dummy values
1508 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1509 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData);
1511 AliWarning("AOD tag creation not supported anymore during reconstruction.");
1514 //Finish QA and end of cycle for out-of-loop QA
1515 if (!fInLoopQA && fRunQA)
1516 fQASteer->Run(fRunLocalReconstruction.Data(), AliQA::kNULLTASKINDEX, fSameQACycle) ;
1517 if (!fInLoopQA && fRunGlobalQA) {
1518 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1520 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1521 qadm->EndOfCycle(AliQA::kRECPOINTS);
1522 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1523 qadm->EndOfCycle(AliQA::kESDS);
1528 // Cleanup of CDB manager: cache and active storages!
1529 AliCDBManager::Instance()->ClearCache();
1535 //_____________________________________________________________________________
1536 Bool_t AliReconstruction::RunLocalReconstruction(const TString& /*detectors*/)
1538 // run the local reconstruction
1539 static Int_t eventNr=0;
1540 AliCodeTimerAuto("")
1542 // AliCDBManager* man = AliCDBManager::Instance();
1543 // Bool_t origCache = man->GetCacheFlag();
1545 // TString detStr = detectors;
1546 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1547 // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1548 // AliReconstructor* reconstructor = GetReconstructor(iDet);
1549 // if (!reconstructor) continue;
1550 // if (reconstructor->HasLocalReconstruction()) continue;
1552 // AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1553 // AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1555 // AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1556 // AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1558 // man->SetCacheFlag(kTRUE);
1559 // TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]);
1560 // man->GetAll(calibPath); // entries are cached!
1562 // AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1564 // if (fRawReader) {
1565 // fRawReader->RewindEvents();
1566 // reconstructor->Reconstruct(fRunLoader, fRawReader);
1568 // reconstructor->Reconstruct(fRunLoader);
1571 // AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1572 // AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr));
1574 // // unload calibration data
1575 // man->UnloadFromCache(calibPath);
1576 // //man->ClearCache();
1579 // man->SetCacheFlag(origCache);
1581 // if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1582 // AliError(Form("the following detectors were not found: %s",
1584 // if (fStopOnError) return kFALSE;
1591 //_____________________________________________________________________________
1592 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1594 // run the local reconstruction
1596 static Int_t eventNr=0;
1597 AliCodeTimerAuto("")
1599 TString detStr = detectors;
1600 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1601 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1602 AliReconstructor* reconstructor = GetReconstructor(iDet);
1603 if (!reconstructor) continue;
1604 AliLoader* loader = fLoader[iDet];
1605 // Matthias April 2008: temporary fix to run HLT reconstruction
1606 // although the HLT loader is missing
1607 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1609 reconstructor->Reconstruct(fRawReader, NULL);
1612 reconstructor->Reconstruct(dummy, NULL);
1617 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1620 // conversion of digits
1621 if (fRawReader && reconstructor->HasDigitConversion()) {
1622 AliInfo(Form("converting raw data digits into root objects for %s",
1623 fgkDetectorName[iDet]));
1624 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1625 // fgkDetectorName[iDet]));
1626 loader->LoadDigits("update");
1627 loader->CleanDigits();
1628 loader->MakeDigitsContainer();
1629 TTree* digitsTree = loader->TreeD();
1630 reconstructor->ConvertDigits(fRawReader, digitsTree);
1631 loader->WriteDigits("OVERWRITE");
1632 loader->UnloadDigits();
1634 // local reconstruction
1635 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1636 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1637 loader->LoadRecPoints("update");
1638 loader->CleanRecPoints();
1639 loader->MakeRecPointsContainer();
1640 TTree* clustersTree = loader->TreeR();
1641 if (fRawReader && !reconstructor->HasDigitConversion()) {
1642 reconstructor->Reconstruct(fRawReader, clustersTree);
1644 loader->LoadDigits("read");
1645 TTree* digitsTree = loader->TreeD();
1647 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1648 if (fStopOnError) return kFALSE;
1650 reconstructor->Reconstruct(digitsTree, clustersTree);
1652 loader->UnloadDigits();
1655 // In-loop QA for local reconstrucion
1656 TString detQAStr(fQADetectors) ;
1657 if (fRunQA && fInLoopQA)
1658 fQASteer->RunOneEventInOneDetector(iDet, clustersTree) ;
1660 loader->WriteRecPoints("OVERWRITE");
1661 loader->UnloadRecPoints();
1662 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1664 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1665 AliError(Form("the following detectors were not found: %s",
1667 if (fStopOnError) return kFALSE;
1673 //_____________________________________________________________________________
1674 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
1676 // run the barrel tracking
1678 AliCodeTimerAuto("")
1680 AliESDVertex* vertex = NULL;
1681 Double_t vtxPos[3] = {0, 0, 0};
1682 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
1683 TArrayF mcVertex(3);
1684 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
1685 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
1686 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
1690 AliInfo("running the ITS vertex finder");
1692 fLoader[0]->LoadRecPoints();
1693 TTree* cltree = fLoader[0]->TreeR();
1695 if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile);
1696 vertex = fVertexer->FindVertexForCurrentEvent(cltree);
1699 AliError("Can't get the ITS cluster tree");
1701 fLoader[0]->UnloadRecPoints();
1704 AliError("Can't get the ITS loader");
1707 AliWarning("Vertex not found");
1708 vertex = new AliESDVertex();
1709 vertex->SetName("default");
1712 vertex->SetName("reconstructed");
1716 AliInfo("getting the primary vertex from MC");
1717 vertex = new AliESDVertex(vtxPos, vtxErr);
1721 vertex->GetXYZ(vtxPos);
1722 vertex->GetSigmaXYZ(vtxErr);
1724 AliWarning("no vertex reconstructed");
1725 vertex = new AliESDVertex(vtxPos, vtxErr);
1727 esd->SetPrimaryVertexSPD(vertex);
1728 // if SPD multiplicity has been determined, it is stored in the ESD
1729 AliMultiplicity *mult = fVertexer->GetMultiplicity();
1730 if(mult)esd->SetMultiplicity(mult);
1732 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1733 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
1740 //_____________________________________________________________________________
1741 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1743 // run the HLT barrel tracking
1745 AliCodeTimerAuto("")
1748 AliError("Missing runLoader!");
1752 AliInfo("running HLT tracking");
1754 // Get a pointer to the HLT reconstructor
1755 AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1);
1756 if (!reconstructor) return kFALSE;
1759 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1760 TString detName = fgkDetectorName[iDet];
1761 AliDebug(1, Form("%s HLT tracking", detName.Data()));
1762 reconstructor->SetOption(detName.Data());
1763 AliTracker *tracker = reconstructor->CreateTracker();
1765 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
1766 if (fStopOnError) return kFALSE;
1770 Double_t vtxErr[3]={0.005,0.005,0.010};
1771 const AliESDVertex *vertex = esd->GetVertex();
1772 vertex->GetXYZ(vtxPos);
1773 tracker->SetVertex(vtxPos,vtxErr);
1775 fLoader[iDet]->LoadRecPoints("read");
1776 TTree* tree = fLoader[iDet]->TreeR();
1778 AliError(Form("Can't get the %s cluster tree", detName.Data()));
1781 tracker->LoadClusters(tree);
1783 if (tracker->Clusters2Tracks(esd) != 0) {
1784 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
1788 tracker->UnloadClusters();
1796 //_____________________________________________________________________________
1797 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
1799 // run the muon spectrometer tracking
1801 AliCodeTimerAuto("")
1804 AliError("Missing runLoader!");
1807 Int_t iDet = 7; // for MUON
1809 AliInfo("is running...");
1811 // Get a pointer to the MUON reconstructor
1812 AliReconstructor *reconstructor = GetReconstructor(iDet);
1813 if (!reconstructor) return kFALSE;
1816 TString detName = fgkDetectorName[iDet];
1817 AliDebug(1, Form("%s tracking", detName.Data()));
1818 AliTracker *tracker = reconstructor->CreateTracker();
1820 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
1825 fLoader[iDet]->LoadRecPoints("read");
1827 tracker->LoadClusters(fLoader[iDet]->TreeR());
1829 Int_t rv = tracker->Clusters2Tracks(esd);
1833 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
1837 fLoader[iDet]->UnloadRecPoints();
1839 tracker->UnloadClusters();
1847 //_____________________________________________________________________________
1848 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
1850 // run the barrel tracking
1851 static Int_t eventNr=0;
1852 AliCodeTimerAuto("")
1854 AliInfo("running tracking");
1856 //Fill the ESD with the T0 info (will be used by the TOF)
1857 if (fReconstructor[11] && fLoader[11]) {
1858 fLoader[11]->LoadRecPoints("READ");
1859 TTree *treeR = fLoader[11]->TreeR();
1860 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
1863 // pass 1: TPC + ITS inwards
1864 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1865 if (!fTracker[iDet]) continue;
1866 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
1869 fLoader[iDet]->LoadRecPoints("read");
1870 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
1871 TTree* tree = fLoader[iDet]->TreeR();
1873 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
1876 fTracker[iDet]->LoadClusters(tree);
1877 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
1879 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
1880 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
1883 if (fCheckPointLevel > 1) {
1884 WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet]));
1886 // preliminary PID in TPC needed by the ITS tracker
1888 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
1889 AliESDpid::MakePID(esd);
1891 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
1894 // pass 2: ALL backwards
1896 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1897 if (!fTracker[iDet]) continue;
1898 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
1901 if (iDet > 1) { // all except ITS, TPC
1903 fLoader[iDet]->LoadRecPoints("read");
1904 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
1905 tree = fLoader[iDet]->TreeR();
1907 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
1910 fTracker[iDet]->LoadClusters(tree);
1911 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
1915 if (iDet>1) // start filling residuals for the "outer" detectors
1916 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
1918 if (fTracker[iDet]->PropagateBack(esd) != 0) {
1919 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
1922 if (fCheckPointLevel > 1) {
1923 WriteESD(esd, Form("%s.back", fgkDetectorName[iDet]));
1927 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
1928 fTracker[iDet]->UnloadClusters();
1929 fLoader[iDet]->UnloadRecPoints();
1931 // updated PID in TPC needed by the ITS tracker -MI
1933 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
1934 AliESDpid::MakePID(esd);
1936 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
1938 //stop filling residuals for the "outer" detectors
1939 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
1941 // pass 3: TRD + TPC + ITS refit inwards
1943 for (Int_t iDet = 2; iDet >= 0; iDet--) {
1944 if (!fTracker[iDet]) continue;
1945 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
1948 if (iDet<2) // start filling residuals for TPC and ITS
1949 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
1951 if (fTracker[iDet]->RefitInward(esd) != 0) {
1952 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
1955 // run postprocessing
1956 if (fTracker[iDet]->PostProcess(esd) != 0) {
1957 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
1960 if (fCheckPointLevel > 1) {
1961 WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet]));
1963 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
1966 // write space-points to the ESD in case alignment data output
1968 if (fWriteAlignmentData)
1969 WriteAlignmentData(esd);
1971 for (Int_t iDet = 3; iDet >= 0; iDet--) {
1972 if (!fTracker[iDet]) continue;
1974 fTracker[iDet]->UnloadClusters();
1975 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
1976 fLoader[iDet]->UnloadRecPoints();
1977 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
1979 // stop filling residuals for TPC and ITS
1980 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
1986 //_____________________________________________________________________________
1987 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
1989 // Remove the data which are not needed for the physics analysis.
1992 Int_t nTracks=esd->GetNumberOfTracks();
1993 Int_t nV0s=esd->GetNumberOfV0s();
1995 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
1997 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
1998 Bool_t rc=esd->Clean(cleanPars);
2000 nTracks=esd->GetNumberOfTracks();
2001 nV0s=esd->GetNumberOfV0s();
2003 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2008 //_____________________________________________________________________________
2009 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2011 // fill the event summary data
2013 AliCodeTimerAuto("")
2014 static Int_t eventNr=0;
2015 TString detStr = detectors;
2017 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2018 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2019 AliReconstructor* reconstructor = GetReconstructor(iDet);
2020 if (!reconstructor) continue;
2021 if (!ReadESD(esd, fgkDetectorName[iDet])) {
2022 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2023 TTree* clustersTree = NULL;
2024 if (fLoader[iDet]) {
2025 fLoader[iDet]->LoadRecPoints("read");
2026 clustersTree = fLoader[iDet]->TreeR();
2027 if (!clustersTree) {
2028 AliError(Form("Can't get the %s clusters tree",
2029 fgkDetectorName[iDet]));
2030 if (fStopOnError) return kFALSE;
2033 if (fRawReader && !reconstructor->HasDigitConversion()) {
2034 reconstructor->FillESD(fRawReader, clustersTree, esd);
2036 TTree* digitsTree = NULL;
2037 if (fLoader[iDet]) {
2038 fLoader[iDet]->LoadDigits("read");
2039 digitsTree = fLoader[iDet]->TreeD();
2041 AliError(Form("Can't get the %s digits tree",
2042 fgkDetectorName[iDet]));
2043 if (fStopOnError) return kFALSE;
2046 reconstructor->FillESD(digitsTree, clustersTree, esd);
2047 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2049 if (fLoader[iDet]) {
2050 fLoader[iDet]->UnloadRecPoints();
2053 if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]);
2057 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2058 AliError(Form("the following detectors were not found: %s",
2060 if (fStopOnError) return kFALSE;
2062 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2067 //_____________________________________________________________________________
2068 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2070 // Reads the trigger decision which is
2071 // stored in Trigger.root file and fills
2072 // the corresponding esd entries
2074 AliCodeTimerAuto("")
2076 AliInfo("Filling trigger information into the ESD");
2079 AliCTPRawStream input(fRawReader);
2080 if (!input.Next()) {
2081 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2084 if (esd->GetTriggerMask() != input.GetClassMask())
2085 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2086 input.GetClassMask(),esd->GetTriggerMask()));
2087 if (esd->GetOrbitNumber() != input.GetOrbitID())
2088 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2089 input.GetOrbitID(),esd->GetOrbitNumber()));
2090 if (esd->GetBunchCrossNumber() != input.GetBCID())
2091 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2092 input.GetBCID(),esd->GetBunchCrossNumber()));
2095 // Here one has to add the filling of trigger inputs and
2096 // interaction records
2106 //_____________________________________________________________________________
2107 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2110 // Filling information from RawReader Header
2113 if (!fRawReader) return kFALSE;
2115 AliInfo("Filling information from RawReader Header");
2117 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2118 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2119 esd->SetPeriodNumber(fRawReader->GetPeriod());
2121 esd->SetTimeStamp(fRawReader->GetTimestamp());
2122 esd->SetEventType(fRawReader->GetType());
2128 //_____________________________________________________________________________
2129 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2131 // check whether detName is contained in detectors
2132 // if yes, it is removed from detectors
2134 // check if all detectors are selected
2135 if ((detectors.CompareTo("ALL") == 0) ||
2136 detectors.BeginsWith("ALL ") ||
2137 detectors.EndsWith(" ALL") ||
2138 detectors.Contains(" ALL ")) {
2143 // search for the given detector
2144 Bool_t result = kFALSE;
2145 if ((detectors.CompareTo(detName) == 0) ||
2146 detectors.BeginsWith(detName+" ") ||
2147 detectors.EndsWith(" "+detName) ||
2148 detectors.Contains(" "+detName+" ")) {
2149 detectors.ReplaceAll(detName, "");
2153 // clean up the detectors string
2154 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2155 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2156 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2161 //_____________________________________________________________________________
2162 Bool_t AliReconstruction::InitRunLoader()
2164 // get or create the run loader
2166 if (gAlice) delete gAlice;
2169 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2170 // load all base libraries to get the loader classes
2171 TString libs = gSystem->GetLibraries();
2172 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2173 TString detName = fgkDetectorName[iDet];
2174 if (detName == "HLT") continue;
2175 if (libs.Contains("lib" + detName + "base.so")) continue;
2176 gSystem->Load("lib" + detName + "base.so");
2178 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2180 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2185 fRunLoader->CdGAFile();
2186 fRunLoader->LoadgAlice();
2188 //PH This is a temporary fix to give access to the kinematics
2189 //PH that is needed for the labels of ITS clusters
2190 fRunLoader->LoadHeader();
2191 fRunLoader->LoadKinematics();
2193 } else { // galice.root does not exist
2195 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2199 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2200 AliConfig::GetDefaultEventFolderName(),
2203 AliError(Form("could not create run loader in file %s",
2204 fGAliceFileName.Data()));
2208 fIsNewRunLoader = kTRUE;
2209 fRunLoader->MakeTree("E");
2211 if (fNumberOfEventsPerFile > 0)
2212 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2214 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2220 //_____________________________________________________________________________
2221 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2223 // get the reconstructor object and the loader for a detector
2225 if (fReconstructor[iDet]) {
2226 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2227 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2228 fReconstructor[iDet]->SetRecoParam(par);
2230 return fReconstructor[iDet];
2233 // load the reconstructor object
2234 TPluginManager* pluginManager = gROOT->GetPluginManager();
2235 TString detName = fgkDetectorName[iDet];
2236 TString recName = "Ali" + detName + "Reconstructor";
2238 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2240 AliReconstructor* reconstructor = NULL;
2241 // first check if a plugin is defined for the reconstructor
2242 TPluginHandler* pluginHandler =
2243 pluginManager->FindHandler("AliReconstructor", detName);
2244 // if not, add a plugin for it
2245 if (!pluginHandler) {
2246 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2247 TString libs = gSystem->GetLibraries();
2248 if (libs.Contains("lib" + detName + "base.so") ||
2249 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2250 pluginManager->AddHandler("AliReconstructor", detName,
2251 recName, detName + "rec", recName + "()");
2253 pluginManager->AddHandler("AliReconstructor", detName,
2254 recName, detName, recName + "()");
2256 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2258 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2259 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2261 if (reconstructor) {
2262 TObject* obj = fOptions.FindObject(detName.Data());
2263 if (obj) reconstructor->SetOption(obj->GetTitle());
2264 reconstructor->Init();
2265 fReconstructor[iDet] = reconstructor;
2268 // get or create the loader
2269 if (detName != "HLT") {
2270 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2271 if (!fLoader[iDet]) {
2272 AliConfig::Instance()
2273 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2275 // first check if a plugin is defined for the loader
2277 pluginManager->FindHandler("AliLoader", detName);
2278 // if not, add a plugin for it
2279 if (!pluginHandler) {
2280 TString loaderName = "Ali" + detName + "Loader";
2281 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2282 pluginManager->AddHandler("AliLoader", detName,
2283 loaderName, detName + "base",
2284 loaderName + "(const char*, TFolder*)");
2285 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2287 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2289 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2290 fRunLoader->GetEventFolder());
2292 if (!fLoader[iDet]) { // use default loader
2293 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2295 if (!fLoader[iDet]) {
2296 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2297 if (fStopOnError) return NULL;
2299 fRunLoader->AddLoader(fLoader[iDet]);
2300 fRunLoader->CdGAFile();
2301 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2302 fRunLoader->Write(0, TObject::kOverwrite);
2307 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2308 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2309 reconstructor->SetRecoParam(par);
2311 return reconstructor;
2314 //_____________________________________________________________________________
2315 Bool_t AliReconstruction::CreateVertexer()
2317 // create the vertexer
2320 AliReconstructor* itsReconstructor = GetReconstructor(0);
2321 if (itsReconstructor) {
2322 fVertexer = itsReconstructor->CreateVertexer();
2325 AliWarning("couldn't create a vertexer for ITS");
2326 if (fStopOnError) return kFALSE;
2332 //_____________________________________________________________________________
2333 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2335 // create the trackers
2337 TString detStr = detectors;
2338 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2339 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2340 AliReconstructor* reconstructor = GetReconstructor(iDet);
2341 if (!reconstructor) continue;
2342 TString detName = fgkDetectorName[iDet];
2343 if (detName == "HLT") {
2344 fRunHLTTracking = kTRUE;
2347 if (detName == "MUON") {
2348 fRunMuonTracking = kTRUE;
2353 fTracker[iDet] = reconstructor->CreateTracker();
2354 if (!fTracker[iDet] && (iDet < 7)) {
2355 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2356 if (fStopOnError) return kFALSE;
2358 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2364 //_____________________________________________________________________________
2365 void AliReconstruction::CleanUp(TFile* file, TFile* fileOld)
2367 // delete trackers and the run loader and close and delete the file
2369 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2370 delete fReconstructor[iDet];
2371 fReconstructor[iDet] = NULL;
2372 fLoader[iDet] = NULL;
2373 delete fTracker[iDet];
2374 fTracker[iDet] = NULL;
2376 if (fRunInfo) delete fRunInfo;
2382 if (ftVertexer) delete ftVertexer;
2385 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2386 delete fDiamondProfile;
2387 fDiamondProfile = NULL;
2388 delete fDiamondProfileTPC;
2389 fDiamondProfileTPC = NULL;
2399 if (fParentRawReader) delete fParentRawReader;
2400 fParentRawReader=NULL;
2410 gSystem->Unlink("AliESDs.old.root");
2415 //_____________________________________________________________________________
2417 Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const
2419 // read the ESD event from a file
2421 if (!esd) return kFALSE;
2423 sprintf(fileName, "ESD_%d.%d_%s.root",
2424 esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
2425 if (gSystem->AccessPathName(fileName)) return kFALSE;
2427 AliInfo(Form("reading ESD from file %s", fileName));
2428 AliDebug(1, Form("reading ESD from file %s", fileName));
2429 TFile* file = TFile::Open(fileName);
2430 if (!file || !file->IsOpen()) {
2431 AliError(Form("opening %s failed", fileName));
2438 esd = (AliESDEvent*) file->Get("ESD");
2447 //_____________________________________________________________________________
2448 void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const
2450 // write the ESD event to a file
2454 sprintf(fileName, "ESD_%d.%d_%s.root",
2455 esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
2457 AliDebug(1, Form("writing ESD to file %s", fileName));
2458 TFile* file = TFile::Open(fileName, "recreate");
2459 if (!file || !file->IsOpen()) {
2460 AliError(Form("opening %s failed", fileName));
2469 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2471 // Write space-points which are then used in the alignment procedures
2472 // For the moment only ITS, TPC, TRD and TOF
2474 Int_t ntracks = esd->GetNumberOfTracks();
2475 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2477 AliESDtrack *track = esd->GetTrack(itrack);
2480 for (Int_t iDet = 3; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2481 nsp += track->GetNcls(iDet);
2483 if (iDet==0) { // ITS "extra" clusters
2484 track->GetClusters(iDet,idx);
2485 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2490 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2491 track->SetTrackPointArray(sp);
2493 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2494 AliTracker *tracker = fTracker[iDet];
2495 if (!tracker) continue;
2496 Int_t nspdet = track->GetClusters(iDet,idx);
2498 if (iDet==0) // ITS "extra" clusters
2499 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2501 if (nspdet <= 0) continue;
2505 while (isp2 < nspdet) {
2506 Bool_t isvalid=kTRUE;
2508 Int_t index=idx[isp++];
2509 if (index < 0) continue;
2511 TString dets = fgkDetectorName[iDet];
2512 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2513 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2514 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2515 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2516 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2518 isvalid = tracker->GetTrackPoint(index,p);
2521 if (!isvalid) continue;
2522 sp->AddPoint(isptrack,&p); isptrack++;
2529 //_____________________________________________________________________________
2530 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2532 // The method reads the raw-data error log
2533 // accumulated within the rawReader.
2534 // It extracts the raw-data errors related to
2535 // the current event and stores them into
2536 // a TClonesArray inside the esd object.
2538 if (!fRawReader) return;
2540 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2542 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2544 if (iEvent != log->GetEventNumber()) continue;
2546 esd->AddRawDataErrorLog(log);
2551 TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){
2552 // Dump a file content into a char in TNamed
2554 in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
2555 Int_t kBytes = (Int_t)in.tellg();
2556 printf("Size: %d \n",kBytes);
2559 char* memblock = new char [kBytes];
2560 in.seekg (0, ios::beg);
2561 in.read (memblock, kBytes);
2563 TString fData(memblock,kBytes);
2564 fn = new TNamed(pName,fData);
2565 printf("fData Size: %d \n",fData.Sizeof());
2566 printf("pName Size: %d \n",pName.Sizeof());
2567 printf("fn Size: %d \n",fn->Sizeof());
2571 AliInfo(Form("Could not Open %s\n",fPath.Data()));
2577 void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){
2578 // This is not really needed in AliReconstruction at the moment
2579 // but can serve as a template
2581 TList *fList = fTree->GetUserInfo();
2582 TNamed *fn = (TNamed*)fList->FindObject(pName.Data());
2583 printf("fn Size: %d \n",fn->Sizeof());
2585 TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works
2586 const char* cdata = fn->GetTitle();
2587 printf("fTmp Size %d\n",fTmp.Sizeof());
2589 int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
2590 printf("calculated size %d\n",size);
2591 ofstream out(pName.Data(),ios::out | ios::binary);
2592 out.write(cdata,size);
2597 //_____________________________________________________________________________
2598 void AliReconstruction::CheckQA()
2600 // check the QA of SIM for this run and remove the detectors
2601 // with status Fatal
2603 TString newRunLocalReconstruction ;
2604 TString newRunTracking ;
2605 TString newFillESD ;
2607 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2608 TString detName(AliQA::GetDetName(iDet)) ;
2609 AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2610 if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) {
2611 AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ;
2613 if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2614 fRunLocalReconstruction.Contains("ALL") ) {
2615 newRunLocalReconstruction += detName ;
2616 newRunLocalReconstruction += " " ;
2618 if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2619 fRunTracking.Contains("ALL") ) {
2620 newRunTracking += detName ;
2621 newRunTracking += " " ;
2623 if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2624 fFillESD.Contains("ALL") ) {
2625 newFillESD += detName ;
2630 fRunLocalReconstruction = newRunLocalReconstruction ;
2631 fRunTracking = newRunTracking ;
2632 fFillESD = newFillESD ;
2635 //_____________________________________________________________________________
2636 Int_t AliReconstruction::GetDetIndex(const char* detector)
2638 // return the detector index corresponding to detector
2640 for (index = 0; index < fgkNDetectors ; index++) {
2641 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2646 //_____________________________________________________________________________
2647 Bool_t AliReconstruction::FinishPlaneEff() {
2649 // Here execute all the necessary operationis, at the end of the tracking phase,
2650 // in case that evaluation of PlaneEfficiencies was required for some detector.
2651 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2653 // This Preliminary version works only FOR ITS !!!!!
2654 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2657 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2660 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2661 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2662 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2663 if(fTracker[iDet]) {
2664 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2665 TString name=planeeff->GetName();
2667 TFile* pefile = TFile::Open(name, "RECREATE");
2668 ret=(Bool_t)planeeff->Write();
2670 if(planeeff->GetCreateHistos()) {
2671 TString hname=planeeff->GetName();
2672 hname+="Histo.root";
2673 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2679 //_____________________________________________________________________________
2680 Bool_t AliReconstruction::InitPlaneEff() {
2682 // Here execute all the necessary operations, before of the tracking phase,
2683 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2684 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2685 // which should be updated/recalculated.
2687 // This Preliminary version will work only FOR ITS !!!!!
2688 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2691 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2693 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2697 //_____________________________________________________________________________
2698 Bool_t AliReconstruction::InitAliEVE()
2700 // This method should be called only in case
2701 // AliReconstruction is run
2702 // within the alieve environment.
2703 // It will initialize AliEVE in a way
2704 // so that it can visualize event processed
2705 // by AliReconstruction.
2706 // The return flag shows whenever the
2707 // AliEVE initialization was successful or not.
2710 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2711 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2712 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2714 gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->SetAutoLoad(kTRUE);gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};");
2715 gROOT->ProcessLine("alieve_online_init()");
2720 //_____________________________________________________________________________
2721 void AliReconstruction::RunAliEVE()
2723 // Runs AliEVE visualisation of
2724 // the current event.
2725 // Should be executed only after
2726 // successful initialization of AliEVE.
2728 AliInfo("Running AliEVE...");
2729 gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd));
2730 gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();");
2734 //_____________________________________________________________________________
2735 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2737 // Allows to run QA for a selected set of detectors
2738 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2739 // all selected detectors run the same selected tasks
2741 if (!detAndAction.Contains(":")) {
2742 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2746 Int_t colon = detAndAction.Index(":") ;
2747 fQADetectors = detAndAction(0, colon) ;
2748 if (fQADetectors.Contains("ALL") )
2749 fQADetectors = fFillESD ;
2750 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2751 if (fQATasks.Contains("ALL") ) {
2752 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2754 fQATasks.ToUpper() ;
2756 if ( fQATasks.Contains("RAW") )
2757 tempo = Form("%d ", AliQA::kRAWS) ;
2758 if ( fQATasks.Contains("RECPOINT") )
2759 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2760 if ( fQATasks.Contains("ESD") )
2761 tempo += Form("%d ", AliQA::kESDS) ;
2763 if (fQATasks.IsNull()) {
2764 AliInfo("No QA requested\n") ;
2769 TString tempo(fQATasks) ;
2770 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2771 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2772 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2773 fQASteer->SetActiveDetectors(fQADetectors) ;
2774 fQASteer->SetTasks(fQATasks) ;
2775 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2780 //_____________________________________________________________________________
2781 Bool_t AliReconstruction::InitRecoParams()
2783 // The method accesses OCDB and retrieves all
2784 // the available reco-param objects from there.
2786 Bool_t isOK = kTRUE;
2788 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2790 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2791 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2795 AliDebug(1, Form("Loading RecoParam objects for detector: %s",fgkDetectorName[iDet]));
2797 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2798 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
2800 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
2804 TObject *recoParamObj = entry->GetObject();
2805 if (dynamic_cast<TObjArray*>(recoParamObj)) {
2806 // The detector has a normal TobjArray of AliDetectorRecoParam objects
2807 // Registering them in AliRecoParam
2808 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
2810 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
2811 // The detector has only onse set of reco parameters
2812 // Registering it in AliRecoParam
2813 AliInfo(Form("Single set of reco parameters found for detector %s",fgkDetectorName[iDet]));
2814 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
2815 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
2818 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
2828 //_____________________________________________________________________________
2829 Bool_t AliReconstruction::GetEventInfo()
2831 // Fill the event info object
2833 AliCodeTimerAuto("")
2835 AliCentralTrigger *aCTP = NULL;
2837 fEventInfo.SetEventType(fRawReader->GetType());
2839 ULong64_t mask = fRawReader->GetClassMask();
2840 fEventInfo.SetTriggerMask(mask);
2841 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
2842 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
2844 aCTP = new AliCentralTrigger();
2845 TString configstr("");
2846 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
2847 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
2851 aCTP->SetClassMask(mask);
2852 aCTP->SetClusterMask(clmask);
2855 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
2857 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
2858 aCTP = fRunLoader->GetTrigger();
2859 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
2860 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
2863 AliWarning("No trigger can be loaded! The trigger information will not be used!");
2868 AliTriggerConfiguration *config = aCTP->GetConfiguration();
2870 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
2871 if (fRawReader) delete aCTP;
2876 ULong64_t trmask = fEventInfo.GetTriggerMask();
2877 const TObjArray& classesArray = config->GetClasses();
2878 Int_t nclasses = classesArray.GetEntriesFast();
2879 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
2880 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
2882 Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask());
2883 fesd->SetTriggerClass(trclass->GetName(),trindex);
2884 if (trmask & (1 << trindex)) {
2886 trclasses += trclass->GetName();
2891 fEventInfo.SetTriggerClasses(trclasses);
2893 if (!aCTP->CheckTriggeredDetectors()) {
2894 if (fRawReader) delete aCTP;
2898 if (fRawReader) delete aCTP;
2900 // We have to fill also the HLT decision here!!
2906 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
2908 // Match the detector list found in the rec.C or the default 'ALL'
2909 // to the list found in the GRP (stored there by the shuttle PP which
2910 // gets the information from ECS)
2911 static TString resultList;
2912 TString detList = detectorList;
2916 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
2917 if ((detectorMask >> iDet) & 0x1) {
2918 TString det = AliDAQ::OfflineModuleName(iDet);
2919 if ((detList.CompareTo("ALL") == 0) ||
2920 detList.BeginsWith("ALL ") ||
2921 detList.EndsWith(" ALL") ||
2922 detList.Contains(" ALL ") ||
2923 (detList.CompareTo(det) == 0) ||
2924 detList.BeginsWith(det) ||
2925 detList.EndsWith(det) ||
2926 detList.Contains( " "+det+" " )) {
2927 if (!resultList.EndsWith(det + " ")) {
2936 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
2937 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
2938 if ((detList.CompareTo("ALL") == 0) ||
2939 detList.BeginsWith("ALL ") ||
2940 detList.EndsWith(" ALL") ||
2941 detList.Contains(" ALL ") ||
2942 (detList.CompareTo(hltDet) == 0) ||
2943 detList.BeginsWith(hltDet) ||
2944 detList.EndsWith(hltDet) ||
2945 detList.Contains( " "+hltDet+" " )) {
2946 resultList += hltDet;
2950 return resultList.Data();