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 "AliTriggerCluster.h"
180 #include "AliCTPRawStream.h"
182 #include "AliQADataMakerRec.h"
183 #include "AliGlobalQADataMaker.h"
185 #include "AliQADataMakerSteer.h"
187 #include "AliPlaneEff.h"
189 #include "AliSysInfo.h" // memory snapshots
190 #include "AliRawHLTManager.h"
192 #include "AliMagWrapCheb.h"
194 #include "AliDetectorRecoParam.h"
195 #include "AliRunInfo.h"
196 #include "AliEventInfo.h"
200 ClassImp(AliReconstruction)
203 //_____________________________________________________________________________
204 const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
206 //_____________________________________________________________________________
207 AliReconstruction::AliReconstruction(const char* gAliceFilename,
208 const char* name, const char* title) :
211 fUniformField(kFALSE),
212 fForcedFieldMap(0x0),
213 fRunVertexFinder(kTRUE),
214 fRunVertexFinderTracks(kTRUE),
215 fRunHLTTracking(kFALSE),
216 fRunMuonTracking(kFALSE),
218 fRunCascadeFinder(kTRUE),
219 fStopOnError(kFALSE),
220 fWriteAlignmentData(kFALSE),
221 fWriteESDfriend(kFALSE),
223 fFillTriggerESD(kTRUE),
231 fRunLocalReconstruction("ALL"),
234 fUseTrackingErrorsForAlignment(""),
235 fGAliceFileName(gAliceFilename),
240 fNumberOfEventsPerFile(1),
243 fLoadAlignFromCDB(kTRUE),
244 fLoadAlignData("ALL"),
252 fParentRawReader(NULL),
257 fDiamondProfile(NULL),
258 fDiamondProfileTPC(NULL),
259 fMeanVertexConstraint(kTRUE),
263 fAlignObjArray(NULL),
266 fInitCDBCalled(kFALSE),
267 fSetRunNumberFromDataCalled(kFALSE),
274 fSameQACycle(kFALSE),
276 fRunPlaneEff(kFALSE),
288 fIsNewRunLoader(kFALSE),
291 // create reconstruction object with default parameters
293 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
294 fReconstructor[iDet] = NULL;
295 fLoader[iDet] = NULL;
296 fTracker[iDet] = NULL;
297 fQACycles[iDet] = 999999;
299 fQASteer = new AliQADataMakerSteer("rec") ;
300 fQASteer->SetActiveDetectors(fQADetectors) ;
301 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
302 fQASteer->SetTasks(fQATasks) ;
306 //_____________________________________________________________________________
307 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
310 fUniformField(rec.fUniformField),
311 fForcedFieldMap(0x0),
312 fRunVertexFinder(rec.fRunVertexFinder),
313 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
314 fRunHLTTracking(rec.fRunHLTTracking),
315 fRunMuonTracking(rec.fRunMuonTracking),
316 fRunV0Finder(rec.fRunV0Finder),
317 fRunCascadeFinder(rec.fRunCascadeFinder),
318 fStopOnError(rec.fStopOnError),
319 fWriteAlignmentData(rec.fWriteAlignmentData),
320 fWriteESDfriend(rec.fWriteESDfriend),
321 fWriteAOD(rec.fWriteAOD),
322 fFillTriggerESD(rec.fFillTriggerESD),
324 fCleanESD(rec.fCleanESD),
325 fV0DCAmax(rec.fV0DCAmax),
326 fV0CsPmin(rec.fV0CsPmin),
330 fRunLocalReconstruction(rec.fRunLocalReconstruction),
331 fRunTracking(rec.fRunTracking),
332 fFillESD(rec.fFillESD),
333 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
334 fGAliceFileName(rec.fGAliceFileName),
336 fEquipIdMap(rec.fEquipIdMap),
337 fFirstEvent(rec.fFirstEvent),
338 fLastEvent(rec.fLastEvent),
339 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
342 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
343 fLoadAlignData(rec.fLoadAlignData),
344 fESDPar(rec.fESDPar),
345 fUseHLTData(rec.fUseHLTData),
351 fParentRawReader(NULL),
356 fDiamondProfile(NULL),
357 fDiamondProfileTPC(NULL),
358 fMeanVertexConstraint(rec.fMeanVertexConstraint),
362 fAlignObjArray(rec.fAlignObjArray),
363 fCDBUri(rec.fCDBUri),
365 fInitCDBCalled(rec.fInitCDBCalled),
366 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
367 fQADetectors(rec.fQADetectors),
368 fQASteer(rec.fQASteer),
369 fQATasks(rec.fQATasks),
371 fRunGlobalQA(rec.fRunGlobalQA),
372 fInLoopQA(rec.fInLoopQA),
373 fSameQACycle(rec.fSameQACycle),
374 fRunPlaneEff(rec.fRunPlaneEff),
386 fIsNewRunLoader(rec.fIsNewRunLoader),
391 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
392 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
394 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
395 fReconstructor[iDet] = NULL;
396 fLoader[iDet] = NULL;
397 fTracker[iDet] = NULL;
398 fQACycles[iDet] = rec.fQACycles[iDet];
400 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
401 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
404 fForcedFieldMap=new AliMagWrapCheb(*((AliMagWrapCheb*)rec.fForcedFieldMap));
407 //_____________________________________________________________________________
408 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
410 // assignment operator
412 this->~AliReconstruction();
413 new(this) AliReconstruction(rec);
417 //_____________________________________________________________________________
418 AliReconstruction::~AliReconstruction()
424 fSpecCDBUri.Delete();
425 delete fForcedFieldMap;
427 AliCodeTimer::Instance()->Print();
430 //_____________________________________________________________________________
431 void AliReconstruction::InitCDB()
433 // activate a default CDB storage
434 // First check if we have any CDB storage set, because it is used
435 // to retrieve the calibration and alignment constants
437 if (fInitCDBCalled) return;
438 fInitCDBCalled = kTRUE;
440 AliCDBManager* man = AliCDBManager::Instance();
441 if (man->IsDefaultStorageSet())
443 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
444 AliWarning("Default CDB storage has been already set !");
445 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
446 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
447 fCDBUri = man->GetDefaultStorage()->GetURI();
450 if (fCDBUri.Length() > 0)
452 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
453 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
454 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
456 fCDBUri="local://$ALICE_ROOT";
457 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
458 AliWarning("Default CDB storage not yet set !!!!");
459 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
460 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
463 man->SetDefaultStorage(fCDBUri);
466 // Now activate the detector specific CDB storage locations
467 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
468 TObject* obj = fSpecCDBUri[i];
470 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
471 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
472 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
473 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
478 //_____________________________________________________________________________
479 void AliReconstruction::SetDefaultStorage(const char* uri) {
480 // Store the desired default CDB storage location
481 // Activate it later within the Run() method
487 //_____________________________________________________________________________
488 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
489 // Store a detector-specific CDB storage location
490 // Activate it later within the Run() method
492 AliCDBPath aPath(calibType);
493 if(!aPath.IsValid()){
494 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
495 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
496 if(!strcmp(calibType, fgkDetectorName[iDet])) {
497 aPath.SetPath(Form("%s/*", calibType));
498 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
502 if(!aPath.IsValid()){
503 AliError(Form("Not a valid path or detector: %s", calibType));
508 // // check that calibType refers to a "valid" detector name
509 // Bool_t isDetector = kFALSE;
510 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
511 // TString detName = fgkDetectorName[iDet];
512 // if(aPath.GetLevel0() == detName) {
513 // isDetector = kTRUE;
519 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
523 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
524 if (obj) fSpecCDBUri.Remove(obj);
525 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
529 //_____________________________________________________________________________
530 Bool_t AliReconstruction::SetRunNumberFromData()
532 // The method is called in Run() in order
533 // to set a correct run number.
534 // In case of raw data reconstruction the
535 // run number is taken from the raw data header
537 if (fSetRunNumberFromDataCalled) return kTRUE;
538 fSetRunNumberFromDataCalled = kTRUE;
540 AliCDBManager* man = AliCDBManager::Instance();
542 if(man->GetRun() > 0) {
543 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
547 AliError("No run loader is found !");
550 // read run number from gAlice
551 if(fRunLoader->GetAliRun())
552 AliCDBManager::Instance()->SetRun(fRunLoader->GetHeader()->GetRun());
555 if(fRawReader->NextEvent()) {
556 AliCDBManager::Instance()->SetRun(fRawReader->GetRunNumber());
557 fRawReader->RewindEvents();
560 if(man->GetRun() > 0) {
561 AliWarning("No raw events is found ! Using settings in AliCDBManager !");
566 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
572 AliError("Neither gAlice nor RawReader objects are found !");
582 //_____________________________________________________________________________
583 void AliReconstruction::SetCDBLock() {
584 // Set CDB lock: from now on it is forbidden to reset the run number
585 // or the default storage or to activate any further storage!
587 AliCDBManager::Instance()->SetLock(1);
590 //_____________________________________________________________________________
591 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
593 // Read the alignment objects from CDB.
594 // Each detector is supposed to have the
595 // alignment objects in DET/Align/Data CDB path.
596 // All the detector objects are then collected,
597 // sorted by geometry level (starting from ALIC) and
598 // then applied to the TGeo geometry.
599 // Finally an overlaps check is performed.
601 // Load alignment data from CDB and fill fAlignObjArray
602 if(fLoadAlignFromCDB){
604 TString detStr = detectors;
605 TString loadAlObjsListOfDets = "";
607 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
608 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
609 loadAlObjsListOfDets += fgkDetectorName[iDet];
610 loadAlObjsListOfDets += " ";
611 } // end loop over detectors
612 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
613 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
615 // Check if the array with alignment objects was
616 // provided by the user. If yes, apply the objects
617 // to the present TGeo geometry
618 if (fAlignObjArray) {
619 if (gGeoManager && gGeoManager->IsClosed()) {
620 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
621 AliError("The misalignment of one or more volumes failed!"
622 "Compare the list of simulated detectors and the list of detector alignment data!");
627 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
633 delete fAlignObjArray; fAlignObjArray=0;
638 //_____________________________________________________________________________
639 void AliReconstruction::SetGAliceFile(const char* fileName)
641 // set the name of the galice file
643 fGAliceFileName = fileName;
646 //_____________________________________________________________________________
647 void AliReconstruction::SetInput(const char* input)
649 // In case the input string starts with 'mem://', we run in an online mode
650 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
651 // file is assumed. One can give as an input:
652 // mem://: - events taken from DAQ monitoring libs online
654 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
658 //_____________________________________________________________________________
659 void AliReconstruction::SetOption(const char* detector, const char* option)
661 // set options for the reconstruction of a detector
663 TObject* obj = fOptions.FindObject(detector);
664 if (obj) fOptions.Remove(obj);
665 fOptions.Add(new TNamed(detector, option));
668 //_____________________________________________________________________________
669 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
671 // Set custom reconstruction parameters for a given detector
672 // Single set of parameters for all the events
673 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
674 if(!strcmp(detector, fgkDetectorName[iDet])) {
676 fRecoParam.AddDetRecoParam(iDet,par);
683 //_____________________________________________________________________________
684 Bool_t AliReconstruction::SetFieldMap(Float_t l3Current, Float_t diCurrent, Float_t factor, const char *path) {
685 //------------------------------------------------
686 // The magnetic field map, defined externally...
687 // L3 current 30000 A -> 0.5 T
688 // L3 current 12000 A -> 0.2 T
689 // dipole current 6000 A
690 // The polarities must be the same
691 //------------------------------------------------
692 const Float_t l3NominalCurrent1=30000.; // (A)
693 const Float_t l3NominalCurrent2=12000.; // (A)
694 const Float_t diNominalCurrent =6000. ; // (A)
696 const Float_t tolerance=0.03; // relative current tolerance
697 const Float_t zero=77.; // "zero" current (A)
700 Bool_t dipoleON=kFALSE;
702 TString s=(factor < 0) ? "L3: -" : "L3: +";
704 l3Current = TMath::Abs(l3Current);
705 if (TMath::Abs(l3Current-l3NominalCurrent1)/l3NominalCurrent1 < tolerance) {
706 map=AliMagWrapCheb::k5kG;
709 if (TMath::Abs(l3Current-l3NominalCurrent2)/l3NominalCurrent2 < tolerance) {
710 map=AliMagWrapCheb::k2kG;
713 if (l3Current < zero) {
714 map=AliMagWrapCheb::k2kG;
716 factor=0.; // in fact, this is a global factor...
717 fUniformField=kTRUE; // track with the uniform (zero) B field
719 AliError(Form("Wrong L3 current (%f A)!",l3Current));
723 diCurrent = TMath::Abs(diCurrent);
724 if (TMath::Abs(diCurrent-diNominalCurrent)/diNominalCurrent < tolerance) {
725 // 3% current tolerance...
729 if (diCurrent < zero) { // some small current..
733 AliError(Form("Wrong dipole current (%f A)!",diCurrent));
737 delete fForcedFieldMap;
739 new AliMagWrapCheb("B field map ",s,2,factor,10.,map,dipoleON,path);
741 fForcedFieldMap->Print();
743 AliTracker::SetFieldMap(fForcedFieldMap,fUniformField);
749 Bool_t AliReconstruction::InitGRP() {
750 //------------------------------------
751 // Initialization of the GRP entry
752 //------------------------------------
753 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
755 if (entry) fGRPData = dynamic_cast<TMap*>(entry->GetObject());
758 AliError("No GRP entry found in OCDB!");
762 TObjString *lhcState=
763 dynamic_cast<TObjString*>(fGRPData->GetValue("fLHCState"));
765 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
768 TObjString *beamType=
769 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamType"));
771 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
774 TObjString *beamEnergyStr=
775 dynamic_cast<TObjString*>(fGRPData->GetValue("fAliceBeamEnergy"));
776 if (!beamEnergyStr) {
777 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
781 dynamic_cast<TObjString*>(fGRPData->GetValue("fRunType"));
783 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
786 TObjString *activeDetectors=
787 dynamic_cast<TObjString*>(fGRPData->GetValue("fDetectorMask"));
788 if (!activeDetectors) {
789 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
792 fRunInfo = new AliRunInfo(lhcState ? lhcState->GetString().Data() : "UNKNOWN",
793 beamType ? beamType->GetString().Data() : "UNKNOWN",
794 beamEnergyStr ? beamEnergyStr->GetString().Atof() : 0,
795 runType ? runType->GetString().Data() : "UNKNOWN",
796 activeDetectors ? activeDetectors->GetString().Atoi() : 1074790399);
798 // Process the list of active detectors
799 if (activeDetectors && activeDetectors->GetString().IsDigit()) {
800 UInt_t detMask = activeDetectors->GetString().Atoi();
801 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
802 fRunTracking = MatchDetectorList(fRunTracking,detMask);
803 fFillESD = MatchDetectorList(fFillESD,detMask);
804 fQADetectors = MatchDetectorList(fQADetectors,detMask);
805 fQASteer->SetActiveDetectors(fQADetectors) ;
808 AliInfo("===================================================================================");
809 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
810 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
811 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
812 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
813 AliInfo("===================================================================================");
815 //*** Dealing with the magnetic field map
816 if (AliTracker::GetFieldMap()) {
817 AliInfo("Running with the externally set B field !");
819 // Construct the field map out of the information retrieved from GRP.
824 TObjString *l3Current=
825 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Current"));
827 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
830 TObjString *l3Polarity=
831 dynamic_cast<TObjString*>(fGRPData->GetValue("fL3Polarity"));
833 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
838 TObjString *diCurrent=
839 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipoleCurrent"));
841 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
844 TObjString *diPolarity=
845 dynamic_cast<TObjString*>(fGRPData->GetValue("fDipolePolarity"));
847 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
852 Float_t l3Cur=TMath::Abs(atof(l3Current->GetName()));
853 Float_t diCur=TMath::Abs(atof(diCurrent->GetName()));
854 Float_t l3Pol=atof(l3Polarity->GetName());
856 if (l3Pol != 0.) factor=-1.;
859 if (!SetFieldMap(l3Cur, diCur, factor)) {
860 AliFatal("Failed to creat a B field map ! Exiting...");
862 AliInfo("Running with the B field constructed out of GRP !");
865 AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
871 //*** Get the diamond profile from OCDB
872 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
874 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
876 AliError("No diamond profile found in OCDB!");
879 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
881 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
883 AliError("No diamond profile found in OCDB!");
889 //_____________________________________________________________________________
890 Bool_t AliReconstruction::Run(const char* input)
893 AliCodeTimerAuto("");
895 if (!InitRun(input)) return kFALSE;
896 //******* The loop over events
898 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
899 (fRawReader && fRawReader->NextEvent())) {
900 if (!RunEvent(iEvent)) return kFALSE;
904 if (!FinishRun()) return kFALSE;
909 //_____________________________________________________________________________
910 Bool_t AliReconstruction::InitRun(const char* input)
912 // Initialize all the stuff before
913 // going into the event loop
914 // If the second argument is given, the first one is ignored and
915 // the reconstruction works in an online mode
916 AliCodeTimerAuto("");
918 // Overwrite the previous setting
919 if (input) fInput = input;
921 // set the input in case of raw data
922 fRawReader = AliRawReader::Create(fInput.Data());
924 AliInfo("Reconstruction will run over digits");
926 if (!fEquipIdMap.IsNull() && fRawReader)
927 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
929 if (!fUseHLTData.IsNull()) {
930 // create the RawReaderHLT which performs redirection of HLT input data for
931 // the specified detectors
932 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
934 fParentRawReader=fRawReader;
935 fRawReader=pRawReader;
937 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
941 AliSysInfo::AddStamp("Start");
942 // get the run loader
943 if (!InitRunLoader()) return kFALSE;
944 AliSysInfo::AddStamp("LoadLoader");
946 // Initialize the CDB storage
949 AliSysInfo::AddStamp("LoadCDB");
951 // Set run number in CDBManager (if it is not already set by the user)
952 if (!SetRunNumberFromData()) if (fStopOnError) return kFALSE;
954 // Set CDB lock: from now on it is forbidden to reset the run number
955 // or the default storage or to activate any further storage!
958 // Import ideal TGeo geometry and apply misalignment
960 TString geom(gSystem->DirName(fGAliceFileName));
961 geom += "/geometry.root";
962 AliGeomManager::LoadGeometry(geom.Data());
964 TString detsToCheck=fRunLocalReconstruction;
965 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data()))
966 AliFatalClass("Current loaded geometry differs in the definition of symbolic names!");
967 if (!gGeoManager) if (fStopOnError) return kFALSE;
970 if (!MisalignGeometry(fLoadAlignData)) if (fStopOnError) return kFALSE;
971 AliSysInfo::AddStamp("LoadGeom");
974 if (!InitGRP()) return kFALSE;
976 // Read the reconstruction parameters from OCDB
977 if (!InitRecoParams()) {
983 AliSysInfo::AddStamp("ReadRecoParam");
985 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
986 if(fDiamondProfile && fMeanVertexConstraint) ftVertexer->SetVtxStart(fDiamondProfile);
989 if (fRunVertexFinder && !CreateVertexer()) {
995 AliSysInfo::AddStamp("Vertexer");
998 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1004 AliSysInfo::AddStamp("LoadTrackers");
1006 // get the possibly already existing ESD file and tree
1007 fesd = new AliESDEvent(); fhltesd = new AliESDEvent();
1008 if (!gSystem->AccessPathName("AliESDs.root")){
1009 gSystem->CopyFile("AliESDs.root", "AliESDs.old.root", kTRUE);
1010 ffileOld = TFile::Open("AliESDs.old.root");
1011 if (ffileOld && ffileOld->IsOpen()) {
1012 ftreeOld = (TTree*) ffileOld->Get("esdTree");
1013 if (ftreeOld)fesd->ReadFromTree(ftreeOld);
1014 fhlttreeOld = (TTree*) ffileOld->Get("HLTesdTree");
1015 if (fhlttreeOld) fhltesd->ReadFromTree(fhlttreeOld);
1019 // create the ESD output file and tree
1020 ffile = TFile::Open("AliESDs.root", "RECREATE");
1021 ffile->SetCompressionLevel(2);
1022 if (!ffile->IsOpen()) {
1023 AliError("opening AliESDs.root failed");
1024 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1027 ftree = new TTree("esdTree", "Tree with ESD objects");
1028 fesd = new AliESDEvent();
1029 fesd->CreateStdContent();
1030 fesd->WriteToTree(ftree);
1032 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1033 fhltesd = new AliESDEvent();
1034 fhltesd->CreateStdContent();
1035 fhltesd->WriteToTree(fhlttree);
1038 if (fWriteESDfriend) {
1039 fesdf = new AliESDfriend();
1040 TBranch *br=ftree->Branch("ESDfriend.","AliESDfriend", &fesdf);
1041 br->SetFile("AliESDfriends.root");
1042 fesd->AddObject(fesdf);
1047 if (fRawReader) fRawReader->RewindEvents();
1049 ProcInfo_t ProcInfo;
1050 gSystem->GetProcInfo(&ProcInfo);
1051 AliInfo(Form("Current memory usage %d %d", ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1055 if (fRunQA && fRawReader && fQATasks.Contains(Form("%d", AliQA::kRAWS))) {
1056 fQASteer->Run(fQADetectors, fRawReader) ;
1057 fSameQACycle = kTRUE ;
1061 //Initialize the QA and start of cycle for out-of-loop QA
1063 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam, fSameQACycle, !fInLoopQA) ;
1067 fSameQACycle = kFALSE;
1068 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1069 AliInfo(Form("Initializing the global QA data maker"));
1070 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1071 TObjArray *arr=qadm->Init(AliQA::kRECPOINTS, AliCDBManager::Instance()->GetRun());
1072 AliTracker::SetResidualsArray(arr);
1074 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
1075 fSameQACycle = kTRUE;
1078 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1079 qadm->Init(AliQA::kESDS, AliCDBManager::Instance()->GetRun());
1081 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
1082 fSameQACycle = kTRUE;
1087 //Initialize the Plane Efficiency framework
1088 if (fRunPlaneEff && !InitPlaneEff()) {
1089 if(fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1092 if (strcmp(gProgName,"alieve") == 0)
1093 fRunAliEVE = InitAliEVE();
1098 //_____________________________________________________________________________
1099 Bool_t AliReconstruction::RunEvent(Int_t iEvent)
1101 // run the reconstruction over a single event
1102 // The event loop is steered in Run method
1104 AliCodeTimerAuto("");
1106 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1107 fRunLoader->SetEventNumber(iEvent);
1108 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1110 //?? fRunLoader->MakeTree("H");
1111 fRunLoader->TreeE()->Fill();
1114 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1115 // copy old ESD to the new one
1117 fesd->ReadFromTree(ftreeOld);
1118 ftreeOld->GetEntry(iEvent);
1122 fhltesd->ReadFromTree(fhlttreeOld);
1123 fhlttreeOld->GetEntry(iEvent);
1129 AliInfo(Form("processing event %d", iEvent));
1131 // Fill Event-info object
1133 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo);
1135 //Start of cycle for the in-loop QA
1136 if (fInLoopQA && fRunQA) {
1137 fQASteer->InitQADataMaker(AliCDBManager::Instance()->GetRun(), fRecoParam, fSameQACycle, fInLoopQA) ;
1139 if (fInLoopQA && fRunGlobalQA) {
1140 fSameQACycle = kFALSE;
1141 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1142 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS))) {
1143 qadm->StartOfCycle(AliQA::kRECPOINTS, fSameQACycle);
1144 fSameQACycle = kTRUE;
1146 if (fQATasks.Contains(Form("%d", AliQA::kESDS))) {
1147 qadm->StartOfCycle(AliQA::kESDS, fSameQACycle);
1148 fSameQACycle = kTRUE;
1152 fRunLoader->GetEvent(iEvent);
1154 char aFileName[256];
1155 sprintf(aFileName, "ESD_%d.%d_final.root",
1156 fRunLoader->GetHeader()->GetRun(),
1157 fRunLoader->GetHeader()->GetEventNrInRun());
1158 if (!gSystem->AccessPathName(aFileName)) return kTRUE;
1161 if (fInLoopQA && fRunQA)
1162 fQASteer->RunOneEvent(fRawReader) ;
1164 // local single event reconstruction
1165 if (!fRunLocalReconstruction.IsNull()) {
1166 TString detectors=fRunLocalReconstruction;
1167 // run HLT event reconstruction first
1168 // ;-( IsSelected changes the string
1169 if (IsSelected("HLT", detectors) &&
1170 !RunLocalEventReconstruction("HLT")) {
1171 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1173 detectors=fRunLocalReconstruction;
1174 detectors.ReplaceAll("HLT", "");
1175 if (!RunLocalEventReconstruction(detectors)) {
1176 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1180 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1181 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1182 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1183 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1185 // Set magnetic field from the tracker
1186 fesd->SetMagneticField(AliTracker::GetBz());
1187 fhltesd->SetMagneticField(AliTracker::GetBz());
1191 // Fill raw-data error log into the ESD
1192 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1195 if (fRunVertexFinder) {
1196 if (!ReadESD(fesd, "vertex")) {
1197 if (!RunVertexFinder(fesd)) {
1198 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1200 if (fCheckPointLevel > 0) WriteESD(fesd, "vertex");
1205 if (!fRunTracking.IsNull()) {
1206 if (fRunMuonTracking) {
1207 if (!RunMuonTracking(fesd)) {
1208 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1214 if (!fRunTracking.IsNull()) {
1215 if (!ReadESD(fesd, "tracking")) {
1216 if (!RunTracking(fesd)) {
1217 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1219 if (fCheckPointLevel > 0) WriteESD(fesd, "tracking");
1224 if (!fFillESD.IsNull()) {
1225 TString detectors=fFillESD;
1226 // run HLT first and on hltesd
1227 // ;-( IsSelected changes the string
1228 if (IsSelected("HLT", detectors) &&
1229 !FillESD(fhltesd, "HLT")) {
1230 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1233 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1234 if (detectors.Contains("ALL")) {
1236 for (Int_t idet=0; idet<fgkNDetectors; ++idet){
1237 detectors += fgkDetectorName[idet];
1241 detectors.ReplaceAll("HLT", "");
1242 if (!FillESD(fesd, detectors)) {
1243 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1247 // fill Event header information from the RawEventHeader
1248 if (fRawReader){FillRawEventHeaderESD(fesd);}
1251 AliESDpid::MakePID(fesd);
1252 if (fCheckPointLevel > 1) WriteESD(fesd, "PID");
1254 if (fFillTriggerESD) {
1255 if (!ReadESD(fesd, "trigger")) {
1256 if (!FillTriggerESD(fesd)) {
1257 if (fStopOnError) {CleanUp(ffile, ffileOld); return kFALSE;}
1259 if (fCheckPointLevel > 1) WriteESD(fesd, "trigger");
1266 // Propagate track to the beam pipe (if not already done by ITS)
1268 const Int_t ntracks = fesd->GetNumberOfTracks();
1269 const Double_t kBz = fesd->GetMagneticField();
1270 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1273 UShort_t *selectedIdx=new UShort_t[ntracks];
1275 for (Int_t itrack=0; itrack<ntracks; itrack++){
1276 const Double_t kMaxStep = 5; //max step over the material
1279 AliESDtrack *track = fesd->GetTrack(itrack);
1280 if (!track) continue;
1282 AliExternalTrackParam *tpcTrack =
1283 (AliExternalTrackParam *)track->GetTPCInnerParam();
1287 PropagateTrackTo(tpcTrack,kRadius,track->GetMass(),kMaxStep,kTRUE);
1290 Int_t n=trkArray.GetEntriesFast();
1291 selectedIdx[n]=track->GetID();
1292 trkArray.AddLast(tpcTrack);
1295 //Tracks refitted by ITS should already be at the SPD vertex
1296 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1299 PropagateTrackTo(track,kRadius,track->GetMass(),kMaxStep,kTRUE);
1300 track->RelateToVertex(fesd->GetPrimaryVertexSPD(), kBz, kVeryBig);
1305 // Improve the reconstructed primary vertex position using the tracks
1307 TObject *obj = fOptions.FindObject("ITS");
1309 TString optITS = obj->GetTitle();
1310 if (optITS.Contains("cosmics") || optITS.Contains("COSMICS"))
1311 fRunVertexFinderTracks=kFALSE;
1313 if (fRunVertexFinderTracks) {
1314 // TPC + ITS primary vertex
1315 ftVertexer->SetITSrefitRequired();
1316 if(fDiamondProfile && fMeanVertexConstraint) {
1317 ftVertexer->SetVtxStart(fDiamondProfile);
1319 ftVertexer->SetConstraintOff();
1321 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1323 if (pvtx->GetStatus()) {
1324 fesd->SetPrimaryVertex(pvtx);
1325 for (Int_t i=0; i<ntracks; i++) {
1326 AliESDtrack *t = fesd->GetTrack(i);
1327 t->RelateToVertex(pvtx, kBz, kVeryBig);
1332 // TPC-only primary vertex
1333 ftVertexer->SetITSrefitNotRequired();
1334 if(fDiamondProfileTPC && fMeanVertexConstraint) {
1335 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1337 ftVertexer->SetConstraintOff();
1339 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1341 if (pvtx->GetStatus()) {
1342 fesd->SetPrimaryVertexTPC(pvtx);
1343 for (Int_t i=0; i<ntracks; i++) {
1344 AliESDtrack *t = fesd->GetTrack(i);
1345 t->RelateToVertexTPC(pvtx, kBz, kVeryBig);
1351 delete[] selectedIdx;
1353 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1358 AliV0vertexer vtxer;
1359 vtxer.Tracks2V0vertices(fesd);
1361 if (fRunCascadeFinder) {
1363 AliCascadeVertexer cvtxer;
1364 cvtxer.V0sTracks2CascadeVertices(fesd);
1369 if (fCleanESD) CleanESD(fesd);
1373 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1374 if (qadm && fQATasks.Contains(Form("%d", AliQA::kESDS)))
1375 qadm->Exec(AliQA::kESDS, fesd);
1379 if (fWriteESDfriend) {
1380 fesdf->~AliESDfriend();
1381 new (fesdf) AliESDfriend(); // Reset...
1382 fesd->GetESDfriend(fesdf);
1386 // Auto-save the ESD tree in case of prompt reco @P2
1387 if (fRawReader && fRawReader->UseAutoSaveESD())
1388 ftree->AutoSave("SaveSelf");
1394 if (fRunAliEVE) RunAliEVE();
1396 if (fCheckPointLevel > 0) WriteESD(fesd, "final");
1399 if (fWriteESDfriend) {
1400 fesdf->~AliESDfriend();
1401 new (fesdf) AliESDfriend(); // Reset...
1404 ProcInfo_t ProcInfo;
1405 gSystem->GetProcInfo(&ProcInfo);
1406 AliInfo(Form("Event %d -> Current memory usage %d %d",iEvent, ProcInfo.fMemResident, ProcInfo.fMemVirtual));
1409 // End of cycle for the in-loop
1410 if (fInLoopQA && fRunQA) {
1411 fQASteer->RunOneEvent(fesd) ;
1412 fQASteer->EndOfCycle() ;
1415 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1417 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1418 qadm->EndOfCycle(AliQA::kRECPOINTS);
1419 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1420 qadm->EndOfCycle(AliQA::kESDS);
1426 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1427 if (fReconstructor[iDet])
1428 fReconstructor[iDet]->SetRecoParam(NULL);
1434 //_____________________________________________________________________________
1435 Bool_t AliReconstruction::FinishRun()
1438 // Called after the exit
1439 // from the event loop
1440 AliCodeTimerAuto("");
1442 if (fIsNewRunLoader) { // galice.root didn't exist
1443 fRunLoader->WriteHeader("OVERWRITE");
1444 fRunLoader->CdGAFile();
1445 fRunLoader->Write(0, TObject::kOverwrite);
1448 ftree->GetUserInfo()->Add(fesd);
1449 fhlttree->GetUserInfo()->Add(fhltesd);
1451 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
1452 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
1454 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
1455 cdbMapCopy->SetOwner(1);
1456 cdbMapCopy->SetName("cdbMap");
1457 TIter iter(cdbMap->GetTable());
1460 while((pair = dynamic_cast<TPair*> (iter.Next()))){
1461 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
1462 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
1463 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
1466 TList *cdbListCopy = new TList();
1467 cdbListCopy->SetOwner(1);
1468 cdbListCopy->SetName("cdbList");
1470 TIter iter2(cdbList);
1473 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
1474 cdbListCopy->Add(new TObjString(id->ToString().Data()));
1477 ftree->GetUserInfo()->Add(cdbMapCopy);
1478 ftree->GetUserInfo()->Add(cdbListCopy);
1481 if(fESDPar.Contains("ESD.par")){
1482 AliInfo("Attaching ESD.par to Tree");
1483 TNamed *fn = CopyFileToTNamed(fESDPar.Data(),"ESD.par");
1484 ftree->GetUserInfo()->Add(fn);
1490 if (fWriteESDfriend)
1491 ftree->SetBranchStatus("ESDfriend*",0);
1492 // we want to have only one tree version number
1493 ftree->Write(ftree->GetName(),TObject::kOverwrite);
1496 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
1497 if (fRunPlaneEff && !FinishPlaneEff()) {
1498 AliWarning("Finish PlaneEff evaluation failed");
1502 CleanUp(ffile, ffileOld);
1505 AliWarning("AOD creation not supported anymore during reconstruction. See ANALYSIS/AliAnalysisTaskESDfilter.cxx instead.");
1508 // Create tags for the events in the ESD tree (the ESD tree is always present)
1509 // In case of empty events the tags will contain dummy values
1510 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
1511 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData);
1513 AliWarning("AOD tag creation not supported anymore during reconstruction.");
1516 //Finish QA and end of cycle for out-of-loop QA
1517 if (!fInLoopQA && fRunQA)
1518 fQASteer->Run(fRunLocalReconstruction.Data(), AliQA::kNULLTASKINDEX, fSameQACycle) ;
1519 if (!fInLoopQA && fRunGlobalQA) {
1520 AliQADataMaker *qadm = fQASteer->GetQADataMaker(AliQA::kGLOBAL);
1522 if (fQATasks.Contains(Form("%d", AliQA::kRECPOINTS)))
1523 qadm->EndOfCycle(AliQA::kRECPOINTS);
1524 if (fQATasks.Contains(Form("%d", AliQA::kESDS)))
1525 qadm->EndOfCycle(AliQA::kESDS);
1530 // Cleanup of CDB manager: cache and active storages!
1531 AliCDBManager::Instance()->ClearCache();
1537 //_____________________________________________________________________________
1538 Bool_t AliReconstruction::RunLocalReconstruction(const TString& /*detectors*/)
1540 // run the local reconstruction
1541 static Int_t eventNr=0;
1542 AliCodeTimerAuto("")
1544 // AliCDBManager* man = AliCDBManager::Instance();
1545 // Bool_t origCache = man->GetCacheFlag();
1547 // TString detStr = detectors;
1548 // for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1549 // if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1550 // AliReconstructor* reconstructor = GetReconstructor(iDet);
1551 // if (!reconstructor) continue;
1552 // if (reconstructor->HasLocalReconstruction()) continue;
1554 // AliCodeTimerStart(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1555 // AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1557 // AliCodeTimerStart(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1558 // AliInfo(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1560 // man->SetCacheFlag(kTRUE);
1561 // TString calibPath = Form("%s/Calib/*", fgkDetectorName[iDet]);
1562 // man->GetAll(calibPath); // entries are cached!
1564 // AliCodeTimerStop(Form("Loading calibration data from OCDB for %s", fgkDetectorName[iDet]));
1566 // if (fRawReader) {
1567 // fRawReader->RewindEvents();
1568 // reconstructor->Reconstruct(fRunLoader, fRawReader);
1570 // reconstructor->Reconstruct(fRunLoader);
1573 // AliCodeTimerStop(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1574 // AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr));
1576 // // unload calibration data
1577 // man->UnloadFromCache(calibPath);
1578 // //man->ClearCache();
1581 // man->SetCacheFlag(origCache);
1583 // if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1584 // AliError(Form("the following detectors were not found: %s",
1586 // if (fStopOnError) return kFALSE;
1593 //_____________________________________________________________________________
1594 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
1596 // run the local reconstruction
1598 static Int_t eventNr=0;
1599 AliCodeTimerAuto("")
1601 TString detStr = detectors;
1602 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1603 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1604 AliReconstructor* reconstructor = GetReconstructor(iDet);
1605 if (!reconstructor) continue;
1606 AliLoader* loader = fLoader[iDet];
1607 // Matthias April 2008: temporary fix to run HLT reconstruction
1608 // although the HLT loader is missing
1609 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
1611 reconstructor->Reconstruct(fRawReader, NULL);
1614 reconstructor->Reconstruct(dummy, NULL);
1619 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
1622 // conversion of digits
1623 if (fRawReader && reconstructor->HasDigitConversion()) {
1624 AliInfo(Form("converting raw data digits into root objects for %s",
1625 fgkDetectorName[iDet]));
1626 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
1627 // fgkDetectorName[iDet]));
1628 loader->LoadDigits("update");
1629 loader->CleanDigits();
1630 loader->MakeDigitsContainer();
1631 TTree* digitsTree = loader->TreeD();
1632 reconstructor->ConvertDigits(fRawReader, digitsTree);
1633 loader->WriteDigits("OVERWRITE");
1634 loader->UnloadDigits();
1636 // local reconstruction
1637 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1638 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]));
1639 loader->LoadRecPoints("update");
1640 loader->CleanRecPoints();
1641 loader->MakeRecPointsContainer();
1642 TTree* clustersTree = loader->TreeR();
1643 if (fRawReader && !reconstructor->HasDigitConversion()) {
1644 reconstructor->Reconstruct(fRawReader, clustersTree);
1646 loader->LoadDigits("read");
1647 TTree* digitsTree = loader->TreeD();
1649 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
1650 if (fStopOnError) return kFALSE;
1652 reconstructor->Reconstruct(digitsTree, clustersTree);
1654 loader->UnloadDigits();
1657 // In-loop QA for local reconstrucion
1658 TString detQAStr(fQADetectors) ;
1659 if (fRunQA && fInLoopQA)
1660 fQASteer->RunOneEventInOneDetector(iDet, clustersTree) ;
1662 loader->WriteRecPoints("OVERWRITE");
1663 loader->UnloadRecPoints();
1664 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
1666 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
1667 AliError(Form("the following detectors were not found: %s",
1669 if (fStopOnError) return kFALSE;
1675 //_____________________________________________________________________________
1676 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
1678 // run the barrel tracking
1680 AliCodeTimerAuto("")
1682 AliESDVertex* vertex = NULL;
1683 Double_t vtxPos[3] = {0, 0, 0};
1684 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
1685 TArrayF mcVertex(3);
1686 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
1687 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
1688 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
1692 AliInfo("running the ITS vertex finder");
1694 fLoader[0]->LoadRecPoints();
1695 TTree* cltree = fLoader[0]->TreeR();
1697 if(fDiamondProfile) fVertexer->SetVtxStart(fDiamondProfile);
1698 vertex = fVertexer->FindVertexForCurrentEvent(cltree);
1701 AliError("Can't get the ITS cluster tree");
1703 fLoader[0]->UnloadRecPoints();
1706 AliError("Can't get the ITS loader");
1709 AliWarning("Vertex not found");
1710 vertex = new AliESDVertex();
1711 vertex->SetName("default");
1714 vertex->SetName("reconstructed");
1718 AliInfo("getting the primary vertex from MC");
1719 vertex = new AliESDVertex(vtxPos, vtxErr);
1723 vertex->GetXYZ(vtxPos);
1724 vertex->GetSigmaXYZ(vtxErr);
1726 AliWarning("no vertex reconstructed");
1727 vertex = new AliESDVertex(vtxPos, vtxErr);
1729 esd->SetPrimaryVertexSPD(vertex);
1730 // if SPD multiplicity has been determined, it is stored in the ESD
1731 AliMultiplicity *mult = fVertexer->GetMultiplicity();
1732 if(mult)esd->SetMultiplicity(mult);
1734 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1735 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
1742 //_____________________________________________________________________________
1743 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
1745 // run the HLT barrel tracking
1747 AliCodeTimerAuto("")
1750 AliError("Missing runLoader!");
1754 AliInfo("running HLT tracking");
1756 // Get a pointer to the HLT reconstructor
1757 AliReconstructor *reconstructor = GetReconstructor(fgkNDetectors-1);
1758 if (!reconstructor) return kFALSE;
1761 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1762 TString detName = fgkDetectorName[iDet];
1763 AliDebug(1, Form("%s HLT tracking", detName.Data()));
1764 reconstructor->SetOption(detName.Data());
1765 AliTracker *tracker = reconstructor->CreateTracker();
1767 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
1768 if (fStopOnError) return kFALSE;
1772 Double_t vtxErr[3]={0.005,0.005,0.010};
1773 const AliESDVertex *vertex = esd->GetVertex();
1774 vertex->GetXYZ(vtxPos);
1775 tracker->SetVertex(vtxPos,vtxErr);
1777 fLoader[iDet]->LoadRecPoints("read");
1778 TTree* tree = fLoader[iDet]->TreeR();
1780 AliError(Form("Can't get the %s cluster tree", detName.Data()));
1783 tracker->LoadClusters(tree);
1785 if (tracker->Clusters2Tracks(esd) != 0) {
1786 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
1790 tracker->UnloadClusters();
1798 //_____________________________________________________________________________
1799 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
1801 // run the muon spectrometer tracking
1803 AliCodeTimerAuto("")
1806 AliError("Missing runLoader!");
1809 Int_t iDet = 7; // for MUON
1811 AliInfo("is running...");
1813 // Get a pointer to the MUON reconstructor
1814 AliReconstructor *reconstructor = GetReconstructor(iDet);
1815 if (!reconstructor) return kFALSE;
1818 TString detName = fgkDetectorName[iDet];
1819 AliDebug(1, Form("%s tracking", detName.Data()));
1820 AliTracker *tracker = reconstructor->CreateTracker();
1822 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
1827 fLoader[iDet]->LoadRecPoints("read");
1829 tracker->LoadClusters(fLoader[iDet]->TreeR());
1831 Int_t rv = tracker->Clusters2Tracks(esd);
1835 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
1839 fLoader[iDet]->UnloadRecPoints();
1841 tracker->UnloadClusters();
1849 //_____________________________________________________________________________
1850 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd)
1852 // run the barrel tracking
1853 static Int_t eventNr=0;
1854 AliCodeTimerAuto("")
1856 AliInfo("running tracking");
1858 //Fill the ESD with the T0 info (will be used by the TOF)
1859 if (fReconstructor[11] && fLoader[11]) {
1860 fLoader[11]->LoadRecPoints("READ");
1861 TTree *treeR = fLoader[11]->TreeR();
1862 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
1865 // pass 1: TPC + ITS inwards
1866 for (Int_t iDet = 1; iDet >= 0; iDet--) {
1867 if (!fTracker[iDet]) continue;
1868 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
1871 fLoader[iDet]->LoadRecPoints("read");
1872 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
1873 TTree* tree = fLoader[iDet]->TreeR();
1875 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
1878 fTracker[iDet]->LoadClusters(tree);
1879 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
1881 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
1882 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
1885 if (fCheckPointLevel > 1) {
1886 WriteESD(esd, Form("%s.tracking", fgkDetectorName[iDet]));
1888 // preliminary PID in TPC needed by the ITS tracker
1890 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
1891 AliESDpid::MakePID(esd);
1893 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
1896 // pass 2: ALL backwards
1898 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
1899 if (!fTracker[iDet]) continue;
1900 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
1903 if (iDet > 1) { // all except ITS, TPC
1905 fLoader[iDet]->LoadRecPoints("read");
1906 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
1907 tree = fLoader[iDet]->TreeR();
1909 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
1912 fTracker[iDet]->LoadClusters(tree);
1913 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
1917 if (iDet>1) // start filling residuals for the "outer" detectors
1918 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
1920 if (fTracker[iDet]->PropagateBack(esd) != 0) {
1921 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
1924 if (fCheckPointLevel > 1) {
1925 WriteESD(esd, Form("%s.back", fgkDetectorName[iDet]));
1929 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
1930 fTracker[iDet]->UnloadClusters();
1931 fLoader[iDet]->UnloadRecPoints();
1933 // updated PID in TPC needed by the ITS tracker -MI
1935 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
1936 AliESDpid::MakePID(esd);
1938 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
1940 //stop filling residuals for the "outer" detectors
1941 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
1943 // pass 3: TRD + TPC + ITS refit inwards
1945 for (Int_t iDet = 2; iDet >= 0; iDet--) {
1946 if (!fTracker[iDet]) continue;
1947 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
1950 if (iDet<2) // start filling residuals for TPC and ITS
1951 if (fRunGlobalQA) AliTracker::SetFillResiduals(kTRUE);
1953 if (fTracker[iDet]->RefitInward(esd) != 0) {
1954 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
1957 // run postprocessing
1958 if (fTracker[iDet]->PostProcess(esd) != 0) {
1959 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
1962 if (fCheckPointLevel > 1) {
1963 WriteESD(esd, Form("%s.refit", fgkDetectorName[iDet]));
1965 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
1968 // write space-points to the ESD in case alignment data output
1970 if (fWriteAlignmentData)
1971 WriteAlignmentData(esd);
1973 for (Int_t iDet = 3; iDet >= 0; iDet--) {
1974 if (!fTracker[iDet]) continue;
1976 fTracker[iDet]->UnloadClusters();
1977 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
1978 fLoader[iDet]->UnloadRecPoints();
1979 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
1981 // stop filling residuals for TPC and ITS
1982 if (fRunGlobalQA) AliTracker::SetFillResiduals(kFALSE);
1988 //_____________________________________________________________________________
1989 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
1991 // Remove the data which are not needed for the physics analysis.
1994 Int_t nTracks=esd->GetNumberOfTracks();
1995 Int_t nV0s=esd->GetNumberOfV0s();
1997 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
1999 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2000 Bool_t rc=esd->Clean(cleanPars);
2002 nTracks=esd->GetNumberOfTracks();
2003 nV0s=esd->GetNumberOfV0s();
2005 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2010 //_____________________________________________________________________________
2011 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2013 // fill the event summary data
2015 AliCodeTimerAuto("")
2016 static Int_t eventNr=0;
2017 TString detStr = detectors;
2019 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2020 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2021 AliReconstructor* reconstructor = GetReconstructor(iDet);
2022 if (!reconstructor) continue;
2023 if (!ReadESD(esd, fgkDetectorName[iDet])) {
2024 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2025 TTree* clustersTree = NULL;
2026 if (fLoader[iDet]) {
2027 fLoader[iDet]->LoadRecPoints("read");
2028 clustersTree = fLoader[iDet]->TreeR();
2029 if (!clustersTree) {
2030 AliError(Form("Can't get the %s clusters tree",
2031 fgkDetectorName[iDet]));
2032 if (fStopOnError) return kFALSE;
2035 if (fRawReader && !reconstructor->HasDigitConversion()) {
2036 reconstructor->FillESD(fRawReader, clustersTree, esd);
2038 TTree* digitsTree = NULL;
2039 if (fLoader[iDet]) {
2040 fLoader[iDet]->LoadDigits("read");
2041 digitsTree = fLoader[iDet]->TreeD();
2043 AliError(Form("Can't get the %s digits tree",
2044 fgkDetectorName[iDet]));
2045 if (fStopOnError) return kFALSE;
2048 reconstructor->FillESD(digitsTree, clustersTree, esd);
2049 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2051 if (fLoader[iDet]) {
2052 fLoader[iDet]->UnloadRecPoints();
2055 if (fCheckPointLevel > 2) WriteESD(esd, fgkDetectorName[iDet]);
2059 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2060 AliError(Form("the following detectors were not found: %s",
2062 if (fStopOnError) return kFALSE;
2064 AliSysInfo::AddStamp(Form("FillESD%d",eventNr), 0,1, eventNr);
2069 //_____________________________________________________________________________
2070 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2072 // Reads the trigger decision which is
2073 // stored in Trigger.root file and fills
2074 // the corresponding esd entries
2076 AliCodeTimerAuto("")
2078 AliInfo("Filling trigger information into the ESD");
2081 AliCTPRawStream input(fRawReader);
2082 if (!input.Next()) {
2083 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2086 if (esd->GetTriggerMask() != input.GetClassMask())
2087 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2088 input.GetClassMask(),esd->GetTriggerMask()));
2089 if (esd->GetOrbitNumber() != input.GetOrbitID())
2090 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2091 input.GetOrbitID(),esd->GetOrbitNumber()));
2092 if (esd->GetBunchCrossNumber() != input.GetBCID())
2093 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2094 input.GetBCID(),esd->GetBunchCrossNumber()));
2097 // Here one has to add the filling of trigger inputs and
2098 // interaction records
2108 //_____________________________________________________________________________
2109 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2112 // Filling information from RawReader Header
2115 if (!fRawReader) return kFALSE;
2117 AliInfo("Filling information from RawReader Header");
2119 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2120 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2121 esd->SetPeriodNumber(fRawReader->GetPeriod());
2123 esd->SetTimeStamp(fRawReader->GetTimestamp());
2124 esd->SetEventType(fRawReader->GetType());
2130 //_____________________________________________________________________________
2131 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2133 // check whether detName is contained in detectors
2134 // if yes, it is removed from detectors
2136 // check if all detectors are selected
2137 if ((detectors.CompareTo("ALL") == 0) ||
2138 detectors.BeginsWith("ALL ") ||
2139 detectors.EndsWith(" ALL") ||
2140 detectors.Contains(" ALL ")) {
2145 // search for the given detector
2146 Bool_t result = kFALSE;
2147 if ((detectors.CompareTo(detName) == 0) ||
2148 detectors.BeginsWith(detName+" ") ||
2149 detectors.EndsWith(" "+detName) ||
2150 detectors.Contains(" "+detName+" ")) {
2151 detectors.ReplaceAll(detName, "");
2155 // clean up the detectors string
2156 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2157 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2158 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2163 //_____________________________________________________________________________
2164 Bool_t AliReconstruction::InitRunLoader()
2166 // get or create the run loader
2168 if (gAlice) delete gAlice;
2171 if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2172 // load all base libraries to get the loader classes
2173 TString libs = gSystem->GetLibraries();
2174 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2175 TString detName = fgkDetectorName[iDet];
2176 if (detName == "HLT") continue;
2177 if (libs.Contains("lib" + detName + "base.so")) continue;
2178 gSystem->Load("lib" + detName + "base.so");
2180 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2182 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2187 fRunLoader->CdGAFile();
2188 fRunLoader->LoadgAlice();
2190 //PH This is a temporary fix to give access to the kinematics
2191 //PH that is needed for the labels of ITS clusters
2192 fRunLoader->LoadHeader();
2193 fRunLoader->LoadKinematics();
2195 } else { // galice.root does not exist
2197 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2201 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2202 AliConfig::GetDefaultEventFolderName(),
2205 AliError(Form("could not create run loader in file %s",
2206 fGAliceFileName.Data()));
2210 fIsNewRunLoader = kTRUE;
2211 fRunLoader->MakeTree("E");
2213 if (fNumberOfEventsPerFile > 0)
2214 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2216 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2222 //_____________________________________________________________________________
2223 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2225 // get the reconstructor object and the loader for a detector
2227 if (fReconstructor[iDet]) {
2228 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2229 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2230 fReconstructor[iDet]->SetRecoParam(par);
2232 return fReconstructor[iDet];
2235 // load the reconstructor object
2236 TPluginManager* pluginManager = gROOT->GetPluginManager();
2237 TString detName = fgkDetectorName[iDet];
2238 TString recName = "Ali" + detName + "Reconstructor";
2240 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2242 AliReconstructor* reconstructor = NULL;
2243 // first check if a plugin is defined for the reconstructor
2244 TPluginHandler* pluginHandler =
2245 pluginManager->FindHandler("AliReconstructor", detName);
2246 // if not, add a plugin for it
2247 if (!pluginHandler) {
2248 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2249 TString libs = gSystem->GetLibraries();
2250 if (libs.Contains("lib" + detName + "base.so") ||
2251 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2252 pluginManager->AddHandler("AliReconstructor", detName,
2253 recName, detName + "rec", recName + "()");
2255 pluginManager->AddHandler("AliReconstructor", detName,
2256 recName, detName, recName + "()");
2258 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2260 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2261 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2263 if (reconstructor) {
2264 TObject* obj = fOptions.FindObject(detName.Data());
2265 if (obj) reconstructor->SetOption(obj->GetTitle());
2266 reconstructor->Init();
2267 fReconstructor[iDet] = reconstructor;
2270 // get or create the loader
2271 if (detName != "HLT") {
2272 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2273 if (!fLoader[iDet]) {
2274 AliConfig::Instance()
2275 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2277 // first check if a plugin is defined for the loader
2279 pluginManager->FindHandler("AliLoader", detName);
2280 // if not, add a plugin for it
2281 if (!pluginHandler) {
2282 TString loaderName = "Ali" + detName + "Loader";
2283 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2284 pluginManager->AddHandler("AliLoader", detName,
2285 loaderName, detName + "base",
2286 loaderName + "(const char*, TFolder*)");
2287 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2289 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2291 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2292 fRunLoader->GetEventFolder());
2294 if (!fLoader[iDet]) { // use default loader
2295 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2297 if (!fLoader[iDet]) {
2298 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2299 if (fStopOnError) return NULL;
2301 fRunLoader->AddLoader(fLoader[iDet]);
2302 fRunLoader->CdGAFile();
2303 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2304 fRunLoader->Write(0, TObject::kOverwrite);
2309 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2310 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2311 reconstructor->SetRecoParam(par);
2313 return reconstructor;
2316 //_____________________________________________________________________________
2317 Bool_t AliReconstruction::CreateVertexer()
2319 // create the vertexer
2322 AliReconstructor* itsReconstructor = GetReconstructor(0);
2323 if (itsReconstructor) {
2324 fVertexer = itsReconstructor->CreateVertexer();
2327 AliWarning("couldn't create a vertexer for ITS");
2328 if (fStopOnError) return kFALSE;
2334 //_____________________________________________________________________________
2335 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2337 // create the trackers
2339 TString detStr = detectors;
2340 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2341 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2342 AliReconstructor* reconstructor = GetReconstructor(iDet);
2343 if (!reconstructor) continue;
2344 TString detName = fgkDetectorName[iDet];
2345 if (detName == "HLT") {
2346 fRunHLTTracking = kTRUE;
2349 if (detName == "MUON") {
2350 fRunMuonTracking = kTRUE;
2355 fTracker[iDet] = reconstructor->CreateTracker();
2356 if (!fTracker[iDet] && (iDet < 7)) {
2357 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2358 if (fStopOnError) return kFALSE;
2360 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
2366 //_____________________________________________________________________________
2367 void AliReconstruction::CleanUp(TFile* file, TFile* fileOld)
2369 // delete trackers and the run loader and close and delete the file
2371 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2372 delete fReconstructor[iDet];
2373 fReconstructor[iDet] = NULL;
2374 fLoader[iDet] = NULL;
2375 delete fTracker[iDet];
2376 fTracker[iDet] = NULL;
2378 if (fRunInfo) delete fRunInfo;
2384 if (ftVertexer) delete ftVertexer;
2387 if(!(AliCDBManager::Instance()->GetCacheFlag())) {
2388 delete fDiamondProfile;
2389 fDiamondProfile = NULL;
2390 delete fDiamondProfileTPC;
2391 fDiamondProfileTPC = NULL;
2401 if (fParentRawReader) delete fParentRawReader;
2402 fParentRawReader=NULL;
2412 gSystem->Unlink("AliESDs.old.root");
2417 //_____________________________________________________________________________
2419 Bool_t AliReconstruction::ReadESD(AliESDEvent*& esd, const char* recStep) const
2421 // read the ESD event from a file
2423 if (!esd) return kFALSE;
2425 sprintf(fileName, "ESD_%d.%d_%s.root",
2426 esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
2427 if (gSystem->AccessPathName(fileName)) return kFALSE;
2429 AliInfo(Form("reading ESD from file %s", fileName));
2430 AliDebug(1, Form("reading ESD from file %s", fileName));
2431 TFile* file = TFile::Open(fileName);
2432 if (!file || !file->IsOpen()) {
2433 AliError(Form("opening %s failed", fileName));
2440 esd = (AliESDEvent*) file->Get("ESD");
2449 //_____________________________________________________________________________
2450 void AliReconstruction::WriteESD(AliESDEvent* esd, const char* recStep) const
2452 // write the ESD event to a file
2456 sprintf(fileName, "ESD_%d.%d_%s.root",
2457 esd->GetRunNumber(), esd->GetEventNumberInFile(), recStep);
2459 AliDebug(1, Form("writing ESD to file %s", fileName));
2460 TFile* file = TFile::Open(fileName, "recreate");
2461 if (!file || !file->IsOpen()) {
2462 AliError(Form("opening %s failed", fileName));
2471 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
2473 // Write space-points which are then used in the alignment procedures
2474 // For the moment only ITS, TPC, TRD and TOF
2476 Int_t ntracks = esd->GetNumberOfTracks();
2477 for (Int_t itrack = 0; itrack < ntracks; itrack++)
2479 AliESDtrack *track = esd->GetTrack(itrack);
2482 for (Int_t iDet = 3; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
2483 nsp += track->GetNcls(iDet);
2485 if (iDet==0) { // ITS "extra" clusters
2486 track->GetClusters(iDet,idx);
2487 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
2492 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
2493 track->SetTrackPointArray(sp);
2495 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2496 AliTracker *tracker = fTracker[iDet];
2497 if (!tracker) continue;
2498 Int_t nspdet = track->GetClusters(iDet,idx);
2500 if (iDet==0) // ITS "extra" clusters
2501 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
2503 if (nspdet <= 0) continue;
2507 while (isp2 < nspdet) {
2508 Bool_t isvalid=kTRUE;
2510 Int_t index=idx[isp++];
2511 if (index < 0) continue;
2513 TString dets = fgkDetectorName[iDet];
2514 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
2515 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
2516 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
2517 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
2518 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
2520 isvalid = tracker->GetTrackPoint(index,p);
2523 if (!isvalid) continue;
2524 sp->AddPoint(isptrack,&p); isptrack++;
2531 //_____________________________________________________________________________
2532 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
2534 // The method reads the raw-data error log
2535 // accumulated within the rawReader.
2536 // It extracts the raw-data errors related to
2537 // the current event and stores them into
2538 // a TClonesArray inside the esd object.
2540 if (!fRawReader) return;
2542 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
2544 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
2546 if (iEvent != log->GetEventNumber()) continue;
2548 esd->AddRawDataErrorLog(log);
2553 TNamed* AliReconstruction::CopyFileToTNamed(TString fPath,TString pName){
2554 // Dump a file content into a char in TNamed
2556 in.open(fPath.Data(),ios::in | ios::binary|ios::ate);
2557 Int_t kBytes = (Int_t)in.tellg();
2558 printf("Size: %d \n",kBytes);
2561 char* memblock = new char [kBytes];
2562 in.seekg (0, ios::beg);
2563 in.read (memblock, kBytes);
2565 TString fData(memblock,kBytes);
2566 fn = new TNamed(pName,fData);
2567 printf("fData Size: %d \n",fData.Sizeof());
2568 printf("pName Size: %d \n",pName.Sizeof());
2569 printf("fn Size: %d \n",fn->Sizeof());
2573 AliInfo(Form("Could not Open %s\n",fPath.Data()));
2579 void AliReconstruction::TNamedToFile(TTree* fTree, TString pName){
2580 // This is not really needed in AliReconstruction at the moment
2581 // but can serve as a template
2583 TList *fList = fTree->GetUserInfo();
2584 TNamed *fn = (TNamed*)fList->FindObject(pName.Data());
2585 printf("fn Size: %d \n",fn->Sizeof());
2587 TString fTmp(fn->GetName()); // to be 100% sure in principle pName also works
2588 const char* cdata = fn->GetTitle();
2589 printf("fTmp Size %d\n",fTmp.Sizeof());
2591 int size = fn->Sizeof()-fTmp.Sizeof()-sizeof(UChar_t)-sizeof(Int_t); // see dfinition of TString::SizeOf()...
2592 printf("calculated size %d\n",size);
2593 ofstream out(pName.Data(),ios::out | ios::binary);
2594 out.write(cdata,size);
2599 //_____________________________________________________________________________
2600 void AliReconstruction::CheckQA()
2602 // check the QA of SIM for this run and remove the detectors
2603 // with status Fatal
2605 TString newRunLocalReconstruction ;
2606 TString newRunTracking ;
2607 TString newFillESD ;
2609 for (Int_t iDet = 0; iDet < AliQA::kNDET; iDet++) {
2610 TString detName(AliQA::GetDetName(iDet)) ;
2611 AliQA * qa = AliQA::Instance(AliQA::DETECTORINDEX_t(iDet)) ;
2612 if ( qa->IsSet(AliQA::DETECTORINDEX_t(iDet), AliQA::kSIM, AliQA::kFATAL)) {
2613 AliInfo(Form("QA status for %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed", detName.Data())) ;
2615 if ( fRunLocalReconstruction.Contains(AliQA::GetDetName(iDet)) ||
2616 fRunLocalReconstruction.Contains("ALL") ) {
2617 newRunLocalReconstruction += detName ;
2618 newRunLocalReconstruction += " " ;
2620 if ( fRunTracking.Contains(AliQA::GetDetName(iDet)) ||
2621 fRunTracking.Contains("ALL") ) {
2622 newRunTracking += detName ;
2623 newRunTracking += " " ;
2625 if ( fFillESD.Contains(AliQA::GetDetName(iDet)) ||
2626 fFillESD.Contains("ALL") ) {
2627 newFillESD += detName ;
2632 fRunLocalReconstruction = newRunLocalReconstruction ;
2633 fRunTracking = newRunTracking ;
2634 fFillESD = newFillESD ;
2637 //_____________________________________________________________________________
2638 Int_t AliReconstruction::GetDetIndex(const char* detector)
2640 // return the detector index corresponding to detector
2642 for (index = 0; index < fgkNDetectors ; index++) {
2643 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
2648 //_____________________________________________________________________________
2649 Bool_t AliReconstruction::FinishPlaneEff() {
2651 // Here execute all the necessary operationis, at the end of the tracking phase,
2652 // in case that evaluation of PlaneEfficiencies was required for some detector.
2653 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
2655 // This Preliminary version works only FOR ITS !!!!!
2656 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2659 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2662 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2663 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
2664 //if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2665 if(fTracker[iDet]) {
2666 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
2667 TString name=planeeff->GetName();
2669 TFile* pefile = TFile::Open(name, "RECREATE");
2670 ret=(Bool_t)planeeff->Write();
2672 if(planeeff->GetCreateHistos()) {
2673 TString hname=planeeff->GetName();
2674 hname+="Histo.root";
2675 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
2681 //_____________________________________________________________________________
2682 Bool_t AliReconstruction::InitPlaneEff() {
2684 // Here execute all the necessary operations, before of the tracking phase,
2685 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
2686 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
2687 // which should be updated/recalculated.
2689 // This Preliminary version will work only FOR ITS !!!!!
2690 // other detectors (TOF,TRD, etc. have to develop their specific codes)
2693 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
2695 AliWarning(Form("Implementation of this method not yet done !! Method return kTRUE"));
2699 //_____________________________________________________________________________
2700 Bool_t AliReconstruction::InitAliEVE()
2702 // This method should be called only in case
2703 // AliReconstruction is run
2704 // within the alieve environment.
2705 // It will initialize AliEVE in a way
2706 // so that it can visualize event processed
2707 // by AliReconstruction.
2708 // The return flag shows whenever the
2709 // AliEVE initialization was successful or not.
2712 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
2713 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
2714 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
2716 gROOT->ProcessLine("if (!gAliEveEvent) {gAliEveEvent = new AliEveEventManager();gAliEveEvent->SetAutoLoad(kTRUE);gAliEveEvent->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(gAliEveEvent);};");
2717 gROOT->ProcessLine("alieve_online_init()");
2722 //_____________________________________________________________________________
2723 void AliReconstruction::RunAliEVE()
2725 // Runs AliEVE visualisation of
2726 // the current event.
2727 // Should be executed only after
2728 // successful initialization of AliEVE.
2730 AliInfo("Running AliEVE...");
2731 gROOT->ProcessLine(Form("gAliEveEvent->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p);",fRunLoader,fRawReader,fesd));
2732 gROOT->ProcessLine("gAliEveEvent->StartStopAutoLoadTimer();");
2736 //_____________________________________________________________________________
2737 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
2739 // Allows to run QA for a selected set of detectors
2740 // and a selected set of tasks among RAWS, RECPOINTS and ESDS
2741 // all selected detectors run the same selected tasks
2743 if (!detAndAction.Contains(":")) {
2744 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
2748 Int_t colon = detAndAction.Index(":") ;
2749 fQADetectors = detAndAction(0, colon) ;
2750 if (fQADetectors.Contains("ALL") )
2751 fQADetectors = fFillESD ;
2752 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
2753 if (fQATasks.Contains("ALL") ) {
2754 fQATasks = Form("%d %d %d", AliQA::kRAWS, AliQA::kRECPOINTS, AliQA::kESDS) ;
2756 fQATasks.ToUpper() ;
2758 if ( fQATasks.Contains("RAW") )
2759 tempo = Form("%d ", AliQA::kRAWS) ;
2760 if ( fQATasks.Contains("RECPOINT") )
2761 tempo += Form("%d ", AliQA::kRECPOINTS) ;
2762 if ( fQATasks.Contains("ESD") )
2763 tempo += Form("%d ", AliQA::kESDS) ;
2765 if (fQATasks.IsNull()) {
2766 AliInfo("No QA requested\n") ;
2771 TString tempo(fQATasks) ;
2772 tempo.ReplaceAll(Form("%d", AliQA::kRAWS), AliQA::GetTaskName(AliQA::kRAWS)) ;
2773 tempo.ReplaceAll(Form("%d", AliQA::kRECPOINTS), AliQA::GetTaskName(AliQA::kRECPOINTS)) ;
2774 tempo.ReplaceAll(Form("%d", AliQA::kESDS), AliQA::GetTaskName(AliQA::kESDS)) ;
2775 fQASteer->SetActiveDetectors(fQADetectors) ;
2776 fQASteer->SetTasks(fQATasks) ;
2777 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
2782 //_____________________________________________________________________________
2783 Bool_t AliReconstruction::InitRecoParams()
2785 // The method accesses OCDB and retrieves all
2786 // the available reco-param objects from there.
2788 Bool_t isOK = kTRUE;
2790 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
2792 if (fRecoParam.GetDetRecoParamArray(iDet)) {
2793 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
2797 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
2799 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
2800 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
2802 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
2806 TObject *recoParamObj = entry->GetObject();
2807 if (dynamic_cast<TObjArray*>(recoParamObj)) {
2808 // The detector has a normal TobjArray of AliDetectorRecoParam objects
2809 // Registering them in AliRecoParam
2810 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
2812 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
2813 // The detector has only onse set of reco parameters
2814 // Registering it in AliRecoParam
2815 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
2816 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
2817 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
2820 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
2832 //_____________________________________________________________________________
2833 Bool_t AliReconstruction::GetEventInfo()
2835 // Fill the event info object
2837 AliCodeTimerAuto("")
2839 AliCentralTrigger *aCTP = NULL;
2841 fEventInfo.SetEventType(fRawReader->GetType());
2843 ULong64_t mask = fRawReader->GetClassMask();
2844 fEventInfo.SetTriggerMask(mask);
2845 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
2846 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
2848 aCTP = new AliCentralTrigger();
2849 TString configstr("");
2850 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
2851 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
2855 aCTP->SetClassMask(mask);
2856 aCTP->SetClusterMask(clmask);
2859 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
2861 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
2862 aCTP = fRunLoader->GetTrigger();
2863 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
2864 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
2867 AliWarning("No trigger can be loaded! The trigger information will not be used!");
2872 AliTriggerConfiguration *config = aCTP->GetConfiguration();
2874 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
2875 if (fRawReader) delete aCTP;
2879 UChar_t clustmask = 0;
2881 ULong64_t trmask = fEventInfo.GetTriggerMask();
2882 const TObjArray& classesArray = config->GetClasses();
2883 Int_t nclasses = classesArray.GetEntriesFast();
2884 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
2885 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
2887 Int_t trindex = (Int_t)TMath::Log2(trclass->GetMask());
2888 fesd->SetTriggerClass(trclass->GetName(),trindex);
2889 if (trmask & (1 << trindex)) {
2891 trclasses += trclass->GetName();
2893 clustmask |= trclass->GetCluster()->GetClusterMask();
2897 fEventInfo.SetTriggerClasses(trclasses);
2899 // Set the information in ESD
2900 fesd->SetTriggerMask(trmask);
2901 fesd->SetTriggerCluster(clustmask);
2903 if (!aCTP->CheckTriggeredDetectors()) {
2904 if (fRawReader) delete aCTP;
2908 if (fRawReader) delete aCTP;
2910 // We have to fill also the HLT decision here!!
2916 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
2918 // Match the detector list found in the rec.C or the default 'ALL'
2919 // to the list found in the GRP (stored there by the shuttle PP which
2920 // gets the information from ECS)
2921 static TString resultList;
2922 TString detList = detectorList;
2926 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
2927 if ((detectorMask >> iDet) & 0x1) {
2928 TString det = AliDAQ::OfflineModuleName(iDet);
2929 if ((detList.CompareTo("ALL") == 0) ||
2930 detList.BeginsWith("ALL ") ||
2931 detList.EndsWith(" ALL") ||
2932 detList.Contains(" ALL ") ||
2933 (detList.CompareTo(det) == 0) ||
2934 detList.BeginsWith(det) ||
2935 detList.EndsWith(det) ||
2936 detList.Contains( " "+det+" " )) {
2937 if (!resultList.EndsWith(det + " ")) {
2946 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
2947 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
2948 if ((detList.CompareTo("ALL") == 0) ||
2949 detList.BeginsWith("ALL ") ||
2950 detList.EndsWith(" ALL") ||
2951 detList.Contains(" ALL ") ||
2952 (detList.CompareTo(hltDet) == 0) ||
2953 detList.BeginsWith(hltDet) ||
2954 detList.EndsWith(hltDet) ||
2955 detList.Contains( " "+hltDet+" " )) {
2956 resultList += hltDet;
2960 return resultList.Data();