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 **************************************************************************/
16 /* $Id: AliReconstruction.cxx 63911 2013-08-19 16:46:41Z hristov $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the reconstruction //
22 // Clusters and tracks are created for all detectors and all events by //
25 // AliReconstruction rec; //
28 // The Run method returns kTRUE in case of successful execution. //
30 // If the input to the reconstruction are not simulated digits but raw data, //
31 // this can be specified by an argument of the Run method or by the method //
33 // rec.SetInput("..."); //
35 // The input formats and the corresponding argument are: //
36 // - DDL raw data files: directory name, ends with "/" //
37 // - raw data root file: root file name, extension ".root" //
38 // - raw data DATE file: DATE file name, any other non-empty string //
39 // - MC root files : empty string, default //
41 // By default all events are reconstructed. The reconstruction can be //
42 // limited to a range of events by giving the index of the first and the //
43 // last event as an argument to the Run method or by calling //
45 // rec.SetEventRange(..., ...); //
47 // The index -1 (default) can be used for the last event to indicate no //
48 // upper limit of the event range. //
50 // In case of raw-data reconstruction the user can modify the default //
51 // number of events per digits/clusters/tracks file. In case the option //
52 // is not used the number is set 1. In case the user provides 0, than //
53 // the number of events is equal to the number of events inside the //
54 // raw-data file (i.e. one digits/clusters/tracks file): //
56 // rec.SetNumberOfEventsPerFile(...); //
59 // The name of the galice file can be changed from the default //
60 // "galice.root" by passing it as argument to the AliReconstruction //
61 // constructor or by //
63 // rec.SetGAliceFile("..."); //
65 // The local reconstruction can be switched on or off for individual //
68 // rec.SetRunLocalReconstruction("..."); //
70 // The argument is a (case sensitive) string with the names of the //
71 // detectors separated by a space. The special string "ALL" selects all //
72 // available detectors. This is the default. //
74 // The reconstruction of the primary vertex position can be switched off by //
76 // rec.SetRunVertexFinder(kFALSE); //
78 // The tracking and the creation of ESD tracks can be switched on for //
79 // selected detectors by //
81 // rec.SetRunTracking("..."); //
83 // Uniform/nonuniform field tracking switches (default: uniform field) //
85 // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
87 // The filling of additional ESD information can be steered by //
89 // rec.SetFillESD("..."); //
91 // Again, for both methods the string specifies the list of detectors. //
92 // The default is "ALL". //
94 // The call of the shortcut method //
96 // rec.SetRunReconstruction("..."); //
98 // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99 // SetFillESD with the same detector selecting string as argument. //
101 // The reconstruction requires digits or raw data as input. For the creation //
102 // of digits and raw data have a look at the class AliSimulation. //
104 // The input data of a detector can be replaced by the corresponding HLT //
105 // data by calling (usual detector string) //
106 // SetUseHLTData("..."); //
109 ///////////////////////////////////////////////////////////////////////////////
116 #include <TGeoGlobalMagField.h>
117 #include <TGeoManager.h>
119 #include <TLorentzVector.h>
121 #include <TObjArray.h>
122 #include <TPRegexp.h>
123 #include <TParameter.h>
124 #include <TPluginManager.h>
126 #include <TProofOutputFile.h>
129 #include <THashTable.h>
131 #include <TMessage.h>
134 #include <THashList.h>
136 #include "AliAlignObj.h"
137 #include "AliAnalysisManager.h"
138 #include "AliAnalysisDataContainer.h"
139 #include "AliCDBEntry.h"
140 #include "AliCDBManager.h"
141 #include "AliCDBStorage.h"
142 #include "AliCTPRawStream.h"
143 #include "AliCascadeVertexer.h"
144 #include "AliCentralTrigger.h"
145 #include "AliCodeTimer.h"
147 #include "AliDetectorRecoParam.h"
148 #include "AliESDCaloCells.h"
149 #include "AliESDCaloCluster.h"
150 #include "AliESDEvent.h"
151 #include "AliESDMuonTrack.h"
152 #include "AliESDPmdTrack.h"
153 #include "AliESDTagCreator.h"
154 #include "AliESDVertex.h"
155 #include "AliESDcascade.h"
156 #include "AliESDfriend.h"
157 #include "AliESDkink.h"
158 #include "AliESDpid.h"
159 #include "AliESDtrack.h"
160 #include "AliESDtrack.h"
161 #include "AliEventInfo.h"
162 #include "AliGRPObject.h"
163 #include "AliGRPRecoParam.h"
164 #include "AliGenEventHeader.h"
165 #include "AliGeomManager.h"
166 #include "AliGlobalQADataMaker.h"
167 #include "AliHeader.h"
170 #include "AliMultiplicity.h"
172 #include "AliPlaneEff.h"
174 #include "AliQADataMakerRec.h"
175 #include "AliQAManager.h"
176 #include "AliRawVEvent.h"
177 #include "AliRawEventHeaderBase.h"
178 #include "AliRawHLTManager.h"
179 #include "AliRawReaderDate.h"
180 #include "AliRawReaderFile.h"
181 #include "AliRawReaderRoot.h"
182 #include "AliRecoInputHandler.h"
183 #include "AliReconstruction.h"
184 #include "AliReconstructor.h"
186 #include "AliRunInfo.h"
187 #include "AliRunLoader.h"
188 #include "AliSysInfo.h" // memory snapshots
189 #include "AliTrackPointArray.h"
190 #include "AliTracker.h"
191 #include "AliTriggerClass.h"
192 #include "AliTriggerCluster.h"
193 #include "AliTriggerIR.h"
194 #include "AliTriggerConfiguration.h"
195 #include "AliV0vertexer.h"
196 #include "AliVertexer.h"
197 #include "AliTrackleter.h"
198 #include "AliVertexerTracks.h"
199 #include "AliTriggerRunScalers.h"
200 #include "AliCTPTimeParams.h"
201 #include "AliESDHLTDecision.h"
202 #include "AliTriggerInput.h"
203 #include "AliLHCData.h"
204 #include "ARVersion.h"
205 #include <RVersion.h>
207 #include <sys/resource.h>
208 ClassImp(AliReconstruction)
212 //_____________________________________________________________________________
213 const char* AliReconstruction::fgkStopEvFName = "_stopEvent_";
214 const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD",
216 "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE","AD","FIT","MFT", "HLT"};
218 //_____________________________________________________________________________
219 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
221 fRunVertexFinder(kTRUE),
222 fRunVertexFinderTracks(kTRUE),
223 fRunMuonTracking(kFALSE),
224 fRunMFTTrackingMU(kFALSE),
226 fRunCascadeFinder(kTRUE),
227 fRunMultFinder(kTRUE),
229 fStopOnMissingTriggerFile(kTRUE),
230 fWriteAlignmentData(kFALSE),
231 fWriteESDfriend(kFALSE),
232 fFillTriggerESD(kTRUE),
240 fRunLocalReconstruction("ALL"),
243 fDeleteRecPoints(""),
246 fUseTrackingErrorsForAlignment(""),
247 fGAliceFileName(gAliceFilename),
250 fProofOutputFileName(""),
251 fProofOutputLocation(""),
252 fProofOutputDataset(kFALSE),
253 fProofOutputArchive(""),
257 fNumberOfEventsPerFile((UInt_t)-1),
258 fFractionFriends(0.04),
260 fLoadAlignFromCDB(kTRUE),
261 fLoadAlignData("ALL"),
266 fCTPTimeParams(NULL),
271 fParentRawReader(NULL),
275 fSPDTrackleter(NULL),
277 fDiamondProfileSPD(NULL),
278 fDiamondProfile(NULL),
279 fDiamondProfileTPC(NULL),
280 fListOfCosmicTriggers(NULL),
284 fAlignObjArray(NULL),
288 fCheckRecoCDBvsSimuCDB(),
289 fInitCDBCalled(kFALSE),
290 fCDBSnapshotMode(kFALSE),
291 fSetRunNumberFromDataCalled(kFALSE),
296 fSameQACycle(kFALSE),
297 fInitQACalled(kFALSE),
298 fWriteQAExpertData(kTRUE),
299 fRunPlaneEff(kFALSE),
312 fIsNewRunLoader(kFALSE),
321 fTreeBuffSize(30000000),
330 fDeclTriggerClasses(""),
335 // create reconstruction object with default parameters
338 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
339 fReconstructor[iDet] = NULL;
340 fUpgradeMask[iDet]=kFALSE;
341 fLoader[iDet] = NULL;
342 fTracker[iDet] = NULL;
344 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
345 fQACycles[iDet] = 999999 ;
346 fQAWriteExpert[iDet] = kFALSE ;
348 fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
350 AddCheckRecoCDBvsSimuCDB("TPC/Calib/RecoParam"); // check for similarity in the sim and rec
355 //_____________________________________________________________________________
356 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
358 fRunVertexFinder(rec.fRunVertexFinder),
359 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
360 fRunMuonTracking(rec.fRunMuonTracking),
361 fRunMFTTrackingMU(rec.fRunMFTTrackingMU),
362 fRunV0Finder(rec.fRunV0Finder),
363 fRunCascadeFinder(rec.fRunCascadeFinder),
364 fRunMultFinder(rec.fRunMultFinder),
365 fStopOnError(rec.fStopOnError),
366 fStopOnMissingTriggerFile(rec.fStopOnMissingTriggerFile),
367 fWriteAlignmentData(rec.fWriteAlignmentData),
368 fWriteESDfriend(rec.fWriteESDfriend),
369 fFillTriggerESD(rec.fFillTriggerESD),
371 fCleanESD(rec.fCleanESD),
372 fV0DCAmax(rec.fV0DCAmax),
373 fV0CsPmin(rec.fV0CsPmin),
377 fRunLocalReconstruction(rec.fRunLocalReconstruction),
378 fRunTracking(rec.fRunTracking),
379 fFillESD(rec.fFillESD),
380 fDeleteRecPoints(""),
382 fLoadCDB(rec.fLoadCDB),
383 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
384 fGAliceFileName(rec.fGAliceFileName),
385 fRawInput(rec.fRawInput),
386 fESDOutput(rec.fESDOutput),
387 fProofOutputFileName(rec.fProofOutputFileName),
388 fProofOutputLocation(rec.fProofOutputLocation),
389 fProofOutputDataset(rec.fProofOutputDataset),
390 fProofOutputArchive(rec.fProofOutputArchive),
391 fEquipIdMap(rec.fEquipIdMap),
392 fFirstEvent(rec.fFirstEvent),
393 fLastEvent(rec.fLastEvent),
394 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
395 fFractionFriends(rec.fFractionFriends),
397 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
398 fLoadAlignData(rec.fLoadAlignData),
399 fUseHLTData(rec.fUseHLTData),
403 fCTPTimeParams(NULL),
408 fParentRawReader(NULL),
410 fRecoParam(rec.fRecoParam),
412 fSPDTrackleter(NULL),
414 fDiamondProfileSPD(rec.fDiamondProfileSPD),
415 fDiamondProfile(rec.fDiamondProfile),
416 fDiamondProfileTPC(rec.fDiamondProfileTPC),
417 fListOfCosmicTriggers(NULL),
421 fAlignObjArray(rec.fAlignObjArray),
422 fCDBUri(rec.fCDBUri),
423 fQARefUri(rec.fQARefUri),
425 fCheckRecoCDBvsSimuCDB(),
426 fInitCDBCalled(rec.fInitCDBCalled),
427 fCDBSnapshotMode(rec.fCDBSnapshotMode),
428 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
429 fQADetectors(rec.fQADetectors),
430 fQATasks(rec.fQATasks),
432 fRunGlobalQA(rec.fRunGlobalQA),
433 fSameQACycle(rec.fSameQACycle),
434 fInitQACalled(rec.fInitQACalled),
435 fWriteQAExpertData(rec.fWriteQAExpertData),
436 fRunPlaneEff(rec.fRunPlaneEff),
449 fIsNewRunLoader(rec.fIsNewRunLoader),
458 fTreeBuffSize(rec.fTreeBuffSize),
464 fAnalysisMacro(rec.fAnalysisMacro),
467 fDeclTriggerClasses(rec.fDeclTriggerClasses),
474 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
475 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
477 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
478 fReconstructor[iDet] = NULL;
479 fUpgradeMask[iDet] = kFALSE;
480 fLoader[iDet] = NULL;
481 fTracker[iDet] = NULL;
484 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
485 fQACycles[iDet] = rec.fQACycles[iDet];
486 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
489 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
490 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
493 for (Int_t i = 0; i < rec.fCheckRecoCDBvsSimuCDB.GetEntriesFast(); i++) {
494 if (rec.fCheckRecoCDBvsSimuCDB[i]) fCheckRecoCDBvsSimuCDB.AddLast(rec.fCheckRecoCDBvsSimuCDB[i]->Clone());
497 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
501 //_____________________________________________________________________________
502 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
504 // assignment operator
505 // Used in PROOF mode
506 // Be very careful while modifing it!
507 // Simple rules to follow:
508 // for persistent data members - use their assignment operators
509 // for non-persistent ones - do nothing or take the default values from constructor
510 // TSelector members should not be touched
511 if(&rec == this) return *this;
513 fRunVertexFinder = rec.fRunVertexFinder;
514 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
515 fRunMuonTracking = rec.fRunMuonTracking;
516 fRunMFTTrackingMU = rec.fRunMFTTrackingMU;
517 fRunV0Finder = rec.fRunV0Finder;
518 fRunCascadeFinder = rec.fRunCascadeFinder;
519 fRunMultFinder = rec.fRunMultFinder;
520 fStopOnError = rec.fStopOnError;
521 fStopOnMissingTriggerFile = rec.fStopOnMissingTriggerFile;
522 fWriteAlignmentData = rec.fWriteAlignmentData;
523 fWriteESDfriend = rec.fWriteESDfriend;
524 fFillTriggerESD = rec.fFillTriggerESD;
526 fCleanESD = rec.fCleanESD;
527 fV0DCAmax = rec.fV0DCAmax;
528 fV0CsPmin = rec.fV0CsPmin;
532 fRunLocalReconstruction = rec.fRunLocalReconstruction;
533 fRunTracking = rec.fRunTracking;
534 fFillESD = rec.fFillESD;
535 fDeleteRecPoints = rec.fDeleteRecPoints;
536 fDeleteDigits = rec.fDeleteDigits;
537 fLoadCDB = rec.fLoadCDB;
538 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
539 fGAliceFileName = rec.fGAliceFileName;
540 fRawInput = rec.fRawInput;
541 fESDOutput = rec.fESDOutput;
542 fProofOutputFileName = rec.fProofOutputFileName;
543 fProofOutputLocation = rec.fProofOutputLocation;
544 fProofOutputDataset = rec.fProofOutputDataset;
545 fProofOutputArchive = rec.fProofOutputArchive;
546 fEquipIdMap = rec.fEquipIdMap;
547 fFirstEvent = rec.fFirstEvent;
548 fLastEvent = rec.fLastEvent;
549 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
550 fFractionFriends = rec.fFractionFriends;
552 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
553 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
556 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
557 fLoadAlignData = rec.fLoadAlignData;
558 fUseHLTData = rec.fUseHLTData;
560 delete fRunInfo; fRunInfo = NULL;
561 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
563 fEventInfo = rec.fEventInfo;
565 delete fRunScalers; fRunScalers = NULL;
566 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
568 delete fCTPTimeParams; fCTPTimeParams = NULL;
569 if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
570 delete fCTPTimeAlign; fCTPTimeAlign = NULL;
571 if (rec.fCTPTimeAlign) fCTPTimeAlign = new AliCTPTimeParams(*rec.fCTPTimeAlign);
575 fParentRawReader = NULL;
577 fRecoParam = rec.fRecoParam;
579 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
580 fUpgradeMask[iDet] = kFALSE;
581 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
582 delete fLoader[iDet]; fLoader[iDet] = NULL;
583 delete fTracker[iDet]; fTracker[iDet] = NULL;
586 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
587 fQACycles[iDet] = rec.fQACycles[iDet];
588 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
591 delete fSPDTrackleter; fSPDTrackleter = NULL;
593 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
594 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
595 delete fDiamondProfile; fDiamondProfile = NULL;
596 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
597 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
598 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
600 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
601 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
603 delete fGRPData; fGRPData = NULL;
604 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
605 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
607 delete fAlignObjArray; fAlignObjArray = NULL;
610 fQARefUri = rec.fQARefUri;
611 fSpecCDBUri.Delete();
612 fCheckRecoCDBvsSimuCDB.Delete();
614 for (Int_t i = 0; i < rec.fCheckRecoCDBvsSimuCDB.GetEntriesFast(); i++) {
615 if (rec.fCheckRecoCDBvsSimuCDB[i]) fCheckRecoCDBvsSimuCDB.AddLast(rec.fCheckRecoCDBvsSimuCDB[i]->Clone());
618 fInitCDBCalled = rec.fInitCDBCalled;
619 fCDBSnapshotMode = rec.fCDBSnapshotMode;
620 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
621 fQADetectors = rec.fQADetectors;
622 fQATasks = rec.fQATasks;
624 fRunGlobalQA = rec.fRunGlobalQA;
625 fSameQACycle = rec.fSameQACycle;
626 fInitQACalled = rec.fInitQACalled;
627 fWriteQAExpertData = rec.fWriteQAExpertData;
628 fRunPlaneEff = rec.fRunPlaneEff;
629 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
640 fIsNewRunLoader = rec.fIsNewRunLoader;
649 fTreeBuffSize = rec.fTreeBuffSize;
655 fAnalysisMacro = rec.fAnalysisMacro;
658 fDeclTriggerClasses = rec.fDeclTriggerClasses;
663 //_____________________________________________________________________________
664 AliReconstruction::~AliReconstruction()
669 if (fListOfCosmicTriggers) {
670 fListOfCosmicTriggers->Delete();
671 delete fListOfCosmicTriggers;
675 delete fCTPTimeParams;
676 delete fCTPTimeAlign;
678 if (fAlignObjArray) {
679 fAlignObjArray->Delete();
680 delete fAlignObjArray;
682 fSpecCDBUri.Delete();
683 fCheckRecoCDBvsSimuCDB.Delete();
684 AliCodeTimer::Instance()->Print();
687 //_____________________________________________________________________________
688 void AliReconstruction::InitQA()
690 //Initialize the QA and start of cycle
691 AliCodeTimerAuto("",0);
693 if (fInitQACalled) return;
694 fInitQACalled = kTRUE;
696 if (fGRPData) AliQADataMaker::SetCloningRequest( fGRPData->GetQATrigClasses(), fGRPData->GetQACloningRequest());
699 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
700 qam->SetSaveData(kTRUE);
701 qam->SetCycleLength(AliQAv1::kITS, 5) ;
702 if (fWriteQAExpertData)
703 qam->SetWriteExpert() ;
705 if (qam->IsDefaultStorageSet()) {
706 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
707 AliWarning("Default QA reference storage has been already set !");
708 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
709 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
710 fQARefUri = qam->GetDefaultStorage()->GetURI();
712 if (fQARefUri.Length() > 0) {
713 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
714 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
715 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
717 fQARefUri="local://$ALICE_ROOT/QAref";
718 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
719 AliWarning("Default QA refeference storage not yet set !!!!");
720 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
721 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
724 qam->SetDefaultStorage(fQARefUri);
728 qam->SetActiveDetectors(fQADetectors) ;
729 qam->SetActiveOnlineDetectors(fRunInfo->GetActiveDetectors());
731 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
732 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
733 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
735 if (!fRawReader && !fInput && IsInTasks(AliQAv1::kRAWS))
736 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
737 qam->SetTasks(fQATasks) ;
738 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
741 Bool_t sameCycle = kFALSE ;
742 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
743 AliInfo(Form("Initializing the global QA data maker"));
744 if (IsInTasks(AliQAv1::kRECPOINTS)) {
745 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
746 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
747 AliTracker::SetResidualsArray(arr);
750 if (IsInTasks(AliQAv1::kESDS)) {
751 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
752 qadm->Init(AliQAv1::kESDS);
755 AliSysInfo::AddStamp("InitQA") ;
758 //_____________________________________________________________________________
759 void AliReconstruction::MergeQA(const char *fileName)
761 //Initialize the QA and start of cycle
762 AliCodeTimerAuto("",0) ;
763 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
764 AliSysInfo::AddStamp("MergeQA") ;
767 //_____________________________________________________________________________
768 void AliReconstruction::InitCDB()
770 // activate a default CDB storage
771 // First check if we have any CDB storage set, because it is used
772 // to retrieve the calibration and alignment constants
773 AliCodeTimerAuto("",0);
775 if (fInitCDBCalled) return;
776 fInitCDBCalled = kTRUE;
778 AliCDBManager* man = AliCDBManager::Instance();
779 if (man->IsDefaultStorageSet())
781 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
782 AliWarning("Default CDB storage has been already set !");
783 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
784 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
785 fCDBUri = man->GetDefaultStorage()->GetURI();
788 if (fCDBUri.Length() > 0)
790 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
791 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
792 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
793 man->SetDefaultStorage(fCDBUri);
795 else if (!man->GetRaw()){
796 fCDBUri="local://$ALICE_ROOT/OCDB";
797 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
798 AliWarning("Default CDB storage not yet set !!!!");
799 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
800 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
801 man->SetDefaultStorage(fCDBUri);
804 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
805 AliWarning("Default storage will be set after setting the Run Number!!!");
806 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
810 // Now activate the detector specific CDB storage locations
811 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
812 TObject* obj = fSpecCDBUri[i];
814 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
815 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
816 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
817 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
819 AliSysInfo::AddStamp("InitCDB");
822 //_____________________________________________________________________________
823 void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) {
824 fCDBSnapshotMode = kTRUE;
825 AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);
828 //_____________________________________________________________________________
829 void AliReconstruction::SetDefaultStorage(const char* uri) {
830 // Store the desired default CDB storage location
831 // Activate it later within the Run() method
837 //_____________________________________________________________________________
838 void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
839 // Store the desired default CDB storage location
840 // Activate it later within the Run() method
843 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
847 //_____________________________________________________________________________
848 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
849 // Store a detector-specific CDB storage location
850 // Activate it later within the Run() method
852 AliCDBPath aPath(calibType);
853 if(!aPath.IsValid()){
854 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
855 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
856 if(!strcmp(calibType, fgkDetectorName[iDet])) {
857 aPath.SetPath(Form("%s/*", calibType));
858 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
862 if(!aPath.IsValid()){
863 AliError(Form("Not a valid path or detector: %s", calibType));
868 // // check that calibType refers to a "valid" detector name
869 // Bool_t isDetector = kFALSE;
870 // for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
871 // TString detName = fgkDetectorName[iDet];
872 // if(aPath.GetLevel0() == detName) {
873 // isDetector = kTRUE;
879 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
883 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
884 if (obj) fSpecCDBUri.Remove(obj);
885 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
889 //_____________________________________________________________________________
890 void AliReconstruction::AddCheckRecoCDBvsSimuCDB(const char* cdbpath,const char* comment)
892 // require the cdb item to be the same in the rec as in the sim
893 // Activate it later within the Run() method
894 TString newent = cdbpath;
895 if (newent.IsNull()) return;
896 TIter nextit(&fCheckRecoCDBvsSimuCDB);
898 while ((cdbent=(TNamed*)nextit())) {
899 TString str = cdbent->GetName();
901 AliInfo(Form("%s is already in the list to check",cdbpath));
905 fCheckRecoCDBvsSimuCDB.AddLast(new TNamed(cdbpath,comment));
909 //_____________________________________________________________________________
910 void AliReconstruction::RemCheckRecoCDBvsSimuCDB(const char* cdbpath)
912 // require the cdb item to be the same in the rec as in the sim
913 // Activate it later within the Run() method
914 TString newent = cdbpath;
915 if (newent.IsNull()) return;
916 TIter nextit(&fCheckRecoCDBvsSimuCDB);
918 while ((cdbent=(TNamed*)nextit())) {
919 TString str = cdbent->GetName();
921 AliInfo(Form("Removing %s from the list to check",cdbpath));
922 delete fCheckRecoCDBvsSimuCDB.Remove(cdbent);
923 fCheckRecoCDBvsSimuCDB.Compress();
927 AliInfo(Form("%s is not in the list to check",cdbpath));
931 //_____________________________________________________________________________
932 Bool_t AliReconstruction::SetRunNumberFromData()
934 // The method is called in Run() in order
935 // to set a correct run number.
936 // In case of raw data reconstruction the
937 // run number is taken from the raw data header
939 if (fSetRunNumberFromDataCalled) return kTRUE;
940 fSetRunNumberFromDataCalled = kTRUE;
942 AliCDBManager* man = AliCDBManager::Instance();
945 if(fRawReader->NextEvent()) {
946 if(man->GetRun() > 0) {
947 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
949 man->SetRun(fRawReader->GetRunNumber());
951 fRawReader->RewindEvents();
954 if(man->GetRun() > 0) {
955 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
958 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
964 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
966 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
971 // read run number from gAlice
972 if(rl->GetHeader()) {
973 man->SetRun(rl->GetHeader()->GetRun());
978 AliError("Neither run-loader header nor RawReader objects are found !");
990 //_____________________________________________________________________________
991 void AliReconstruction::SetCDBLock() {
992 // Set CDB lock: from now on it is forbidden to reset the run number
993 // or the default storage or to activate any further storage!
995 AliCDBManager::Instance()->SetLock(1);
998 //_____________________________________________________________________________
999 void AliReconstruction::MatchUpgradeDetector() {
1000 // Translates detector name in a boolean.
1001 // The boolean is used in GetReconstructor to load the
1002 // upgrade reconstructor instead of the standard one.
1003 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1004 if(fUpgradeModule.Contains(fgkDetectorName[iDet])) fUpgradeMask[iDet]=kTRUE;
1007 //_____________________________________________________________________________
1008 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
1010 // Read the alignment objects from CDB.
1011 // Each detector is supposed to have the
1012 // alignment objects in DET/Align/Data CDB path.
1013 // All the detector objects are then collected,
1014 // sorted by geometry level (starting from ALIC) and
1015 // then applied to the TGeo geometry.
1016 // Finally an overlaps check is performed.
1018 // Load alignment data from CDB and fill fAlignObjArray
1019 if(fLoadAlignFromCDB){
1021 TString detStr = detectors;
1022 TString loadAlObjsListOfDets = "";
1024 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1025 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1026 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
1028 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
1030 loadAlObjsListOfDets += fgkDetectorName[iDet];
1031 loadAlObjsListOfDets += " ";
1033 } // end loop over detectors
1035 if(AliGeomManager::GetNalignable("GRP") != 0)
1036 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
1037 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
1039 // Check if the array with alignment objects was
1040 // provided by the user. If yes, apply the objects
1041 // to the present TGeo geometry
1042 if (fAlignObjArray) {
1043 if (gGeoManager && gGeoManager->IsClosed()) {
1044 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
1045 AliError("The misalignment of one or more volumes failed!"
1046 "Compare the list of simulated detectors and the list of detector alignment data!");
1051 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
1057 if (fAlignObjArray) {
1058 fAlignObjArray->Delete();
1059 delete fAlignObjArray; fAlignObjArray=NULL;
1065 //_____________________________________________________________________________
1066 void AliReconstruction::SetGAliceFile(const char* fileName)
1068 // set the name of the galice file
1070 fGAliceFileName = fileName;
1073 //_____________________________________________________________________________
1074 void AliReconstruction::SetInput(const char* input)
1076 // In case the input string starts with 'mem://', we run in an online mode
1077 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
1078 // file is assumed. One can give as an input:
1079 // mem://: - events taken from DAQ monitoring libs online
1081 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
1082 if (input) fRawInput = input;
1085 //_____________________________________________________________________________
1086 void AliReconstruction::SetOutput(const char* output)
1088 // Set the output ESD filename
1089 // 'output' is a normalt ROOT url
1090 // The method is used in case of raw-data reco with PROOF
1091 if (output) fESDOutput = output;
1094 //_____________________________________________________________________________
1095 void AliReconstruction::SetOption(const char* detector, const char* option)
1097 // set options for the reconstruction of a detector
1099 TObject* obj = fOptions.FindObject(detector);
1100 if (obj) fOptions.Remove(obj);
1101 fOptions.Add(new TNamed(detector, option));
1104 //_____________________________________________________________________________
1105 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1107 // Set custom reconstruction parameters for a given detector
1108 // Single set of parameters for all the events
1110 // First check if the reco-params are global
1111 if(!strcmp(detector, "GRP")) {
1112 par->SetAsDefault();
1113 fRecoParam.AddDetRecoParam(kNDetectors,par);
1117 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1118 if(!strcmp(detector, fgkDetectorName[iDet])) {
1119 par->SetAsDefault();
1120 fRecoParam.AddDetRecoParam(iDet,par);
1127 //_____________________________________________________________________________
1128 Bool_t AliReconstruction::InitGRP() {
1129 //------------------------------------
1130 // Initialization of the GRP entry
1131 //------------------------------------
1132 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
1136 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
1139 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
1141 fGRPData = new AliGRPObject();
1142 fGRPData->ReadValuesFromMap(m);
1146 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
1147 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
1151 // FIX ME: The unloading of GRP entry is temporarily disabled
1152 // because ZDC and VZERO are using it in order to initialize
1153 // their reconstructor objects. In the future one has to think
1154 // of propagating AliRunInfo to the reconstructors.
1155 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
1159 AliError("No GRP entry found in OCDB!");
1163 TString lhcState = fGRPData->GetLHCState();
1164 if (lhcState==AliGRPObject::GetInvalidString()) {
1165 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
1166 lhcState = "UNKNOWN";
1169 TString beamType = fGRPData->GetBeamType();
1170 if (beamType==AliGRPObject::GetInvalidString()) {
1171 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
1172 beamType = "UNKNOWN";
1175 Float_t beamEnergy = fGRPData->GetBeamEnergy();
1176 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
1177 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
1181 TString runType = fGRPData->GetRunType();
1182 if (runType==AliGRPObject::GetInvalidString()) {
1183 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
1184 runType = "UNKNOWN";
1187 Int_t activeDetectors = fGRPData->GetDetectorMask();
1188 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
1189 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
1190 activeDetectors = 1074790399;
1192 AliDebug(1, Form("activeDetectors = %d", activeDetectors));
1194 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
1198 // Process the list of active detectors
1199 if (activeDetectors) {
1200 UInt_t detMask = activeDetectors;
1201 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1202 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
1203 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1204 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1205 fFillESD = MatchDetectorList(fFillESD,detMask);
1206 fQADetectors = MatchDetectorList(fQADetectors,detMask);
1207 AliInfo(Form("fQADetectors=%s",fQADetectors.Data()));
1208 fDeleteRecPoints = MatchDetectorList(fDeleteRecPoints,detMask);
1209 fDeleteDigits = MatchDetectorList(fDeleteDigits,detMask);
1210 fLoadCDB.Form("%s %s %s %s",
1211 fRunLocalReconstruction.Data(),
1212 fRunTracking.Data(),
1214 fQADetectors.Data());
1215 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
1216 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1) &&
1217 !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
1218 !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
1219 // switch off the vertexer
1220 AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer and Trackleter are switched off.");
1221 fRunVertexFinder = kFALSE;
1222 fRunMultFinder = kFALSE;
1224 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1225 // switch off the reading of CTP raw-data payload
1226 if (fFillTriggerESD) {
1227 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1228 fFillTriggerESD = kFALSE;
1233 AliInfo("===================================================================================");
1234 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1235 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1236 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
1237 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
1238 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
1239 AliInfo("===================================================================================");
1241 //*** Dealing with the magnetic field map
1242 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1243 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1244 AliInfo("ExpertMode!!! GRP information will be ignored !");
1245 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1248 AliInfo("Destroying existing B field instance!");
1249 delete TGeoGlobalMagField::Instance();
1252 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
1253 // Construct the field map out of the information retrieved from GRP.
1256 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1257 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1258 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1262 Char_t l3Polarity = fGRPData->GetL3Polarity();
1263 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1264 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1269 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1270 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1271 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1275 Char_t diPolarity = fGRPData->GetDipolePolarity();
1276 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1277 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1281 // read special bits for the polarity convention and map type
1282 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1283 Bool_t uniformB = fGRPData->IsUniformBMap();
1286 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1287 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1288 polConvention,uniformB,beamEnergy, beamType.Data());
1290 TGeoGlobalMagField::Instance()->SetField( fld );
1291 TGeoGlobalMagField::Instance()->Lock();
1292 AliInfo("Running with the B field constructed out of GRP !");
1294 else AliFatal("Failed to create a B field map !");
1296 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1299 //*** Get the diamond profiles from OCDB
1300 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1302 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1304 AliError("No SPD diamond profile found in OCDB!");
1307 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1309 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1311 AliError("No diamond profile found in OCDB!");
1314 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1316 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1318 AliError("No TPC diamond profile found in OCDB!");
1321 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1323 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1327 if (!fListOfCosmicTriggers) {
1328 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1334 //_____________________________________________________________________________
1335 Bool_t AliReconstruction::LoadCDB()
1337 // Load CDB entries for all active detectors.
1338 // By default we load all the entries in <det>/Calib
1341 AliCodeTimerAuto("",0);
1343 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1345 AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
1347 TString detStr = fLoadCDB;
1348 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1349 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1350 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1351 AliCDBManager::Instance()->GetAll(Form("%s/Trigger/*",fgkDetectorName[iDet]));
1354 // Temporary fix - one has to define the correct policy in order
1355 // to load the trigger OCDB entries only for the detectors that
1356 // in the trigger or that are needed in order to put correct
1357 // information in ESD
1358 AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
1359 AliCDBManager::Instance()->GetAll("HLT/*/*");
1363 //_____________________________________________________________________________
1364 Bool_t AliReconstruction::LoadTriggerScalersCDB()
1366 // Load CTP scalers from OCDB.
1367 // The scalers are checked for consistency.
1369 AliCodeTimerAuto("",0);
1371 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
1375 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1376 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1378 if (fRunScalers && (fRunScalers->CorrectScalersOverflow() == 0)) AliInfo("32bit Trigger counters corrected for overflow");
1383 //_____________________________________________________________________________
1384 Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
1386 // Load CTP timing information (alignment)
1389 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
1390 if (!entry) return kFALSE;
1392 AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
1393 fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
1396 AliCDBEntry* entry2 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
1397 if (!entry2) return kFALSE;
1399 AliInfo("Found an AliCTPTimeParams in GRP/CTP/TimeAlign, reading it");
1400 fCTPTimeAlign = dynamic_cast<AliCTPTimeParams*> (entry2->GetObject());
1401 entry2->SetOwner(0);
1406 //_____________________________________________________________________________
1407 Bool_t AliReconstruction::ReadIntensityInfoCDB()
1409 // Load LHC DIP data
1410 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/LHCData");
1411 AliCDBEntry* entryCTP = AliCDBManager::Instance()->Get("GRP/CTP/Config");
1413 if (!entry || !entryCTP) {
1414 AliError(Form("Failed to extract CDB objects GRP/GRP/LHCData: %p or GRP/CTP/Config: %p",entry,entryCTP));
1418 enum {kA,kB,kC,kE,kNMasks};
1419 AliTriggerConfiguration* conf = (AliTriggerConfiguration*)entryCTP->GetObject();
1420 const TObjArray& clArr = conf->GetClasses();
1421 TObjArray masks(kNMasks);
1423 AliTriggerClass* trClass = 0;
1425 masks.SetOwner(kFALSE);
1427 while ( (trClass=(AliTriggerClass*)next()) ) {
1428 TString trName = trClass->GetName();
1429 int ind = trName.Index("-"); // prefix in front of A,B,C,E
1430 if (ind<1) continue; // anomaly
1432 trName = trName.Data() + ind;
1433 AliTriggerBCMask* bcMask = trClass->GetBCMask();
1434 if (!bcMask) continue;
1436 if (trName.BeginsWith("-A-")) which |= 0x1<<kA;
1437 else if (trName.BeginsWith("-B-")) which |= 0x1<<kB;
1438 else if (trName.BeginsWith("-C-")) which |= 0x1<<kC;
1439 else if (trName.BeginsWith("-E-")) which |= 0x1<<kE;
1440 else if (trName.BeginsWith("-AC-")) which |= (0x1<<kA) | (0x1<<kC);
1441 else if (trName.BeginsWith("-CA-")) which |= (0x1<<kA) | (0x1<<kC);
1442 else { AliWarning(Form("Unknown trigger type %s\n",trClass->GetName())); continue;}
1444 for (int ip=kNMasks;ip--;) {
1445 if ( !(which&(0x1<<ip)) || masks[ip] ) continue; // does not match or already done
1446 masks[ip] = (TObject*)bcMask;
1449 if (nFound==kNMasks) break;
1452 AliInfo("Reading mean bunch intensities from GRP/GRP/LHCData");
1453 AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
1455 for (int ib=2;ib--;) {
1457 if (dipData && (dipData->GetMeanIntensity(ib,intI,intNI,&masks)>=0)) {
1458 fBeamInt[ib][0] = intI;
1459 fBeamInt[ib][1] = intNI;
1460 AliInfo(Form("Mean intensity for beam %d: Interacting:%.2e Non-Interacting:%.2e",ib,intI,intNI));
1468 //_____________________________________________________________________________
1469 Bool_t AliReconstruction::Run(const char* input)
1472 AliCodeTimerAuto("",0);
1475 if (GetAbort() != TSelector::kContinue) return kFALSE;
1477 TChain *chain = NULL;
1478 if (fRawReader && (chain = fRawReader->GetChain())) {
1479 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
1482 // Temporary fix for long raw-data runs (until socket timeout handling in PROOF is revised)
1483 gProof->Exec("gEnv->SetValue(\"Proof.SocketActivityTimeout\",-1)", kTRUE);
1486 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1488 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1489 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1491 gProof->AddInput(this);
1493 if (!ParseOutput()) return kFALSE;
1495 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
1497 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
1500 chain->Process(this,"",nEntries,fFirstEvent);
1505 if (GetAbort() != TSelector::kContinue) return kFALSE;
1507 if (GetAbort() != TSelector::kContinue) return kFALSE;
1508 //******* The loop over events
1509 AliInfo("Starting looping over events");
1511 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1512 (fRawReader && fRawReader->NextEvent())) {
1514 // check if process has enough resources
1515 if (!HasEnoughResources(iEvent)) break;
1516 if (!ProcessEvent(iEvent)) {
1517 Abort("ProcessEvent",TSelector::kAbortFile);
1520 CleanProcessedEvent();
1523 if (!iEvent) AliWarning("No events passed trigger selection");
1525 if (GetAbort() != TSelector::kContinue) return kFALSE;
1527 if (GetAbort() != TSelector::kContinue) return kFALSE;
1533 //_____________________________________________________________________________
1534 void AliReconstruction::InitRawReader(const char* input)
1536 // Init raw-reader and
1537 // set the input in case of raw data
1539 AliCodeTimerAuto("",0);
1541 if (input) fRawInput = input;
1542 fRawReader = AliRawReader::Create(fRawInput.Data());
1544 if (fRawInput.IsNull()) {
1545 AliInfo("Reconstruction will run over digits");
1548 AliFatal("Can not create raw-data reader ! Exiting...");
1552 if (!fEquipIdMap.IsNull() && fRawReader)
1553 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1555 if (!fUseHLTData.IsNull()) {
1556 // create the RawReaderHLT which performs redirection of HLT input data for
1557 // the specified detectors
1558 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1560 fParentRawReader=fRawReader;
1561 fRawReader=pRawReader;
1563 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1566 AliSysInfo::AddStamp("CreateRawReader");
1569 //_____________________________________________________________________________
1570 void AliReconstruction::InitRun(const char* input)
1572 // Initialization of raw-reader,
1573 // run number, CDB etc.
1574 AliCodeTimerAuto("",0);
1575 AliSysInfo::AddStamp("Start");
1577 // Initialize raw-reader if any
1578 InitRawReader(input);
1580 // Initialize the CDB storage
1583 // Set run number in CDBManager (if it is not already set by the user)
1584 if (!SetRunNumberFromData()) {
1585 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1589 // Set CDB lock: from now on it is forbidden to reset the run number
1590 // or the default storage or to activate any further storage!
1595 //_____________________________________________________________________________
1596 void AliReconstruction::Begin(TTree *)
1598 // Initialize AlReconstruction before
1599 // going into the event loop
1600 // Should follow the TSelector convention
1601 // i.e. initialize only the object on the client side
1602 AliCodeTimerAuto("",0);
1604 AliReconstruction *reco = NULL;
1606 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1609 AliSysInfo::AddStamp("ReadInputInBegin");
1612 // Import ideal TGeo geometry and apply misalignment
1613 if (!AliGeomManager::GetGeometry()) {
1614 TString geom(gSystem->DirName(fGAliceFileName));
1615 geom += "/geometry.root";
1616 AliGeomManager::LoadGeometry(geom.Data());
1618 Abort("LoadGeometry", TSelector::kAbortProcess);
1621 AliSysInfo::AddStamp("LoadGeom");
1622 TString detsToCheck=fRunLocalReconstruction;
1623 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1624 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1627 AliSysInfo::AddStamp("CheckGeom");
1630 Bool_t toCDBSnapshot=kFALSE;
1631 TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
1632 // in reading from and writing to a snapshot file at the same time
1633 if(TString(getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){
1634 toCDBSnapshot=kTRUE;
1635 //fFromCDBSnapshot=kFALSE;
1636 TString snapshotFile(getenv("OCDB_SNAPSHOT_FILENAME"));
1637 if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace()))
1638 snapshotFileOut = snapshotFile;
1640 snapshotFileOut="OCDB.root";
1643 if (!MisalignGeometry(fLoadAlignData)) {
1644 Abort("MisalignGeometry", TSelector::kAbortProcess);
1648 const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache();
1649 if(cdbCache->Contains("GRP/Geometry/Data"))
1650 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1651 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1652 AliSysInfo::AddStamp("MisalignGeom");
1655 Abort("InitGRP", TSelector::kAbortProcess);
1658 AliSysInfo::AddStamp("InitGRP");
1660 if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
1661 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1663 if(!fCDBSnapshotMode || toCDBSnapshot){
1665 Abort("LoadCDB", TSelector::kAbortProcess);
1668 AliSysInfo::AddStamp("LoadCDB");
1671 if (!LoadTriggerScalersCDB()) {
1672 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1675 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1677 if (!LoadCTPTimeParamsCDB()) {
1678 Abort("LoadCTPTimeParamsCDB", TSelector::kAbortProcess);
1681 AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
1683 if (!ReadIntensityInfoCDB()) {
1684 Abort("ReadIntensityInfoCDB", TSelector::kAbortProcess);
1687 AliSysInfo::AddStamp("ReadIntensityInfoCDB");
1689 // Read the reconstruction parameters from OCDB
1690 if (!InitRecoParams()) {
1691 AliWarning("Not all detectors have correct RecoParam objects initialized");
1693 AliSysInfo::AddStamp("InitRecoParams");
1697 AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
1698 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1699 if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
1700 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1703 if (fInput && gProof) {
1704 if (reco) *reco = *this;
1706 gGeoManager->SetName("Geometry");
1707 gProof->AddInputData(gGeoManager,kTRUE);
1709 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
1710 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1711 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1712 magFieldMap->SetName("MagneticFieldMap");
1713 gProof->AddInputData(magFieldMap,kTRUE);
1715 fAnalysis->SetName("Analysis");
1716 gProof->AddInputData(fAnalysis,kTRUE);
1722 //_____________________________________________________________________________
1723 void AliReconstruction::SlaveBegin(TTree*)
1725 // Initialization related to run-loader,
1726 // vertexer, trackers, recontructors
1727 // In proof mode it is executed on the slave
1728 AliCodeTimerAuto("",0);
1730 TProofOutputFile *outProofFile = NULL;
1732 if (AliDebugLevel() > 0) fInput->Print();
1733 if (AliDebugLevel() > 10) fInput->Dump();
1734 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1737 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1739 AliGeomManager::SetGeometry(tgeo);
1741 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1742 Int_t runNumber = -1;
1743 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1744 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1745 man->SetCacheFlag(kTRUE);
1746 man->SetLock(kTRUE);
1750 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1751 AliMagF *newMap = new AliMagF(*map);
1752 if (!newMap->LoadParameterization()) {
1753 Abort("AliMagF::LoadParameterization", TSelector::kAbortProcess);
1756 TGeoGlobalMagField::Instance()->SetField(newMap);
1757 TGeoGlobalMagField::Instance()->Lock();
1760 // Attempt to get the analysis manager from the input list
1761 fAnalysis = (AliAnalysisManager*)fInput->FindObject("Analysis");
1762 if (fAnalysis) AliInfo("==== Analysis manager retrieved from input list ====");
1764 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1765 fProofOutputFileName = outputFileName->GetTitle();
1766 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1767 fProofOutputLocation = outputLocation->GetTitle();
1768 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1769 fProofOutputDataset = kTRUE;
1770 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1771 fProofOutputArchive = archiveList->GetTitle();
1772 if (!fProofOutputFileName.IsNull() &&
1773 !fProofOutputLocation.IsNull() &&
1774 fProofOutputArchive.IsNull()) {
1775 if (!fProofOutputDataset) {
1776 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1777 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1780 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1782 if (AliDebugLevel() > 0) outProofFile->Dump();
1783 fOutput->Add(outProofFile);
1785 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1787 // Check if analysis was requested in the reconstruction event loop
1789 // Attempt to connect in-memory singleton
1790 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1791 if (fAnalysis) AliInfo(Form("==== Analysis manager <%s> found in memory ====", fAnalysis->GetName()));
1792 // Check if an analysis macro was specified
1793 if (!fAnalysis && !fAnalysisMacro.IsNull()) {
1794 // Run specified analysis macro
1795 gROOT->ProcessLine(Form(".x %s",fAnalysisMacro.Data()));
1796 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1797 if (!fAnalysis) AliError(Form("No analysis manager produced by analysis macro %s", fAnalysisMacro.Data()));
1798 else AliInfo(Form("==== Analysis manager <%s> produced by analysis macro <%s> ====",
1799 fAnalysis->GetName(), fAnalysisMacro.Data()));
1803 // get the run loader
1804 if (!InitRunLoader()) {
1805 Abort("InitRunLoader", TSelector::kAbortProcess);
1808 AliSysInfo::AddStamp("LoadLoader");
1810 CheckRecoCDBvsSimuCDB();
1812 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1815 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1816 Abort("CreateTrackers", TSelector::kAbortProcess);
1819 AliSysInfo::AddStamp("CreateTrackers");
1821 // create the ESD output file and tree
1822 if (!outProofFile) {
1823 ffile = TFile::Open("AliESDs.root", "RECREATE");
1824 ffile->SetCompressionLevel(2);
1825 if (!ffile->IsOpen()) {
1826 Abort("OpenESDFile", TSelector::kAbortProcess);
1831 AliInfo(Form("Opening output PROOF file: %s/%s",
1832 outProofFile->GetDir(), outProofFile->GetFileName()));
1833 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1834 Abort(Form("Problems opening output PROOF file: %s/%s",
1835 outProofFile->GetDir(), outProofFile->GetFileName()),
1836 TSelector::kAbortProcess);
1841 ftree = new TTree("esdTree", "Tree with ESD objects");
1842 fesd = new AliESDEvent();
1843 fesd->CreateStdContent();
1844 // add a so far non-std object to the ESD, this will
1845 // become part of the std content
1846 fesd->AddObject(new AliESDHLTDecision);
1848 fesd->WriteToTree(ftree);
1849 if (fWriteESDfriend) {
1850 ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
1851 ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
1852 fesdf = new AliESDfriend();
1853 ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf);
1854 fesd->AddObject(fesdf);
1857 ftree->GetUserInfo()->Add(fesd);
1859 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1860 fhltesd = new AliESDEvent();
1861 fhltesd->CreateStdContent();
1862 // read the ESD template from CDB
1863 // HLT is allowed to put non-std content to its ESD, the non-std
1864 // objects need to be created before invocation of WriteToTree in
1865 // order to create all branches. Initialization is done from an
1866 // ESD layout template in CDB
1867 AliCDBManager* man = AliCDBManager::Instance();
1868 AliCDBEntry* hltESDConfig = man->Get("HLT/Calib/esdLayout");
1870 AliError(Form("Error getting \"HLT/Calib/esdLayout\""));
1873 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1875 // init all internal variables from the list of objects
1876 pESDLayout->GetStdContent();
1878 // copy content and create non-std objects
1879 *fhltesd=*pESDLayout;
1882 AliError(Form("error setting hltEsd layout from \"HLT/Calib/esdLayout\": invalid object type"));
1885 fhltesd->WriteToTree(fhlttree);
1886 fhlttree->GetUserInfo()->Add(fhltesd);
1888 ProcInfo_t procInfo;
1889 gSystem->GetProcInfo(&procInfo);
1890 AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
1893 fESDpid = new AliESDpid();
1896 //Initialize the QA and start of cycle
1897 if (fRunQA || fRunGlobalQA)
1900 //Initialize the Plane Efficiency framework
1901 if (fRunPlaneEff && !InitPlaneEff()) {
1902 Abort("InitPlaneEff", TSelector::kAbortProcess);
1906 if (strcmp(gProgName,"alieve") == 0)
1907 fRunAliEVE = InitAliEVE();
1908 // If we have an analysis manager, connect the AliRecoInputHandler here
1910 if (!dynamic_cast<AliRecoInputHandler*>(fAnalysis->GetInputEventHandler())) {
1911 AliError("Analysis manager used in reconstruction should use AliRecoInputHandler - \
1912 \n ->Replacing with AliRecoInputHandler instance.");
1913 delete fAnalysis->GetInputEventHandler();
1915 // Set the event and other data pointers
1916 fRecoHandler = new AliRecoInputHandler();
1917 // fRecoHandler->Init(ftree, "LOCAL");
1918 fRecoHandler->SetEvent(fesd);
1919 fRecoHandler->SetESDfriend(fesdf);
1920 fRecoHandler->SetHLTEvent(fhltesd);
1921 fRecoHandler->SetHLTTree(fhlttree);
1922 fAnalysis->SetInputEventHandler(fRecoHandler);
1923 // Enter external loop mode
1924 fAnalysis->SetExternalLoop(kTRUE);
1925 // Initialize analysis
1926 fAnalysis->SlaveBegin(ftree);
1927 fAnalysis->StartAnalysis("local", (TTree*)0);
1928 // Connect ESD tree with the input container
1929 fAnalysis->GetCommonInputContainer()->SetData(ftree);
1934 //_____________________________________________________________________________
1935 Bool_t AliReconstruction::Process(Long64_t entry)
1937 // run the reconstruction over a single entry
1938 // from the chain with raw data
1939 AliCodeTimerAuto("",0);
1941 TTree *currTree = fChain->GetTree();
1942 AliRawVEvent *event = NULL;
1943 currTree->SetBranchAddress("rawevent",&event);
1944 currTree->GetEntry(entry);
1945 fRawReader = new AliRawReaderRoot(event);
1946 // check if process has enough resources
1947 if (!HasEnoughResources(entry)) return kFALSE;
1948 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1956 //_____________________________________________________________________________
1957 void AliReconstruction::Init(TTree *tree)
1959 // Implementation of TSelector::Init()
1962 AliError("The input tree is not found!");
1968 //_____________________________________________________________________________
1969 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1971 // run the reconstruction over a single event
1972 // The event loop is steered in Run method
1975 static Long_t oldMres=0;
1976 static Long_t oldMvir=0;
1977 static Float_t oldCPU=0;
1978 // static Long_t aveDMres=0;
1979 // static Long_t aveDMvir=0;
1980 // static Float_t aveDCPU=0;
1982 AliCodeTimerAuto("",0);
1984 AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
1986 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1987 fRunLoader->SetEventNumber(iEvent);
1989 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1991 fRunLoader->TreeE()->Fill();
1993 if (fRawReader && fRawReader->UseAutoSaveESD())
1994 fRunLoader->TreeE()->AutoSave("SaveSelf");
1997 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
2002 fRunLoader->GetEvent(iEvent);
2004 // Fill Event-info object
2006 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
2008 ProcInfo_t procInfo;
2009 if(iEvent==fFirstEvent) {
2010 gSystem->GetProcInfo(&procInfo);
2011 oldMres=procInfo.fMemResident;
2012 oldMvir=procInfo.fMemVirtual;
2013 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
2015 AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
2017 AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent);
2019 // Set the reco-params
2021 TString detStr = fLoadCDB;
2022 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2023 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2024 AliReconstructor *reconstructor = GetReconstructor(iDet);
2025 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
2026 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2027 reconstructor->SetRecoParam(par);
2028 reconstructor->GetPidSettings(fESDpid);
2029 reconstructor->SetEventInfo(&fEventInfo);
2031 AliQAManager::QAManager()->SetEventInfo(&fEventInfo) ;
2032 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
2033 if (par) AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
2038 if (fRunQA || fRunGlobalQA) AliQADataMaker::SetEventTrigClasses(fEventInfo.GetTriggerClasses()); // RS: select which histo clones are to be filled
2041 const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
2042 AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ;
2043 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
2048 if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
2049 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2050 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
2051 AliSysInfo::AddStamp(Form("RawQA_%d",iEvent), 0,0,iEvent);
2054 // fill Event header information from the RawEventHeader
2055 if (fRawReader){FillRawEventHeaderESD(fesd);}
2056 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
2058 // Store DAQ detector pattern and attributes
2059 fesd->SetDAQDetectorPattern(fRawReader->GetDetectorPattern()[0]);
2060 fesd->SetDAQAttributes(fRawReader->GetAttributes()[2]);
2063 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
2064 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
2066 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
2067 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
2068 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
2069 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
2071 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
2072 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
2074 fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
2075 fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
2077 // Set magnetic field from the tracker
2078 fesd->SetMagneticField(AliTracker::GetBz());
2079 fhltesd->SetMagneticField(AliTracker::GetBz());
2081 AliESDRun *esdRun,*esdRunH;
2082 esdRun = (AliESDRun*)fesd->GetESDRun();
2083 esdRunH = (AliESDRun*)fhltesd->GetESDRun();
2084 esdRun->SetBeamEnergyIsSqrtSHalfGeV();
2085 esdRunH->SetBeamEnergyIsSqrtSHalfGeV();
2087 for (int ib=2;ib--;) for (int it=2;it--;) {
2088 esdRun->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2089 esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2092 fesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2093 fesd->SetBeamType(fGRPData->GetBeamType().Data());
2094 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2095 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2096 fhltesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2097 fhltesd->SetBeamType(fGRPData->GetBeamType().Data());
2098 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2099 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2101 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
2102 if (fld) { // set info needed for field initialization
2103 fesd->SetCurrentL3(fld->GetCurrentSol());
2104 fesd->SetCurrentDip(fld->GetCurrentDip());
2105 fesd->SetUniformBMap(fld->IsUniform());
2106 fesd->SetBInfoStored();
2108 fhltesd->SetCurrentL3(fld->GetCurrentSol());
2109 fhltesd->SetCurrentDip(fld->GetCurrentDip());
2110 fhltesd->SetUniformBMap(fld->IsUniform());
2111 fhltesd->SetBInfoStored();
2115 // run full HLT reconstruction first
2118 TString detectors=fRunLocalReconstruction;
2119 if (IsSelected("HLT", detectors) &&
2120 !RunLocalEventReconstruction("HLT")) {
2121 if (fStopOnError) {CleanUp(); return kFALSE;}
2124 // run HLT on hltesd
2125 if (IsSelected("HLT", detectors) &&
2126 !FillESD(fhltesd, "HLT")) {
2127 if (fStopOnError) {CleanUp(); return kFALSE;}
2131 // local single event reconstruction
2132 if (!fRunLocalReconstruction.IsNull()) {
2133 TString detectors=fRunLocalReconstruction;
2134 // the logic for selection and correct sequence of reconstruction relies on the
2135 // full list of detectors. Keyword 'ALL' should have been replaced at this point.
2136 if (detectors.Contains("ALL")) {
2137 AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
2138 "fRunLocalReconstruction. This should have been done by the framework");
2140 detectors.ReplaceAll("HLT", "");
2141 if (!RunLocalEventReconstruction(detectors)) {
2151 // Set most probable pt, for B=0 tracking
2152 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
2153 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
2154 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
2156 // Fill raw-data error log into the ESD
2157 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
2159 AliSysInfo::AddStamp(Form("FillHeadErrs_%d",iEvent), 0,0,iEvent);
2162 if (fRunVertexFinder) {
2163 if (!RunVertexFinder(fesd)) {
2164 if (fStopOnError) {CleanUp(); return kFALSE;}
2166 AliSysInfo::AddStamp(Form("VtxFinder_%d",iEvent), 0,0,iEvent);
2169 // For Plane Efficiency: run the SPD trackleter
2170 if (fRunPlaneEff && fSPDTrackleter) {
2171 if (!RunSPDTrackleting(fesd)) {
2172 if (fStopOnError) {CleanUp(); return kFALSE;}
2174 AliSysInfo::AddStamp(Form("TrackletEff_%d",iEvent), 0,0,iEvent);
2178 if (!fRunTracking.IsNull()) {
2179 if (fRunMuonTracking) {
2180 if (!RunMuonTracking(fesd)) {
2181 if (fStopOnError) {CleanUp(); return kFALSE;}
2184 AliSysInfo::AddStamp(Form("TrackingMUON_%d",iEvent), 0,0,iEvent);
2187 //---------------- AU From here...
2189 // MFT tracking of MUON tracks
2190 if (!fRunTracking.IsNull()) {
2191 if (fRunMFTTrackingMU && fRunMuonTracking) {
2192 if (!RunMFTTrackingMU(fesd)) {
2193 if (fStopOnError) {CleanUp(); return kFALSE;}
2196 AliSysInfo::AddStamp(Form("TrackingMFT_MUON_%d",iEvent), 0,0,iEvent);
2199 //---------------- ...to here
2202 if (!fRunTracking.IsNull()) {
2203 if (!RunTracking(fesd,*fESDpid)) {
2204 if (fStopOnError) {CleanUp(); return kFALSE;}
2209 if (!fFillESD.IsNull()) {
2210 TString detectors=fFillESD;
2211 // the logic for selection and correct sequence of reconstruction relies on the
2212 // full list of detectors. Keyword 'ALL' should have been replaced at this point.
2213 if (detectors.Contains("ALL")) {
2214 AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
2215 "fFillESD. This should have been done by the framework");
2217 // remove HLT as this has been executed at the beginning of the event reconstruction
2218 detectors.ReplaceAll("HLT", "");
2219 if (!FillESD(fesd, detectors)) {
2220 if (fStopOnError) {CleanUp(); return kFALSE;}
2227 // Propagate track to the beam pipe (if not already done by ITS)
2229 const Int_t ntracks = fesd->GetNumberOfTracks();
2230 const Double_t kRadius = 2.8; //something less than the beam pipe radius
2233 UShort_t selectedIdx[ntracks];
2235 for (Int_t itrack=0; itrack<ntracks; itrack++){
2236 const Double_t kMaxStep = 1; //max step over the material
2239 AliESDtrack *track = fesd->GetTrack(itrack);
2240 if (!track) continue;
2242 AliExternalTrackParam *tpcTrack =
2243 (AliExternalTrackParam *)track->GetTPCInnerParam();
2247 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
2250 Int_t n=trkArray.GetEntriesFast();
2251 selectedIdx[n]=track->GetID();
2252 trkArray.AddLast(tpcTrack);
2255 //Tracks refitted by ITS should already be at the SPD vertex
2256 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
2259 PropagateTrackToBxByBz(track,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
2260 Double_t x[3]; track->GetXYZ(x);
2261 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2262 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
2265 AliSysInfo::AddStamp(Form("RelToSPDVtx_%d",iEvent), 0,0,iEvent);
2267 // Improve the reconstructed primary vertex position using the tracks
2269 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
2270 if(fesd->GetPrimaryVertexSPD()) {
2271 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
2272 if(vtitle.Contains("cosmics")) {
2273 runVertexFinderTracks=kFALSE;
2277 if (runVertexFinderTracks) {
2278 // TPC + ITS primary vertex
2279 ftVertexer->SetITSMode();
2280 ftVertexer->SetConstraintOff();
2281 // get cuts for vertexer from AliGRPRecoParam
2282 Bool_t constrSPD=kFALSE;
2284 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2285 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2286 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer,nCutsVertexer);
2287 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2288 delete [] cutsVertexer; cutsVertexer = NULL;
2289 if(grpRecoParam->GetVertexerTracksConstraintITS()) {
2290 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius){
2291 ftVertexer->SetVtxStart(fDiamondProfile); // apply constraint only if sigmax is smaller than the beam pipe radius
2293 if(fDiamondProfileSPD && fDiamondProfileSPD->GetXRes()<kRadius){
2294 ftVertexer->SetVtxStart(fDiamondProfileSPD);
2300 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
2303 TString title=pvtx->GetTitle();
2304 title.Append("SPD");
2305 pvtx->SetTitle(title);
2307 if (pvtx->GetStatus()) {
2308 fesd->SetPrimaryVertexTracks(pvtx);
2309 for (Int_t i=0; i<ntracks; i++) {
2310 AliESDtrack *t = fesd->GetTrack(i);
2311 Double_t x[3]; t->GetXYZ(x);
2312 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2313 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
2316 delete pvtx; pvtx=NULL;
2318 AliSysInfo::AddStamp(Form("VtxTrk_%d",iEvent), 0,0,iEvent);
2320 // TPC-only primary vertex
2321 ftVertexer->SetTPCMode();
2322 ftVertexer->SetConstraintOff();
2323 // get cuts for vertexer from AliGRPRecoParam
2325 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2326 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2327 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer,nCutsVertexer);
2328 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2329 delete [] cutsVertexer; cutsVertexer = NULL;
2330 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC()) {
2331 if(fDiamondProfileTPC->GetXRes()<kRadius) ftVertexer->SetVtxStart(fDiamondProfileTPC); // apply constraint only if sigmax is smaller than the beam pipe radius
2334 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
2336 if (pvtx->GetStatus()) {
2337 fesd->SetPrimaryVertexTPC(pvtx);
2338 for (Int_t i=0; i<ntracks; i++) {
2339 AliESDtrack *t = fesd->GetTrack(i);
2340 Double_t x[3]; t->GetXYZ(x);
2341 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2342 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
2345 delete pvtx; pvtx=NULL;
2347 AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);
2351 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
2352 else fesd->SetDiamond(fDiamondProfileSPD);
2356 AliV0vertexer vtxer;
2357 // get cuts for V0vertexer from AliGRPRecoParam
2359 Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
2360 Double_t cutsV0vertexer[nCutsV0vertexer];
2361 grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
2362 vtxer.SetCuts(cutsV0vertexer);
2364 vtxer.Tracks2V0vertices(fesd);
2365 AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent);
2367 if (fRunCascadeFinder) {
2369 AliCascadeVertexer cvtxer;
2370 // get cuts for CascadeVertexer from AliGRPRecoParam
2372 Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
2373 Double_t cutsCascadeVertexer[nCutsCascadeVertexer];
2374 grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
2375 cvtxer.SetCuts(cutsCascadeVertexer);
2377 cvtxer.V0sTracks2CascadeVertices(fesd);
2378 AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,iEvent);
2383 if (fReconstructor[3])
2384 GetReconstructor(3)->FillEventTimeWithTOF(fesd,fESDpid);
2387 // fESDpid->MakePID(fesd);
2389 if (fFillTriggerESD) {
2390 if (!FillTriggerESD(fesd)) {
2391 if (fStopOnError) {CleanUp(); return kFALSE;}
2394 // Always fill scalers
2395 if (!FillTriggerScalers(fesd)) {
2396 if (fStopOnError) {CleanUp(); return kFALSE;}
2399 AliSysInfo::AddStamp(Form("FillVaria_%d",iEvent), 0,0,iEvent);
2402 UInt_t specie = fesd->GetEventSpecie();
2403 Bool_t keepAll = (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib);
2404 if (fCleanESD && (!keepAll) ) {
2406 AliSysInfo::AddStamp(Form("CleanESD_%d",iEvent), 0,0,iEvent);
2409 // RS run updated trackleter: since we want to mark the clusters used by tracks and also mark the
2410 // tracks interpreted as primary, this step should be done in the very end, when full
2411 // ESD info is available (particulalry, V0s)
2413 if (fRunMultFinder) {
2414 if (!RunMultFinder(fesd)) {
2415 if (fStopOnError) {CleanUp(); return kFALSE;}
2417 AliSysInfo::AddStamp(Form("MultFinder_%d",iEvent), 0,0,iEvent);
2420 if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
2421 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2422 AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ;
2423 AliSysInfo::AddStamp(Form("RunQA_%d",iEvent), 0,0,iEvent);
2426 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2428 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2429 if (qadm && IsInTasks(AliQAv1::kESDS))
2430 qadm->Exec(AliQAv1::kESDS, fesd);
2431 AliSysInfo::AddStamp(Form("RunGlobQA_%d",iEvent), 0,0,iEvent);
2434 // copy HLT decision from HLTesd to esd
2435 // the most relevant information is stored in a reduced container in the esd,
2436 // while the full information can be found in the HLTesd
2437 TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
2438 TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
2439 if (pHLTSrc && pHLTTgt) {
2440 pHLTSrc->Copy(*pHLTTgt);
2443 // Perform analysis of this event if requested
2444 // RS: Should be done before WriteESDfriend, since the latter may clean the esdfriend
2446 fRecoHandler->BeginEvent(iEvent);
2447 fAnalysis->ExecAnalysis();
2448 fRecoHandler->FinishEvent();
2449 AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);
2452 if (fWriteESDfriend) {
2453 fesd->GetESDfriend(fesdf);
2454 AliSysInfo::AddStamp(Form("CreateFriend_%d",iEvent), 0,0,iEvent);
2459 nbf = ftree->Fill();
2460 if (fTreeBuffSize>0 && ftree->GetAutoFlush()<0 && (fMemCountESD += nbf)>fTreeBuffSize ) { // default limit is still not reached
2461 nbf = ftree->GetZipBytes();
2462 if (nbf>0) nbf = -nbf;
2463 else nbf = ftree->GetEntries();
2464 ftree->SetAutoFlush(nbf);
2465 AliInfo(Form("Calling ftree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
2466 nbf,fMemCountESD,ftree->GetTotBytes(),ftree->GetZipBytes()));
2468 AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);
2470 if (fWriteESDfriend) {
2472 AliSysInfo::AddStamp(Form("WriteFriend_%d",iEvent), 0,0,iEvent);
2476 // Auto-save the ESD tree in case of prompt reco @P2
2477 if (fRawReader && fRawReader->UseAutoSaveESD()) {
2478 ftree->AutoSave("SaveSelf");
2479 if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
2483 nbf = fhlttree->Fill();
2484 if (fTreeBuffSize>0 && fhlttree->GetAutoFlush()<0 && (fMemCountESDHLT += nbf)>fTreeBuffSize ) { // default limit is still not reached
2485 nbf = fhlttree->GetZipBytes();
2486 if (nbf>0) nbf = -nbf;
2487 else nbf = fhlttree->GetEntries();
2488 fhlttree->SetAutoFlush(nbf);
2489 AliInfo(Form("Calling fhlttree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
2490 nbf,fMemCountESDHLT,fhlttree->GetTotBytes(),fhlttree->GetZipBytes()));
2497 void AliReconstruction::CleanProcessedEvent()
2502 if (fWriteESDfriend) {
2503 fesdf->~AliESDfriend();
2504 new (fesdf) AliESDfriend(); // Reset...
2507 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2508 if (fReconstructor[iDet]) fReconstructor[iDet]->FinishEvent();
2511 AliInfo("======================= End Event ===================");
2514 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2515 if (fReconstructor[iDet]) {
2516 fReconstructor[iDet]->SetRecoParam(NULL);
2517 fReconstructor[iDet]->SetEventInfo(NULL);
2519 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
2522 if (fRunQA || fRunGlobalQA)
2523 AliQAManager::QAManager()->Increment() ;
2525 DeleteRecPoints(fDeleteRecPoints);
2526 DeleteDigits(fDeleteDigits);
2531 //_____________________________________________________________________________
2532 void AliReconstruction::SlaveTerminate()
2534 // Finalize the run on the slave side
2535 // Called after the exit
2536 // from the event loop
2537 AliCodeTimerAuto("",0);
2538 // If analysis was done during reconstruction, we need to call SlaveTerminate for it
2540 fAnalysis->PackOutput(fOutput);
2541 fAnalysis->SetSkipTerminate(kTRUE);
2542 fAnalysis->Terminate();
2545 if (fIsNewRunLoader) { // galice.root didn't exist
2546 fRunLoader->WriteHeader("OVERWRITE");
2547 fRunLoader->WriteTrigger("OVERWRITE");
2548 fRunLoader->CdGAFile();
2549 fRunLoader->Write(0, TObject::kOverwrite);
2552 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
2553 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
2555 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
2556 cdbMapCopy->SetOwner(1);
2557 cdbMapCopy->SetName("cdbMap");
2558 TIter iter(cdbMap->GetTable());
2561 while((pair = dynamic_cast<TPair*> (iter.Next()))){
2562 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
2563 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
2564 if (keyStr && valStr)
2565 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
2568 TList *cdbListCopy = new TList();
2569 cdbListCopy->SetOwner(1);
2570 cdbListCopy->SetName("cdbList");
2572 TIter iter2(cdbList);
2575 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
2576 cdbListCopy->Add(new TObjString(id->ToString().Data()));
2579 ftree->GetUserInfo()->Add(cdbMapCopy);
2580 ftree->GetUserInfo()->Add(cdbListCopy);
2582 // Add the AliRoot version that created this file
2583 TString sVersion("aliroot ");
2584 sVersion += ALIROOT_BRANCH;
2586 sVersion += ALIROOT_REVISION;
2587 sVersion += "; root ";
2588 #ifdef ROOT_SVN_BRANCH
2589 sVersion += ROOT_SVN_BRANCH;
2590 #elif defined(ROOT_GIT_BRANCH)
2591 sVersion += ROOT_GIT_BRANCH;
2596 #ifdef ROOT_SVN_REVSION
2597 sVersion += ROOT_SVN_REVISION;
2598 #elif defined(ROOT_GIT_COMMIT)
2599 sVersion += ROOT_GIT_COMMIT;
2603 sVersion += "; metadata ";
2604 sVersion += getenv("PRODUCTION_METADATA");
2607 TNamed * alirootVersion = new TNamed("alirootVersion",sVersion.Data());
2608 ftree->GetUserInfo()->Add(alirootVersion); // The list becomes owner of alirootVersion
2612 // we want to have only one tree version number
2613 ftree->Write(ftree->GetName(),TObject::kOverwrite);
2614 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
2616 if (fWriteESDfriend) {
2618 ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
2621 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
2622 if (fRunPlaneEff && !FinishPlaneEff()) {
2623 AliWarning("Finish PlaneEff evaluation failed");
2626 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2627 if (fReconstructor[iDet]) fReconstructor[iDet]->Terminate();
2629 // End of cycle for the in-loop
2631 if (fRunQA || fRunGlobalQA) {
2632 AliQAManager::QAManager()->EndOfCycle() ;
2634 !fProofOutputLocation.IsNull() &&
2635 fProofOutputArchive.IsNull() &&
2636 !fProofOutputDataset) {
2637 TString qaOutputFile(Form("%sMerged.%s.Data.root",
2638 fProofOutputLocation.Data(),
2639 AliQAv1::GetQADataFileName()));
2640 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
2641 AliQAv1::GetQADataFileName()));
2642 qaProofFile->SetOutputFileName(qaOutputFile.Data());
2643 if (AliDebugLevel() > 0) qaProofFile->Dump();
2644 fOutput->Add(qaProofFile);
2645 MergeQA(qaProofFile->GetFileName());
2656 if (!fProofOutputFileName.IsNull() &&
2657 !fProofOutputLocation.IsNull() &&
2658 fProofOutputDataset &&
2659 !fProofOutputArchive.IsNull()) {
2660 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2662 fProofOutputLocation.Data());
2663 if (AliDebugLevel() > 0) zipProofFile->Dump();
2664 fOutput->Add(zipProofFile);
2665 TString fileList(fProofOutputArchive.Data());
2666 fileList.ReplaceAll(","," ");
2668 #if ROOT_SVN_REVISION >= 30174
2669 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(kTRUE),zipProofFile->GetFileName(),fileList.Data());
2671 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(),zipProofFile->GetFileName(),fileList.Data());
2673 AliInfo(Form("Executing: %s",command.Data()));
2674 gSystem->Exec(command.Data());
2679 //_____________________________________________________________________________
2680 void AliReconstruction::Terminate()
2682 // Create tags for the events in the ESD tree (the ESD tree is always present)
2683 // In case of empty events the tags will contain dummy values
2684 AliCodeTimerAuto("",0);
2686 // Do not call the ESD tag creator in case of PROOF-based reconstruction
2688 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2689 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
2690 delete esdtagCreator;
2693 // Cleanup of CDB manager: cache and active storages!
2694 AliCDBManager::Instance()->ClearCache();
2697 //_____________________________________________________________________________
2698 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2700 // run the local reconstruction
2702 static Int_t eventNr=0;
2703 AliCodeTimerAuto("",0)
2705 TString detStr = detectors;
2706 // execute HLT reconstruction first since other detector reconstruction
2707 // might depend on HLT data
2708 // key 'HLT' is removed from detStr by IsSelected
2709 if (IsSelected("HLT", detStr)) {
2710 AliReconstructor* reconstructor = GetReconstructor(kNDetectors-1);
2711 if (reconstructor) {
2712 // there is no AliLoader for HLT, see
2713 // https://savannah.cern.ch/bugs/?35473
2714 AliInfo("running reconstruction for HLT");
2716 AliInfo("reconstructor->Reconstruct(fRawReader, NULL)");
2717 reconstructor->Reconstruct(fRawReader, NULL);
2720 AliInfo("reconstructor->Reconstruct(dummy, NULL)");
2722 reconstructor->Reconstruct(dummy, NULL);
2725 AliSysInfo::AddStamp(Form("LRecHLT_%d",eventNr), -1,1,eventNr);
2728 AliInfo(Form("kNDetectors = %d",kNDetectors));
2730 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2731 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2732 AliDebug(1, Form("Detector: %s", fgkDetectorName[iDet]));
2733 AliReconstructor* reconstructor = GetReconstructor(iDet);
2734 if (!reconstructor) continue;
2735 AliLoader* loader = fLoader[iDet];
2737 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2740 // conversion of digits
2741 if (fRawReader && reconstructor->HasDigitConversion()) {
2742 AliInfo(Form("converting raw data digits into root objects for %s",
2743 fgkDetectorName[iDet]));
2744 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
2745 // fgkDetectorName[iDet]),0);
2746 loader->LoadDigits("update");
2747 loader->CleanDigits();
2748 loader->MakeDigitsContainer();
2749 TTree* digitsTree = loader->TreeD();
2750 reconstructor->ConvertDigits(fRawReader, digitsTree);
2751 loader->WriteDigits("OVERWRITE");
2752 loader->UnloadDigits();
2754 // local reconstruction
2755 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
2756 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]),0);
2757 AliDebug(1, "Loading Rec Points");
2758 loader->LoadRecPoints("update");
2759 AliDebug(1, "Cleaning Rec Points");
2760 loader->CleanRecPoints();
2761 AliDebug(1, "Making Rec Points Container");
2762 loader->MakeRecPointsContainer();
2763 TTree* clustersTree = loader->TreeR();
2764 if (fRawReader && !reconstructor->HasDigitConversion()) {
2765 reconstructor->Reconstruct(fRawReader, clustersTree);
2768 AliDebug(1, "Loading Digits");
2769 loader->LoadDigits("read");
2770 TTree* digitsTree = loader->TreeD();
2771 AliDebug(1, Form("Digits Tree = %p",digitsTree));
2773 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
2778 AliDebug(1, "Digits -> Clusters");
2779 reconstructor->Reconstruct(digitsTree, clustersTree);
2780 if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
2781 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2782 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
2785 loader->UnloadDigits();
2787 if (fRunQA && IsInTasks(AliQAv1::kRECPOINTS)) {
2788 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2789 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
2791 loader->WriteRecPoints("OVERWRITE");
2792 loader->UnloadRecPoints();
2793 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2795 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
2796 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2797 AliError(Form("the following detectors were not found: %s",
2805 //_____________________________________________________________________________
2806 Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2808 // run the SPD trackleting (for SPD efficiency purpouses)
2810 AliCodeTimerAuto("",0)
2812 Double_t vtxPos[3] = {0, 0, 0};
2813 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2819 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2820 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2821 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2824 const AliESDVertex *vertex = esd->GetVertex();
2826 AliWarning("Vertex not found");
2829 vertex->GetXYZ(vtxPos);
2830 vertex->GetSigmaXYZ(vtxErr);
2831 if (fSPDTrackleter) {
2832 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2835 fLoader[0]->LoadRecPoints("read");
2836 TTree* tree = fLoader[0]->TreeR();
2838 AliError("Can't get the ITS cluster tree");
2841 fSPDTrackleter->LoadClusters(tree);
2842 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2844 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
2845 AliWarning("AliITSTrackleterSPDEff Clusters2Tracks failed");
2846 // fLoader[0]->UnloadRecPoints();
2849 //fSPDTrackleter->UnloadRecPoints();
2851 AliWarning("SPDTrackleter not available");
2857 //_____________________________________________________________________________
2858 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
2860 // run the barrel tracking
2862 AliCodeTimerAuto("",0)
2864 AliVertexer *vertexer = CreateVertexer();
2865 if (!vertexer) return kFALSE;
2867 AliInfo(Form("running the ITS vertex finder: %s",vertexer->ClassName()));
2868 AliESDVertex* vertex = NULL;
2870 fLoader[0]->LoadRecPoints();
2871 TTree* cltree = fLoader[0]->TreeR();
2873 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2874 vertex = vertexer->FindVertexForCurrentEvent(cltree);
2877 AliError("Can't get the ITS cluster tree");
2879 fLoader[0]->UnloadRecPoints();
2882 AliError("Can't get the ITS loader");
2885 AliWarning("Vertex not found");
2886 vertex = new AliESDVertex();
2887 vertex->SetName("default");
2890 vertex->SetName("reconstructed");
2895 vertex->GetXYZ(vtxPos);
2896 vertex->GetSigmaXYZ(vtxErr);
2898 esd->SetPrimaryVertexSPD(vertex);
2899 AliESDVertex *vpileup = NULL;
2900 Int_t novertices = 0;
2901 vpileup = vertexer->GetAllVertices(novertices);
2903 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2906 // if SPD multiplicity has been determined, it is stored in the ESD
2907 AliMultiplicity *mult = vertexer->GetMultiplicity();
2908 if(mult)esd->SetMultiplicity(mult);
2910 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2911 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2920 //_____________________________________________________________________________
2921 Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
2923 // run the trackleter for multiplicity study
2925 AliCodeTimerAuto("",0)
2927 AliTrackleter *trackleter = CreateMultFinder();
2928 if (!trackleter) return kFALSE;
2930 AliInfo(Form("running the ITS multiplicity finder: %s",trackleter->ClassName()));
2933 fLoader[0]->LoadRecPoints();
2934 TTree* cltree = fLoader[0]->TreeR();
2936 trackleter->Reconstruct(esd,cltree);
2937 AliMultiplicity *mult = trackleter->GetMultiplicity();
2938 if(mult) esd->SetMultiplicity(mult);
2941 AliError("Can't get the ITS cluster tree");
2943 fLoader[0]->UnloadRecPoints();
2946 AliError("Can't get the ITS loader");
2954 //_____________________________________________________________________________
2955 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2957 // run the muon spectrometer tracking
2959 AliCodeTimerAuto("",0)
2962 AliError("Missing runLoader!");
2965 Int_t iDet = GetDetIndex("MUON"); // for MUON
2967 // Get a pointer to the MUON reconstructor
2968 AliReconstructor *reconstructor = GetReconstructor(iDet);
2969 if (!reconstructor) return kFALSE;
2972 TString detName = fgkDetectorName[iDet];
2973 AliDebug(1, Form("%s tracking", detName.Data()));
2974 AliTracker *tracker = reconstructor->CreateTracker();
2976 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2981 fLoader[iDet]->LoadRecPoints("read");
2983 tracker->LoadClusters(fLoader[iDet]->TreeR());
2985 Int_t rv = tracker->Clusters2Tracks(esd);
2987 fLoader[iDet]->UnloadRecPoints();
2989 tracker->UnloadClusters();
2993 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
3001 //_____________________________________________________________________________
3002 Bool_t AliReconstruction::RunMFTTrackingMU(AliESDEvent*& esd) {
3006 // run the global muon tracking: matching the MUON tracks with the MFT clusters
3008 AliCodeTimerAuto("",0)
3011 AliError("Missing runLoader!");
3014 Int_t iDet = GetDetIndex("MFT"); // for MFT
3016 // Get a pointer to the MFT reconstructor
3017 AliReconstructor *reconstructor = GetReconstructor(iDet);
3018 if (!reconstructor) return kFALSE;
3020 TString detName = fgkDetectorName[iDet];
3021 AliDebug(1, Form("%s tracking for muon tracks", detName.Data()));
3022 AliTracker *tracker = reconstructor->CreateTracker();
3024 AliWarning(Form("couldn't create a Muon tracker for %s", detName.Data()));
3029 fLoader[iDet]->LoadRecPoints("read");
3031 tracker->LoadClusters(fLoader[iDet]->TreeR());
3033 Int_t rv = tracker->Clusters2Tracks(esd);
3035 fLoader[iDet]->UnloadRecPoints();
3037 tracker->UnloadClusters();
3040 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
3048 //_____________________________________________________________________________
3049 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
3051 // run the barrel tracking
3052 static Int_t eventNr=0;
3053 AliCodeTimerAuto("",0)
3055 AliInfo("running tracking");
3057 // Set the event info which is used
3058 // by the trackers in order to obtain
3059 // information about read-out detectors,
3061 AliDebug(1, "Setting event info");
3062 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3063 if (!fTracker[iDet]) continue;
3064 fTracker[iDet]->SetEventInfo(&fEventInfo);
3067 //Fill the ESD with the T0 info (will be used by the TOF)
3068 if (fReconstructor[11] && fLoader[11]) {
3069 fLoader[11]->LoadRecPoints("READ");
3070 TTree *treeR = fLoader[11]->TreeR();
3072 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
3076 // pass 1: TPC + ITS inwards
3077 for (Int_t iDet = 1; iDet >= 0; iDet--) {
3078 if (!fTracker[iDet]) continue;
3079 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
3082 fLoader[iDet]->LoadRecPoints("read");
3083 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
3084 TTree* tree = fLoader[iDet]->TreeR();
3086 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
3089 fTracker[iDet]->LoadClusters(tree);
3090 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
3092 if (fTracker[iDet]->Clusters2TracksHLT(esd, fhltesd) != 0) {
3093 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
3096 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
3097 // preliminary PID in TPC needed by the ITS tracker
3099 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
3100 PID.MakePIDForTracking(esd);
3101 AliSysInfo::AddStamp(Form("MakePID0%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
3105 // pass 2: ALL backwards
3107 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3108 if (!fTracker[iDet]) continue;
3109 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
3112 if (iDet > 1) { // all except ITS, TPC
3114 fLoader[iDet]->LoadRecPoints("read");
3115 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
3116 tree = fLoader[iDet]->TreeR();
3118 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
3121 fTracker[iDet]->LoadClusters(tree);
3122 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
3126 if (iDet>1) // start filling residuals for the "outer" detectors
3128 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
3129 TObjArray ** arr = AliTracker::GetResidualsArray() ;
3131 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3132 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3133 if ( elem && (! elem->At(0)) ) {
3134 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3135 if (qadm) qadm->InitRecPointsForTracker() ;
3138 // AliSysInfo::AddStamp(Form("QAInitResid%s_%d",fgkDetectorName[iDet],eventNr), iDet,0, eventNr);
3140 if (fTracker[iDet]->PropagateBack(esd) != 0) {
3141 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
3144 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3147 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
3148 fTracker[iDet]->UnloadClusters();
3149 fLoader[iDet]->UnloadRecPoints();
3151 // updated PID in TPC needed by the ITS tracker -MI
3153 //GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
3154 //AliESDpid::MakePID(esd);
3155 PID.MakePIDForTracking(esd);
3156 AliSysInfo::AddStamp(Form("MakePID1%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
3160 //stop filling residuals for the "outer" detectors
3161 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3163 // pass 3: TRD + TPC + ITS refit inwards
3165 for (Int_t iDet = 2; iDet >= 0; iDet--) {
3166 if (!fTracker[iDet]) continue;
3167 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
3170 if (iDet<2) // start filling residuals for TPC and ITS
3172 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
3173 TObjArray ** arr = AliTracker::GetResidualsArray() ;
3175 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3176 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3177 if ( elem && (! elem->At(0)) ) {
3178 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3179 if (qadm) qadm->InitRecPointsForTracker() ;
3184 if (fTracker[iDet]->RefitInward(esd) != 0) {
3185 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
3188 // run postprocessing
3189 if (fTracker[iDet]->PostProcess(esd) != 0) {
3190 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
3193 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3196 // write space-points to the ESD in case alignment data output
3198 if (fWriteAlignmentData) {
3199 WriteAlignmentData(esd);
3200 AliSysInfo::AddStamp(Form("WrtAlignData_%d",eventNr), 0,0, eventNr);
3203 for (Int_t iDet = 3; iDet >= 0; iDet--) {
3204 if (!fTracker[iDet]) continue;
3206 fTracker[iDet]->UnloadClusters();
3207 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
3208 fLoader[iDet]->UnloadRecPoints();
3209 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
3211 // stop filling residuals for TPC and ITS
3212 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3218 //_____________________________________________________________________________
3219 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
3221 // Remove the data which are not needed for the physics analysis.
3224 Int_t nTracks=esd->GetNumberOfTracks();
3225 Int_t nV0s=esd->GetNumberOfV0s();
3227 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
3229 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
3230 Bool_t rc=esd->Clean(cleanPars);
3232 nTracks=esd->GetNumberOfTracks();
3233 nV0s=esd->GetNumberOfV0s();
3235 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
3240 //_____________________________________________________________________________
3241 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
3243 // fill the event summary data
3245 AliCodeTimerAuto("",0)
3246 static Int_t eventNr=0;
3247 TString detStr = detectors;
3249 AliSysInfo::AddStamp(Form("FillESDb%d",eventNr), -19,-19, eventNr);
3250 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3251 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3252 AliReconstructor* reconstructor = GetReconstructor(iDet);
3253 if (!reconstructor) continue;
3254 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
3255 TTree* clustersTree = NULL;
3256 if (fLoader[iDet]) {
3257 fLoader[iDet]->LoadRecPoints("read");
3258 clustersTree = fLoader[iDet]->TreeR();
3259 if (!clustersTree) {
3260 AliError(Form("Can't get the %s clusters tree",
3261 fgkDetectorName[iDet]));
3262 if (fStopOnError) return kFALSE;
3265 if (fRawReader && !reconstructor->HasDigitConversion()) {
3266 reconstructor->FillESD(fRawReader, clustersTree, esd);
3268 TTree* digitsTree = NULL;
3269 if (fLoader[iDet]) {
3270 fLoader[iDet]->LoadDigits("read");
3271 digitsTree = fLoader[iDet]->TreeD();
3273 AliError(Form("Can't get the %s digits tree",
3274 fgkDetectorName[iDet]));
3275 if (fStopOnError) return kFALSE;
3278 reconstructor->FillESD(digitsTree, clustersTree, esd);
3279 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
3281 if (fLoader[iDet]) {
3282 fLoader[iDet]->UnloadRecPoints();
3286 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
3287 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
3288 AliError(Form("the following detectors were not found: %s",
3290 if (fStopOnError) return kFALSE;
3292 AliSysInfo::AddStamp(Form("FillESDe%d",eventNr), -20,-20, eventNr);
3297 //_____________________________________________________________________________
3298 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
3300 // Reads the trigger decision which is
3301 // stored in Trigger.root file and fills
3302 // the corresponding esd entries
3304 AliCodeTimerAuto("",0)
3306 AliInfo("Filling trigger information into the ESD");
3309 AliCTPRawStream input(fRawReader);
3310 if (!input.Next()) {
3311 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
3314 if (esd->GetTriggerMask() != input.GetClassMask())
3315 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
3316 input.GetClassMask(),esd->GetTriggerMask()));
3317 if (esd->GetOrbitNumber() != input.GetOrbitID())
3318 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
3319 input.GetOrbitID(),esd->GetOrbitNumber()));
3320 if (esd->GetBunchCrossNumber() != input.GetBCID())
3321 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
3322 input.GetBCID(),esd->GetBunchCrossNumber()));
3323 AliESDHeader* esdheader = esd->GetHeader();
3324 esdheader->SetL0TriggerInputs(input.GetL0Inputs());
3325 esdheader->SetL1TriggerInputs(input.GetL1Inputs());
3326 esdheader->SetL2TriggerInputs(input.GetL2Inputs());
3328 // UInt_t orbit=input.GetOrbitID();
3329 for(Int_t i=0 ; i<input.GetNIRs() ; i++ ) {
3330 esdheader->AddTriggerIR(input.GetIR(i));
3332 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
3334 rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
3335 rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
3336 rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
3339 if (fIsNewRunLoader) fRunLoader->TreeCT()->Fill();
3343 //_____________________________________________________________________________
3344 Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
3347 //fRunScalers->Print();
3348 if(fRunScalers && fRunScalers->CheckRunScalers()){
3349 AliTimeStamp* timestamp = new AliTimeStamp(esd->GetOrbitNumber(), esd->GetPeriodNumber(), esd->GetBunchCrossNumber());
3350 //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
3351 AliESDHeader* esdheader = fesd->GetHeader();
3352 for(Int_t i=0;i<50;i++){
3353 if((1ull<<i) & esd->GetTriggerMask()){
3354 AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
3355 if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
3358 const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp);
3359 const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun();
3360 if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent);
3361 if (scalrecRun) esdheader->SetTriggerScalersDeltaRun(scalrecRun);
3365 //_____________________________________________________________________________
3366 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
3369 // Filling information from RawReader Header
3372 if (!fRawReader) return kFALSE;
3374 AliInfo("Filling information from RawReader Header");
3376 esd->SetBunchCrossNumber(fRawReader->GetBCID());
3377 esd->SetOrbitNumber(fRawReader->GetOrbitID());
3378 esd->SetPeriodNumber(fRawReader->GetPeriod());
3380 esd->SetTimeStamp(fRawReader->GetTimestamp());
3381 esd->SetEventType(fRawReader->GetType());
3387 //_____________________________________________________________________________
3388 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
3390 // check whether detName is contained in detectors
3391 // if yes, it is removed from detectors
3393 // check if all detectors are selected
3394 if ((detectors.CompareTo("ALL") == 0) ||
3395 detectors.BeginsWith("ALL ") ||
3396 detectors.EndsWith(" ALL") ||
3397 detectors.Contains(" ALL ")) {
3402 // search for the given detector
3403 Bool_t result = kFALSE;
3404 if ((detectors.CompareTo(detName) == 0) ||
3405 detectors.BeginsWith(detName+" ") ||
3406 detectors.EndsWith(" "+detName) ||
3407 detectors.Contains(" "+detName+" ")) {
3408 detectors.ReplaceAll(detName, "");
3412 // clean up the detectors string
3413 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
3414 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
3415 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
3420 //_____________________________________________________________________________
3421 Bool_t AliReconstruction::InitRunLoader()
3423 // get or create the run loader
3425 if (gAlice) delete gAlice;
3428 TFile *gafile = TFile::Open(fGAliceFileName.Data());
3429 // if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
3430 if (gafile) { // galice.root exists
3434 // load all base libraries to get the loader classes
3435 TString libs = gSystem->GetLibraries();
3436 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3437 TString detName = fgkDetectorName[iDet];
3438 if (libs.Contains("lib" + detName + "base.so")) continue;
3439 gSystem->Load("lib" + detName + "base.so");
3441 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
3443 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
3448 fRunLoader->CdGAFile();
3449 fRunLoader->LoadgAlice();
3451 //PH This is a temporary fix to give access to the kinematics
3452 //PH that is needed for the labels of ITS clusters
3453 fRunLoader->LoadHeader();
3454 fRunLoader->LoadKinematics();
3456 } else { // galice.root does not exist
3458 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
3460 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
3461 AliConfig::GetDefaultEventFolderName(),
3464 AliError(Form("could not create run loader in file %s",
3465 fGAliceFileName.Data()));
3469 fIsNewRunLoader = kTRUE;
3470 fRunLoader->MakeTree("E");
3471 fRunLoader->MakeTree("GG");
3473 if (fNumberOfEventsPerFile > 0)
3474 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
3476 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
3482 //_____________________________________________________________________________
3483 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
3485 // get the reconstructor object and the loader for a detector
3487 if (fReconstructor[iDet]) {
3488 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3489 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3490 fReconstructor[iDet]->SetRecoParam(par);
3491 fReconstructor[iDet]->SetRunInfo(fRunInfo);
3493 return fReconstructor[iDet];
3496 // load the reconstructor object
3497 TPluginManager* pluginManager = gROOT->GetPluginManager();
3498 TString detName = fgkDetectorName[iDet];
3499 TString recName = "Ali" + detName + "Reconstructor";
3501 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
3503 AliReconstructor* reconstructor = NULL;
3504 // first check if a plugin is defined for the reconstructor
3505 TPluginHandler* pluginHandler =
3506 pluginManager->FindHandler("AliReconstructor", detName);
3507 // if not, add a plugin for it
3508 if (!pluginHandler) {
3509 AliDebug(1, Form("defining plugin for %s", recName.Data()));
3510 TString libs = gSystem->GetLibraries();
3511 if (libs.Contains("lib" + detName + "base.so") ||
3512 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
3513 pluginManager->AddHandler("AliReconstructor", detName,
3514 recName, detName + "rec", recName + "()");
3516 pluginManager->AddHandler("AliReconstructor", detName,
3517 recName, detName, recName + "()");
3519 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
3521 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3522 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
3525 // check if the upgrade reconstructor should be used instead of the standard one
3526 if(fUpgradeMask[iDet]) {
3527 if(reconstructor) delete reconstructor;
3528 TClass *cl = new TClass(Form("Ali%sUpgradeReconstructor",fgkDetectorName[iDet]));
3529 reconstructor = (AliReconstructor*)(cl->New());
3532 if (reconstructor) {
3533 TObject* obj = fOptions.FindObject(detName.Data());
3534 if (obj) reconstructor->SetOption(obj->GetTitle());
3535 reconstructor->SetRunInfo(fRunInfo);
3536 reconstructor->SetHLTESD(fhltesd);
3537 reconstructor->Init();
3538 fReconstructor[iDet] = reconstructor;
3541 // get or create the loader
3542 if (detName != "HLT") {
3543 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
3544 if (!fLoader[iDet]) {
3545 AliConfig::Instance()
3546 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
3548 // first check if a plugin is defined for the loader
3550 pluginManager->FindHandler("AliLoader", detName);
3551 // if not, add a plugin for it
3552 if (!pluginHandler) {
3553 TString loaderName = "Ali" + detName + "Loader";
3554 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
3555 pluginManager->AddHandler("AliLoader", detName,
3556 loaderName, detName + "base",
3557 loaderName + "(const char*, TFolder*)");
3558 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
3560 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3562 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
3563 fRunLoader->GetEventFolder());
3565 if (!fLoader[iDet]) { // use default loader
3566 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
3568 if (!fLoader[iDet]) {
3569 AliWarning(Form("couldn't get loader for %s", detName.Data()));
3570 if (fStopOnError) return NULL;
3572 fRunLoader->AddLoader(fLoader[iDet]);
3573 fRunLoader->CdGAFile();
3574 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
3575 fRunLoader->Write(0, TObject::kOverwrite);
3580 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3581 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3582 if (reconstructor) {
3583 reconstructor->SetRecoParam(par);
3584 reconstructor->SetRunInfo(fRunInfo);
3587 return reconstructor;
3590 //_____________________________________________________________________________
3591 AliVertexer* AliReconstruction::CreateVertexer()
3593 // create the vertexer
3594 // Please note that the caller is the owner of the
3597 AliVertexer* vertexer = NULL;
3598 AliReconstructor* itsReconstructor = GetReconstructor(0);
3599 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3600 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3601 vertexer = itsReconstructor->CreateVertexer();
3604 AliWarning("couldn't create a vertexer for ITS");
3610 //_____________________________________________________________________________
3611 AliTrackleter* AliReconstruction::CreateMultFinder()
3613 // create the ITS trackleter for mult. estimation
3614 // Please note that the caller is the owner of the
3617 AliTrackleter* trackleter = NULL;
3618 AliReconstructor* itsReconstructor = GetReconstructor(0);
3619 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3620 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3621 trackleter = itsReconstructor->CreateMultFinder();
3624 AliWarning("ITS is not in reconstruction, switching off RunMultFinder");
3625 fRunMultFinder = kFALSE;
3631 //_____________________________________________________________________________
3632 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
3634 // create the trackers
3635 AliInfo("Creating trackers");
3637 TString detStr = detectors;
3638 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3639 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3640 AliReconstructor* reconstructor = GetReconstructor(iDet);
3641 if (!reconstructor) continue;
3642 TString detName = fgkDetectorName[iDet];
3643 if (detName == "MUON") {
3644 fRunMuonTracking = kTRUE;
3647 if (detName == "MFT") { // AU
3648 fRunMFTTrackingMU = kTRUE; // AU
3652 fTracker[iDet] = reconstructor->CreateTracker();
3653 if (!fTracker[iDet] && (iDet < 7)) {
3654 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
3655 if (fStopOnError) return kFALSE;
3657 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
3663 //_____________________________________________________________________________
3664 void AliReconstruction::CleanUp()
3666 // delete trackers and the run loader and close and delete the file
3667 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3668 delete fReconstructor[iDet];
3669 fReconstructor[iDet] = NULL;
3670 fLoader[iDet] = NULL;
3671 delete fTracker[iDet];
3672 fTracker[iDet] = NULL;
3678 delete fSPDTrackleter;
3679 fSPDTrackleter = NULL;
3688 delete fParentRawReader;
3689 fParentRawReader=NULL;
3700 if (AliQAManager::QAManager())
3701 AliQAManager::QAManager()->ShowQA() ;
3702 // AliQAManager::Destroy() ;
3707 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
3709 // Write space-points which are then used in the alignment procedures
3710 // For the moment only ITS, TPC, TRD and TOF
3712 Int_t ntracks = esd->GetNumberOfTracks();
3713 for (Int_t itrack = 0; itrack < ntracks; itrack++)
3715 AliESDtrack *track = esd->GetTrack(itrack);
3718 for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
3719 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
3720 nsp += (iDet==GetDetIndex("TRD")) ? track->GetTRDntracklets():track->GetNcls(iDet);
3722 if (iDet==GetDetIndex("ITS")) { // ITS "extra" clusters
3723 track->GetClusters(iDet,idx);
3724 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
3729 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
3730 track->SetTrackPointArray(sp);
3732 for (Int_t iDet = 5; iDet >= 0; iDet--) {
3733 AliTracker *tracker = fTracker[iDet];
3734 if (!tracker) continue;
3735 Int_t nspdet = (iDet==GetDetIndex("TRD")) ? track->GetTRDtracklets(idx):track->GetClusters(iDet,idx);
3737 if (iDet==GetDetIndex("ITS")) // ITS "extra" clusters
3738 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
3740 if (nspdet <= 0) continue;
3744 while (isp2 < nspdet) {
3745 Bool_t isvalid=kTRUE;
3747 Int_t index=idx[isp++];
3748 if (index < 0) continue;
3750 TString dets = fgkDetectorName[iDet];
3751 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
3752 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
3753 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
3754 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
3755 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
3757 isvalid = tracker->GetTrackPoint(index,p);
3760 if (!isvalid) continue;
3761 if (iDet==GetDetIndex("ITS") && (isp-1)>=6) p.SetExtra();
3762 sp->AddPoint(isptrack,&p); isptrack++;
3769 //_____________________________________________________________________________
3770 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
3772 // The method reads the raw-data error log
3773 // accumulated within the rawReader.
3774 // It extracts the raw-data errors related to
3775 // the current event and stores them into
3776 // a TClonesArray inside the esd object.
3778 if (!fRawReader) return;
3780 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
3782 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
3784 if (iEvent != log->GetEventNumber()) continue;
3786 esd->AddRawDataErrorLog(log);
3791 //_____________________________________________________________________________
3792 // void AliReconstruction::CheckQA()
3794 // check the QA of SIM for this run and remove the detectors
3795 // with status Fatal
3797 // TString newRunLocalReconstruction ;
3798 // TString newRunTracking ;
3799 // TString newFillESD ;
3801 // for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
3802 // TString detName(AliQAv1::GetDetName(iDet)) ;
3803 // AliQAv1 * qa = AliQAv1::Instance(AliQAv1::DETECTORINDEX_t(iDet)) ;
3804 // if ( qa->IsSet(AliQAv1::DETECTORINDEX_t(iDet), AliQAv1::kSIM, specie, AliQAv1::kFATAL)) {
3805 // AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
3806 // detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
3808 // if ( fRunLocalReconstruction.Contains(AliQAv1::GetDetName(iDet)) ||
3809 // fRunLocalReconstruction.Contains("ALL") ) {
3810 // newRunLocalReconstruction += detName ;
3811 // newRunLocalReconstruction += " " ;
3813 // if ( fRunTracking.Contains(AliQAv1::GetDetName(iDet)) ||
3814 // fRunTracking.Contains("ALL") ) {
3815 // newRunTracking += detName ;
3816 // newRunTracking += " " ;
3818 // if ( fFillESD.Contains(AliQAv1::GetDetName(iDet)) ||
3819 // fFillESD.Contains("ALL") ) {
3820 // newFillESD += detName ;
3821 // newFillESD += " " ;
3825 // fRunLocalReconstruction = newRunLocalReconstruction ;
3826 // fRunTracking = newRunTracking ;
3827 // fFillESD = newFillESD ;
3830 //_____________________________________________________________________________
3831 Int_t AliReconstruction::GetDetIndex(const char* detector)
3833 // return the detector index corresponding to detector
3835 for (index = 0; index < kNDetectors ; index++) {
3836 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
3841 //_____________________________________________________________________________
3842 Bool_t AliReconstruction::FinishPlaneEff() {
3844 // Here execute all the necessary operationis, at the end of the tracking phase,
3845 // in case that evaluation of PlaneEfficiencies was required for some detector.
3846 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
3848 // This Preliminary version works only FOR ITS !!!!!
3849 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3852 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3855 TString detStr = fLoadCDB;
3856 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
3857 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
3858 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3859 if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
3860 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
3861 TString name=planeeff->GetName();
3863 TFile* pefile = TFile::Open(name, "RECREATE");
3864 ret=(Bool_t)planeeff->Write();
3866 if(planeeff->GetCreateHistos()) {
3867 TString hname=planeeff->GetName();
3868 hname+="Histo.root";
3869 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
3872 if(fSPDTrackleter) {
3873 AliPlaneEff *planeeff=fSPDTrackleter->GetPlaneEff();
3874 TString name="AliITSPlaneEffSPDtracklet.root";
3875 TFile* pefile = TFile::Open(name, "RECREATE");
3876 ret=(Bool_t)planeeff->Write();
3878 AliESDEvent *dummy=NULL;
3879 ret=(Bool_t)fSPDTrackleter->PostProcess(dummy); // take care of writing other files
3884 //_____________________________________________________________________________
3885 Bool_t AliReconstruction::InitPlaneEff() {
3887 // Here execute all the necessary operations, before of the tracking phase,
3888 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
3889 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
3890 // which should be updated/recalculated.
3892 // This Preliminary version will work only FOR ITS !!!!!
3893 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3896 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3899 fSPDTrackleter = NULL;
3900 TString detStr = fLoadCDB;
3901 if (IsSelected(fgkDetectorName[0], detStr)) {
3902 AliReconstructor* itsReconstructor = GetReconstructor(0);
3903 if (itsReconstructor) {
3904 fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
3906 if (fSPDTrackleter) {
3907 AliInfo("Trackleter for SPD has been created");
3913 //_____________________________________________________________________________
3914 Bool_t AliReconstruction::InitAliEVE()
3916 // This method should be called only in case
3917 // AliReconstruction is run
3918 // within the alieve environment.
3919 // It will initialize AliEVE in a way
3920 // so that it can visualize event processed
3921 // by AliReconstruction.
3922 // The return flag shows whenever the
3923 // AliEVE initialization was successful or not.
3925 TString macroStr(getenv("ALIEVE_ONLINE_MACRO"));
3927 if (macroStr.IsNull())
3928 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
3930 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
3932 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
3934 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
3935 gROOT->ProcessLine("alieve_online_init()");
3940 //_____________________________________________________________________________
3941 void AliReconstruction::RunAliEVE()
3943 // Runs AliEVE visualisation of
3944 // the current event.
3945 // Should be executed only after
3946 // successful initialization of AliEVE.
3948 AliInfo("Running AliEVE...");
3949 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p,(AliESDfriend*)%p);",fRunLoader,fRawReader,fesd,fesdf));
3953 //_____________________________________________________________________________
3954 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
3956 // Allows to run QA for a selected set of detectors
3957 // and a selected set of tasks among RAWS, DIGITSR, RECPOINTS and ESDS
3958 // all selected detectors run the same selected tasks
3960 if (!detAndAction.Contains(":")) {
3961 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
3965 Int_t colon = detAndAction.Index(":") ;
3966 fQADetectors = detAndAction(0, colon) ;
3967 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
3968 if (fQATasks.Contains("ALL") ) {
3969 fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ;
3971 fQATasks.ToUpper() ;
3973 if ( fQATasks.Contains("RAW") )
3974 tempo = Form("%d ", AliQAv1::kRAWS) ;
3975 if ( fQATasks.Contains("DIGIT") )
3976 tempo += Form("%d ", AliQAv1::kDIGITSR) ;
3977 if ( fQATasks.Contains("RECPOINT") )
3978 tempo += Form("%d ", AliQAv1::kRECPOINTS) ;
3979 if ( fQATasks.Contains("ESD") )
3980 tempo += Form("%d ", AliQAv1::kESDS) ;
3982 if (fQATasks.IsNull()) {
3983 AliInfo("No QA requested\n") ;
3988 TString tempo(fQATasks) ;
3989 tempo.ReplaceAll(Form("%d", AliQAv1::kRAWS), AliQAv1::GetTaskName(AliQAv1::kRAWS)) ;
3990 tempo.ReplaceAll(Form("%d", AliQAv1::kDIGITSR), AliQAv1::GetTaskName(AliQAv1::kDIGITSR)) ;
3991 tempo.ReplaceAll(Form("%d", AliQAv1::kRECPOINTS), AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)) ;
3992 tempo.ReplaceAll(Form("%d", AliQAv1::kESDS), AliQAv1::GetTaskName(AliQAv1::kESDS)) ;
3993 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
3998 //_____________________________________________________________________________
3999 Bool_t AliReconstruction::InitRecoParams()
4001 // The method accesses OCDB and retrieves all
4002 // the available reco-param objects from there.
4004 Bool_t isOK = kTRUE;
4006 if (fRecoParam.GetDetRecoParamArray(kNDetectors)) {
4007 AliInfo("Using custom GRP reconstruction parameters");
4010 AliInfo("Loading GRP reconstruction parameter objects");
4012 AliCDBPath path("GRP","Calib","RecoParam");
4013 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
4015 AliWarning("Couldn't find GRP RecoParam entry in OCDB");
4019 TObject *recoParamObj = entry->GetObject();
4020 if (dynamic_cast<TObjArray*>(recoParamObj)) {
4021 // GRP has a normal TobjArray of AliDetectorRecoParam objects
4022 // Registering them in AliRecoParam
4023 fRecoParam.AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
4025 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
4026 // GRP has only onse set of reco parameters
4027 // Registering it in AliRecoParam
4028 AliInfo("Single set of GRP reconstruction parameters found");
4029 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
4030 fRecoParam.AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
4033 AliError("No valid GRP RecoParam object found in the OCDB");
4040 TString detStr = fLoadCDB;
4041 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4043 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
4045 if (fRecoParam.GetDetRecoParamArray(iDet)) {
4046 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
4050 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
4052 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
4053 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
4055 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
4059 TObject *recoParamObj = entry->GetObject();
4060 if (dynamic_cast<TObjArray*>(recoParamObj)) {
4061 // The detector has a normal TobjArray of AliDetectorRecoParam objects
4062 // Registering them in AliRecoParam
4063 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
4065 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
4066 // The detector has only onse set of reco parameters
4067 // Registering it in AliRecoParam
4068 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
4069 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
4070 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
4073 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
4077 // FIX ME: We have to disable the unloading of reco-param CDB
4078 // entries because QA framework is using them. Has to be fix in
4079 // a way that the QA takes the objects already constructed in
4081 // AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
4085 if (AliDebugLevel() > 0) fRecoParam.Print();
4090 //_____________________________________________________________________________
4091 Bool_t AliReconstruction::GetEventInfo()
4093 // Fill the event info object
4095 AliCodeTimerAuto("",0)
4097 AliCentralTrigger *aCTP = NULL;
4099 fEventInfo.SetEventType(fRawReader->GetType());
4101 ULong64_t mask = fRawReader->GetClassMask();
4102 fEventInfo.SetTriggerMask(mask);
4103 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
4104 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
4106 aCTP = new AliCentralTrigger();
4107 TString configstr("");
4108 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
4109 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
4113 aCTP->SetClassMask(mask);
4114 aCTP->SetClusterMask(clmask);
4117 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
4119 rlCTP->SetClassMask(mask);
4120 rlCTP->SetClusterMask(clmask);
4125 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
4127 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
4128 aCTP = fRunLoader->GetTrigger();
4129 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
4130 // get inputs from actp - just get
4131 AliESDHeader* esdheader = fesd->GetHeader();
4132 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
4133 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
4134 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
4135 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
4138 if (fStopOnMissingTriggerFile) AliFatal("No trigger can be loaded! Stopping reconstruction!");
4139 AliWarning("No trigger can be loaded! The trigger information will not be used!");
4144 AliTriggerConfiguration *config = aCTP->GetConfiguration();
4146 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
4147 if (fRawReader) delete aCTP;
4151 // Load trigger aliases and declare the trigger classes included in aliases
4152 //PH Why do we do it in each event and not only once in the beginning of the chunk??
4153 //PH Temporary fix for #99725: AliReconstruction::GetEventInfo bug
4154 fDeclTriggerClasses.Clear();
4155 AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
4157 THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
4159 lst->Sort(kSortDescending); // to avoid problems with substrungs
4160 if (fRawReader) fRawReader->LoadTriggerAlias(lst);
4161 // Now declare all the triggers present in the aliases
4164 while((nmd = dynamic_cast<TNamed*>(iter.Next()))){
4165 fDeclTriggerClasses += " ";
4166 fDeclTriggerClasses += nmd->GetName();
4170 AliError("Cannot cast the object with trigger aliases to THashList!");
4174 AliError("No OCDB ebtry for the trigger aliases!");
4176 // Load trigger classes for this run
4177 UChar_t clustmask = 0;
4179 ULong64_t trmask = fEventInfo.GetTriggerMask();
4180 const TObjArray& classesArray = config->GetClasses();
4181 Int_t nclasses = classesArray.GetEntriesFast();
4182 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
4183 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
4184 if (trclass && trclass->GetMask()>0) {
4185 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
4186 if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex);
4187 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
4188 if (trmask & (1ull << trindex)) {
4190 trclasses += trclass->GetName();
4192 clustmask |= trclass->GetCluster()->GetClusterMask();
4196 fEventInfo.SetTriggerClasses(trclasses);
4197 // Now put the declared trigger classes (not present in the run)
4198 // to 0/false in the event selection
4199 if (!fDeclTriggerClasses.IsNull()) {
4200 TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
4201 Int_t ntokens = tokens->GetEntriesFast();
4202 for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
4203 if (fRawReader) fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
4208 // Write names of active trigger inputs in ESD Header
4209 const TObjArray& inputsArray = config->GetInputs();
4210 Int_t ninputs = inputsArray.GetEntriesFast();
4211 for( Int_t iinput=0; iinput < ninputs; iinput++ ) {
4212 AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
4213 if (trginput && trginput->GetMask()>0) {
4214 Int_t inputIndex = (Int_t)TMath::Nint(TMath::Log2(trginput->GetMask()));
4215 AliESDHeader* headeresd = 0x0;
4216 if (fesd) headeresd = fesd->GetHeader();
4218 Int_t trglevel = (Int_t)trginput->GetLevel();
4219 if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
4220 if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
4221 if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
4226 // Set the information in ESD
4228 fesd->SetTriggerMask(trmask);
4229 fesd->SetTriggerCluster(clustmask);
4232 if (!aCTP->CheckTriggeredDetectors()) {
4233 if (fRawReader) delete aCTP;
4237 if (fRawReader) delete aCTP;
4239 // We have to fill also the HLT decision here!!
4245 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
4247 // Match the detector list found in the rec.C or the default 'ALL'
4248 // to the list found in the GRP (stored there by the shuttle PP which
4249 // gets the information from ECS)
4250 static TString resultList;
4251 TString detList = detectorList;
4255 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
4256 if ((detectorMask >> iDet) & 0x1) {
4257 TString det = AliDAQ::OfflineModuleName(iDet);
4258 if ((detList.CompareTo("ALL") == 0) ||
4259 ((detList.BeginsWith("ALL ") ||
4260 detList.EndsWith(" ALL") ||
4261 detList.Contains(" ALL ")) &&
4262 !(detList.BeginsWith("-"+det+" ") ||
4263 detList.EndsWith(" -"+det) ||
4264 detList.Contains(" -"+det+" "))) ||
4265 (detList.CompareTo(det) == 0) ||
4266 detList.BeginsWith(det+" ") ||
4267 detList.EndsWith(" "+det) ||
4268 detList.Contains( " "+det+" " )) {
4269 if (!resultList.EndsWith(det + " ")) {
4278 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
4279 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
4280 if ((detList.CompareTo("ALL") == 0) ||
4281 ((detList.BeginsWith("ALL ") ||
4282 detList.EndsWith(" ALL") ||
4283 detList.Contains(" ALL ")) &&
4284 !(detList.BeginsWith("-"+hltDet+" ") ||
4285 detList.EndsWith(" -"+hltDet) ||
4286 detList.Contains(" -"+hltDet+" "))) ||
4287 (detList.CompareTo(hltDet) == 0) ||
4288 detList.BeginsWith(hltDet+" ") ||
4289 detList.EndsWith(" "+hltDet) ||
4290 detList.Contains( " "+hltDet+" " )) {
4291 resultList += hltDet;
4295 return resultList.Data();
4299 //______________________________________________________________________________
4300 void AliReconstruction::Abort(const char *method, EAbort what)
4302 // Abort processing. If what = kAbortProcess, the Process() loop will be
4303 // aborted. If what = kAbortFile, the current file in a chain will be
4304 // aborted and the processing will continue with the next file, if there
4305 // is no next file then Process() will be aborted. Abort() can also be
4306 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
4307 // the SlaveTerminate() and Terminate() are always called. The abort flag
4308 // can be checked in these methods using GetAbort().
4310 // The method is overwritten in AliReconstruction for better handling of
4311 // reco specific errors
4313 if (!fStopOnError) return;
4317 TString whyMess = method;
4318 whyMess += " failed! Aborting...";
4320 AliError(whyMess.Data());
4323 TString mess = "Abort";
4324 if (fAbort == kAbortProcess)
4325 mess = "AbortProcess";
4326 else if (fAbort == kAbortFile)
4329 Info(mess.Data(), "%s", whyMess.Data());
4332 //______________________________________________________________________________
4333 Bool_t AliReconstruction::ProcessEvent(void* event)
4335 // Method that is used in case the event loop
4336 // is steered from outside, for example by AMORE
4337 // 'event' is a pointer to the DATE event in the memory
4339 if (fRawReader) delete fRawReader;
4340 fRawReader = new AliRawReaderDate(event);
4341 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
4348 //______________________________________________________________________________
4349 Bool_t AliReconstruction::ParseOutput()
4351 // The method parses the output file
4352 // location string in order to steer
4353 // properly the selector
4355 TPMERegexp re1("(\\w+\\.zip#\\w+\\.root):([,*\\w+\\.root,*]+)@dataset://(\\w++)");
4356 TPMERegexp re2("(\\w+\\.root)?@?dataset://(\\w++)");
4358 if (re1.Match(fESDOutput) == 4) {
4359 // root archive with output files stored and regustered
4361 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",re1[1].Data()));
4362 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re1[3].Data()));
4363 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4364 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_ARCHIVE",re1[2].Data()));
4365 AliInfo(Form("%s files will be stored within %s in dataset %s",
4370 else if (re2.Match(fESDOutput) == 3) {
4371 // output file stored and registered
4373 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",(re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data()));
4374 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re2[2].Data()));
4375 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4376 AliInfo(Form("%s will be stored in dataset %s",
4377 (re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data(),
4381 if (fESDOutput.IsNull()) {
4382 // Output location not given.
4383 // Assuming xrootd has been already started and
4384 // the output file has to be sent back
4385 // to the client machine
4386 TString esdUrl(Form("root://%s/%s/",
4387 TUrl(gSystem->HostName()).GetHostFQDN(),
4389 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE","AliESDs.root"));
4390 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",esdUrl.Data()));
4391 AliInfo(Form("AliESDs.root will be stored in %s",
4395 // User specified an output location.
4396 // Ones has just to parse it here
4397 TUrl outputUrl(fESDOutput.Data());
4398 TString outputFile(gSystem->BaseName(outputUrl.GetFile()));
4399 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.IsNull() ? "AliESDs.root" : outputFile.Data()));
4400 TString outputLocation(outputUrl.GetUrl());
4401 outputLocation.ReplaceAll(outputFile.Data(),"");
4402 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",outputLocation.Data()));
4403 AliInfo(Form("%s will be stored in %s",
4404 outputFile.IsNull() ? "AliESDs.root" : outputFile.Data(),
4405 outputLocation.Data()));
4412 //______________________________________________________________________________
4413 Bool_t AliReconstruction::IsHighPt() const {
4414 // Selection of events containing "high" pT tracks
4415 // If at least one track is found within 1.5 and 100 GeV (pT)
4416 // that was reconstructed by both ITS and TPC, the event is accepted
4419 const Double_t pTmin = 1.5;
4420 const Double_t pTmax = 100;
4422 mask |= (AliESDtrack::kITSrefit);
4423 mask |= (AliESDtrack::kTPCrefit);
4424 const Double_t pTminCosmic = 5.;
4425 const Double_t pTmaxCosmic = 100;
4426 ULong_t maskCosmic = 0;
4427 Int_t cosmicCount=0;
4428 maskCosmic |= (AliESDtrack::kTPCrefit);
4430 Bool_t isOK = kFALSE;
4432 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4433 // Check if this ia a physics event (code 7)
4434 Int_t ntrk = fesd->GetNumberOfTracks();
4435 for (Int_t itrk=0; itrk<ntrk; ++itrk) {
4437 AliESDtrack * trk = fesd->GetTrack(itrk);
4439 && trk->Pt() > pTmin
4440 && trk->Pt() < pTmax
4441 && (trk->GetStatus() & mask) == mask ) {
4447 && trk->GetInnerParam()
4448 && trk->GetInnerParam()->Pt() > pTminCosmic
4449 && trk->GetInnerParam()->Pt() < pTmaxCosmic
4450 && (trk->GetStatus() & maskCosmic) == maskCosmic ) {
4456 if (cosmicCount>1) isOK=kTRUE;
4461 //______________________________________________________________________________
4462 Bool_t AliReconstruction::IsCosmicOrCalibSpecie() const {
4463 // Select cosmic or calibration events
4465 Bool_t isOK = kFALSE;
4467 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4468 // Check if this ia a physics event (code 7)
4470 UInt_t specie = fesd->GetEventSpecie();
4471 if (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib) {
4478 //______________________________________________________________________________
4479 void AliReconstruction::WriteESDfriend() {
4480 // Fill the ESD friend in the tree. The required fraction of ESD friends is stored
4481 // in fFractionFriends. We select events where we store the ESD friends according
4482 // to the following algorithm:
4483 // 1. Store all Cosmic or Calibration events within the required fraction
4484 // 2. Sample "high Pt" events within the remaining fraction after step 1.
4485 // 3. Sample randomly events if we still have remaining slot
4488 Bool_t isSelected = kFALSE;
4490 // Store all friends for B field OFF
4491 if (TMath::Abs(AliTrackerBase::GetBz())<0.5) isSelected=kTRUE;
4493 if (IsCosmicOrCalibSpecie()) { // Selection of calib or cosmic events
4500 Double_t remainingFraction = fFractionFriends;
4501 remainingFraction -= ((Double_t)(fSspecie)/(Double_t)(fNall));
4503 if (IsHighPt()) { // Selection of "high Pt" events
4505 Double_t curentHighPtFraction = ((Double_t)(fNhighPt+1))/((Double_t)(fNall+1));
4506 // "Bayesian" estimate supposing that without events all the events are of the required type
4509 Double_t rnd = gRandom->Rndm()*curentHighPtFraction;
4510 if (rnd<remainingFraction) {
4516 remainingFraction -= ((Double_t)(fShighPt)/(Double_t)(fNall));
4518 // Random selection to fill the remaining fraction (if any)
4520 Double_t rnd = gRandom->Rndm();
4521 if (rnd<remainingFraction) {
4527 fesdf->~AliESDfriend();
4528 new (fesdf) AliESDfriend(); // Reset...
4529 fesdf->SetSkipBit(kTRUE);
4532 Long64_t nbf = ftreeF->Fill();
4533 if (fTreeBuffSize>0 && ftreeF->GetAutoFlush()<0 && (fMemCountESDF += nbf)>fTreeBuffSize ) { // default limit is still not reached
4534 nbf = ftreeF->GetZipBytes();
4535 if (nbf>0) nbf = -nbf;
4536 else nbf = ftreeF->GetEntries();
4537 ftreeF->SetAutoFlush(nbf);
4538 AliInfo(Form("Calling ftreeF->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
4539 nbf,fMemCountESDF,ftreeF->GetTotBytes(),ftreeF->GetZipBytes()));
4544 //_________________________________________________________________
4545 void AliReconstruction::DeleteDigits(const TString& detectors)
4547 // delete requested digit files produced at current event
4548 static int iEvent = 0;
4549 if (detectors.IsNull()) return;
4550 TString detStr = detectors;
4551 AliInfo(Form("Deleting Digits: %s",detectors.Data()));
4553 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4554 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
4555 unlink(Form("%s.Digits.root",fgkDetectorName[iDet]));
4557 AliSysInfo::AddStamp(Form("DelDigits_%d",iEvent), 0,0,iEvent);
4561 //_________________________________________________________________
4562 void AliReconstruction::DeleteRecPoints(const TString& detectors)
4564 // delete requested recpoint files produced at current event
4565 static int iEvent = 0;
4566 if (detectors.IsNull()) return;
4567 TString detStr = detectors;
4568 AliInfo(Form("Deleting Recpoints: %s",detectors.Data()));
4570 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4571 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
4572 unlink(Form("%s.RecPoints.root",fgkDetectorName[iDet]));
4574 AliSysInfo::AddStamp(Form("DelRecPoints_%d",iEvent), 0,0,iEvent);
4578 //_________________________________________________________________
4579 void AliReconstruction::SetStopOnResourcesExcess(Int_t vRSS,Int_t vVMEM)
4581 // require checking the resources left and stopping on excess
4582 // if 0 : no check is done
4583 // if >0 : stop reconstruction if exceeds this value
4584 // if <0 : use as margin to system limits
4586 const int kKB2MB = 1024;
4587 const int kInfMem = 9999999;
4590 int pgSize = getpagesize();
4594 AliInfo(Form("Setting max. RSS usage to user value %d MB",fMaxRSS));
4597 getrlimit(RLIMIT_RSS,&r);
4598 fMaxRSS = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vRSS;
4599 AliInfo(Form("Setting max. RSS usage to system hard limit %d%s MB (%d margin)",fMaxRSS,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vRSS));
4601 else {AliInfo("No check on RSS memory usage will be applied");}
4605 AliInfo(Form("Setting max. VMEM usage to user value %d MB",fMaxVMEM));
4608 getrlimit(RLIMIT_AS,&r);
4609 fMaxVMEM = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vVMEM;
4610 AliInfo(Form("Setting max. VMEM usage to system hard limit %d%s MB (%d margin)",fMaxVMEM,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vVMEM));
4612 else {AliInfo("No check on RSS memory usage will be applied");}
4616 //_________________________________________________________________
4617 Bool_t AliReconstruction::HasEnoughResources(int ev)
4619 // check if process consumed more than allowed resources
4620 const int kKB2MB = 1024;
4622 if (!fMaxRSS && !fMaxVMEM) return res;
4624 ProcInfo_t procInfo;
4625 gSystem->GetProcInfo(&procInfo);
4626 if (procInfo.fMemResident/kKB2MB > fMaxRSS) res = kFALSE;
4627 if (procInfo.fMemVirtual/kKB2MB > fMaxVMEM) res = kFALSE;
4630 AliInfo(Form("Job exceeded allowed limits: RSS:%d (%d) VMEM:%d (%d), will stop",
4631 int(procInfo.fMemResident/kKB2MB),fMaxRSS,
4632 int(procInfo.fMemVirtual/kKB2MB) ,fMaxVMEM));
4634 unlink(Form("%s",fgkStopEvFName));
4635 ofstream outfile(fgkStopEvFName);
4636 outfile << ev << std::endl;
4643 Bool_t AliReconstruction::HasNextEventAfter(Int_t eventId)
4645 return ( (eventId < fRunLoader->GetNumberOfEvents()) ||
4646 (fRawReader && fRawReader->NextEvent()) );
4649 //_________________________________________________________________
4650 void AliReconstruction::CheckRecoCDBvsSimuCDB()
4652 // if some CDB entries must be the same in the simulation
4653 // and reconstruction, check here
4654 int nent = fCheckRecoCDBvsSimuCDB.GetEntriesFast();
4655 AliInfo(Form("Check %d entries for matching between sim and rec",nent));
4657 // get simulation CDB
4658 fRunLoader->CdGAFile();
4659 TMap* cdbMapSim = (TMap*)gDirectory->Get("cdbMap");
4660 TList* cdbListSim = (TList*)gDirectory->Get("cdbList");
4661 if (!(cdbMapSim && cdbListSim)) {
4662 AliInfo(Form("No CDBMap/List found in %s, nothing to check",fGAliceFileName.Data()));
4665 // read the requested objects to make sure they will appear in the reco list
4666 for (Int_t i=0;i<nent;i++) {
4667 TNamed* cdbent = (TNamed*) fCheckRecoCDBvsSimuCDB[i];
4668 if (!cdbent) continue;
4669 AliCDBManager::Instance()->Get(cdbent->GetName());
4671 // get default path for simulation
4674 pair = (TPair*)cdbMapSim->FindObject("default");
4675 if (!pair) {AliFatal("Did not find default storage used for simulations"); return;}
4676 TString defSimStore = ((TObjString*)pair->Value())->GetString();
4677 RectifyCDBurl(defSimStore);
4679 // get reconstruction CDB
4680 const TMap *cdbMapRec = AliCDBManager::Instance()->GetStorageMap();
4681 const TList *cdbListRec = AliCDBManager::Instance()->GetRetrievedIds();
4683 // get default path for reconstruction
4684 pair = (TPair*)cdbMapRec->FindObject("default");
4685 if (!pair) {AliFatal("Did not find default storage used for reconstruction"); return;}
4686 TString defRecStore = ((TObjString*)pair->Value())->GetString();
4687 RectifyCDBurl(defRecStore);
4689 for (Int_t i=0;i<nent;i++) {
4690 TNamed* cdbent = (TNamed*) fCheckRecoCDBvsSimuCDB[i];
4691 if (!cdbent) continue;
4693 AliInfo(Form("#%d Checking %s",i,cdbent->GetName()));
4695 // find cdbID used for sim
4696 TString idSim="",storSim="";
4697 TIter nextSim(cdbListSim);
4698 while ((stro=(TObjString*)nextSim())) {
4699 if (stro->GetString().Contains(cdbent->GetName())) {
4700 idSim = stro->GetString();
4704 // find the storage used for sim
4705 // check in the simuCDB special paths
4706 pair = (TPair*)cdbMapSim->FindObject(cdbent->GetName());
4707 if (pair) { // specific path is used
4708 storSim = ((TObjString*)pair->Value())->GetString();
4709 RectifyCDBurl(storSim);
4711 else storSim = defSimStore; // default storage list is used
4713 if (!idSim.IsNull()) AliInfo(Form("Sim. used %s from %s",idSim.Data(), storSim.Data()));
4714 else AliInfo("Sim. did not use this object");
4716 // find cdbID used for rec
4717 TString idRec="",storRec="";
4718 TIter nextRec(cdbListRec);
4720 while ((id=(AliCDBId*)nextRec())) {
4721 idRec = id->ToString();
4722 if (idRec.Contains(cdbent->GetName())) break;
4726 // find storage used for the rec
4727 pair = (TPair*)cdbMapRec->FindObject(cdbent->GetName());
4728 if (pair) { // specific path is used
4729 storRec = ((TObjString*)pair->Value())->GetString();
4730 RectifyCDBurl(storRec);
4732 else storRec = defRecStore; // default storage list is used
4734 if (!idRec.IsNull()) AliInfo(Form("Rec. used %s from %s",idRec.Data(), storRec.Data()));
4735 else AliInfo("Rec. did not use this object");
4737 if (!idSim.IsNull() && !idRec.IsNull() && ((idSim!=idRec) || (storSim!=storRec)) )
4738 AliFatal("Different objects were used in sim and rec");
4743 //_________________________________________________________
4744 void AliReconstruction::RectifyCDBurl(TString& url)
4747 // remove everything but the url
4749 if (!(sbs=url("\\?User=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4750 if (!(sbs=url("\\?DBFolder=[^?]*")).IsNull()) url.ReplaceAll("?DB","");
4751 if (!(sbs=url("\\?SE=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4752 if (!(sbs=url("\\?CacheFolder=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4753 if (!(sbs=url("\\?OperateDisconnected=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4754 if (!(sbs=url("\\?CacheSize=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4755 if (!(sbs=url("\\?CleanupInterval=[^?]*")).IsNull()) url.ReplaceAll(sbs,"");
4756 Bool_t slash=kFALSE,space=kFALSE;
4757 while ( (slash=url.EndsWith("/")) || (space=url.EndsWith(" ")) ) {
4758 if (slash) url = url.Strip(TString::kTrailing,'/');
4759 if (space) url = url.Strip(TString::kTrailing,' ');