1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the reconstruction //
22 // Clusters and tracks are created for all detectors and all events by //
25 // AliReconstruction rec; //
28 // The Run method returns kTRUE in case of successful execution. //
30 // If the input to the reconstruction are not simulated digits but raw data, //
31 // this can be specified by an argument of the Run method or by the method //
33 // rec.SetInput("..."); //
35 // The input formats and the corresponding argument are: //
36 // - DDL raw data files: directory name, ends with "/" //
37 // - raw data root file: root file name, extension ".root" //
38 // - raw data DATE file: DATE file name, any other non-empty string //
39 // - MC root files : empty string, default //
41 // By default all events are reconstructed. The reconstruction can be //
42 // limited to a range of events by giving the index of the first and the //
43 // last event as an argument to the Run method or by calling //
45 // rec.SetEventRange(..., ...); //
47 // The index -1 (default) can be used for the last event to indicate no //
48 // upper limit of the event range. //
50 // In case of raw-data reconstruction the user can modify the default //
51 // number of events per digits/clusters/tracks file. In case the option //
52 // is not used the number is set 1. In case the user provides 0, than //
53 // the number of events is equal to the number of events inside the //
54 // raw-data file (i.e. one digits/clusters/tracks file): //
56 // rec.SetNumberOfEventsPerFile(...); //
59 // The name of the galice file can be changed from the default //
60 // "galice.root" by passing it as argument to the AliReconstruction //
61 // constructor or by //
63 // rec.SetGAliceFile("..."); //
65 // The local reconstruction can be switched on or off for individual //
68 // rec.SetRunLocalReconstruction("..."); //
70 // The argument is a (case sensitive) string with the names of the //
71 // detectors separated by a space. The special string "ALL" selects all //
72 // available detectors. This is the default. //
74 // The reconstruction of the primary vertex position can be switched off by //
76 // rec.SetRunVertexFinder(kFALSE); //
78 // The tracking and the creation of ESD tracks can be switched on for //
79 // selected detectors by //
81 // rec.SetRunTracking("..."); //
83 // Uniform/nonuniform field tracking switches (default: uniform field) //
85 // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
87 // The filling of additional ESD information can be steered by //
89 // rec.SetFillESD("..."); //
91 // Again, for both methods the string specifies the list of detectors. //
92 // The default is "ALL". //
94 // The call of the shortcut method //
96 // rec.SetRunReconstruction("..."); //
98 // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99 // SetFillESD with the same detector selecting string as argument. //
101 // The reconstruction requires digits or raw data as input. For the creation //
102 // of digits and raw data have a look at the class AliSimulation. //
104 // The input data of a detector can be replaced by the corresponding HLT //
105 // data by calling (usual detector string) //
106 // SetUseHLTData("..."); //
109 ///////////////////////////////////////////////////////////////////////////////
116 #include <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>
135 #include "AliAlignObj.h"
136 #include "AliAnalysisManager.h"
137 #include "AliAnalysisDataContainer.h"
138 #include "AliCDBEntry.h"
139 #include "AliCDBManager.h"
140 #include "AliCDBStorage.h"
141 #include "AliCTPRawStream.h"
142 #include "AliCascadeVertexer.h"
143 #include "AliCentralTrigger.h"
144 #include "AliCodeTimer.h"
146 #include "AliDetectorRecoParam.h"
147 #include "AliESDCaloCells.h"
148 #include "AliESDCaloCluster.h"
149 #include "AliESDEvent.h"
150 #include "AliESDMuonTrack.h"
151 #include "AliESDPmdTrack.h"
152 #include "AliESDTagCreator.h"
153 #include "AliESDVertex.h"
154 #include "AliESDcascade.h"
155 #include "AliESDfriend.h"
156 #include "AliESDkink.h"
157 #include "AliESDpid.h"
158 #include "AliESDtrack.h"
159 #include "AliESDtrack.h"
160 #include "AliEventInfo.h"
161 #include "AliGRPObject.h"
162 #include "AliGRPRecoParam.h"
163 #include "AliGenEventHeader.h"
164 #include "AliGeomManager.h"
165 #include "AliGlobalQADataMaker.h"
166 #include "AliHeader.h"
169 #include "AliMultiplicity.h"
171 #include "AliPlaneEff.h"
173 #include "AliQADataMakerRec.h"
174 #include "AliQAManager.h"
175 #include "AliRawVEvent.h"
176 #include "AliRawEventHeaderBase.h"
177 #include "AliRawHLTManager.h"
178 #include "AliRawReaderDate.h"
179 #include "AliRawReaderFile.h"
180 #include "AliRawReaderRoot.h"
181 #include "AliRecoInputHandler.h"
182 #include "AliReconstruction.h"
183 #include "AliReconstructor.h"
185 #include "AliRunInfo.h"
186 #include "AliRunLoader.h"
187 #include "AliSysInfo.h" // memory snapshots
188 #include "AliTrackPointArray.h"
189 #include "AliTracker.h"
190 #include "AliTriggerClass.h"
191 #include "AliTriggerCluster.h"
192 #include "AliTriggerIR.h"
193 #include "AliTriggerConfiguration.h"
194 #include "AliV0vertexer.h"
195 #include "AliVertexer.h"
196 #include "AliTrackleter.h"
197 #include "AliVertexerTracks.h"
198 #include "AliTriggerRunScalers.h"
199 #include "AliCTPTimeParams.h"
200 #include "AliESDHLTDecision.h"
201 #include "AliTriggerInput.h"
202 #include "AliLHCData.h"
203 #include "AliPoolN.h"
204 #include "AliClonesPool.h"
205 #include "AliPoolsSet.h"
206 #include "ARVersion.h"
207 #include <RVersion.h>
209 #include <sys/resource.h>
210 ClassImp(AliReconstruction)
212 //_____________________________________________________________________________
213 const char* AliReconstruction::fgkStopEvFName = "_stopEvent_";
214 const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE"
215 // #ifdef MFT_UPGRADE
222 //_____________________________________________________________________________
223 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
225 fRunVertexFinder(kTRUE),
226 fRunVertexFinderTracks(kTRUE),
227 fRunHLTTracking(kFALSE),
228 fRunMuonTracking(kFALSE),
230 fRunCascadeFinder(kTRUE),
231 fRunMultFinder(kTRUE),
233 fWriteAlignmentData(kFALSE),
234 fWriteESDfriend(kFALSE),
235 fFillTriggerESD(kTRUE),
243 fRunLocalReconstruction("ALL"),
246 fDeleteRecPoints(""),
249 fUseTrackingErrorsForAlignment(""),
250 fGAliceFileName(gAliceFilename),
253 fProofOutputFileName(""),
254 fProofOutputLocation(""),
255 fProofOutputDataset(kFALSE),
256 fProofOutputArchive(""),
260 fNumberOfEventsPerFile((UInt_t)-1),
261 fFractionFriends(0.04),
263 fLoadAlignFromCDB(kTRUE),
264 fLoadAlignData("ALL"),
269 fCTPTimeParams(NULL),
274 fParentRawReader(NULL),
278 fSPDTrackleter(NULL),
280 fDiamondProfileSPD(NULL),
281 fDiamondProfile(NULL),
282 fDiamondProfileTPC(NULL),
283 fListOfCosmicTriggers(NULL),
287 fAlignObjArray(NULL),
291 fInitCDBCalled(kFALSE),
292 fFromCDBSnapshot(kFALSE),
293 fSnapshotFileName(""),
294 fSetRunNumberFromDataCalled(kFALSE),
299 fSameQACycle(kFALSE),
300 fInitQACalled(kFALSE),
301 fWriteQAExpertData(kTRUE),
302 fRunPlaneEff(kFALSE),
313 fIsNewRunLoader(kFALSE),
325 fDeclTriggerClasses(""),
331 // create reconstruction object with default parameters
334 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
335 fReconstructor[iDet] = NULL;
336 fUpgradeMask[iDet]=kFALSE;
337 fLoader[iDet] = NULL;
338 fTracker[iDet] = NULL;
340 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
341 fQACycles[iDet] = 999999 ;
342 fQAWriteExpert[iDet] = kFALSE ;
344 fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
349 //_____________________________________________________________________________
350 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
352 fRunVertexFinder(rec.fRunVertexFinder),
353 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
354 fRunHLTTracking(rec.fRunHLTTracking),
355 fRunMuonTracking(rec.fRunMuonTracking),
356 fRunV0Finder(rec.fRunV0Finder),
357 fRunCascadeFinder(rec.fRunCascadeFinder),
358 fRunMultFinder(rec.fRunMultFinder),
359 fStopOnError(rec.fStopOnError),
360 fWriteAlignmentData(rec.fWriteAlignmentData),
361 fWriteESDfriend(rec.fWriteESDfriend),
362 fFillTriggerESD(rec.fFillTriggerESD),
364 fCleanESD(rec.fCleanESD),
365 fV0DCAmax(rec.fV0DCAmax),
366 fV0CsPmin(rec.fV0CsPmin),
370 fRunLocalReconstruction(rec.fRunLocalReconstruction),
371 fRunTracking(rec.fRunTracking),
372 fFillESD(rec.fFillESD),
373 fDeleteRecPoints(""),
375 fLoadCDB(rec.fLoadCDB),
376 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
377 fGAliceFileName(rec.fGAliceFileName),
378 fRawInput(rec.fRawInput),
379 fESDOutput(rec.fESDOutput),
380 fProofOutputFileName(rec.fProofOutputFileName),
381 fProofOutputLocation(rec.fProofOutputLocation),
382 fProofOutputDataset(rec.fProofOutputDataset),
383 fProofOutputArchive(rec.fProofOutputArchive),
384 fEquipIdMap(rec.fEquipIdMap),
385 fFirstEvent(rec.fFirstEvent),
386 fLastEvent(rec.fLastEvent),
387 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
388 fFractionFriends(rec.fFractionFriends),
390 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
391 fLoadAlignData(rec.fLoadAlignData),
392 fUseHLTData(rec.fUseHLTData),
396 fCTPTimeParams(NULL),
401 fParentRawReader(NULL),
403 fRecoParam(rec.fRecoParam),
405 fSPDTrackleter(NULL),
407 fDiamondProfileSPD(rec.fDiamondProfileSPD),
408 fDiamondProfile(rec.fDiamondProfile),
409 fDiamondProfileTPC(rec.fDiamondProfileTPC),
410 fListOfCosmicTriggers(NULL),
414 fAlignObjArray(rec.fAlignObjArray),
415 fCDBUri(rec.fCDBUri),
416 fQARefUri(rec.fQARefUri),
418 fInitCDBCalled(rec.fInitCDBCalled),
419 fFromCDBSnapshot(rec.fFromCDBSnapshot),
420 fSnapshotFileName(rec.fSnapshotFileName),
421 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
422 fQADetectors(rec.fQADetectors),
423 fQATasks(rec.fQATasks),
425 fRunGlobalQA(rec.fRunGlobalQA),
426 fSameQACycle(rec.fSameQACycle),
427 fInitQACalled(rec.fInitQACalled),
428 fWriteQAExpertData(rec.fWriteQAExpertData),
429 fRunPlaneEff(rec.fRunPlaneEff),
440 fIsNewRunLoader(rec.fIsNewRunLoader),
449 fAnalysisMacro(rec.fAnalysisMacro),
452 fDeclTriggerClasses(rec.fDeclTriggerClasses),
460 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
461 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
463 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
464 fReconstructor[iDet] = NULL;
465 fUpgradeMask[iDet] = kFALSE;
466 fLoader[iDet] = NULL;
467 fTracker[iDet] = NULL;
470 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
471 fQACycles[iDet] = rec.fQACycles[iDet];
472 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
475 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
476 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
479 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
483 //_____________________________________________________________________________
484 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
486 // assignment operator
487 // Used in PROOF mode
488 // Be very careful while modifing it!
489 // Simple rules to follow:
490 // for persistent data members - use their assignment operators
491 // for non-persistent ones - do nothing or take the default values from constructor
492 // TSelector members should not be touched
493 if(&rec == this) return *this;
495 fRunVertexFinder = rec.fRunVertexFinder;
496 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
497 fRunHLTTracking = rec.fRunHLTTracking;
498 fRunMuonTracking = rec.fRunMuonTracking;
499 fRunV0Finder = rec.fRunV0Finder;
500 fRunCascadeFinder = rec.fRunCascadeFinder;
501 fRunMultFinder = rec.fRunMultFinder;
502 fStopOnError = rec.fStopOnError;
503 fWriteAlignmentData = rec.fWriteAlignmentData;
504 fWriteESDfriend = rec.fWriteESDfriend;
505 fFillTriggerESD = rec.fFillTriggerESD;
507 fCleanESD = rec.fCleanESD;
508 fV0DCAmax = rec.fV0DCAmax;
509 fV0CsPmin = rec.fV0CsPmin;
513 fRunLocalReconstruction = rec.fRunLocalReconstruction;
514 fRunTracking = rec.fRunTracking;
515 fFillESD = rec.fFillESD;
516 fDeleteRecPoints = rec.fDeleteRecPoints;
517 fDeleteDigits = rec.fDeleteDigits;
518 fLoadCDB = rec.fLoadCDB;
519 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
520 fGAliceFileName = rec.fGAliceFileName;
521 fRawInput = rec.fRawInput;
522 fESDOutput = rec.fESDOutput;
523 fProofOutputFileName = rec.fProofOutputFileName;
524 fProofOutputLocation = rec.fProofOutputLocation;
525 fProofOutputDataset = rec.fProofOutputDataset;
526 fProofOutputArchive = rec.fProofOutputArchive;
527 fEquipIdMap = rec.fEquipIdMap;
528 fFirstEvent = rec.fFirstEvent;
529 fLastEvent = rec.fLastEvent;
530 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
531 fFractionFriends = rec.fFractionFriends;
533 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
534 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
537 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
538 fLoadAlignData = rec.fLoadAlignData;
539 fUseHLTData = rec.fUseHLTData;
541 delete fRunInfo; fRunInfo = NULL;
542 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
544 fEventInfo = rec.fEventInfo;
546 delete fRunScalers; fRunScalers = NULL;
547 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
549 delete fCTPTimeParams; fCTPTimeParams = NULL;
550 if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
551 delete fCTPTimeAlign; fCTPTimeAlign = NULL;
552 if (rec.fCTPTimeAlign) fCTPTimeAlign = new AliCTPTimeParams(*rec.fCTPTimeAlign);
556 fParentRawReader = NULL;
558 fRecoParam = rec.fRecoParam;
560 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
561 fUpgradeMask[iDet] = kFALSE;
562 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
563 delete fLoader[iDet]; fLoader[iDet] = NULL;
564 delete fTracker[iDet]; fTracker[iDet] = NULL;
567 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
568 fQACycles[iDet] = rec.fQACycles[iDet];
569 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
572 delete fSPDTrackleter; fSPDTrackleter = NULL;
574 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
575 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
576 delete fDiamondProfile; fDiamondProfile = NULL;
577 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
578 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
579 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
581 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
582 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
584 delete fGRPData; fGRPData = NULL;
585 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
586 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
588 delete fAlignObjArray; fAlignObjArray = NULL;
591 fQARefUri = rec.fQARefUri;
592 fSpecCDBUri.Delete();
593 fInitCDBCalled = rec.fInitCDBCalled;
594 fFromCDBSnapshot = rec.fFromCDBSnapshot;
595 fSnapshotFileName = rec.fSnapshotFileName;
596 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
597 fQADetectors = rec.fQADetectors;
598 fQATasks = rec.fQATasks;
600 fRunGlobalQA = rec.fRunGlobalQA;
601 fSameQACycle = rec.fSameQACycle;
602 fInitQACalled = rec.fInitQACalled;
603 fWriteQAExpertData = rec.fWriteQAExpertData;
604 fRunPlaneEff = rec.fRunPlaneEff;
605 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
615 fIsNewRunLoader = rec.fIsNewRunLoader;
624 fAnalysisMacro = rec.fAnalysisMacro;
627 fDeclTriggerClasses = rec.fDeclTriggerClasses;
632 //_____________________________________________________________________________
633 AliReconstruction::~AliReconstruction()
638 if (fListOfCosmicTriggers) {
639 fListOfCosmicTriggers->Delete();
640 delete fListOfCosmicTriggers;
644 delete fCTPTimeParams;
645 delete fCTPTimeAlign;
647 if (fAlignObjArray) {
648 fAlignObjArray->Delete();
649 delete fAlignObjArray;
651 fSpecCDBUri.Delete();
652 AliCodeTimer::Instance()->Print();
655 //_____________________________________________________________________________
656 void AliReconstruction::InitQA()
658 //Initialize the QA and start of cycle
659 AliCodeTimerAuto("",0);
661 if (fInitQACalled) return;
662 fInitQACalled = kTRUE;
664 if (fGRPData) AliQADataMaker::SetCloningRequest( fGRPData->GetQATrigClasses(), fGRPData->GetQACloningRequest());
667 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
668 if (fWriteQAExpertData)
669 qam->SetWriteExpert() ;
671 if (qam->IsDefaultStorageSet()) {
672 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
673 AliWarning("Default QA reference storage has been already set !");
674 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
675 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
676 fQARefUri = qam->GetDefaultStorage()->GetURI();
678 if (fQARefUri.Length() > 0) {
679 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
680 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
681 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
683 fQARefUri="local://$ALICE_ROOT/QAref";
684 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
685 AliWarning("Default QA refeference storage not yet set !!!!");
686 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
687 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
690 qam->SetDefaultStorage(fQARefUri);
694 qam->SetActiveDetectors(fQADetectors) ;
695 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
696 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
697 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
699 if (!fRawReader && !fInput && IsInTasks(AliQAv1::kRAWS))
700 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
701 qam->SetTasks(fQATasks) ;
702 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
705 Bool_t sameCycle = kFALSE ;
706 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
707 AliInfo(Form("Initializing the global QA data maker"));
708 if (IsInTasks(AliQAv1::kRECPOINTS)) {
709 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
710 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
711 AliTracker::SetResidualsArray(arr);
714 if (IsInTasks(AliQAv1::kESDS)) {
715 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
716 qadm->Init(AliQAv1::kESDS);
719 AliSysInfo::AddStamp("InitQA") ;
722 //_____________________________________________________________________________
723 void AliReconstruction::MergeQA(const char *fileName)
725 //Initialize the QA and start of cycle
726 AliCodeTimerAuto("",0) ;
727 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
728 AliSysInfo::AddStamp("MergeQA") ;
731 //_____________________________________________________________________________
732 void AliReconstruction::InitCDB()
734 // activate a default CDB storage
735 // First check if we have any CDB storage set, because it is used
736 // to retrieve the calibration and alignment constants
737 AliCodeTimerAuto("",0);
739 if (fInitCDBCalled) return;
740 fInitCDBCalled = kTRUE;
742 AliCDBManager* man = AliCDBManager::Instance();
743 if (man->IsDefaultStorageSet())
745 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
746 AliWarning("Default CDB storage has been already set !");
747 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
748 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
749 fCDBUri = man->GetDefaultStorage()->GetURI();
752 if (fCDBUri.Length() > 0)
754 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
755 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
756 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
757 man->SetDefaultStorage(fCDBUri);
759 else if (!man->GetRaw()){
760 fCDBUri="local://$ALICE_ROOT/OCDB";
761 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
762 AliWarning("Default CDB storage not yet set !!!!");
763 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
764 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
765 man->SetDefaultStorage(fCDBUri);
768 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
769 AliWarning("Default storage will be set after setting the Run Number!!!");
770 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
774 // Now activate the detector specific CDB storage locations
775 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
776 TObject* obj = fSpecCDBUri[i];
778 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
779 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
780 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
781 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
783 AliSysInfo::AddStamp("InitCDB");
786 //_____________________________________________________________________________
787 void AliReconstruction::SetDefaultStorage(const char* uri) {
788 // Store the desired default CDB storage location
789 // Activate it later within the Run() method
795 //_____________________________________________________________________________
796 void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
797 // Store the desired default CDB storage location
798 // Activate it later within the Run() method
801 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
804 //_____________________________________________________________________________
805 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
806 // Store a detector-specific CDB storage location
807 // Activate it later within the Run() method
809 AliCDBPath aPath(calibType);
810 if(!aPath.IsValid()){
811 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
812 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
813 if(!strcmp(calibType, fgkDetectorName[iDet])) {
814 aPath.SetPath(Form("%s/*", calibType));
815 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
819 if(!aPath.IsValid()){
820 AliError(Form("Not a valid path or detector: %s", calibType));
825 // // check that calibType refers to a "valid" detector name
826 // Bool_t isDetector = kFALSE;
827 // for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
828 // TString detName = fgkDetectorName[iDet];
829 // if(aPath.GetLevel0() == detName) {
830 // isDetector = kTRUE;
836 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
840 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
841 if (obj) fSpecCDBUri.Remove(obj);
842 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
846 //_____________________________________________________________________________
847 Bool_t AliReconstruction::SetRunNumberFromData()
849 // The method is called in Run() in order
850 // to set a correct run number.
851 // In case of raw data reconstruction the
852 // run number is taken from the raw data header
854 if (fSetRunNumberFromDataCalled) return kTRUE;
855 fSetRunNumberFromDataCalled = kTRUE;
857 AliCDBManager* man = AliCDBManager::Instance();
860 if(fRawReader->NextEvent()) {
861 if(man->GetRun() > 0) {
862 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
864 man->SetRun(fRawReader->GetRunNumber());
865 fRawReader->RewindEvents();
868 if(man->GetRun() > 0) {
869 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
872 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
878 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
880 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
885 // read run number from gAlice
886 if(rl->GetHeader()) {
887 man->SetRun(rl->GetHeader()->GetRun());
892 AliError("Neither run-loader header nor RawReader objects are found !");
904 //_____________________________________________________________________________
905 void AliReconstruction::SetCDBLock() {
906 // Set CDB lock: from now on it is forbidden to reset the run number
907 // or the default storage or to activate any further storage!
909 AliCDBManager::Instance()->SetLock(1);
912 //_____________________________________________________________________________
913 void AliReconstruction::MatchUpgradeDetector() {
914 // Translates detector name in a boolean.
915 // The boolean is used in GetReconstructor to load the
916 // upgrade reconstructor instead of the standard one.
917 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
918 if(fUpgradeModule.Contains(fgkDetectorName[iDet])) fUpgradeMask[iDet]=kTRUE;
921 //_____________________________________________________________________________
922 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
924 // Read the alignment objects from CDB.
925 // Each detector is supposed to have the
926 // alignment objects in DET/Align/Data CDB path.
927 // All the detector objects are then collected,
928 // sorted by geometry level (starting from ALIC) and
929 // then applied to the TGeo geometry.
930 // Finally an overlaps check is performed.
932 // Load alignment data from CDB and fill fAlignObjArray
933 if(fLoadAlignFromCDB){
935 TString detStr = detectors;
936 TString loadAlObjsListOfDets = "";
938 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
939 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
940 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
942 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
944 loadAlObjsListOfDets += fgkDetectorName[iDet];
945 loadAlObjsListOfDets += " ";
947 } // end loop over detectors
949 if(AliGeomManager::GetNalignable("GRP") != 0)
950 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
951 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
953 // Check if the array with alignment objects was
954 // provided by the user. If yes, apply the objects
955 // to the present TGeo geometry
956 if (fAlignObjArray) {
957 if (gGeoManager && gGeoManager->IsClosed()) {
958 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
959 AliError("The misalignment of one or more volumes failed!"
960 "Compare the list of simulated detectors and the list of detector alignment data!");
965 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
971 if (fAlignObjArray) {
972 fAlignObjArray->Delete();
973 delete fAlignObjArray; fAlignObjArray=NULL;
979 //_____________________________________________________________________________
980 void AliReconstruction::SetGAliceFile(const char* fileName)
982 // set the name of the galice file
984 fGAliceFileName = fileName;
987 //_____________________________________________________________________________
988 void AliReconstruction::SetInput(const char* input)
990 // In case the input string starts with 'mem://', we run in an online mode
991 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
992 // file is assumed. One can give as an input:
993 // mem://: - events taken from DAQ monitoring libs online
995 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
996 if (input) fRawInput = input;
999 //_____________________________________________________________________________
1000 void AliReconstruction::SetOutput(const char* output)
1002 // Set the output ESD filename
1003 // 'output' is a normalt ROOT url
1004 // The method is used in case of raw-data reco with PROOF
1005 if (output) fESDOutput = output;
1008 //_____________________________________________________________________________
1009 void AliReconstruction::SetOption(const char* detector, const char* option)
1011 // set options for the reconstruction of a detector
1013 TObject* obj = fOptions.FindObject(detector);
1014 if (obj) fOptions.Remove(obj);
1015 fOptions.Add(new TNamed(detector, option));
1018 //_____________________________________________________________________________
1019 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1021 // Set custom reconstruction parameters for a given detector
1022 // Single set of parameters for all the events
1024 // First check if the reco-params are global
1025 if(!strcmp(detector, "GRP")) {
1026 par->SetAsDefault();
1027 fRecoParam.AddDetRecoParam(kNDetectors,par);
1031 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1032 if(!strcmp(detector, fgkDetectorName[iDet])) {
1033 par->SetAsDefault();
1034 fRecoParam.AddDetRecoParam(iDet,par);
1041 //_____________________________________________________________________________
1042 Bool_t AliReconstruction::InitGRP() {
1043 //------------------------------------
1044 // Initialization of the GRP entry
1045 //------------------------------------
1046 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
1050 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
1053 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
1055 fGRPData = new AliGRPObject();
1056 fGRPData->ReadValuesFromMap(m);
1060 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
1061 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
1065 // FIX ME: The unloading of GRP entry is temporarily disabled
1066 // because ZDC and VZERO are using it in order to initialize
1067 // their reconstructor objects. In the future one has to think
1068 // of propagating AliRunInfo to the reconstructors.
1069 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
1073 AliError("No GRP entry found in OCDB!");
1077 TString lhcState = fGRPData->GetLHCState();
1078 if (lhcState==AliGRPObject::GetInvalidString()) {
1079 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
1080 lhcState = "UNKNOWN";
1083 TString beamType = fGRPData->GetBeamType();
1084 if (beamType==AliGRPObject::GetInvalidString()) {
1085 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
1086 beamType = "UNKNOWN";
1089 Float_t beamEnergy = fGRPData->GetBeamEnergy();
1090 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
1091 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
1095 TString runType = fGRPData->GetRunType();
1096 if (runType==AliGRPObject::GetInvalidString()) {
1097 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
1098 runType = "UNKNOWN";
1101 Int_t activeDetectors = fGRPData->GetDetectorMask();
1102 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
1103 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
1104 activeDetectors = 1074790399;
1106 AliDebug(1, Form("activeDetectors = %d", activeDetectors));
1108 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
1112 // Process the list of active detectors
1113 if (activeDetectors) {
1114 UInt_t detMask = activeDetectors;
1115 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1116 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
1117 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1118 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1119 fFillESD = MatchDetectorList(fFillESD,detMask);
1120 fQADetectors = MatchDetectorList(fQADetectors,detMask);
1121 fDeleteRecPoints = MatchDetectorList(fDeleteRecPoints,detMask);
1122 fDeleteDigits = MatchDetectorList(fDeleteDigits,detMask);
1123 fLoadCDB.Form("%s %s %s %s",
1124 fRunLocalReconstruction.Data(),
1125 fRunTracking.Data(),
1127 fQADetectors.Data());
1128 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
1129 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1) &&
1130 !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
1131 !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
1132 // switch off the vertexer
1133 AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer and Trackleter are switched off.");
1134 fRunVertexFinder = kFALSE;
1135 fRunMultFinder = kFALSE;
1137 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1138 // switch off the reading of CTP raw-data payload
1139 if (fFillTriggerESD) {
1140 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1141 fFillTriggerESD = kFALSE;
1146 AliInfo("===================================================================================");
1147 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1148 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1149 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
1150 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
1151 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
1152 AliInfo("===================================================================================");
1154 //*** Dealing with the magnetic field map
1155 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1156 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1157 AliInfo("ExpertMode!!! GRP information will be ignored !");
1158 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1161 AliInfo("Destroying existing B field instance!");
1162 delete TGeoGlobalMagField::Instance();
1165 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
1166 // Construct the field map out of the information retrieved from GRP.
1169 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1170 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1171 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1175 Char_t l3Polarity = fGRPData->GetL3Polarity();
1176 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1177 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1182 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1183 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1184 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1188 Char_t diPolarity = fGRPData->GetDipolePolarity();
1189 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1190 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1194 // read special bits for the polarity convention and map type
1195 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1196 Bool_t uniformB = fGRPData->IsUniformBMap();
1199 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1200 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1201 polConvention,uniformB,beamEnergy, beamType.Data());
1203 TGeoGlobalMagField::Instance()->SetField( fld );
1204 TGeoGlobalMagField::Instance()->Lock();
1205 AliInfo("Running with the B field constructed out of GRP !");
1207 else AliFatal("Failed to create a B field map !");
1209 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1212 //*** Get the diamond profiles from OCDB
1213 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1215 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1217 AliError("No SPD diamond profile found in OCDB!");
1220 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1222 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1224 AliError("No diamond profile found in OCDB!");
1227 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1229 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1231 AliError("No TPC diamond profile found in OCDB!");
1234 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1236 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1240 if (!fListOfCosmicTriggers) {
1241 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1247 //_____________________________________________________________________________
1248 Bool_t AliReconstruction::LoadCDB()
1250 // Load CDB entries for all active detectors.
1251 // By default we load all the entries in <det>/Calib
1254 AliCodeTimerAuto("",0);
1256 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1258 AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
1260 TString detStr = fLoadCDB;
1261 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1262 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1263 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1264 AliCDBManager::Instance()->GetAll(Form("%s/Trigger/*",fgkDetectorName[iDet]));
1267 // Temporary fix - one has to define the correct policy in order
1268 // to load the trigger OCDB entries only for the detectors that
1269 // in the trigger or that are needed in order to put correct
1270 // information in ESD
1271 AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
1275 //_____________________________________________________________________________
1276 Bool_t AliReconstruction::LoadTriggerScalersCDB()
1278 // Load CTP scalers from OCDB.
1279 // The scalers are checked for consistency.
1281 AliCodeTimerAuto("",0);
1283 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
1287 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1288 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1290 if (fRunScalers && (fRunScalers->CorrectScalersOverflow() == 0)) AliInfo("32bit Trigger counters corrected for overflow");
1295 //_____________________________________________________________________________
1296 Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
1298 // Load CTP timing information (alignment)
1301 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
1302 if (!entry) return kFALSE;
1304 AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
1305 fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
1308 AliCDBEntry* entry2 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
1309 if (!entry2) return kFALSE;
1311 AliInfo("Found an AliCTPTimeParams in GRP/CTP/TimeAlign, reading it");
1312 fCTPTimeAlign = dynamic_cast<AliCTPTimeParams*> (entry2->GetObject());
1313 entry2->SetOwner(0);
1318 //_____________________________________________________________________________
1319 Bool_t AliReconstruction::ReadIntensityInfoCDB()
1321 // Load LHC DIP data
1322 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/LHCData");
1323 AliCDBEntry* entryCTP = AliCDBManager::Instance()->Get("GRP/CTP/Config");
1325 if (!entry || !entryCTP) {
1326 AliError(Form("Failed to extract CDB objects GRP/GRP/LHCData: %p or GRP/CTP/Config: %p",entry,entryCTP));
1330 enum {kA,kB,kC,kE,kNMasks};
1331 AliTriggerConfiguration* conf = (AliTriggerConfiguration*)entryCTP->GetObject();
1332 const TObjArray& clArr = conf->GetClasses();
1333 TObjArray masks(kNMasks);
1335 AliTriggerClass* trClass = 0;
1337 masks.SetOwner(kFALSE);
1339 while ( (trClass=(AliTriggerClass*)next()) ) {
1340 TString trName = trClass->GetName();
1341 int ind = trName.Index("-"); // prefix in front of A,B,C,E
1342 if (ind<1) continue; // anomaly
1344 trName = trName.Data() + ind;
1345 AliTriggerBCMask* bcMask = trClass->GetBCMask();
1346 if (!bcMask) continue;
1348 if (trName.BeginsWith("-A-")) which |= 0x1<<kA;
1349 else if (trName.BeginsWith("-B-")) which |= 0x1<<kB;
1350 else if (trName.BeginsWith("-C-")) which |= 0x1<<kC;
1351 else if (trName.BeginsWith("-E-")) which |= 0x1<<kE;
1352 else if (trName.BeginsWith("-AC-")) which |= (0x1<<kA) | (0x1<<kC);
1353 else if (trName.BeginsWith("-CA-")) which |= (0x1<<kA) | (0x1<<kC);
1354 else { AliWarning(Form("Unknown trigger type %s\n",trClass->GetName())); continue;}
1356 for (int ip=kNMasks;ip--;) {
1357 if ( !(which&(0x1<<ip)) || masks[ip] ) continue; // does not match or already done
1358 masks[ip] = (TObject*)bcMask;
1361 if (nFound==kNMasks) break;
1364 AliInfo("Reading mean bunch intensities from GRP/GRP/LHCData");
1365 AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
1367 for (int ib=2;ib--;) {
1369 if (dipData && (dipData->GetMeanIntensity(ib,intI,intNI,&masks)>=0)) {
1370 fBeamInt[ib][0] = intI;
1371 fBeamInt[ib][1] = intNI;
1372 AliInfo(Form("Mean intensity for beam %d: Interacting:%.2e Non-Interacting:%.2e",ib,intI,intNI));
1380 //_____________________________________________________________________________
1381 Bool_t AliReconstruction::Run(const char* input)
1384 AliCodeTimerAuto("",0);
1387 if (GetAbort() != TSelector::kContinue) return kFALSE;
1389 TChain *chain = NULL;
1390 if (fRawReader && (chain = fRawReader->GetChain())) {
1391 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
1394 // Temporary fix for long raw-data runs (until socket timeout handling in PROOF is revised)
1395 gProof->Exec("gEnv->SetValue(\"Proof.SocketActivityTimeout\",-1)", kTRUE);
1398 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1400 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1401 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1403 gProof->AddInput(this);
1405 if (!ParseOutput()) return kFALSE;
1407 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
1409 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
1412 chain->Process(this,"",nEntries,fFirstEvent);
1417 if (GetAbort() != TSelector::kContinue) return kFALSE;
1419 if (GetAbort() != TSelector::kContinue) return kFALSE;
1420 //******* The loop over events
1421 AliInfo("Starting looping over events");
1423 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1424 (fRawReader && fRawReader->NextEvent())) {
1426 // check if process has enough resources
1427 if (!HasEnoughResources(iEvent)) break;
1428 if (!ProcessEvent(iEvent)) {
1429 Abort("ProcessEvent",TSelector::kAbortFile);
1435 if (GetAbort() != TSelector::kContinue) return kFALSE;
1437 if (GetAbort() != TSelector::kContinue) return kFALSE;
1443 //_____________________________________________________________________________
1444 void AliReconstruction::InitRawReader(const char* input)
1446 // Init raw-reader and
1447 // set the input in case of raw data
1449 AliCodeTimerAuto("",0);
1451 if (input) fRawInput = input;
1452 fRawReader = AliRawReader::Create(fRawInput.Data());
1454 if (fRawInput.IsNull()) {
1455 AliInfo("Reconstruction will run over digits");
1458 AliFatal("Can not create raw-data reader ! Exiting...");
1462 if (!fEquipIdMap.IsNull() && fRawReader)
1463 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1465 if (!fUseHLTData.IsNull()) {
1466 // create the RawReaderHLT which performs redirection of HLT input data for
1467 // the specified detectors
1468 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1470 fParentRawReader=fRawReader;
1471 fRawReader=pRawReader;
1473 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1476 AliSysInfo::AddStamp("CreateRawReader");
1479 //_____________________________________________________________________________
1480 void AliReconstruction::InitRun(const char* input)
1482 // Initialization of raw-reader,
1483 // run number, CDB etc.
1484 AliCodeTimerAuto("",0);
1485 AliSysInfo::AddStamp("Start");
1487 // Initialize raw-reader if any
1488 InitRawReader(input);
1490 // Initialize the CDB storage
1493 // Set run number in CDBManager (if it is not already set by the user)
1494 if (!SetRunNumberFromData()) {
1495 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1499 // Set CDB lock: from now on it is forbidden to reset the run number
1500 // or the default storage or to activate any further storage!
1505 //_____________________________________________________________________________
1506 void AliReconstruction::Begin(TTree *)
1508 // Initialize AlReconstruction before
1509 // going into the event loop
1510 // Should follow the TSelector convention
1511 // i.e. initialize only the object on the client side
1512 AliCodeTimerAuto("",0);
1514 AliReconstruction *reco = NULL;
1516 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1519 AliSysInfo::AddStamp("ReadInputInBegin");
1522 // Import ideal TGeo geometry and apply misalignment
1524 TString geom(gSystem->DirName(fGAliceFileName));
1525 geom += "/geometry.root";
1526 AliGeomManager::LoadGeometry(geom.Data());
1528 Abort("LoadGeometry", TSelector::kAbortProcess);
1531 AliSysInfo::AddStamp("LoadGeom");
1532 TString detsToCheck=fRunLocalReconstruction;
1533 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1534 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1537 AliSysInfo::AddStamp("CheckGeom");
1540 Bool_t loadedFromSnapshot=kFALSE;
1541 Bool_t toCDBSnapshot=kFALSE;
1542 TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
1543 // in reading from and writing to a snapshot file at the same time
1544 if(TString(gSystem->Getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){
1545 toCDBSnapshot=kTRUE;
1546 //fFromCDBSnapshot=kFALSE;
1547 TString snapshotFile(gSystem->Getenv("OCDB_SNAPSHOT_FILENAME"));
1548 if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace()))
1549 snapshotFileOut = snapshotFile;
1551 snapshotFileOut="OCDB.root";
1553 if(fFromCDBSnapshot){
1554 AliDebug(2,"Initializing from a CDB snapshot");
1555 loadedFromSnapshot = AliCDBManager::Instance()->InitFromSnapshot(fSnapshotFileName.Data());
1558 if (!MisalignGeometry(fLoadAlignData)) {
1559 Abort("MisalignGeometry", TSelector::kAbortProcess);
1562 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1563 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1564 AliSysInfo::AddStamp("MisalignGeom");
1567 Abort("InitGRP", TSelector::kAbortProcess);
1570 AliSysInfo::AddStamp("InitGRP");
1571 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1573 if(!loadedFromSnapshot){
1575 Abort("LoadCDB", TSelector::kAbortProcess);
1578 AliSysInfo::AddStamp("LoadCDB");
1581 if (!LoadTriggerScalersCDB()) {
1582 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1585 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1587 if (!LoadCTPTimeParamsCDB()) {
1588 Abort("LoadCTPTimeParamsCDB", TSelector::kAbortProcess);
1591 AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
1593 if (!ReadIntensityInfoCDB()) {
1594 Abort("ReadIntensityInfoCDB", TSelector::kAbortProcess);
1597 AliSysInfo::AddStamp("ReadIntensityInfoCDB");
1599 // Read the reconstruction parameters from OCDB
1600 if (!InitRecoParams()) {
1601 AliWarning("Not all detectors have correct RecoParam objects initialized");
1603 AliSysInfo::AddStamp("InitRecoParams");
1606 AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data());
1607 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1608 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1610 if (fInput && gProof) {
1611 if (reco) *reco = *this;
1613 gGeoManager->SetName("Geometry");
1614 gProof->AddInputData(gGeoManager,kTRUE);
1616 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
1617 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1618 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1619 magFieldMap->SetName("MagneticFieldMap");
1620 gProof->AddInputData(magFieldMap,kTRUE);
1622 fAnalysis->SetName("Analysis");
1623 gProof->AddInputData(fAnalysis,kTRUE);
1629 //_____________________________________________________________________________
1630 void AliReconstruction::SlaveBegin(TTree*)
1632 // Initialization related to run-loader,
1633 // vertexer, trackers, recontructors
1634 // In proof mode it is executed on the slave
1635 AliCodeTimerAuto("",0);
1637 TProofOutputFile *outProofFile = NULL;
1639 if (AliDebugLevel() > 0) fInput->Print();
1640 if (AliDebugLevel() > 10) fInput->Dump();
1641 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1644 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1646 AliGeomManager::SetGeometry(tgeo);
1648 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1649 Int_t runNumber = -1;
1650 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1651 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1652 man->SetCacheFlag(kTRUE);
1653 man->SetLock(kTRUE);
1657 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1658 AliMagF *newMap = new AliMagF(*map);
1659 if (!newMap->LoadParameterization()) {
1660 Abort("AliMagF::LoadParameterization", TSelector::kAbortProcess);
1663 TGeoGlobalMagField::Instance()->SetField(newMap);
1664 TGeoGlobalMagField::Instance()->Lock();
1667 // Attempt to get the analysis manager from the input list
1668 fAnalysis = (AliAnalysisManager*)fInput->FindObject("Analysis");
1669 if (fAnalysis) AliInfo("==== Analysis manager retrieved from input list ====");
1671 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1672 fProofOutputFileName = outputFileName->GetTitle();
1673 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1674 fProofOutputLocation = outputLocation->GetTitle();
1675 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1676 fProofOutputDataset = kTRUE;
1677 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1678 fProofOutputArchive = archiveList->GetTitle();
1679 if (!fProofOutputFileName.IsNull() &&
1680 !fProofOutputLocation.IsNull() &&
1681 fProofOutputArchive.IsNull()) {
1682 if (!fProofOutputDataset) {
1683 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1684 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1687 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1689 if (AliDebugLevel() > 0) outProofFile->Dump();
1690 fOutput->Add(outProofFile);
1692 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1694 // Check if analysis was requested in the reconstruction event loop
1696 // Attempt to connect in-memory singleton
1697 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1698 if (fAnalysis) AliInfo(Form("==== Analysis manager <%s> found in memory ====", fAnalysis->GetName()));
1699 // Check if an analysis macro was specified
1700 if (!fAnalysis && !fAnalysisMacro.IsNull()) {
1701 // Run specified analysis macro
1702 gROOT->ProcessLine(Form(".x %s",fAnalysisMacro.Data()));
1703 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1704 if (!fAnalysis) AliError(Form("No analysis manager produced by analysis macro %s", fAnalysisMacro.Data()));
1705 else AliInfo(Form("==== Analysis manager <%s> produced by analysis macro <%s> ====",
1706 fAnalysis->GetName(), fAnalysisMacro.Data()));
1710 // get the run loader
1711 if (!InitRunLoader()) {
1712 Abort("InitRunLoader", TSelector::kAbortProcess);
1715 AliSysInfo::AddStamp("LoadLoader");
1717 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1720 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1721 Abort("CreateTrackers", TSelector::kAbortProcess);
1724 AliSysInfo::AddStamp("CreateTrackers");
1726 // create the ESD output file and tree
1727 if (!outProofFile) {
1728 ffile = TFile::Open("AliESDs.root", "RECREATE");
1729 ffile->SetCompressionLevel(2);
1730 if (!ffile->IsOpen()) {
1731 Abort("OpenESDFile", TSelector::kAbortProcess);
1736 AliInfo(Form("Opening output PROOF file: %s/%s",
1737 outProofFile->GetDir(), outProofFile->GetFileName()));
1738 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1739 Abort(Form("Problems opening output PROOF file: %s/%s",
1740 outProofFile->GetDir(), outProofFile->GetFileName()),
1741 TSelector::kAbortProcess);
1746 ftree = new TTree("esdTree", "Tree with ESD objects");
1747 ftree->SetAutoFlush(1);
1748 fesd = new AliESDEvent();
1749 fesd->CreateStdContent();
1750 // add a so far non-std object to the ESD, this will
1751 // become part of the std content
1752 fesd->AddObject(new AliESDHLTDecision);
1754 const Int_t kBufsize = 32000/4; // default value in TTree::Branch()
1755 fesd->WriteToTree(ftree);
1756 if (fWriteESDfriend) {
1757 ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
1758 ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
1759 ftreeF->SetAutoFlush(1);
1760 fesdf = new AliESDfriend();
1761 ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf, kBufsize);
1762 fesd->AddObject(fesdf);
1765 ftree->GetUserInfo()->Add(fesd);
1767 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1768 fhlttree->SetAutoFlush(1);
1769 fhltesd = new AliESDEvent();
1770 fhltesd->CreateStdContent();
1771 // read the ESD template from CDB
1772 // HLT is allowed to put non-std content to its ESD, the non-std
1773 // objects need to be created before invocation of WriteToTree in
1774 // order to create all branches. Initialization is done from an
1775 // ESD layout template in CDB
1776 AliCDBManager* man = AliCDBManager::Instance();
1777 AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
1778 AliCDBEntry* hltESDConfig=NULL;
1779 if (man->GetId(hltESDConfigPath)!=NULL &&
1780 (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
1781 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1783 // init all internal variables from the list of objects
1784 pESDLayout->GetStdContent();
1786 // copy content and create non-std objects
1787 *fhltesd=*pESDLayout;
1790 AliError(Form("error setting hltEsd layout from %s: invalid object type",
1791 hltESDConfigPath.GetPath().Data()));
1795 fhltesd->WriteToTree(fhlttree);
1796 fhlttree->GetUserInfo()->Add(fhltesd);
1798 ProcInfo_t procInfo;
1799 gSystem->GetProcInfo(&procInfo);
1800 AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
1803 //Initialize the QA and start of cycle
1804 if (fRunQA || fRunGlobalQA)
1807 //Initialize the Plane Efficiency framework
1808 if (fRunPlaneEff && !InitPlaneEff()) {
1809 Abort("InitPlaneEff", TSelector::kAbortProcess);
1813 if (strcmp(gProgName,"alieve") == 0)
1814 fRunAliEVE = InitAliEVE();
1815 // If we have an analysis manager, connect the AliRecoInputHandler here
1817 if (!dynamic_cast<AliRecoInputHandler*>(fAnalysis->GetInputEventHandler())) {
1818 AliError("Analysis manager used in reconstruction should use AliRecoInputHandler - \
1819 \n ->Replacing with AliRecoInputHandler instance.");
1820 delete fAnalysis->GetInputEventHandler();
1822 // Set the event and other data pointers
1823 fRecoHandler = new AliRecoInputHandler();
1824 fRecoHandler->Init(ftree, "LOCAL");
1825 fRecoHandler->SetEvent(fesd);
1826 fRecoHandler->SetESDfriend(fesdf);
1827 fRecoHandler->SetHLTEvent(fhltesd);
1828 fRecoHandler->SetHLTTree(fhlttree);
1829 fAnalysis->SetInputEventHandler(fRecoHandler);
1830 // Enter external loop mode
1831 fAnalysis->SetExternalLoop(kTRUE);
1832 // Initialize analysis
1833 fAnalysis->StartAnalysis("local", (TTree*)0);
1834 // Connect ESD tree with the input container
1835 fAnalysis->GetCommonInputContainer()->SetData(ftree);
1840 //_____________________________________________________________________________
1841 Bool_t AliReconstruction::Process(Long64_t entry)
1843 // run the reconstruction over a single entry
1844 // from the chain with raw data
1845 AliCodeTimerAuto("",0);
1847 TTree *currTree = fChain->GetTree();
1848 AliRawVEvent *event = NULL;
1849 currTree->SetBranchAddress("rawevent",&event);
1850 currTree->GetEntry(entry);
1851 fRawReader = new AliRawReaderRoot(event);
1852 // check if process has enough resources
1853 if (!HasEnoughResources(entry)) return kFALSE;
1854 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1862 //_____________________________________________________________________________
1863 void AliReconstruction::Init(TTree *tree)
1865 // Implementation of TSelector::Init()
1868 AliError("The input tree is not found!");
1874 //_____________________________________________________________________________
1875 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1877 // run the reconstruction over a single event
1878 // The event loop is steered in Run method
1881 static Long_t oldMres=0;
1882 static Long_t oldMvir=0;
1883 static Float_t oldCPU=0;
1884 static Long_t aveDMres=0;
1885 static Long_t aveDMvir=0;
1886 static Float_t aveDCPU=0;
1888 AliCodeTimerAuto("",0);
1892 AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
1894 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1895 fRunLoader->SetEventNumber(iEvent);
1897 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1899 fRunLoader->TreeE()->Fill();
1901 if (fRawReader && fRawReader->UseAutoSaveESD())
1902 fRunLoader->TreeE()->AutoSave("SaveSelf");
1905 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1909 InitPools(); // make sure the pools are ready
1911 fRunLoader->GetEvent(iEvent);
1913 // Fill Event-info object
1915 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
1917 ProcInfo_t procInfo;
1918 if(iEvent==fFirstEvent) {
1919 gSystem->GetProcInfo(&procInfo);
1920 oldMres=procInfo.fMemResident;
1921 oldMvir=procInfo.fMemVirtual;
1922 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
1924 AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
1926 AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent);
1928 // Set the reco-params
1930 TString detStr = fLoadCDB;
1931 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1932 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1933 AliReconstructor *reconstructor = GetReconstructor(iDet);
1934 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1935 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1936 reconstructor->SetRecoParam(par);
1937 reconstructor->GetPidSettings(&pid);
1938 reconstructor->SetEventInfo(&fEventInfo);
1940 AliQAManager::QAManager()->SetEventInfo(&fEventInfo) ;
1941 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
1942 if (par) AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
1947 if (fRunQA || fRunGlobalQA) AliQADataMaker::SetEventTrigClasses(fEventInfo.GetTriggerClasses()); // RS: select which histo clones are to be filled
1950 const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
1951 AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ;
1952 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
1957 if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
1958 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1959 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
1960 AliSysInfo::AddStamp(Form("RawQA_%d",iEvent), 0,0,iEvent);
1962 // local single event reconstruction
1963 if (!fRunLocalReconstruction.IsNull()) {
1964 TString detectors=fRunLocalReconstruction;
1965 // run HLT event reconstruction first
1966 // ;-( IsSelected changes the string
1967 if (IsSelected("HLT", detectors) &&
1968 !RunLocalEventReconstruction("HLT")) {
1969 if (fStopOnError) {CleanUp(); return kFALSE;}
1971 detectors=fRunLocalReconstruction;
1972 detectors.ReplaceAll("HLT", "");
1973 if (!RunLocalEventReconstruction(detectors)) {
1982 // fill Event header information from the RawEventHeader
1983 if (fRawReader){FillRawEventHeaderESD(fesd);}
1984 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
1986 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1987 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1989 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
1990 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
1991 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
1992 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
1994 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1995 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1997 fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
1998 fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
2000 // Set magnetic field from the tracker
2001 fesd->SetMagneticField(AliTracker::GetBz());
2002 fhltesd->SetMagneticField(AliTracker::GetBz());
2004 AliESDRun *esdRun,*esdRunH;
2005 esdRun = (AliESDRun*)fesd->GetESDRun();
2006 esdRunH = (AliESDRun*)fhltesd->GetESDRun();
2007 esdRun->SetBeamEnergyIsSqrtSHalfGeV();
2008 esdRunH->SetBeamEnergyIsSqrtSHalfGeV();
2010 for (int ib=2;ib--;) for (int it=2;it--;) {
2011 esdRun->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2012 esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2015 fesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2016 fesd->SetBeamType(fGRPData->GetBeamType().Data());
2017 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2018 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2019 fhltesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2020 fhltesd->SetBeamType(fGRPData->GetBeamType().Data());
2021 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2022 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2024 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
2025 if (fld) { // set info needed for field initialization
2026 fesd->SetCurrentL3(fld->GetCurrentSol());
2027 fesd->SetCurrentDip(fld->GetCurrentDip());
2028 fesd->SetUniformBMap(fld->IsUniform());
2029 fesd->SetBInfoStored();
2031 fhltesd->SetCurrentL3(fld->GetCurrentSol());
2032 fhltesd->SetCurrentDip(fld->GetCurrentDip());
2033 fhltesd->SetUniformBMap(fld->IsUniform());
2034 fhltesd->SetBInfoStored();
2037 // Set most probable pt, for B=0 tracking
2038 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
2039 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
2040 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
2042 // Fill raw-data error log into the ESD
2043 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
2045 AliSysInfo::AddStamp(Form("FillHeadErrs_%d",iEvent), 0,0,iEvent);
2048 if (fRunVertexFinder) {
2049 if (!RunVertexFinder(fesd)) {
2050 if (fStopOnError) {CleanUp(); return kFALSE;}
2052 AliSysInfo::AddStamp(Form("VtxFinder_%d",iEvent), 0,0,iEvent);
2055 // For Plane Efficiency: run the SPD trackleter
2056 if (fRunPlaneEff && fSPDTrackleter) {
2057 if (!RunSPDTrackleting(fesd)) {
2058 if (fStopOnError) {CleanUp(); return kFALSE;}
2060 AliSysInfo::AddStamp(Form("TrackletEff_%d",iEvent), 0,0,iEvent);
2064 if (!fRunTracking.IsNull()) {
2065 if (fRunMuonTracking) {
2066 if (!RunMuonTracking(fesd)) {
2067 if (fStopOnError) {CleanUp(); return kFALSE;}
2070 AliSysInfo::AddStamp(Form("TrackingMUON_%d",iEvent), 0,0,iEvent);
2074 if (!fRunTracking.IsNull()) {
2075 if (!RunTracking(fesd,pid)) {
2076 if (fStopOnError) {CleanUp(); return kFALSE;}
2081 if (!fFillESD.IsNull()) {
2082 TString detectors=fFillESD;
2083 // run HLT first and on hltesd
2084 // ;-( IsSelected changes the string
2085 if (IsSelected("HLT", detectors) &&
2086 !FillESD(fhltesd, "HLT")) {
2087 if (fStopOnError) {CleanUp(); return kFALSE;}
2090 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
2091 if (detectors.Contains("ALL")) {
2093 for (Int_t idet=0; idet<kNDetectors; ++idet){
2094 detectors += fgkDetectorName[idet];
2098 detectors.ReplaceAll("HLT", "");
2099 if (!FillESD(fesd, detectors)) {
2100 if (fStopOnError) {CleanUp(); return kFALSE;}
2108 // Propagate track to the beam pipe (if not already done by ITS)
2110 const Int_t ntracks = fesd->GetNumberOfTracks();
2111 const Double_t kRadius = 2.8; //something less than the beam pipe radius
2114 UShort_t selectedIdx[ntracks];
2116 for (Int_t itrack=0; itrack<ntracks; itrack++){
2117 const Double_t kMaxStep = 1; //max step over the material
2120 AliESDtrack *track = fesd->GetTrack(itrack);
2121 if (!track) continue;
2123 AliExternalTrackParam *tpcTrack =
2124 (AliExternalTrackParam *)track->GetTPCInnerParam();
2128 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
2131 Int_t n=trkArray.GetEntriesFast();
2132 selectedIdx[n]=track->GetID();
2133 trkArray.AddLast(tpcTrack);
2136 //Tracks refitted by ITS should already be at the SPD vertex
2137 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
2140 PropagateTrackToBxByBz(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
2141 Double_t x[3]; track->GetXYZ(x);
2142 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2143 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
2146 AliSysInfo::AddStamp(Form("RelToSPDVtx_%d",iEvent), 0,0,iEvent);
2148 // Improve the reconstructed primary vertex position using the tracks
2150 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
2151 if(fesd->GetPrimaryVertexSPD()) {
2152 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
2153 if(vtitle.Contains("cosmics")) {
2154 runVertexFinderTracks=kFALSE;
2158 if (runVertexFinderTracks) {
2159 // TPC + ITS primary vertex
2160 ftVertexer->SetITSMode();
2161 ftVertexer->SetConstraintOff();
2162 // get cuts for vertexer from AliGRPRecoParam
2163 Bool_t constrSPD=kFALSE;
2165 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2166 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2167 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer,nCutsVertexer);
2168 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2169 delete [] cutsVertexer; cutsVertexer = NULL;
2170 if(grpRecoParam->GetVertexerTracksConstraintITS()) {
2171 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius){
2172 ftVertexer->SetVtxStart(fDiamondProfile); // apply constraint only if sigmax is smaller than the beam pipe radius
2174 if(fDiamondProfileSPD && fDiamondProfileSPD->GetXRes()<kRadius){
2175 ftVertexer->SetVtxStart(fDiamondProfileSPD);
2181 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
2184 TString title=pvtx->GetTitle();
2185 title.Append("SPD");
2186 pvtx->SetTitle(title);
2188 if (pvtx->GetStatus()) {
2189 fesd->SetPrimaryVertexTracks(pvtx);
2190 for (Int_t i=0; i<ntracks; i++) {
2191 AliESDtrack *t = fesd->GetTrack(i);
2192 Double_t x[3]; t->GetXYZ(x);
2193 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2194 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
2197 delete pvtx; pvtx=NULL;
2199 AliSysInfo::AddStamp(Form("VtxTrk_%d",iEvent), 0,0,iEvent);
2201 // TPC-only primary vertex
2202 ftVertexer->SetTPCMode();
2203 ftVertexer->SetConstraintOff();
2204 // get cuts for vertexer from AliGRPRecoParam
2206 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2207 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2208 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer,nCutsVertexer);
2209 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2210 delete [] cutsVertexer; cutsVertexer = NULL;
2211 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC()) {
2212 if(fDiamondProfileTPC->GetXRes()<kRadius) ftVertexer->SetVtxStart(fDiamondProfileTPC); // apply constraint only if sigmax is smaller than the beam pipe radius
2215 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
2217 if (pvtx->GetStatus()) {
2218 fesd->SetPrimaryVertexTPC(pvtx);
2219 for (Int_t i=0; i<ntracks; i++) {
2220 AliESDtrack *t = fesd->GetTrack(i);
2221 Double_t x[3]; t->GetXYZ(x);
2222 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2223 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
2226 delete pvtx; pvtx=NULL;
2228 AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);
2232 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
2233 else fesd->SetDiamond(fDiamondProfileSPD);
2237 AliV0vertexer vtxer;
2238 // get cuts for V0vertexer from AliGRPRecoParam
2240 Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
2241 Double_t cutsV0vertexer[nCutsV0vertexer];
2242 grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
2243 vtxer.SetCuts(cutsV0vertexer);
2245 vtxer.Tracks2V0vertices(fesd);
2246 AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent);
2248 if (fRunCascadeFinder) {
2250 AliCascadeVertexer cvtxer;
2251 // get cuts for CascadeVertexer from AliGRPRecoParam
2253 Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
2254 Double_t cutsCascadeVertexer[nCutsCascadeVertexer];
2255 grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
2256 cvtxer.SetCuts(cutsCascadeVertexer);
2258 cvtxer.V0sTracks2CascadeVertices(fesd);
2259 AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,iEvent);
2264 if (fReconstructor[3])
2265 GetReconstructor(3)->FillEventTimeWithTOF(fesd,&pid);
2270 if (fFillTriggerESD) {
2271 if (!FillTriggerESD(fesd)) {
2272 if (fStopOnError) {CleanUp(); return kFALSE;}
2275 // Always fill scalers
2276 if (!FillTriggerScalers(fesd)) {
2277 if (fStopOnError) {CleanUp(); return kFALSE;}
2280 AliSysInfo::AddStamp(Form("FillVaria_%d",iEvent), 0,0,iEvent);
2285 AliSysInfo::AddStamp(Form("CleanESD_%d",iEvent), 0,0,iEvent);
2288 // RS run updated trackleter: since we want to mark the clusters used by tracks and also mark the
2289 // tracks interpreted as primary, this step should be done in the very end, when full
2290 // ESD info is available (particulalry, V0s)
2292 if (fRunMultFinder) {
2293 if (!RunMultFinder(fesd)) {
2294 if (fStopOnError) {CleanUp(); return kFALSE;}
2296 AliSysInfo::AddStamp(Form("MultFinder_%d",iEvent), 0,0,iEvent);
2299 if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
2300 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2301 AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ;
2302 AliSysInfo::AddStamp(Form("RunQA_%d",iEvent), 0,0,iEvent);
2305 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2307 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2308 if (qadm && IsInTasks(AliQAv1::kESDS))
2309 qadm->Exec(AliQAv1::kESDS, fesd);
2310 AliSysInfo::AddStamp(Form("RunGlobQA_%d",iEvent), 0,0,iEvent);
2313 // copy HLT decision from HLTesd to esd
2314 // the most relevant information is stored in a reduced container in the esd,
2315 // while the full information can be found in the HLTesd
2316 TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
2317 TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
2318 if (pHLTSrc && pHLTTgt) {
2319 pHLTSrc->Copy(*pHLTTgt);
2322 fPools->Print(); // RS:tmp
2323 // Perform analysis of this event if requested
2324 // RS: Should be done before WriteESDfriend, since the latter may clean the esdfriend
2326 fRecoHandler->BeginEvent(iEvent);
2327 fAnalysis->ExecAnalysis();
2328 fRecoHandler->FinishEvent();
2329 AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);
2332 // RS there is no point in filling the esdFriend object if it is not going to be written
2333 if (fWriteESDfriend) {
2335 AliSysInfo::AddStamp(Form("WriteFriend_%d",iEvent), 0,0,iEvent);
2340 AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);
2341 if (fWriteESDfriend) {
2342 // Auto-save the ESD tree in case of prompt reco @P2
2343 if (fRawReader && fRawReader->UseAutoSaveESD()) {
2344 ftree->AutoSave("SaveSelf");
2345 if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
2351 AliSysInfo::AddStamp(Form("WriteESDs_%d",iEvent), 0,0,iEvent);
2354 if (fRunAliEVE) RunAliEVE();
2358 if (fWriteESDfriend) {
2360 // fesdf->~AliESDfriend();
2361 // new (fesdf) AliESDfriend(); // Reset...
2364 gSystem->GetProcInfo(&procInfo);
2365 Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
2366 Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
2367 Float_t dCPU=procInfo.fCpuUser+procInfo.fCpuSys-oldCPU;
2368 aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
2369 aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
2370 aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
2371 AliInfo(Form("======================= End Event %d: Res %ld(%3ld <%3ld>) Vir %ld(%3ld <%3ld>) CPU %5.2f <%5.2f> ===================",
2372 iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
2373 oldMres=procInfo.fMemResident;
2374 oldMvir=procInfo.fMemVirtual;
2375 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
2378 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2379 if (fReconstructor[iDet]) {
2380 fReconstructor[iDet]->SetRecoParam(NULL);
2381 fReconstructor[iDet]->SetEventInfo(NULL);
2383 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
2386 if (fRunQA || fRunGlobalQA)
2387 AliQAManager::QAManager()->Increment() ;
2390 fPools->ResetPools();
2391 DeleteRecPoints(fDeleteRecPoints);
2392 DeleteDigits(fDeleteDigits);
2396 //_____________________________________________________________________________
2397 void AliReconstruction::SlaveTerminate()
2399 // Finalize the run on the slave side
2400 // Called after the exit
2401 // from the event loop
2402 AliCodeTimerAuto("",0);
2403 // If analysis was done during reconstruction, we need to call SlaveTerminate for it
2405 fAnalysis->PackOutput(fOutput);
2406 fAnalysis->SetSkipTerminate(kTRUE);
2407 fAnalysis->Terminate();
2410 if (fIsNewRunLoader) { // galice.root didn't exist
2411 fRunLoader->WriteHeader("OVERWRITE");
2412 fRunLoader->WriteTrigger("OVERWRITE");
2413 fRunLoader->CdGAFile();
2414 fRunLoader->Write(0, TObject::kOverwrite);
2417 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
2418 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
2420 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
2421 cdbMapCopy->SetOwner(1);
2422 cdbMapCopy->SetName("cdbMap");
2423 TIter iter(cdbMap->GetTable());
2426 while((pair = dynamic_cast<TPair*> (iter.Next()))){
2427 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
2428 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
2429 if (keyStr && valStr)
2430 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
2433 TList *cdbListCopy = new TList();
2434 cdbListCopy->SetOwner(1);
2435 cdbListCopy->SetName("cdbList");
2437 TIter iter2(cdbList);
2440 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
2441 cdbListCopy->Add(new TObjString(id->ToString().Data()));
2444 ftree->GetUserInfo()->Add(cdbMapCopy);
2445 ftree->GetUserInfo()->Add(cdbListCopy);
2447 // Add the AliRoot version that created this file
2448 TString sVersion("aliroot ");
2449 sVersion += ALIROOT_SVN_BRANCH;
2451 sVersion += ALIROOT_SVN_REVISION;
2452 sVersion += "; root ";
2453 sVersion += ROOT_SVN_BRANCH;
2455 sVersion += ROOT_SVN_REVISION;
2456 sVersion += "; metadata ";
2457 sVersion += gSystem->Getenv("PRODUCTION_METADATA");
2460 TNamed * alirootVersion = new TNamed("alirootVersion",sVersion.Data());
2461 ftree->GetUserInfo()->Add(alirootVersion); // The list becomes owner of alirootVersion
2465 // we want to have only one tree version number
2466 ftree->Write(ftree->GetName(),TObject::kOverwrite);
2467 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
2469 if (fWriteESDfriend) {
2471 ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
2474 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
2475 if (fRunPlaneEff && !FinishPlaneEff()) {
2476 AliWarning("Finish PlaneEff evaluation failed");
2479 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2480 if (fReconstructor[iDet]) fReconstructor[iDet]->Terminate();
2482 // End of cycle for the in-loop
2484 if (fRunQA || fRunGlobalQA) {
2485 AliQAManager::QAManager()->EndOfCycle() ;
2487 !fProofOutputLocation.IsNull() &&
2488 fProofOutputArchive.IsNull() &&
2489 !fProofOutputDataset) {
2490 TString qaOutputFile(Form("%sMerged.%s.Data.root",
2491 fProofOutputLocation.Data(),
2492 AliQAv1::GetQADataFileName()));
2493 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
2494 AliQAv1::GetQADataFileName()));
2495 qaProofFile->SetOutputFileName(qaOutputFile.Data());
2496 if (AliDebugLevel() > 0) qaProofFile->Dump();
2497 fOutput->Add(qaProofFile);
2498 MergeQA(qaProofFile->GetFileName());
2509 if (!fProofOutputFileName.IsNull() &&
2510 !fProofOutputLocation.IsNull() &&
2511 fProofOutputDataset &&
2512 !fProofOutputArchive.IsNull()) {
2513 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2515 fProofOutputLocation.Data());
2516 if (AliDebugLevel() > 0) zipProofFile->Dump();
2517 fOutput->Add(zipProofFile);
2518 TString fileList(fProofOutputArchive.Data());
2519 fileList.ReplaceAll(","," ");
2521 #if ROOT_SVN_REVISION >= 30174
2522 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(kTRUE),zipProofFile->GetFileName(),fileList.Data());
2524 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(),zipProofFile->GetFileName(),fileList.Data());
2526 AliInfo(Form("Executing: %s",command.Data()));
2527 gSystem->Exec(command.Data());
2532 //_____________________________________________________________________________
2533 void AliReconstruction::Terminate()
2535 // Create tags for the events in the ESD tree (the ESD tree is always present)
2536 // In case of empty events the tags will contain dummy values
2537 AliCodeTimerAuto("",0);
2540 // or for the files stopped due to the limited resources
2542 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2543 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
2544 delete esdtagCreator;
2547 // Cleanup of CDB manager: cache and active storages!
2548 AliCDBManager::Instance()->ClearCache();
2551 //_____________________________________________________________________________
2552 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2554 // run the local reconstruction
2556 static Int_t eventNr=0;
2557 AliCodeTimerAuto("",0)
2559 TString detStr = detectors;
2560 // execute HLT reconstruction first since other detector reconstruction
2561 // might depend on HLT data
2562 // key 'HLT' is removed from detStr by IsSelected
2563 if (!IsSelected("HLT", detStr)) {
2564 AliReconstructor* reconstructor = GetReconstructor(kNDetectors-1);
2565 if (reconstructor) {
2566 // there is no AliLoader for HLT, see
2567 // https://savannah.cern.ch/bugs/?35473
2568 AliInfo("running reconstruction for HLT");
2570 AliInfo("reconstructor->Reconstruct(fRawReader, NULL)");
2571 reconstructor->Reconstruct(fRawReader, NULL);
2574 AliInfo("reconstructor->Reconstruct(dummy, NULL)");
2576 reconstructor->Reconstruct(dummy, NULL);
2579 AliSysInfo::AddStamp(Form("LRecHLT_%d",eventNr), -1,1,eventNr);
2582 AliInfo(Form("kNDetectors = %d",kNDetectors));
2584 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2585 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2586 AliDebug(1, Form("Detector: %s", fgkDetectorName[iDet]));
2587 AliReconstructor* reconstructor = GetReconstructor(iDet);
2588 if (!reconstructor) continue;
2589 AliLoader* loader = fLoader[iDet];
2591 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2594 // conversion of digits
2595 if (fRawReader && reconstructor->HasDigitConversion()) {
2596 AliInfo(Form("converting raw data digits into root objects for %s",
2597 fgkDetectorName[iDet]));
2598 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
2599 // fgkDetectorName[iDet]),0);
2600 loader->LoadDigits("update");
2601 loader->CleanDigits();
2602 loader->MakeDigitsContainer();
2603 TTree* digitsTree = loader->TreeD();
2604 reconstructor->ConvertDigits(fRawReader, digitsTree);
2605 loader->WriteDigits("OVERWRITE");
2606 loader->UnloadDigits();
2607 AliSysInfo::AddStamp(Form("LRecRW2Root%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2609 // local reconstruction
2610 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
2611 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]),0);
2612 AliDebug(1, "Loading Rec Points");
2613 loader->LoadRecPoints("update");
2614 AliDebug(1, "Cleaning Rec Points");
2615 loader->CleanRecPoints();
2616 AliDebug(1, "Making Rec Points Container");
2617 loader->MakeRecPointsContainer();
2618 TTree* clustersTree = loader->TreeR();
2619 if (fRawReader && !reconstructor->HasDigitConversion()) {
2620 reconstructor->Reconstruct(fRawReader, clustersTree);
2621 AliSysInfo::AddStamp(Form("LRecRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2624 AliDebug(1, "Loading Digits");
2625 loader->LoadDigits("read");
2626 TTree* digitsTree = loader->TreeD();
2627 AliDebug(1, Form("Digits Tree = %p",digitsTree));
2629 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
2634 AliDebug(1, "Digits -> Clusters");
2635 reconstructor->Reconstruct(digitsTree, clustersTree);
2636 if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
2637 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2638 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
2640 AliSysInfo::AddStamp(Form("LRecD2C%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2642 loader->UnloadDigits();
2644 if (fRunQA && IsInTasks(AliQAv1::kRECPOINTS)) {
2645 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2646 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
2648 loader->WriteRecPoints("OVERWRITE");
2649 loader->UnloadRecPoints();
2650 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2652 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
2653 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2654 AliError(Form("the following detectors were not found: %s",
2662 //_____________________________________________________________________________
2663 Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2665 // run the SPD trackleting (for SPD efficiency purpouses)
2667 AliCodeTimerAuto("",0)
2669 Double_t vtxPos[3] = {0, 0, 0};
2670 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2676 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2677 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2678 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2681 const AliESDVertex *vertex = esd->GetVertex();
2683 AliWarning("Vertex not found");
2686 vertex->GetXYZ(vtxPos);
2687 vertex->GetSigmaXYZ(vtxErr);
2688 if (fSPDTrackleter) {
2689 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2692 fLoader[0]->LoadRecPoints("read");
2693 TTree* tree = fLoader[0]->TreeR();
2695 AliError("Can't get the ITS cluster tree");
2698 fSPDTrackleter->LoadClusters(tree);
2699 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2701 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
2702 AliWarning("AliITSTrackleterSPDEff Clusters2Tracks failed");
2703 // fLoader[0]->UnloadRecPoints();
2706 //fSPDTrackleter->UnloadRecPoints();
2708 AliWarning("SPDTrackleter not available");
2714 //_____________________________________________________________________________
2715 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
2717 // run the barrel tracking
2719 AliCodeTimerAuto("",0)
2721 AliVertexer *vertexer = CreateVertexer();
2722 if (!vertexer) return kFALSE;
2724 AliInfo(Form("running the ITS vertex finder: %s",vertexer->ClassName()));
2725 AliESDVertex* vertex = NULL;
2727 fLoader[0]->LoadRecPoints();
2728 TTree* cltree = fLoader[0]->TreeR();
2730 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2731 vertex = vertexer->FindVertexForCurrentEvent(cltree);
2734 AliError("Can't get the ITS cluster tree");
2736 fLoader[0]->UnloadRecPoints();
2739 AliError("Can't get the ITS loader");
2742 AliWarning("Vertex not found");
2743 vertex = new AliESDVertex();
2744 vertex->SetName("default");
2747 vertex->SetName("reconstructed");
2752 vertex->GetXYZ(vtxPos);
2753 vertex->GetSigmaXYZ(vtxErr);
2755 esd->SetPrimaryVertexSPD(vertex);
2756 AliESDVertex *vpileup = NULL;
2757 Int_t novertices = 0;
2758 vpileup = vertexer->GetAllVertices(novertices);
2760 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2763 // if SPD multiplicity has been determined, it is stored in the ESD
2764 AliMultiplicity *mult = vertexer->GetMultiplicity();
2765 if(mult)esd->SetMultiplicity(mult);
2767 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2768 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2777 //_____________________________________________________________________________
2778 Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
2780 // run the trackleter for multiplicity study
2782 AliCodeTimerAuto("",0)
2784 AliTrackleter *trackleter = CreateMultFinder();
2785 if (!trackleter) return kFALSE;
2787 AliInfo(Form("running the ITS multiplicity finder: %s",trackleter->ClassName()));
2790 fLoader[0]->LoadRecPoints();
2791 TTree* cltree = fLoader[0]->TreeR();
2793 trackleter->Reconstruct(esd,cltree);
2794 AliMultiplicity *mult = trackleter->GetMultiplicity();
2795 if(mult) esd->SetMultiplicity(mult);
2798 AliError("Can't get the ITS cluster tree");
2800 fLoader[0]->UnloadRecPoints();
2803 AliError("Can't get the ITS loader");
2811 //_____________________________________________________________________________
2812 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
2814 // run the HLT barrel tracking
2816 AliCodeTimerAuto("",0)
2819 AliError("Missing runLoader!");
2823 AliInfo("running HLT tracking");
2825 // Get a pointer to the HLT reconstructor
2826 AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
2827 if (!reconstructor) return kFALSE;
2830 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2831 TString detName = fgkDetectorName[iDet];
2832 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2833 reconstructor->SetOption(detName.Data());
2834 AliTracker *tracker = reconstructor->CreateTracker();
2836 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2837 if (fStopOnError) return kFALSE;
2841 Double_t vtxErr[3]={0.005,0.005,0.010};
2842 const AliESDVertex *vertex = esd->GetVertex();
2843 vertex->GetXYZ(vtxPos);
2844 tracker->SetVertex(vtxPos,vtxErr);
2846 fLoader[iDet]->LoadRecPoints("read");
2847 TTree* tree = fLoader[iDet]->TreeR();
2849 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2852 tracker->LoadClusters(tree);
2854 if (tracker->Clusters2Tracks(esd) != 0) {
2855 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2859 tracker->UnloadClusters();
2867 //_____________________________________________________________________________
2868 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2870 // run the muon spectrometer tracking
2872 AliCodeTimerAuto("",0)
2875 AliError("Missing runLoader!");
2878 Int_t iDet = GetDetIndex("MUON"); // for MUON
2880 // Get a pointer to the MUON reconstructor
2881 AliReconstructor *reconstructor = GetReconstructor(iDet);
2882 if (!reconstructor) return kFALSE;
2885 TString detName = fgkDetectorName[iDet];
2886 AliDebug(1, Form("%s tracking", detName.Data()));
2887 AliTracker *tracker = reconstructor->CreateTracker();
2889 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2892 tracker->SetPools(fPools);
2895 fLoader[iDet]->LoadRecPoints("read");
2897 tracker->LoadClusters(fLoader[iDet]->TreeR());
2899 Int_t rv = tracker->Clusters2Tracks(esd);
2901 fLoader[iDet]->UnloadRecPoints();
2903 tracker->UnloadClusters();
2907 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2915 //_____________________________________________________________________________
2916 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
2918 // run the barrel tracking
2919 static Int_t eventNr=0;
2920 AliCodeTimerAuto("",0)
2922 AliInfo("running tracking");
2924 // Set the event info which is used
2925 // by the trackers in order to obtain
2926 // information about read-out detectors,
2928 AliDebug(1, "Setting event info");
2929 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2930 if (!fTracker[iDet]) continue;
2931 fTracker[iDet]->SetEventInfo(&fEventInfo);
2932 fTracker[iDet]->SetPools(fPools);
2935 //Fill the ESD with the T0 info (will be used by the TOF)
2936 if (fReconstructor[11] && fLoader[11]) {
2937 fLoader[11]->LoadRecPoints("READ");
2938 TTree *treeR = fLoader[11]->TreeR();
2940 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2944 // pass 1: TPC + ITS inwards
2945 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2946 if (!fTracker[iDet]) continue;
2947 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2950 fLoader[iDet]->LoadRecPoints("read");
2951 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2952 TTree* tree = fLoader[iDet]->TreeR();
2954 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2957 fTracker[iDet]->LoadClusters(tree);
2958 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2960 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2961 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2964 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2965 // preliminary PID in TPC needed by the ITS tracker
2967 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2968 PID.MakePID(esd,kTRUE);
2969 AliSysInfo::AddStamp(Form("MakePID0%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
2973 // pass 2: ALL backwards
2975 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2976 if (!fTracker[iDet]) continue;
2977 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2980 if (iDet > 1) { // all except ITS, TPC
2982 fLoader[iDet]->LoadRecPoints("read");
2983 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2984 tree = fLoader[iDet]->TreeR();
2986 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2989 fTracker[iDet]->LoadClusters(tree);
2990 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2994 if (iDet>1) // start filling residuals for the "outer" detectors
2996 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2997 TObjArray ** arr = AliTracker::GetResidualsArray() ;
2999 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3000 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3001 if ( elem && (! elem->At(0)) ) {
3002 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3003 if (qadm) qadm->InitRecPointsForTracker() ;
3006 // AliSysInfo::AddStamp(Form("QAInitResid%s_%d",fgkDetectorName[iDet],eventNr), iDet,0, eventNr);
3008 if (fTracker[iDet]->PropagateBack(esd) != 0) {
3009 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
3012 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3015 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
3016 fTracker[iDet]->UnloadClusters();
3017 fLoader[iDet]->UnloadRecPoints();
3019 // updated PID in TPC needed by the ITS tracker -MI
3021 //GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
3022 //AliESDpid::MakePID(esd);
3023 PID.MakePID(esd,kTRUE);
3024 AliSysInfo::AddStamp(Form("MakePID1%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
3028 //stop filling residuals for the "outer" detectors
3029 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3031 // pass 3: TRD + TPC + ITS refit inwards
3033 for (Int_t iDet = 2; iDet >= 0; iDet--) {
3034 if (!fTracker[iDet]) continue;
3035 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
3038 if (iDet<2) // start filling residuals for TPC and ITS
3040 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
3041 TObjArray ** arr = AliTracker::GetResidualsArray() ;
3043 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3044 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3045 if ( elem && (! elem->At(0)) ) {
3046 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3047 if (qadm) qadm->InitRecPointsForTracker() ;
3052 if (fTracker[iDet]->RefitInward(esd) != 0) {
3053 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
3056 // run postprocessing
3057 if (fTracker[iDet]->PostProcess(esd) != 0) {
3058 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
3061 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3064 // write space-points to the ESD in case alignment data output
3066 if (fWriteAlignmentData) {
3067 WriteAlignmentData(esd);
3068 AliSysInfo::AddStamp(Form("WrtAlignData_%d",eventNr), 0,0, eventNr);
3071 for (Int_t iDet = 3; iDet >= 0; iDet--) {
3072 if (!fTracker[iDet]) continue;
3074 fTracker[iDet]->UnloadClusters();
3075 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
3076 fLoader[iDet]->UnloadRecPoints();
3077 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
3079 // stop filling residuals for TPC and ITS
3080 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3086 //_____________________________________________________________________________
3087 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
3089 // Remove the data which are not needed for the physics analysis.
3092 Int_t nTracks=esd->GetNumberOfTracks();
3093 Int_t nV0s=esd->GetNumberOfV0s();
3095 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
3097 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
3098 Bool_t rc=esd->Clean(cleanPars);
3100 nTracks=esd->GetNumberOfTracks();
3101 nV0s=esd->GetNumberOfV0s();
3103 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
3108 //_____________________________________________________________________________
3109 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
3111 // fill the event summary data
3113 AliCodeTimerAuto("",0)
3114 static Int_t eventNr=0;
3115 TString detStr = detectors;
3117 AliSysInfo::AddStamp(Form("FillESDb%d",eventNr), -19,-19, eventNr);
3118 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3119 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3120 AliReconstructor* reconstructor = GetReconstructor(iDet);
3121 if (!reconstructor) continue;
3122 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
3123 TTree* clustersTree = NULL;
3124 if (fLoader[iDet]) {
3125 fLoader[iDet]->LoadRecPoints("read");
3126 clustersTree = fLoader[iDet]->TreeR();
3127 if (!clustersTree) {
3128 AliError(Form("Can't get the %s clusters tree",
3129 fgkDetectorName[iDet]));
3130 if (fStopOnError) return kFALSE;
3133 if (fRawReader && !reconstructor->HasDigitConversion()) {
3134 reconstructor->FillESD(fRawReader, clustersTree, esd);
3136 TTree* digitsTree = NULL;
3137 if (fLoader[iDet]) {
3138 fLoader[iDet]->LoadDigits("read");
3139 digitsTree = fLoader[iDet]->TreeD();
3141 AliError(Form("Can't get the %s digits tree",
3142 fgkDetectorName[iDet]));
3143 if (fStopOnError) return kFALSE;
3146 reconstructor->FillESD(digitsTree, clustersTree, esd);
3147 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
3149 if (fLoader[iDet]) {
3150 fLoader[iDet]->UnloadRecPoints();
3154 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
3155 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
3156 AliError(Form("the following detectors were not found: %s",
3158 if (fStopOnError) return kFALSE;
3160 AliSysInfo::AddStamp(Form("FillESDe%d",eventNr), -20,-20, eventNr);
3165 //_____________________________________________________________________________
3166 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
3168 // Reads the trigger decision which is
3169 // stored in Trigger.root file and fills
3170 // the corresponding esd entries
3172 AliCodeTimerAuto("",0)
3174 AliInfo("Filling trigger information into the ESD");
3177 AliCTPRawStream input(fRawReader);
3178 if (!input.Next()) {
3179 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
3182 if (esd->GetTriggerMask() != input.GetClassMask())
3183 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
3184 input.GetClassMask(),esd->GetTriggerMask()));
3185 if (esd->GetOrbitNumber() != input.GetOrbitID())
3186 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
3187 input.GetOrbitID(),esd->GetOrbitNumber()));
3188 if (esd->GetBunchCrossNumber() != input.GetBCID())
3189 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
3190 input.GetBCID(),esd->GetBunchCrossNumber()));
3191 AliESDHeader* esdheader = esd->GetHeader();
3192 esdheader->SetL0TriggerInputs(input.GetL0Inputs());
3193 esdheader->SetL1TriggerInputs(input.GetL1Inputs());
3194 esdheader->SetL2TriggerInputs(input.GetL2Inputs());
3196 // UInt_t orbit=input.GetOrbitID();
3197 for(Int_t i=0 ; i<input.GetNIRs() ; i++ ) {
3198 esdheader->AddTriggerIR(input.GetIR(i));
3200 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
3201 rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
3202 rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
3203 rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
3205 if (fIsNewRunLoader) fRunLoader->TreeCT()->Fill();
3209 //_____________________________________________________________________________
3210 Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
3213 //fRunScalers->Print();
3214 if(fRunScalers && fRunScalers->CheckRunScalers()){
3215 AliTimeStamp* timestamp = new AliTimeStamp(esd->GetOrbitNumber(), esd->GetPeriodNumber(), esd->GetBunchCrossNumber());
3216 //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
3217 AliESDHeader* esdheader = fesd->GetHeader();
3218 for(Int_t i=0;i<50;i++){
3219 if((1ull<<i) & esd->GetTriggerMask()){
3220 AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
3221 if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
3224 const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp);
3225 const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun();
3226 if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent);
3227 if (scalrecRun) esdheader->SetTriggerScalersDeltaRun(scalrecRun);
3231 //_____________________________________________________________________________
3232 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
3235 // Filling information from RawReader Header
3238 if (!fRawReader) return kFALSE;
3240 AliInfo("Filling information from RawReader Header");
3242 esd->SetBunchCrossNumber(fRawReader->GetBCID());
3243 esd->SetOrbitNumber(fRawReader->GetOrbitID());
3244 esd->SetPeriodNumber(fRawReader->GetPeriod());
3246 esd->SetTimeStamp(fRawReader->GetTimestamp());
3247 esd->SetEventType(fRawReader->GetType());
3253 //_____________________________________________________________________________
3254 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
3256 // check whether detName is contained in detectors
3257 // if yes, it is removed from detectors
3259 // check if all detectors are selected
3260 if ((detectors.CompareTo("ALL") == 0) ||
3261 detectors.BeginsWith("ALL ") ||
3262 detectors.EndsWith(" ALL") ||
3263 detectors.Contains(" ALL ")) {
3268 // search for the given detector
3269 Bool_t result = kFALSE;
3270 if ((detectors.CompareTo(detName) == 0) ||
3271 detectors.BeginsWith(detName+" ") ||
3272 detectors.EndsWith(" "+detName) ||
3273 detectors.Contains(" "+detName+" ")) {
3274 detectors.ReplaceAll(detName, "");
3278 // clean up the detectors string
3279 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
3280 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
3281 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
3286 //_____________________________________________________________________________
3287 Bool_t AliReconstruction::InitRunLoader()
3289 // get or create the run loader
3291 if (gAlice) delete gAlice;
3294 TFile *gafile = TFile::Open(fGAliceFileName.Data());
3295 // if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
3296 if (gafile) { // galice.root exists
3300 // load all base libraries to get the loader classes
3301 TString libs = gSystem->GetLibraries();
3302 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3303 TString detName = fgkDetectorName[iDet];
3304 if (detName == "HLT") continue;
3305 if (libs.Contains("lib" + detName + "base.so")) continue;
3306 gSystem->Load("lib" + detName + "base.so");
3308 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
3310 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
3315 fRunLoader->CdGAFile();
3316 fRunLoader->LoadgAlice();
3318 //PH This is a temporary fix to give access to the kinematics
3319 //PH that is needed for the labels of ITS clusters
3320 fRunLoader->LoadHeader();
3321 fRunLoader->LoadKinematics();
3323 } else { // galice.root does not exist
3325 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
3327 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
3328 AliConfig::GetDefaultEventFolderName(),
3331 AliError(Form("could not create run loader in file %s",
3332 fGAliceFileName.Data()));
3336 fIsNewRunLoader = kTRUE;
3337 fRunLoader->MakeTree("E");
3338 fRunLoader->MakeTree("GG");
3340 if (fNumberOfEventsPerFile > 0)
3341 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
3343 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
3349 //_____________________________________________________________________________
3350 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
3352 // get the reconstructor object and the loader for a detector
3354 if (fReconstructor[iDet]) {
3355 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3356 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3357 fReconstructor[iDet]->SetRecoParam(par);
3358 fReconstructor[iDet]->SetRunInfo(fRunInfo);
3360 return fReconstructor[iDet];
3363 // load the reconstructor object
3364 TPluginManager* pluginManager = gROOT->GetPluginManager();
3365 TString detName = fgkDetectorName[iDet];
3366 TString recName = "Ali" + detName + "Reconstructor";
3368 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
3370 AliReconstructor* reconstructor = NULL;
3371 // first check if a plugin is defined for the reconstructor
3372 TPluginHandler* pluginHandler =
3373 pluginManager->FindHandler("AliReconstructor", detName);
3374 // if not, add a plugin for it
3375 if (!pluginHandler) {
3376 AliDebug(1, Form("defining plugin for %s", recName.Data()));
3377 TString libs = gSystem->GetLibraries();
3378 if (libs.Contains("lib" + detName + "base.so") ||
3379 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
3380 pluginManager->AddHandler("AliReconstructor", detName,
3381 recName, detName + "rec", recName + "()");
3383 pluginManager->AddHandler("AliReconstructor", detName,
3384 recName, detName, recName + "()");
3386 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
3388 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3389 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
3392 // check if the upgrade reconstructor should be used instead of the standard one
3393 if(fUpgradeMask[iDet]) {
3394 if(reconstructor) delete reconstructor;
3395 TClass *cl = new TClass(Form("Ali%sUpgradeReconstructor",fgkDetectorName[iDet]));
3396 reconstructor = (AliReconstructor*)(cl->New());
3399 if (reconstructor) {
3400 TObject* obj = fOptions.FindObject(detName.Data());
3401 if (obj) reconstructor->SetOption(obj->GetTitle());
3402 reconstructor->SetRunInfo(fRunInfo);
3403 reconstructor->Init();
3404 fReconstructor[iDet] = reconstructor;
3407 // get or create the loader
3408 if (detName != "HLT") {
3409 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
3410 if (!fLoader[iDet]) {
3411 AliConfig::Instance()
3412 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
3414 // first check if a plugin is defined for the loader
3416 pluginManager->FindHandler("AliLoader", detName);
3417 // if not, add a plugin for it
3418 if (!pluginHandler) {
3419 TString loaderName = "Ali" + detName + "Loader";
3420 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
3421 pluginManager->AddHandler("AliLoader", detName,
3422 loaderName, detName + "base",
3423 loaderName + "(const char*, TFolder*)");
3424 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
3426 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3428 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
3429 fRunLoader->GetEventFolder());
3431 if (!fLoader[iDet]) { // use default loader
3432 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
3434 if (!fLoader[iDet]) {
3435 AliWarning(Form("couldn't get loader for %s", detName.Data()));
3436 if (fStopOnError) return NULL;
3438 fRunLoader->AddLoader(fLoader[iDet]);
3439 fRunLoader->CdGAFile();
3440 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
3441 fRunLoader->Write(0, TObject::kOverwrite);
3446 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3447 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3448 if (reconstructor) {
3449 reconstructor->SetRecoParam(par);
3450 reconstructor->SetRunInfo(fRunInfo);
3453 return reconstructor;
3456 //_____________________________________________________________________________
3457 AliVertexer* AliReconstruction::CreateVertexer()
3459 // create the vertexer
3460 // Please note that the caller is the owner of the
3463 AliVertexer* vertexer = NULL;
3464 AliReconstructor* itsReconstructor = GetReconstructor(0);
3465 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3466 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3467 vertexer = itsReconstructor->CreateVertexer();
3470 AliWarning("couldn't create a vertexer for ITS");
3476 //_____________________________________________________________________________
3477 AliTrackleter* AliReconstruction::CreateMultFinder()
3479 // create the ITS trackleter for mult. estimation
3480 // Please note that the caller is the owner of the
3483 AliTrackleter* trackleter = NULL;
3484 AliReconstructor* itsReconstructor = GetReconstructor(0);
3485 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3486 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3487 trackleter = itsReconstructor->CreateMultFinder();
3490 AliWarning("ITS is not in reconstruction, switching off RunMultFinder");
3491 fRunMultFinder = kFALSE;
3497 //_____________________________________________________________________________
3498 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
3500 // create the trackers
3501 AliInfo("Creating trackers");
3503 TString detStr = detectors;
3504 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3505 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3506 AliReconstructor* reconstructor = GetReconstructor(iDet);
3507 if (!reconstructor) continue;
3508 TString detName = fgkDetectorName[iDet];
3509 if (detName == "HLT") {
3510 fRunHLTTracking = kTRUE;
3513 if (detName == "MUON") {
3514 fRunMuonTracking = kTRUE;
3518 fTracker[iDet] = reconstructor->CreateTracker();
3519 if (!fTracker[iDet] && (iDet < 7)) {
3520 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
3521 if (fStopOnError) return kFALSE;
3523 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
3529 //_____________________________________________________________________________
3530 void AliReconstruction::CleanUp()
3532 // delete trackers and the run loader and close and delete the file
3534 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3535 delete fReconstructor[iDet];
3536 fReconstructor[iDet] = NULL;
3537 fLoader[iDet] = NULL;
3538 delete fTracker[iDet];
3539 fTracker[iDet] = NULL;
3543 if (fesd) fesd->Reset();
3544 if (fhltesd) fhltesd->Reset();
3545 if (fesdf) fesdf->Clear();
3546 fPools->ResetPools();
3547 AliTrackPointArray::SetPool(0);
3548 AliESDtrack::SetPools(0);
3549 AliESDfriendTrack::SetPools(0);
3550 delete fPools; fPools = 0;
3557 delete fSPDTrackleter;
3558 fSPDTrackleter = NULL;
3567 delete fParentRawReader;
3568 fParentRawReader=NULL;
3576 if (AliQAManager::QAManager())
3577 AliQAManager::QAManager()->ShowQA() ;
3578 // AliQAManager::Destroy() ;
3584 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
3586 // Write space-points which are then used in the alignment procedures
3587 // For the moment only ITS, TPC, TRD and TOF
3588 AliClonesPool* poolTPA = fPools ? fPools->GetPoolTrPoints() : 0;
3590 Int_t ntracks = esd->GetNumberOfTracks();
3591 for (Int_t itrack = 0; itrack < ntracks; itrack++)
3593 AliESDtrack *track = esd->GetTrack(itrack);
3596 for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
3597 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
3598 nsp += (iDet==GetDetIndex("TRD")) ? track->GetTRDntracklets():track->GetNcls(iDet);
3600 if (iDet==GetDetIndex("ITS")) { // ITS "extra" clusters
3601 track->GetClusters(iDet,idx);
3602 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
3607 AliTrackPointArray *sp = 0;
3608 if (poolTPA) {sp = new(poolTPA->NextFreeSlot()) AliTrackPointArray(nsp); poolTPA->RegisterClone(sp);}
3609 else sp = new AliTrackPointArray(nsp);
3610 track->SetTrackPointArray(sp);
3612 for (Int_t iDet = 5; iDet >= 0; iDet--) {
3613 AliTracker *tracker = fTracker[iDet];
3614 if (!tracker) continue;
3615 Int_t nspdet = (iDet==GetDetIndex("TRD")) ? track->GetTRDtracklets(idx):track->GetClusters(iDet,idx);
3617 if (iDet==GetDetIndex("ITS")) // ITS "extra" clusters
3618 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
3620 if (nspdet <= 0) continue;
3624 while (isp2 < nspdet) {
3625 Bool_t isvalid=kTRUE;
3627 Int_t index=idx[isp++];
3628 if (index < 0) continue;
3630 TString dets = fgkDetectorName[iDet];
3631 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
3632 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
3633 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
3634 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
3635 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
3637 isvalid = tracker->GetTrackPoint(index,p);
3640 if (!isvalid) continue;
3641 if (iDet==GetDetIndex("ITS") && (isp-1)>=6) p.SetExtra();
3642 sp->AddPoint(isptrack,&p); isptrack++;
3649 //_____________________________________________________________________________
3650 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
3652 // The method reads the raw-data error log
3653 // accumulated within the rawReader.
3654 // It extracts the raw-data errors related to
3655 // the current event and stores them into
3656 // a TClonesArray inside the esd object.
3658 if (!fRawReader) return;
3660 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
3662 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
3664 if (iEvent != log->GetEventNumber()) continue;
3666 esd->AddRawDataErrorLog(log);
3671 //_____________________________________________________________________________
3672 // void AliReconstruction::CheckQA()
3674 // check the QA of SIM for this run and remove the detectors
3675 // with status Fatal
3677 // TString newRunLocalReconstruction ;
3678 // TString newRunTracking ;
3679 // TString newFillESD ;
3681 // for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
3682 // TString detName(AliQAv1::GetDetName(iDet)) ;
3683 // AliQAv1 * qa = AliQAv1::Instance(AliQAv1::DETECTORINDEX_t(iDet)) ;
3684 // if ( qa->IsSet(AliQAv1::DETECTORINDEX_t(iDet), AliQAv1::kSIM, specie, AliQAv1::kFATAL)) {
3685 // AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
3686 // detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
3688 // if ( fRunLocalReconstruction.Contains(AliQAv1::GetDetName(iDet)) ||
3689 // fRunLocalReconstruction.Contains("ALL") ) {
3690 // newRunLocalReconstruction += detName ;
3691 // newRunLocalReconstruction += " " ;
3693 // if ( fRunTracking.Contains(AliQAv1::GetDetName(iDet)) ||
3694 // fRunTracking.Contains("ALL") ) {
3695 // newRunTracking += detName ;
3696 // newRunTracking += " " ;
3698 // if ( fFillESD.Contains(AliQAv1::GetDetName(iDet)) ||
3699 // fFillESD.Contains("ALL") ) {
3700 // newFillESD += detName ;
3701 // newFillESD += " " ;
3705 // fRunLocalReconstruction = newRunLocalReconstruction ;
3706 // fRunTracking = newRunTracking ;
3707 // fFillESD = newFillESD ;
3710 //_____________________________________________________________________________
3711 Int_t AliReconstruction::GetDetIndex(const char* detector)
3713 // return the detector index corresponding to detector
3715 for (index = 0; index < kNDetectors ; index++) {
3716 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
3721 //_____________________________________________________________________________
3722 Bool_t AliReconstruction::FinishPlaneEff() {
3724 // Here execute all the necessary operationis, at the end of the tracking phase,
3725 // in case that evaluation of PlaneEfficiencies was required for some detector.
3726 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
3728 // This Preliminary version works only FOR ITS !!!!!
3729 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3732 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3735 TString detStr = fLoadCDB;
3736 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
3737 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
3738 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3739 if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
3740 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
3741 TString name=planeeff->GetName();
3743 TFile* pefile = TFile::Open(name, "RECREATE");
3744 ret=(Bool_t)planeeff->Write();
3746 if(planeeff->GetCreateHistos()) {
3747 TString hname=planeeff->GetName();
3748 hname+="Histo.root";
3749 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
3752 if(fSPDTrackleter) {
3753 AliPlaneEff *planeeff=fSPDTrackleter->GetPlaneEff();
3754 TString name="AliITSPlaneEffSPDtracklet.root";
3755 TFile* pefile = TFile::Open(name, "RECREATE");
3756 ret=(Bool_t)planeeff->Write();
3758 AliESDEvent *dummy=NULL;
3759 ret=(Bool_t)fSPDTrackleter->PostProcess(dummy); // take care of writing other files
3764 //_____________________________________________________________________________
3765 Bool_t AliReconstruction::InitPlaneEff() {
3767 // Here execute all the necessary operations, before of the tracking phase,
3768 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
3769 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
3770 // which should be updated/recalculated.
3772 // This Preliminary version will work only FOR ITS !!!!!
3773 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3776 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3779 fSPDTrackleter = NULL;
3780 TString detStr = fLoadCDB;
3781 if (IsSelected(fgkDetectorName[0], detStr)) {
3782 AliReconstructor* itsReconstructor = GetReconstructor(0);
3783 if (itsReconstructor) {
3784 fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
3786 if (fSPDTrackleter) {
3787 AliInfo("Trackleter for SPD has been created");
3793 //_____________________________________________________________________________
3794 Bool_t AliReconstruction::InitAliEVE()
3796 // This method should be called only in case
3797 // AliReconstruction is run
3798 // within the alieve environment.
3799 // It will initialize AliEVE in a way
3800 // so that it can visualize event processed
3801 // by AliReconstruction.
3802 // The return flag shows whenever the
3803 // AliEVE initialization was successful or not.
3805 TString macroStr(gSystem->Getenv("ALIEVE_ONLINE_MACRO"));
3807 if (macroStr.IsNull())
3808 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
3810 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
3812 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
3814 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
3815 gROOT->ProcessLine("alieve_online_init()");
3820 //_____________________________________________________________________________
3821 void AliReconstruction::RunAliEVE()
3823 // Runs AliEVE visualisation of
3824 // the current event.
3825 // Should be executed only after
3826 // successful initialization of AliEVE.
3828 AliInfo("Running AliEVE...");
3829 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p,(AliESDfriend*)%p);",fRunLoader,fRawReader,fesd,fesdf));
3833 //_____________________________________________________________________________
3834 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
3836 // Allows to run QA for a selected set of detectors
3837 // and a selected set of tasks among RAWS, DIGITSR, RECPOINTS and ESDS
3838 // all selected detectors run the same selected tasks
3840 if (!detAndAction.Contains(":")) {
3841 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
3845 Int_t colon = detAndAction.Index(":") ;
3846 fQADetectors = detAndAction(0, colon) ;
3847 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
3848 if (fQATasks.Contains("ALL") ) {
3849 fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ;
3851 fQATasks.ToUpper() ;
3853 if ( fQATasks.Contains("RAW") )
3854 tempo = Form("%d ", AliQAv1::kRAWS) ;
3855 if ( fQATasks.Contains("DIGIT") )
3856 tempo += Form("%d ", AliQAv1::kDIGITSR) ;
3857 if ( fQATasks.Contains("RECPOINT") )
3858 tempo += Form("%d ", AliQAv1::kRECPOINTS) ;
3859 if ( fQATasks.Contains("ESD") )
3860 tempo += Form("%d ", AliQAv1::kESDS) ;
3862 if (fQATasks.IsNull()) {
3863 AliInfo("No QA requested\n") ;
3868 TString tempo(fQATasks) ;
3869 tempo.ReplaceAll(Form("%d", AliQAv1::kRAWS), AliQAv1::GetTaskName(AliQAv1::kRAWS)) ;
3870 tempo.ReplaceAll(Form("%d", AliQAv1::kDIGITSR), AliQAv1::GetTaskName(AliQAv1::kDIGITSR)) ;
3871 tempo.ReplaceAll(Form("%d", AliQAv1::kRECPOINTS), AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)) ;
3872 tempo.ReplaceAll(Form("%d", AliQAv1::kESDS), AliQAv1::GetTaskName(AliQAv1::kESDS)) ;
3873 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
3878 //_____________________________________________________________________________
3879 Bool_t AliReconstruction::InitRecoParams()
3881 // The method accesses OCDB and retrieves all
3882 // the available reco-param objects from there.
3884 Bool_t isOK = kTRUE;
3886 if (fRecoParam.GetDetRecoParamArray(kNDetectors)) {
3887 AliInfo("Using custom GRP reconstruction parameters");
3890 AliInfo("Loading GRP reconstruction parameter objects");
3892 AliCDBPath path("GRP","Calib","RecoParam");
3893 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3895 AliWarning("Couldn't find GRP RecoParam entry in OCDB");
3899 TObject *recoParamObj = entry->GetObject();
3900 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3901 // GRP has a normal TobjArray of AliDetectorRecoParam objects
3902 // Registering them in AliRecoParam
3903 fRecoParam.AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
3905 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3906 // GRP has only onse set of reco parameters
3907 // Registering it in AliRecoParam
3908 AliInfo("Single set of GRP reconstruction parameters found");
3909 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3910 fRecoParam.AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3913 AliError("No valid GRP RecoParam object found in the OCDB");
3920 TString detStr = fLoadCDB;
3921 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3923 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3925 if (fRecoParam.GetDetRecoParamArray(iDet)) {
3926 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
3930 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
3932 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
3933 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3935 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
3939 TObject *recoParamObj = entry->GetObject();
3940 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3941 // The detector has a normal TobjArray of AliDetectorRecoParam objects
3942 // Registering them in AliRecoParam
3943 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
3945 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3946 // The detector has only onse set of reco parameters
3947 // Registering it in AliRecoParam
3948 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
3949 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3950 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3953 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
3957 // FIX ME: We have to disable the unloading of reco-param CDB
3958 // entries because QA framework is using them. Has to be fix in
3959 // a way that the QA takes the objects already constructed in
3961 // AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
3965 if (AliDebugLevel() > 0) fRecoParam.Print();
3970 //_____________________________________________________________________________
3971 Bool_t AliReconstruction::GetEventInfo()
3973 // Fill the event info object
3975 AliCodeTimerAuto("",0)
3977 AliCentralTrigger *aCTP = NULL;
3979 fEventInfo.SetEventType(fRawReader->GetType());
3981 ULong64_t mask = fRawReader->GetClassMask();
3982 fEventInfo.SetTriggerMask(mask);
3983 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
3984 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
3986 aCTP = new AliCentralTrigger();
3987 TString configstr("");
3988 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
3989 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
3993 aCTP->SetClassMask(mask);
3994 aCTP->SetClusterMask(clmask);
3996 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
3997 rlCTP->SetClassMask(mask);
3998 rlCTP->SetClusterMask(clmask);
4001 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
4003 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
4004 aCTP = fRunLoader->GetTrigger();
4005 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
4006 // get inputs from actp - just get
4007 AliESDHeader* esdheader = fesd->GetHeader();
4008 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
4009 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
4010 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
4011 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
4014 AliWarning("No trigger can be loaded! The trigger information will not be used!");
4019 AliTriggerConfiguration *config = aCTP->GetConfiguration();
4021 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
4022 if (fRawReader) delete aCTP;
4026 UChar_t clustmask = 0;
4028 ULong64_t trmask = fEventInfo.GetTriggerMask();
4029 const TObjArray& classesArray = config->GetClasses();
4030 Int_t nclasses = classesArray.GetEntriesFast();
4031 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
4032 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
4033 if (trclass && trclass->GetMask()>0) {
4034 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
4035 fesd->SetTriggerClass(trclass->GetName(),trindex);
4036 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
4037 if (trmask & (1ull << trindex)) {
4039 trclasses += trclass->GetName();
4041 clustmask |= trclass->GetCluster()->GetClusterMask();
4045 fEventInfo.SetTriggerClasses(trclasses);
4046 // Now put the declared trigger classes (not present in the run)
4047 // to 0/false in the event selection
4048 if (!fDeclTriggerClasses.IsNull()) {
4049 TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
4050 Int_t ntokens = tokens->GetEntriesFast();
4051 for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
4052 if (fRawReader) fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
4057 // Write names of active trigger inputs in ESD Header
4058 const TObjArray& inputsArray = config->GetInputs();
4059 Int_t ninputs = inputsArray.GetEntriesFast();
4060 for( Int_t iinput=0; iinput < ninputs; iinput++ ) {
4061 AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
4062 if (trginput && trginput->GetMask()>0) {
4063 Int_t inputIndex = (Int_t)TMath::Nint(TMath::Log2(trginput->GetMask()));
4064 AliESDHeader* headeresd = fesd->GetHeader();
4065 Int_t trglevel = (Int_t)trginput->GetLevel();
4066 if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
4067 if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
4068 if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
4072 // Set the information in ESD
4073 fesd->SetTriggerMask(trmask);
4074 fesd->SetTriggerCluster(clustmask);
4076 if (!aCTP->CheckTriggeredDetectors()) {
4077 if (fRawReader) delete aCTP;
4081 if (fRawReader) delete aCTP;
4083 // We have to fill also the HLT decision here!!
4089 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
4091 // Match the detector list found in the rec.C or the default 'ALL'
4092 // to the list found in the GRP (stored there by the shuttle PP which
4093 // gets the information from ECS)
4094 static TString resultList;
4095 TString detList = detectorList;
4099 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
4100 if ((detectorMask >> iDet) & 0x1) {
4101 TString det = AliDAQ::OfflineModuleName(iDet);
4102 if ((detList.CompareTo("ALL") == 0) ||
4103 ((detList.BeginsWith("ALL ") ||
4104 detList.EndsWith(" ALL") ||
4105 detList.Contains(" ALL ")) &&
4106 !(detList.BeginsWith("-"+det+" ") ||
4107 detList.EndsWith(" -"+det) ||
4108 detList.Contains(" -"+det+" "))) ||
4109 (detList.CompareTo(det) == 0) ||
4110 detList.BeginsWith(det+" ") ||
4111 detList.EndsWith(" "+det) ||
4112 detList.Contains( " "+det+" " )) {
4113 if (!resultList.EndsWith(det + " ")) {
4122 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
4123 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
4124 if ((detList.CompareTo("ALL") == 0) ||
4125 ((detList.BeginsWith("ALL ") ||
4126 detList.EndsWith(" ALL") ||
4127 detList.Contains(" ALL ")) &&
4128 !(detList.BeginsWith("-"+hltDet+" ") ||
4129 detList.EndsWith(" -"+hltDet) ||
4130 detList.Contains(" -"+hltDet+" "))) ||
4131 (detList.CompareTo(hltDet) == 0) ||
4132 detList.BeginsWith(hltDet+" ") ||
4133 detList.EndsWith(" "+hltDet) ||
4134 detList.Contains( " "+hltDet+" " )) {
4135 resultList += hltDet;
4139 return resultList.Data();
4143 //______________________________________________________________________________
4144 void AliReconstruction::Abort(const char *method, EAbort what)
4146 // Abort processing. If what = kAbortProcess, the Process() loop will be
4147 // aborted. If what = kAbortFile, the current file in a chain will be
4148 // aborted and the processing will continue with the next file, if there
4149 // is no next file then Process() will be aborted. Abort() can also be
4150 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
4151 // the SlaveTerminate() and Terminate() are always called. The abort flag
4152 // can be checked in these methods using GetAbort().
4154 // The method is overwritten in AliReconstruction for better handling of
4155 // reco specific errors
4157 if (!fStopOnError) return;
4161 TString whyMess = method;
4162 whyMess += " failed! Aborting...";
4164 AliError(whyMess.Data());
4167 TString mess = "Abort";
4168 if (fAbort == kAbortProcess)
4169 mess = "AbortProcess";
4170 else if (fAbort == kAbortFile)
4173 Info(mess.Data(), "%s", whyMess.Data());
4176 //______________________________________________________________________________
4177 Bool_t AliReconstruction::ProcessEvent(void* event)
4179 // Method that is used in case the event loop
4180 // is steered from outside, for example by AMORE
4181 // 'event' is a pointer to the DATE event in the memory
4183 if (fRawReader) delete fRawReader;
4184 fRawReader = new AliRawReaderDate(event);
4185 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
4192 //______________________________________________________________________________
4193 Bool_t AliReconstruction::ParseOutput()
4195 // The method parses the output file
4196 // location string in order to steer
4197 // properly the selector
4199 TPMERegexp re1("(\\w+\\.zip#\\w+\\.root):([,*\\w+\\.root,*]+)@dataset://(\\w++)");
4200 TPMERegexp re2("(\\w+\\.root)?@?dataset://(\\w++)");
4202 if (re1.Match(fESDOutput) == 4) {
4203 // root archive with output files stored and regustered
4205 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",re1[1].Data()));
4206 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re1[3].Data()));
4207 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4208 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_ARCHIVE",re1[2].Data()));
4209 AliInfo(Form("%s files will be stored within %s in dataset %s",
4214 else if (re2.Match(fESDOutput) == 3) {
4215 // output file stored and registered
4217 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",(re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data()));
4218 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re2[2].Data()));
4219 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4220 AliInfo(Form("%s will be stored in dataset %s",
4221 (re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data(),
4225 if (fESDOutput.IsNull()) {
4226 // Output location not given.
4227 // Assuming xrootd has been already started and
4228 // the output file has to be sent back
4229 // to the client machine
4230 TString esdUrl(Form("root://%s/%s/",
4231 TUrl(gSystem->HostName()).GetHostFQDN(),
4233 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE","AliESDs.root"));
4234 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",esdUrl.Data()));
4235 AliInfo(Form("AliESDs.root will be stored in %s",
4239 // User specified an output location.
4240 // Ones has just to parse it here
4241 TUrl outputUrl(fESDOutput.Data());
4242 TString outputFile(gSystem->BaseName(outputUrl.GetFile()));
4243 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.IsNull() ? "AliESDs.root" : outputFile.Data()));
4244 TString outputLocation(outputUrl.GetUrl());
4245 outputLocation.ReplaceAll(outputFile.Data(),"");
4246 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",outputLocation.Data()));
4247 AliInfo(Form("%s will be stored in %s",
4248 outputFile.IsNull() ? "AliESDs.root" : outputFile.Data(),
4249 outputLocation.Data()));
4256 //______________________________________________________________________________
4257 Bool_t AliReconstruction::IsHighPt() const {
4258 // Selection of events containing "high" pT tracks
4259 // If at least one track is found within 1.5 and 100 GeV (pT)
4260 // that was reconstructed by both ITS and TPC, the event is accepted
4263 const Double_t pTmin = 1.5;
4264 const Double_t pTmax = 100;
4266 mask |= (AliESDtrack::kITSrefit);
4267 mask |= (AliESDtrack::kTPCrefit);
4268 const Double_t pTminCosmic = 5.;
4269 const Double_t pTmaxCosmic = 100;
4270 ULong_t maskCosmic = 0;
4271 Int_t cosmicCount=0;
4272 maskCosmic |= (AliESDtrack::kTPCrefit);
4274 Bool_t isOK = kFALSE;
4276 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4277 // Check if this ia a physics event (code 7)
4278 Int_t ntrk = fesd->GetNumberOfTracks();
4279 for (Int_t itrk=0; itrk<ntrk; ++itrk) {
4281 AliESDtrack * trk = fesd->GetTrack(itrk);
4283 && trk->Pt() > pTmin
4284 && trk->Pt() < pTmax
4285 && (trk->GetStatus() & mask) == mask ) {
4291 && trk->GetInnerParam()
4292 && trk->GetInnerParam()->Pt() > pTminCosmic
4293 && trk->GetInnerParam()->Pt() < pTmaxCosmic
4294 && (trk->GetStatus() & maskCosmic) == maskCosmic ) {
4300 if (cosmicCount>1) isOK=kTRUE;
4305 //______________________________________________________________________________
4306 Bool_t AliReconstruction::IsCosmicOrCalibSpecie() const {
4307 // Select cosmic or calibration events
4309 Bool_t isOK = kFALSE;
4311 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4312 // Check if this ia a physics event (code 7)
4314 UInt_t specie = fesd->GetEventSpecie();
4315 if (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib) {
4322 //______________________________________________________________________________
4323 void AliReconstruction::WriteESDfriend() {
4324 // Fill the ESD friend in the tree. The required fraction of ESD friends is stored
4325 // in fFractionFriends. We select events where we store the ESD friends according
4326 // to the following algorithm:
4327 // 1. Store all Cosmic or Calibration events within the required fraction
4328 // 2. Sample "high Pt" events within the remaining fraction after step 1.
4329 // 3. Sample randomly events if we still have remaining slot
4331 static int iEvent = 0;
4334 Bool_t isSelected = kFALSE;
4336 // Store all friends for B field OFF
4337 if (TMath::Abs(AliTrackerBase::GetBz())<0.5) isSelected=kTRUE;
4339 if (IsCosmicOrCalibSpecie()) { // Selection of calib or cosmic events
4346 Double_t remainingFraction = fFractionFriends;
4347 remainingFraction -= ((Double_t)(fSspecie)/(Double_t)(fNall));
4349 if (IsHighPt()) { // Selection of "high Pt" events
4351 Double_t curentHighPtFraction = ((Double_t)(fNhighPt+1))/((Double_t)(fNall+1));
4352 // "Bayesian" estimate supposing that without events all the events are of the required type
4355 Double_t rnd = gRandom->Rndm()*curentHighPtFraction;
4356 if (rnd<remainingFraction) {
4362 remainingFraction -= ((Double_t)(fShighPt)/(Double_t)(fNall));
4364 // Random selection to fill the remaining fraction (if any)
4366 Double_t rnd = gRandom->Rndm();
4367 if (rnd<remainingFraction) {
4374 fesdf->SetSkipBit(kTRUE);
4375 fesd->DetachFriends(); // remove friend tracks
4377 else fesd->GetESDfriend(fesdf); // move friend tracks to AliESDfriens object
4379 AliSysInfo::AddStamp(Form("WriteFriend%d_%d",isSelected,iEvent), 0,0,iEvent);
4382 AliSysInfo::AddStamp(Form("WriteFrFill%d_%d",isSelected,iEvent), 0,0,iEvent);
4387 //___________________________________________________________________
4388 void AliReconstruction::InitPools()
4390 // create general purpose pools
4392 fPools = new AliPoolsSet();
4393 fPools->InitPools(); // this will initialize only obligatory pools
4395 if (fWriteAlignmentData) {
4396 AliClonesPool* pta = new AliClonesPool("AliTrackPointArray",5000);
4397 fPools->SetPool(pta,AliPoolsSet::kPoolTrPoints);
4399 AliTrackPointArray::SetPool(fPools->GetPoolN());
4400 AliESDtrack::SetPools(fPools);
4401 AliESDfriendTrack::SetPools(fPools);
4404 fPools->ResetPools();
4408 //_________________________________________________________________
4409 void AliReconstruction::DeleteDigits(const TString& detectors)
4411 // delete requested digit files produced at current event
4412 static int iEvent = 0;
4413 if (detectors.IsNull()) return;
4414 TString detStr = detectors;
4415 AliInfo(Form("Deleting Digits: %s",detectors.Data()));
4417 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4418 gSystem->Exec(Form("if [ -e %s.Digits.root ]; then\nrm %s.Digits.root\nfi",
4419 fgkDetectorName[iDet],fgkDetectorName[iDet]));
4421 AliSysInfo::AddStamp(Form("DelDigits_%d",iEvent), 0,0,iEvent);
4425 //_________________________________________________________________
4426 void AliReconstruction::DeleteRecPoints(const TString& detectors)
4428 // delete requested recpoint files produced at current event
4429 static int iEvent = 0;
4430 if (detectors.IsNull()) return;
4431 TString detStr = detectors;
4432 AliInfo(Form("Deleting Recpoints: %s",detectors.Data()));
4434 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4435 gSystem->Exec(Form("if [ -e %s.RecPoints.root ]; then\nrm %s.RecPoints.root\nfi",
4436 fgkDetectorName[iDet],fgkDetectorName[iDet]));
4438 AliSysInfo::AddStamp(Form("DelRecPoints_%d",iEvent), 0,0,iEvent);
4442 //_________________________________________________________________
4443 void AliReconstruction::SetStopOnResourcesExcess(Int_t vRSS,Int_t vVMEM)
4445 // require checking the resources left and stopping on excess
4446 // if 0 : no check is done
4447 // if >0 : stop reconstruction if exceeds this value
4448 // if <0 : use as margin to system limits
4450 const int kKB2MB = 1024;
4451 const int kInfMem = 9999999;
4454 int pgSize = getpagesize();
4458 AliInfo(Form("Setting max. RSS usage to user value %d MB",fMaxRSS));
4461 getrlimit(RLIMIT_RSS,&r);
4462 fMaxRSS = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vRSS;
4463 AliInfo(Form("Setting max. RSS usage to system hard limit %d%s MB (%d margin)",fMaxRSS,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vRSS));
4465 else {AliInfo("No check on RSS memory usage will be applied");}
4469 AliInfo(Form("Setting max. VMEM usage to user value %d MB",fMaxVMEM));
4472 getrlimit(RLIMIT_AS,&r);
4473 fMaxVMEM = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vVMEM;
4474 AliInfo(Form("Setting max. VMEM usage to system hard limit %d%s MB (%d margin)",fMaxVMEM,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vVMEM));
4476 else {AliInfo("No check on RSS memory usage will be applied");}
4480 //_________________________________________________________________
4481 Bool_t AliReconstruction::HasEnoughResources(int ev)
4483 // check if process consumed more than allowed resources
4484 const int kKB2MB = 1024;
4486 if (!fMaxRSS && !fMaxVMEM) return res;
4488 ProcInfo_t procInfo;
4489 gSystem->GetProcInfo(&procInfo);
4490 if (procInfo.fMemResident/kKB2MB > fMaxRSS) res = kFALSE;
4491 if (procInfo.fMemVirtual/kKB2MB > fMaxVMEM) res = kFALSE;
4494 AliInfo(Form("Job exceeded allowed limits: RSS:%d (%d) VMEM:%d (%d), will stop",
4495 int(procInfo.fMemResident/kKB2MB),fMaxRSS,
4496 int(procInfo.fMemVirtual/kKB2MB) ,fMaxVMEM));
4498 gSystem->Exec(Form("if [ -e %s ]; then\nrm %s\nfi\necho %d > %s",fgkStopEvFName,fgkStopEvFName,ev,fgkStopEvFName));