1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
16 /* $Id: AliReconstruction.cxx 63911 2013-08-19 16:46:41Z hristov $ */
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the reconstruction //
22 // Clusters and tracks are created for all detectors and all events by //
25 // AliReconstruction rec; //
28 // The Run method returns kTRUE in case of successful execution. //
30 // If the input to the reconstruction are not simulated digits but raw data, //
31 // this can be specified by an argument of the Run method or by the method //
33 // rec.SetInput("..."); //
35 // The input formats and the corresponding argument are: //
36 // - DDL raw data files: directory name, ends with "/" //
37 // - raw data root file: root file name, extension ".root" //
38 // - raw data DATE file: DATE file name, any other non-empty string //
39 // - MC root files : empty string, default //
41 // By default all events are reconstructed. The reconstruction can be //
42 // limited to a range of events by giving the index of the first and the //
43 // last event as an argument to the Run method or by calling //
45 // rec.SetEventRange(..., ...); //
47 // The index -1 (default) can be used for the last event to indicate no //
48 // upper limit of the event range. //
50 // In case of raw-data reconstruction the user can modify the default //
51 // number of events per digits/clusters/tracks file. In case the option //
52 // is not used the number is set 1. In case the user provides 0, than //
53 // the number of events is equal to the number of events inside the //
54 // raw-data file (i.e. one digits/clusters/tracks file): //
56 // rec.SetNumberOfEventsPerFile(...); //
59 // The name of the galice file can be changed from the default //
60 // "galice.root" by passing it as argument to the AliReconstruction //
61 // constructor or by //
63 // rec.SetGAliceFile("..."); //
65 // The local reconstruction can be switched on or off for individual //
68 // rec.SetRunLocalReconstruction("..."); //
70 // The argument is a (case sensitive) string with the names of the //
71 // detectors separated by a space. The special string "ALL" selects all //
72 // available detectors. This is the default. //
74 // The reconstruction of the primary vertex position can be switched off by //
76 // rec.SetRunVertexFinder(kFALSE); //
78 // The tracking and the creation of ESD tracks can be switched on for //
79 // selected detectors by //
81 // rec.SetRunTracking("..."); //
83 // Uniform/nonuniform field tracking switches (default: uniform field) //
85 // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
87 // The filling of additional ESD information can be steered by //
89 // rec.SetFillESD("..."); //
91 // Again, for both methods the string specifies the list of detectors. //
92 // The default is "ALL". //
94 // The call of the shortcut method //
96 // rec.SetRunReconstruction("..."); //
98 // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99 // SetFillESD with the same detector selecting string as argument. //
101 // The reconstruction requires digits or raw data as input. For the creation //
102 // of digits and raw data have a look at the class AliSimulation. //
104 // The input data of a detector can be replaced by the corresponding HLT //
105 // data by calling (usual detector string) //
106 // SetUseHLTData("..."); //
109 ///////////////////////////////////////////////////////////////////////////////
116 #include <TGeoGlobalMagField.h>
117 #include <TGeoManager.h>
119 #include <TLorentzVector.h>
121 #include <TObjArray.h>
122 #include <TPRegexp.h>
123 #include <TParameter.h>
124 #include <TPluginManager.h>
126 #include <TProofOutputFile.h>
129 #include <THashTable.h>
131 #include <TMessage.h>
134 #include <THashList.h>
136 #include "AliAlignObj.h"
137 #include "AliAnalysisManager.h"
138 #include "AliAnalysisDataContainer.h"
139 #include "AliCDBEntry.h"
140 #include "AliCDBManager.h"
141 #include "AliCDBStorage.h"
142 #include "AliCTPRawStream.h"
143 #include "AliCascadeVertexer.h"
144 #include "AliCentralTrigger.h"
145 #include "AliCodeTimer.h"
147 #include "AliDetectorRecoParam.h"
148 #include "AliESDCaloCells.h"
149 #include "AliESDCaloCluster.h"
150 #include "AliESDEvent.h"
151 #include "AliESDMuonTrack.h"
152 #include "AliESDPmdTrack.h"
153 #include "AliESDTagCreator.h"
154 #include "AliESDVertex.h"
155 #include "AliESDcascade.h"
156 #include "AliESDfriend.h"
157 #include "AliESDkink.h"
158 #include "AliESDpid.h"
159 #include "AliESDtrack.h"
160 #include "AliESDtrack.h"
161 #include "AliEventInfo.h"
162 #include "AliGRPObject.h"
163 #include "AliGRPRecoParam.h"
164 #include "AliGenEventHeader.h"
165 #include "AliGeomManager.h"
166 #include "AliGlobalQADataMaker.h"
167 #include "AliHeader.h"
170 #include "AliMultiplicity.h"
172 #include "AliPlaneEff.h"
174 #include "AliQADataMakerRec.h"
175 #include "AliQAManager.h"
176 #include "AliRawVEvent.h"
177 #include "AliRawEventHeaderBase.h"
178 #include "AliRawHLTManager.h"
179 #include "AliRawReaderDate.h"
180 #include "AliRawReaderFile.h"
181 #include "AliRawReaderRoot.h"
182 #include "AliRecoInputHandler.h"
183 #include "AliReconstruction.h"
184 #include "AliReconstructor.h"
186 #include "AliRunInfo.h"
187 #include "AliRunLoader.h"
188 #include "AliSysInfo.h" // memory snapshots
189 #include "AliTrackPointArray.h"
190 #include "AliTracker.h"
191 #include "AliTriggerClass.h"
192 #include "AliTriggerCluster.h"
193 #include "AliTriggerIR.h"
194 #include "AliTriggerConfiguration.h"
195 #include "AliV0vertexer.h"
196 #include "AliVertexer.h"
197 #include "AliTrackleter.h"
198 #include "AliVertexerTracks.h"
199 #include "AliTriggerRunScalers.h"
200 #include "AliCTPTimeParams.h"
201 #include "AliESDHLTDecision.h"
202 #include "AliTriggerInput.h"
203 #include "AliLHCData.h"
204 #include "ARVersion.h"
205 #include <RVersion.h>
207 #include <sys/resource.h>
208 ClassImp(AliReconstruction)
212 //_____________________________________________________________________________
213 const char* AliReconstruction::fgkStopEvFName = "_stopEvent_";
214 const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD",
216 "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE","AD","FIT","MFT", "HLT"};
218 //_____________________________________________________________________________
219 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
221 fRunVertexFinder(kTRUE),
222 fRunVertexFinderTracks(kTRUE),
223 fRunMuonTracking(kFALSE),
224 fRunMFTTrackingMU(kFALSE),
226 fRunCascadeFinder(kTRUE),
227 fRunMultFinder(kTRUE),
229 fStopOnMissingTriggerFile(kTRUE),
230 fWriteAlignmentData(kFALSE),
231 fWriteESDfriend(kFALSE),
232 fFillTriggerESD(kTRUE),
240 fRunLocalReconstruction("ALL"),
243 fDeleteRecPoints(""),
246 fUseTrackingErrorsForAlignment(""),
247 fGAliceFileName(gAliceFilename),
250 fProofOutputFileName(""),
251 fProofOutputLocation(""),
252 fProofOutputDataset(kFALSE),
253 fProofOutputArchive(""),
257 fNumberOfEventsPerFile((UInt_t)-1),
258 fFractionFriends(0.04),
260 fLoadAlignFromCDB(kTRUE),
261 fLoadAlignData("ALL"),
266 fCTPTimeParams(NULL),
271 fParentRawReader(NULL),
275 fSPDTrackleter(NULL),
277 fDiamondProfileSPD(NULL),
278 fDiamondProfile(NULL),
279 fDiamondProfileTPC(NULL),
280 fListOfCosmicTriggers(NULL),
284 fAlignObjArray(NULL),
288 fInitCDBCalled(kFALSE),
289 fCDBSnapshotMode(kFALSE),
290 fSetRunNumberFromDataCalled(kFALSE),
295 fSameQACycle(kFALSE),
296 fInitQACalled(kFALSE),
297 fWriteQAExpertData(kTRUE),
298 fRunPlaneEff(kFALSE),
311 fIsNewRunLoader(kFALSE),
320 fTreeBuffSize(30000000),
329 fDeclTriggerClasses(""),
334 // create reconstruction object with default parameters
337 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
338 fReconstructor[iDet] = NULL;
339 fUpgradeMask[iDet]=kFALSE;
340 fLoader[iDet] = NULL;
341 fTracker[iDet] = NULL;
343 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
344 fQACycles[iDet] = 999999 ;
345 fQAWriteExpert[iDet] = kFALSE ;
347 fBeamInt[0][0]=fBeamInt[0][1]=fBeamInt[1][0]=fBeamInt[1][1] = -1;
352 //_____________________________________________________________________________
353 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
355 fRunVertexFinder(rec.fRunVertexFinder),
356 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
357 fRunMuonTracking(rec.fRunMuonTracking),
358 fRunMFTTrackingMU(rec.fRunMFTTrackingMU),
359 fRunV0Finder(rec.fRunV0Finder),
360 fRunCascadeFinder(rec.fRunCascadeFinder),
361 fRunMultFinder(rec.fRunMultFinder),
362 fStopOnError(rec.fStopOnError),
363 fStopOnMissingTriggerFile(rec.fStopOnMissingTriggerFile),
364 fWriteAlignmentData(rec.fWriteAlignmentData),
365 fWriteESDfriend(rec.fWriteESDfriend),
366 fFillTriggerESD(rec.fFillTriggerESD),
368 fCleanESD(rec.fCleanESD),
369 fV0DCAmax(rec.fV0DCAmax),
370 fV0CsPmin(rec.fV0CsPmin),
374 fRunLocalReconstruction(rec.fRunLocalReconstruction),
375 fRunTracking(rec.fRunTracking),
376 fFillESD(rec.fFillESD),
377 fDeleteRecPoints(""),
379 fLoadCDB(rec.fLoadCDB),
380 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
381 fGAliceFileName(rec.fGAliceFileName),
382 fRawInput(rec.fRawInput),
383 fESDOutput(rec.fESDOutput),
384 fProofOutputFileName(rec.fProofOutputFileName),
385 fProofOutputLocation(rec.fProofOutputLocation),
386 fProofOutputDataset(rec.fProofOutputDataset),
387 fProofOutputArchive(rec.fProofOutputArchive),
388 fEquipIdMap(rec.fEquipIdMap),
389 fFirstEvent(rec.fFirstEvent),
390 fLastEvent(rec.fLastEvent),
391 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
392 fFractionFriends(rec.fFractionFriends),
394 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
395 fLoadAlignData(rec.fLoadAlignData),
396 fUseHLTData(rec.fUseHLTData),
400 fCTPTimeParams(NULL),
405 fParentRawReader(NULL),
407 fRecoParam(rec.fRecoParam),
409 fSPDTrackleter(NULL),
411 fDiamondProfileSPD(rec.fDiamondProfileSPD),
412 fDiamondProfile(rec.fDiamondProfile),
413 fDiamondProfileTPC(rec.fDiamondProfileTPC),
414 fListOfCosmicTriggers(NULL),
418 fAlignObjArray(rec.fAlignObjArray),
419 fCDBUri(rec.fCDBUri),
420 fQARefUri(rec.fQARefUri),
422 fInitCDBCalled(rec.fInitCDBCalled),
423 fCDBSnapshotMode(rec.fCDBSnapshotMode),
424 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
425 fQADetectors(rec.fQADetectors),
426 fQATasks(rec.fQATasks),
428 fRunGlobalQA(rec.fRunGlobalQA),
429 fSameQACycle(rec.fSameQACycle),
430 fInitQACalled(rec.fInitQACalled),
431 fWriteQAExpertData(rec.fWriteQAExpertData),
432 fRunPlaneEff(rec.fRunPlaneEff),
445 fIsNewRunLoader(rec.fIsNewRunLoader),
454 fTreeBuffSize(rec.fTreeBuffSize),
460 fAnalysisMacro(rec.fAnalysisMacro),
463 fDeclTriggerClasses(rec.fDeclTriggerClasses),
470 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
471 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
473 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
474 fReconstructor[iDet] = NULL;
475 fUpgradeMask[iDet] = kFALSE;
476 fLoader[iDet] = NULL;
477 fTracker[iDet] = NULL;
480 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
481 fQACycles[iDet] = rec.fQACycles[iDet];
482 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
485 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
486 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
489 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
493 //_____________________________________________________________________________
494 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
496 // assignment operator
497 // Used in PROOF mode
498 // Be very careful while modifing it!
499 // Simple rules to follow:
500 // for persistent data members - use their assignment operators
501 // for non-persistent ones - do nothing or take the default values from constructor
502 // TSelector members should not be touched
503 if(&rec == this) return *this;
505 fRunVertexFinder = rec.fRunVertexFinder;
506 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
507 fRunMuonTracking = rec.fRunMuonTracking;
508 fRunMFTTrackingMU = rec.fRunMFTTrackingMU;
509 fRunV0Finder = rec.fRunV0Finder;
510 fRunCascadeFinder = rec.fRunCascadeFinder;
511 fRunMultFinder = rec.fRunMultFinder;
512 fStopOnError = rec.fStopOnError;
513 fStopOnMissingTriggerFile = rec.fStopOnMissingTriggerFile;
514 fWriteAlignmentData = rec.fWriteAlignmentData;
515 fWriteESDfriend = rec.fWriteESDfriend;
516 fFillTriggerESD = rec.fFillTriggerESD;
518 fCleanESD = rec.fCleanESD;
519 fV0DCAmax = rec.fV0DCAmax;
520 fV0CsPmin = rec.fV0CsPmin;
524 fRunLocalReconstruction = rec.fRunLocalReconstruction;
525 fRunTracking = rec.fRunTracking;
526 fFillESD = rec.fFillESD;
527 fDeleteRecPoints = rec.fDeleteRecPoints;
528 fDeleteDigits = rec.fDeleteDigits;
529 fLoadCDB = rec.fLoadCDB;
530 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
531 fGAliceFileName = rec.fGAliceFileName;
532 fRawInput = rec.fRawInput;
533 fESDOutput = rec.fESDOutput;
534 fProofOutputFileName = rec.fProofOutputFileName;
535 fProofOutputLocation = rec.fProofOutputLocation;
536 fProofOutputDataset = rec.fProofOutputDataset;
537 fProofOutputArchive = rec.fProofOutputArchive;
538 fEquipIdMap = rec.fEquipIdMap;
539 fFirstEvent = rec.fFirstEvent;
540 fLastEvent = rec.fLastEvent;
541 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
542 fFractionFriends = rec.fFractionFriends;
544 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
545 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
548 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
549 fLoadAlignData = rec.fLoadAlignData;
550 fUseHLTData = rec.fUseHLTData;
552 delete fRunInfo; fRunInfo = NULL;
553 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
555 fEventInfo = rec.fEventInfo;
557 delete fRunScalers; fRunScalers = NULL;
558 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
560 delete fCTPTimeParams; fCTPTimeParams = NULL;
561 if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
562 delete fCTPTimeAlign; fCTPTimeAlign = NULL;
563 if (rec.fCTPTimeAlign) fCTPTimeAlign = new AliCTPTimeParams(*rec.fCTPTimeAlign);
567 fParentRawReader = NULL;
569 fRecoParam = rec.fRecoParam;
571 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
572 fUpgradeMask[iDet] = kFALSE;
573 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
574 delete fLoader[iDet]; fLoader[iDet] = NULL;
575 delete fTracker[iDet]; fTracker[iDet] = NULL;
578 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
579 fQACycles[iDet] = rec.fQACycles[iDet];
580 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
583 delete fSPDTrackleter; fSPDTrackleter = NULL;
585 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
586 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
587 delete fDiamondProfile; fDiamondProfile = NULL;
588 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
589 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
590 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
592 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
593 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
595 delete fGRPData; fGRPData = NULL;
596 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
597 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
599 delete fAlignObjArray; fAlignObjArray = NULL;
602 fQARefUri = rec.fQARefUri;
603 fSpecCDBUri.Delete();
604 fInitCDBCalled = rec.fInitCDBCalled;
605 fCDBSnapshotMode = rec.fCDBSnapshotMode;
606 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
607 fQADetectors = rec.fQADetectors;
608 fQATasks = rec.fQATasks;
610 fRunGlobalQA = rec.fRunGlobalQA;
611 fSameQACycle = rec.fSameQACycle;
612 fInitQACalled = rec.fInitQACalled;
613 fWriteQAExpertData = rec.fWriteQAExpertData;
614 fRunPlaneEff = rec.fRunPlaneEff;
615 for (int i=2;i--;) for (int j=2;j--;) fBeamInt[i][j] = rec.fBeamInt[i][j];
626 fIsNewRunLoader = rec.fIsNewRunLoader;
635 fTreeBuffSize = rec.fTreeBuffSize;
641 fAnalysisMacro = rec.fAnalysisMacro;
644 fDeclTriggerClasses = rec.fDeclTriggerClasses;
649 //_____________________________________________________________________________
650 AliReconstruction::~AliReconstruction()
655 if (fListOfCosmicTriggers) {
656 fListOfCosmicTriggers->Delete();
657 delete fListOfCosmicTriggers;
661 delete fCTPTimeParams;
662 delete fCTPTimeAlign;
664 if (fAlignObjArray) {
665 fAlignObjArray->Delete();
666 delete fAlignObjArray;
668 fSpecCDBUri.Delete();
670 AliCodeTimer::Instance()->Print();
673 //_____________________________________________________________________________
674 void AliReconstruction::InitQA()
676 //Initialize the QA and start of cycle
677 AliCodeTimerAuto("",0);
679 if (fInitQACalled) return;
680 fInitQACalled = kTRUE;
682 if (fGRPData) AliQADataMaker::SetCloningRequest( fGRPData->GetQATrigClasses(), fGRPData->GetQACloningRequest());
685 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
686 qam->SetSaveData(kTRUE);
687 qam->SetCycleLength(AliQAv1::kITS, 5) ;
688 if (fWriteQAExpertData)
689 qam->SetWriteExpert() ;
691 if (qam->IsDefaultStorageSet()) {
692 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
693 AliWarning("Default QA reference storage has been already set !");
694 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
695 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
696 fQARefUri = qam->GetDefaultStorage()->GetURI();
698 if (fQARefUri.Length() > 0) {
699 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
700 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
701 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
703 fQARefUri="local://$ALICE_ROOT/QAref";
704 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
705 AliWarning("Default QA refeference storage not yet set !!!!");
706 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
707 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
710 qam->SetDefaultStorage(fQARefUri);
714 qam->SetActiveDetectors(fQADetectors) ;
715 qam->SetActiveOnlineDetectors(fRunInfo->GetActiveDetectors());
717 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
718 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
719 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
721 if (!fRawReader && !fInput && IsInTasks(AliQAv1::kRAWS))
722 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
723 qam->SetTasks(fQATasks) ;
724 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
727 Bool_t sameCycle = kFALSE ;
728 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
729 AliInfo(Form("Initializing the global QA data maker"));
730 if (IsInTasks(AliQAv1::kRECPOINTS)) {
731 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
732 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
733 AliTracker::SetResidualsArray(arr);
736 if (IsInTasks(AliQAv1::kESDS)) {
737 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
738 qadm->Init(AliQAv1::kESDS);
741 AliSysInfo::AddStamp("InitQA") ;
744 //_____________________________________________________________________________
745 void AliReconstruction::MergeQA(const char *fileName)
747 //Initialize the QA and start of cycle
748 AliCodeTimerAuto("",0) ;
749 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
750 AliSysInfo::AddStamp("MergeQA") ;
753 //_____________________________________________________________________________
754 void AliReconstruction::InitCDB()
756 // activate a default CDB storage
757 // First check if we have any CDB storage set, because it is used
758 // to retrieve the calibration and alignment constants
759 AliCodeTimerAuto("",0);
761 if (fInitCDBCalled) return;
762 fInitCDBCalled = kTRUE;
764 AliCDBManager* man = AliCDBManager::Instance();
765 if (man->IsDefaultStorageSet())
767 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
768 AliWarning("Default CDB storage has been already set !");
769 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
770 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
771 fCDBUri = man->GetDefaultStorage()->GetURI();
774 if (fCDBUri.Length() > 0)
776 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
777 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
778 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
779 man->SetDefaultStorage(fCDBUri);
781 else if (!man->GetRaw()){
782 fCDBUri="local://$ALICE_ROOT/OCDB";
783 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
784 AliWarning("Default CDB storage not yet set !!!!");
785 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
786 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
787 man->SetDefaultStorage(fCDBUri);
790 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
791 AliWarning("Default storage will be set after setting the Run Number!!!");
792 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
796 // Now activate the detector specific CDB storage locations
797 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
798 TObject* obj = fSpecCDBUri[i];
800 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
801 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
802 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
803 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
805 AliSysInfo::AddStamp("InitCDB");
808 //_____________________________________________________________________________
809 void AliReconstruction::SetCDBSnapshotMode(const char* snapshotFileName) {
810 fCDBSnapshotMode = kTRUE;
811 AliCDBManager::Instance()->SetSnapshotMode(snapshotFileName);
814 //_____________________________________________________________________________
815 void AliReconstruction::SetDefaultStorage(const char* uri) {
816 // Store the desired default CDB storage location
817 // Activate it later within the Run() method
823 //_____________________________________________________________________________
824 void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
825 // Store the desired default CDB storage location
826 // Activate it later within the Run() method
829 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
832 //_____________________________________________________________________________
833 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
834 // Store a detector-specific CDB storage location
835 // Activate it later within the Run() method
837 AliCDBPath aPath(calibType);
838 if(!aPath.IsValid()){
839 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
840 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
841 if(!strcmp(calibType, fgkDetectorName[iDet])) {
842 aPath.SetPath(Form("%s/*", calibType));
843 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
847 if(!aPath.IsValid()){
848 AliError(Form("Not a valid path or detector: %s", calibType));
853 // // check that calibType refers to a "valid" detector name
854 // Bool_t isDetector = kFALSE;
855 // for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
856 // TString detName = fgkDetectorName[iDet];
857 // if(aPath.GetLevel0() == detName) {
858 // isDetector = kTRUE;
864 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
868 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
869 if (obj) fSpecCDBUri.Remove(obj);
870 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
874 //_____________________________________________________________________________
875 Bool_t AliReconstruction::SetRunNumberFromData()
877 // The method is called in Run() in order
878 // to set a correct run number.
879 // In case of raw data reconstruction the
880 // run number is taken from the raw data header
882 if (fSetRunNumberFromDataCalled) return kTRUE;
883 fSetRunNumberFromDataCalled = kTRUE;
885 AliCDBManager* man = AliCDBManager::Instance();
888 if(fRawReader->NextEvent()) {
889 if(man->GetRun() > 0) {
890 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
892 man->SetRun(fRawReader->GetRunNumber());
894 fRawReader->RewindEvents();
897 if(man->GetRun() > 0) {
898 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
901 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
907 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
909 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
914 // read run number from gAlice
915 if(rl->GetHeader()) {
916 man->SetRun(rl->GetHeader()->GetRun());
921 AliError("Neither run-loader header nor RawReader objects are found !");
933 //_____________________________________________________________________________
934 void AliReconstruction::SetCDBLock() {
935 // Set CDB lock: from now on it is forbidden to reset the run number
936 // or the default storage or to activate any further storage!
938 AliCDBManager::Instance()->SetLock(1);
941 //_____________________________________________________________________________
942 void AliReconstruction::MatchUpgradeDetector() {
943 // Translates detector name in a boolean.
944 // The boolean is used in GetReconstructor to load the
945 // upgrade reconstructor instead of the standard one.
946 for(Int_t iDet = 0; iDet < kNDetectors; iDet++) {
947 if(fUpgradeModule.Contains(fgkDetectorName[iDet])) fUpgradeMask[iDet]=kTRUE;
950 //_____________________________________________________________________________
951 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
953 // Read the alignment objects from CDB.
954 // Each detector is supposed to have the
955 // alignment objects in DET/Align/Data CDB path.
956 // All the detector objects are then collected,
957 // sorted by geometry level (starting from ALIC) and
958 // then applied to the TGeo geometry.
959 // Finally an overlaps check is performed.
961 // Load alignment data from CDB and fill fAlignObjArray
962 if(fLoadAlignFromCDB){
964 TString detStr = detectors;
965 TString loadAlObjsListOfDets = "";
967 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
968 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
969 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
971 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
973 loadAlObjsListOfDets += fgkDetectorName[iDet];
974 loadAlObjsListOfDets += " ";
976 } // end loop over detectors
978 if(AliGeomManager::GetNalignable("GRP") != 0)
979 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
980 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
982 // Check if the array with alignment objects was
983 // provided by the user. If yes, apply the objects
984 // to the present TGeo geometry
985 if (fAlignObjArray) {
986 if (gGeoManager && gGeoManager->IsClosed()) {
987 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
988 AliError("The misalignment of one or more volumes failed!"
989 "Compare the list of simulated detectors and the list of detector alignment data!");
994 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
1000 if (fAlignObjArray) {
1001 fAlignObjArray->Delete();
1002 delete fAlignObjArray; fAlignObjArray=NULL;
1008 //_____________________________________________________________________________
1009 void AliReconstruction::SetGAliceFile(const char* fileName)
1011 // set the name of the galice file
1013 fGAliceFileName = fileName;
1016 //_____________________________________________________________________________
1017 void AliReconstruction::SetInput(const char* input)
1019 // In case the input string starts with 'mem://', we run in an online mode
1020 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
1021 // file is assumed. One can give as an input:
1022 // mem://: - events taken from DAQ monitoring libs online
1024 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
1025 if (input) fRawInput = input;
1028 //_____________________________________________________________________________
1029 void AliReconstruction::SetOutput(const char* output)
1031 // Set the output ESD filename
1032 // 'output' is a normalt ROOT url
1033 // The method is used in case of raw-data reco with PROOF
1034 if (output) fESDOutput = output;
1037 //_____________________________________________________________________________
1038 void AliReconstruction::SetOption(const char* detector, const char* option)
1040 // set options for the reconstruction of a detector
1042 TObject* obj = fOptions.FindObject(detector);
1043 if (obj) fOptions.Remove(obj);
1044 fOptions.Add(new TNamed(detector, option));
1047 //_____________________________________________________________________________
1048 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
1050 // Set custom reconstruction parameters for a given detector
1051 // Single set of parameters for all the events
1053 // First check if the reco-params are global
1054 if(!strcmp(detector, "GRP")) {
1055 par->SetAsDefault();
1056 fRecoParam.AddDetRecoParam(kNDetectors,par);
1060 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1061 if(!strcmp(detector, fgkDetectorName[iDet])) {
1062 par->SetAsDefault();
1063 fRecoParam.AddDetRecoParam(iDet,par);
1070 //_____________________________________________________________________________
1071 Bool_t AliReconstruction::InitGRP() {
1072 //------------------------------------
1073 // Initialization of the GRP entry
1074 //------------------------------------
1075 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
1079 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
1082 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
1084 fGRPData = new AliGRPObject();
1085 fGRPData->ReadValuesFromMap(m);
1089 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
1090 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
1094 // FIX ME: The unloading of GRP entry is temporarily disabled
1095 // because ZDC and VZERO are using it in order to initialize
1096 // their reconstructor objects. In the future one has to think
1097 // of propagating AliRunInfo to the reconstructors.
1098 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
1102 AliError("No GRP entry found in OCDB!");
1106 TString lhcState = fGRPData->GetLHCState();
1107 if (lhcState==AliGRPObject::GetInvalidString()) {
1108 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
1109 lhcState = "UNKNOWN";
1112 TString beamType = fGRPData->GetBeamType();
1113 if (beamType==AliGRPObject::GetInvalidString()) {
1114 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
1115 beamType = "UNKNOWN";
1118 Float_t beamEnergy = fGRPData->GetBeamEnergy();
1119 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
1120 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
1124 TString runType = fGRPData->GetRunType();
1125 if (runType==AliGRPObject::GetInvalidString()) {
1126 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
1127 runType = "UNKNOWN";
1130 Int_t activeDetectors = fGRPData->GetDetectorMask();
1131 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
1132 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
1133 activeDetectors = 1074790399;
1135 AliDebug(1, Form("activeDetectors = %d", activeDetectors));
1137 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
1141 // Process the list of active detectors
1142 if (activeDetectors) {
1143 UInt_t detMask = activeDetectors;
1144 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1145 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
1146 AliDebug(1, Form("Detector List = %s", fRunLocalReconstruction.Data()));
1147 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1148 fFillESD = MatchDetectorList(fFillESD,detMask);
1149 fQADetectors = MatchDetectorList(fQADetectors,detMask);
1150 AliInfo(Form("fQADetectors=%s",fQADetectors.Data()));
1151 fDeleteRecPoints = MatchDetectorList(fDeleteRecPoints,detMask);
1152 fDeleteDigits = MatchDetectorList(fDeleteDigits,detMask);
1153 fLoadCDB.Form("%s %s %s %s",
1154 fRunLocalReconstruction.Data(),
1155 fRunTracking.Data(),
1157 fQADetectors.Data());
1158 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
1159 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1) &&
1160 !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
1161 !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
1162 // switch off the vertexer
1163 AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer and Trackleter are switched off.");
1164 fRunVertexFinder = kFALSE;
1165 fRunMultFinder = kFALSE;
1167 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1168 // switch off the reading of CTP raw-data payload
1169 if (fFillTriggerESD) {
1170 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1171 fFillTriggerESD = kFALSE;
1176 AliInfo("===================================================================================");
1177 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1178 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1179 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
1180 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
1181 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
1182 AliInfo("===================================================================================");
1184 //*** Dealing with the magnetic field map
1185 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1186 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1187 AliInfo("ExpertMode!!! GRP information will be ignored !");
1188 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1191 AliInfo("Destroying existing B field instance!");
1192 delete TGeoGlobalMagField::Instance();
1195 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
1196 // Construct the field map out of the information retrieved from GRP.
1199 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1200 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1201 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1205 Char_t l3Polarity = fGRPData->GetL3Polarity();
1206 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1207 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1212 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1213 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1214 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1218 Char_t diPolarity = fGRPData->GetDipolePolarity();
1219 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1220 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1224 // read special bits for the polarity convention and map type
1225 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1226 Bool_t uniformB = fGRPData->IsUniformBMap();
1229 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1230 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1231 polConvention,uniformB,beamEnergy, beamType.Data());
1233 TGeoGlobalMagField::Instance()->SetField( fld );
1234 TGeoGlobalMagField::Instance()->Lock();
1235 AliInfo("Running with the B field constructed out of GRP !");
1237 else AliFatal("Failed to create a B field map !");
1239 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1242 //*** Get the diamond profiles from OCDB
1243 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1245 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1247 AliError("No SPD diamond profile found in OCDB!");
1250 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1252 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1254 AliError("No diamond profile found in OCDB!");
1257 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1259 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1261 AliError("No TPC diamond profile found in OCDB!");
1264 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1266 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1270 if (!fListOfCosmicTriggers) {
1271 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1277 //_____________________________________________________________________________
1278 Bool_t AliReconstruction::LoadCDB()
1280 // Load CDB entries for all active detectors.
1281 // By default we load all the entries in <det>/Calib
1284 AliCodeTimerAuto("",0);
1286 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1288 AliCDBManager::Instance()->Get("GRP/Calib/LHCClockPhase");
1290 TString detStr = fLoadCDB;
1291 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1292 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1293 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1294 AliCDBManager::Instance()->GetAll(Form("%s/Trigger/*",fgkDetectorName[iDet]));
1297 // Temporary fix - one has to define the correct policy in order
1298 // to load the trigger OCDB entries only for the detectors that
1299 // in the trigger or that are needed in order to put correct
1300 // information in ESD
1301 AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
1302 AliCDBManager::Instance()->GetAll("HLT/*/*");
1306 //_____________________________________________________________________________
1307 Bool_t AliReconstruction::LoadTriggerScalersCDB()
1309 // Load CTP scalers from OCDB.
1310 // The scalers are checked for consistency.
1312 AliCodeTimerAuto("",0);
1314 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
1318 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1319 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1321 if (fRunScalers && (fRunScalers->CorrectScalersOverflow() == 0)) AliInfo("32bit Trigger counters corrected for overflow");
1326 //_____________________________________________________________________________
1327 Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
1329 // Load CTP timing information (alignment)
1332 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
1333 if (!entry) return kFALSE;
1335 AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
1336 fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
1339 AliCDBEntry* entry2 = AliCDBManager::Instance()->Get("GRP/CTP/TimeAlign");
1340 if (!entry2) return kFALSE;
1342 AliInfo("Found an AliCTPTimeParams in GRP/CTP/TimeAlign, reading it");
1343 fCTPTimeAlign = dynamic_cast<AliCTPTimeParams*> (entry2->GetObject());
1344 entry2->SetOwner(0);
1349 //_____________________________________________________________________________
1350 Bool_t AliReconstruction::ReadIntensityInfoCDB()
1352 // Load LHC DIP data
1353 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/LHCData");
1354 AliCDBEntry* entryCTP = AliCDBManager::Instance()->Get("GRP/CTP/Config");
1356 if (!entry || !entryCTP) {
1357 AliError(Form("Failed to extract CDB objects GRP/GRP/LHCData: %p or GRP/CTP/Config: %p",entry,entryCTP));
1361 enum {kA,kB,kC,kE,kNMasks};
1362 AliTriggerConfiguration* conf = (AliTriggerConfiguration*)entryCTP->GetObject();
1363 const TObjArray& clArr = conf->GetClasses();
1364 TObjArray masks(kNMasks);
1366 AliTriggerClass* trClass = 0;
1368 masks.SetOwner(kFALSE);
1370 while ( (trClass=(AliTriggerClass*)next()) ) {
1371 TString trName = trClass->GetName();
1372 int ind = trName.Index("-"); // prefix in front of A,B,C,E
1373 if (ind<1) continue; // anomaly
1375 trName = trName.Data() + ind;
1376 AliTriggerBCMask* bcMask = trClass->GetBCMask();
1377 if (!bcMask) continue;
1379 if (trName.BeginsWith("-A-")) which |= 0x1<<kA;
1380 else if (trName.BeginsWith("-B-")) which |= 0x1<<kB;
1381 else if (trName.BeginsWith("-C-")) which |= 0x1<<kC;
1382 else if (trName.BeginsWith("-E-")) which |= 0x1<<kE;
1383 else if (trName.BeginsWith("-AC-")) which |= (0x1<<kA) | (0x1<<kC);
1384 else if (trName.BeginsWith("-CA-")) which |= (0x1<<kA) | (0x1<<kC);
1385 else { AliWarning(Form("Unknown trigger type %s\n",trClass->GetName())); continue;}
1387 for (int ip=kNMasks;ip--;) {
1388 if ( !(which&(0x1<<ip)) || masks[ip] ) continue; // does not match or already done
1389 masks[ip] = (TObject*)bcMask;
1392 if (nFound==kNMasks) break;
1395 AliInfo("Reading mean bunch intensities from GRP/GRP/LHCData");
1396 AliLHCData* dipData = dynamic_cast<AliLHCData*> (entry->GetObject());
1398 for (int ib=2;ib--;) {
1400 if (dipData && (dipData->GetMeanIntensity(ib,intI,intNI,&masks)>=0)) {
1401 fBeamInt[ib][0] = intI;
1402 fBeamInt[ib][1] = intNI;
1403 AliInfo(Form("Mean intensity for beam %d: Interacting:%.2e Non-Interacting:%.2e",ib,intI,intNI));
1411 //_____________________________________________________________________________
1412 Bool_t AliReconstruction::Run(const char* input)
1415 AliCodeTimerAuto("",0);
1418 if (GetAbort() != TSelector::kContinue) return kFALSE;
1420 TChain *chain = NULL;
1421 if (fRawReader && (chain = fRawReader->GetChain())) {
1422 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
1425 // Temporary fix for long raw-data runs (until socket timeout handling in PROOF is revised)
1426 gProof->Exec("gEnv->SetValue(\"Proof.SocketActivityTimeout\",-1)", kTRUE);
1429 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1431 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1432 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1434 gProof->AddInput(this);
1436 if (!ParseOutput()) return kFALSE;
1438 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
1440 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
1443 chain->Process(this,"",nEntries,fFirstEvent);
1448 if (GetAbort() != TSelector::kContinue) return kFALSE;
1450 if (GetAbort() != TSelector::kContinue) return kFALSE;
1451 //******* The loop over events
1452 AliInfo("Starting looping over events");
1454 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1455 (fRawReader && fRawReader->NextEvent())) {
1457 // check if process has enough resources
1458 if (!HasEnoughResources(iEvent)) break;
1459 if (!ProcessEvent(iEvent)) {
1460 Abort("ProcessEvent",TSelector::kAbortFile);
1463 CleanProcessedEvent();
1466 if (!iEvent) AliWarning("No events passed trigger selection");
1468 if (GetAbort() != TSelector::kContinue) return kFALSE;
1470 if (GetAbort() != TSelector::kContinue) return kFALSE;
1476 //_____________________________________________________________________________
1477 void AliReconstruction::InitRawReader(const char* input)
1479 // Init raw-reader and
1480 // set the input in case of raw data
1482 AliCodeTimerAuto("",0);
1484 if (input) fRawInput = input;
1485 fRawReader = AliRawReader::Create(fRawInput.Data());
1487 if (fRawInput.IsNull()) {
1488 AliInfo("Reconstruction will run over digits");
1491 AliFatal("Can not create raw-data reader ! Exiting...");
1495 if (!fEquipIdMap.IsNull() && fRawReader)
1496 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1498 if (!fUseHLTData.IsNull()) {
1499 // create the RawReaderHLT which performs redirection of HLT input data for
1500 // the specified detectors
1501 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1503 fParentRawReader=fRawReader;
1504 fRawReader=pRawReader;
1506 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1509 AliSysInfo::AddStamp("CreateRawReader");
1512 //_____________________________________________________________________________
1513 void AliReconstruction::InitRun(const char* input)
1515 // Initialization of raw-reader,
1516 // run number, CDB etc.
1517 AliCodeTimerAuto("",0);
1518 AliSysInfo::AddStamp("Start");
1520 // Initialize raw-reader if any
1521 InitRawReader(input);
1523 // Initialize the CDB storage
1526 // Set run number in CDBManager (if it is not already set by the user)
1527 if (!SetRunNumberFromData()) {
1528 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1532 // Set CDB lock: from now on it is forbidden to reset the run number
1533 // or the default storage or to activate any further storage!
1538 //_____________________________________________________________________________
1539 void AliReconstruction::Begin(TTree *)
1541 // Initialize AlReconstruction before
1542 // going into the event loop
1543 // Should follow the TSelector convention
1544 // i.e. initialize only the object on the client side
1545 AliCodeTimerAuto("",0);
1547 AliReconstruction *reco = NULL;
1549 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1552 AliSysInfo::AddStamp("ReadInputInBegin");
1555 // Import ideal TGeo geometry and apply misalignment
1556 if (!AliGeomManager::GetGeometry()) {
1557 TString geom(gSystem->DirName(fGAliceFileName));
1558 geom += "/geometry.root";
1559 AliGeomManager::LoadGeometry(geom.Data());
1561 Abort("LoadGeometry", TSelector::kAbortProcess);
1564 AliSysInfo::AddStamp("LoadGeom");
1565 TString detsToCheck=fRunLocalReconstruction;
1566 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1567 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1570 AliSysInfo::AddStamp("CheckGeom");
1573 Bool_t toCDBSnapshot=kFALSE;
1574 TString snapshotFileOut(""); // we could use fSnapshotFileName if we are not interested
1575 // in reading from and writing to a snapshot file at the same time
1576 if(TString(getenv("OCDB_SNAPSHOT_CREATE")) == TString("kTRUE")){
1577 toCDBSnapshot=kTRUE;
1578 //fFromCDBSnapshot=kFALSE;
1579 TString snapshotFile(getenv("OCDB_SNAPSHOT_FILENAME"));
1580 if(!(snapshotFile.IsNull() || snapshotFile.IsWhitespace()))
1581 snapshotFileOut = snapshotFile;
1583 snapshotFileOut="OCDB.root";
1586 if (!MisalignGeometry(fLoadAlignData)) {
1587 Abort("MisalignGeometry", TSelector::kAbortProcess);
1591 const TMap* cdbCache = AliCDBManager::Instance()->GetEntryCache();
1592 if(cdbCache->Contains("GRP/Geometry/Data"))
1593 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1594 if(!toCDBSnapshot) AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1595 AliSysInfo::AddStamp("MisalignGeom");
1598 Abort("InitGRP", TSelector::kAbortProcess);
1601 AliSysInfo::AddStamp("InitGRP");
1603 if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
1604 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1606 if(!fCDBSnapshotMode || toCDBSnapshot){
1608 Abort("LoadCDB", TSelector::kAbortProcess);
1611 AliSysInfo::AddStamp("LoadCDB");
1614 if (!LoadTriggerScalersCDB()) {
1615 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1618 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1620 if (!LoadCTPTimeParamsCDB()) {
1621 Abort("LoadCTPTimeParamsCDB", TSelector::kAbortProcess);
1624 AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
1626 if (!ReadIntensityInfoCDB()) {
1627 Abort("ReadIntensityInfoCDB", TSelector::kAbortProcess);
1630 AliSysInfo::AddStamp("ReadIntensityInfoCDB");
1632 // Read the reconstruction parameters from OCDB
1633 if (!InitRecoParams()) {
1634 AliWarning("Not all detectors have correct RecoParam objects initialized");
1636 AliSysInfo::AddStamp("InitRecoParams");
1640 AliCDBManager::Instance()->DumpToSnapshotFile(snapshotFileOut.Data(),kFALSE);
1641 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
1642 if(cdbCache->Contains("GRP/Calib/CosmicTriggers"))
1643 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1646 if (fInput && gProof) {
1647 if (reco) *reco = *this;
1649 gGeoManager->SetName("Geometry");
1650 gProof->AddInputData(gGeoManager,kTRUE);
1652 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
1653 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1654 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1655 magFieldMap->SetName("MagneticFieldMap");
1656 gProof->AddInputData(magFieldMap,kTRUE);
1658 fAnalysis->SetName("Analysis");
1659 gProof->AddInputData(fAnalysis,kTRUE);
1665 //_____________________________________________________________________________
1666 void AliReconstruction::SlaveBegin(TTree*)
1668 // Initialization related to run-loader,
1669 // vertexer, trackers, recontructors
1670 // In proof mode it is executed on the slave
1671 AliCodeTimerAuto("",0);
1673 TProofOutputFile *outProofFile = NULL;
1675 if (AliDebugLevel() > 0) fInput->Print();
1676 if (AliDebugLevel() > 10) fInput->Dump();
1677 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1680 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1682 AliGeomManager::SetGeometry(tgeo);
1684 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1685 Int_t runNumber = -1;
1686 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1687 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1688 man->SetCacheFlag(kTRUE);
1689 man->SetLock(kTRUE);
1693 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1694 AliMagF *newMap = new AliMagF(*map);
1695 if (!newMap->LoadParameterization()) {
1696 Abort("AliMagF::LoadParameterization", TSelector::kAbortProcess);
1699 TGeoGlobalMagField::Instance()->SetField(newMap);
1700 TGeoGlobalMagField::Instance()->Lock();
1703 // Attempt to get the analysis manager from the input list
1704 fAnalysis = (AliAnalysisManager*)fInput->FindObject("Analysis");
1705 if (fAnalysis) AliInfo("==== Analysis manager retrieved from input list ====");
1707 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1708 fProofOutputFileName = outputFileName->GetTitle();
1709 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1710 fProofOutputLocation = outputLocation->GetTitle();
1711 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1712 fProofOutputDataset = kTRUE;
1713 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1714 fProofOutputArchive = archiveList->GetTitle();
1715 if (!fProofOutputFileName.IsNull() &&
1716 !fProofOutputLocation.IsNull() &&
1717 fProofOutputArchive.IsNull()) {
1718 if (!fProofOutputDataset) {
1719 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1720 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1723 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1725 if (AliDebugLevel() > 0) outProofFile->Dump();
1726 fOutput->Add(outProofFile);
1728 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1730 // Check if analysis was requested in the reconstruction event loop
1732 // Attempt to connect in-memory singleton
1733 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1734 if (fAnalysis) AliInfo(Form("==== Analysis manager <%s> found in memory ====", fAnalysis->GetName()));
1735 // Check if an analysis macro was specified
1736 if (!fAnalysis && !fAnalysisMacro.IsNull()) {
1737 // Run specified analysis macro
1738 gROOT->ProcessLine(Form(".x %s",fAnalysisMacro.Data()));
1739 fAnalysis = AliAnalysisManager::GetAnalysisManager();
1740 if (!fAnalysis) AliError(Form("No analysis manager produced by analysis macro %s", fAnalysisMacro.Data()));
1741 else AliInfo(Form("==== Analysis manager <%s> produced by analysis macro <%s> ====",
1742 fAnalysis->GetName(), fAnalysisMacro.Data()));
1746 // get the run loader
1747 if (!InitRunLoader()) {
1748 Abort("InitRunLoader", TSelector::kAbortProcess);
1751 AliSysInfo::AddStamp("LoadLoader");
1753 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1756 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1757 Abort("CreateTrackers", TSelector::kAbortProcess);
1760 AliSysInfo::AddStamp("CreateTrackers");
1762 // create the ESD output file and tree
1763 if (!outProofFile) {
1764 ffile = TFile::Open("AliESDs.root", "RECREATE");
1765 ffile->SetCompressionLevel(2);
1766 if (!ffile->IsOpen()) {
1767 Abort("OpenESDFile", TSelector::kAbortProcess);
1772 AliInfo(Form("Opening output PROOF file: %s/%s",
1773 outProofFile->GetDir(), outProofFile->GetFileName()));
1774 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1775 Abort(Form("Problems opening output PROOF file: %s/%s",
1776 outProofFile->GetDir(), outProofFile->GetFileName()),
1777 TSelector::kAbortProcess);
1782 ftree = new TTree("esdTree", "Tree with ESD objects");
1783 fesd = new AliESDEvent();
1784 fesd->CreateStdContent();
1785 // add a so far non-std object to the ESD, this will
1786 // become part of the std content
1787 fesd->AddObject(new AliESDHLTDecision);
1789 fesd->WriteToTree(ftree);
1790 if (fWriteESDfriend) {
1791 ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
1792 ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
1793 fesdf = new AliESDfriend();
1794 ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf);
1795 fesd->AddObject(fesdf);
1798 ftree->GetUserInfo()->Add(fesd);
1800 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1801 fhltesd = new AliESDEvent();
1802 fhltesd->CreateStdContent();
1803 // read the ESD template from CDB
1804 // HLT is allowed to put non-std content to its ESD, the non-std
1805 // objects need to be created before invocation of WriteToTree in
1806 // order to create all branches. Initialization is done from an
1807 // ESD layout template in CDB
1808 AliCDBManager* man = AliCDBManager::Instance();
1809 AliCDBEntry* hltESDConfig = man->Get("HLT/Calib/esdLayout");
1811 AliError(Form("Error getting \"HLT/Calib/esdLayout\""));
1814 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1816 // init all internal variables from the list of objects
1817 pESDLayout->GetStdContent();
1819 // copy content and create non-std objects
1820 *fhltesd=*pESDLayout;
1823 AliError(Form("error setting hltEsd layout from \"HLT/Calib/esdLayout\": invalid object type"));
1826 fhltesd->WriteToTree(fhlttree);
1827 fhlttree->GetUserInfo()->Add(fhltesd);
1829 ProcInfo_t procInfo;
1830 gSystem->GetProcInfo(&procInfo);
1831 AliInfo(Form("Current memory usage %ld %ld", procInfo.fMemResident, procInfo.fMemVirtual));
1834 fESDpid = new AliESDpid();
1837 //Initialize the QA and start of cycle
1838 if (fRunQA || fRunGlobalQA)
1841 //Initialize the Plane Efficiency framework
1842 if (fRunPlaneEff && !InitPlaneEff()) {
1843 Abort("InitPlaneEff", TSelector::kAbortProcess);
1847 if (strcmp(gProgName,"alieve") == 0)
1848 fRunAliEVE = InitAliEVE();
1849 // If we have an analysis manager, connect the AliRecoInputHandler here
1851 if (!dynamic_cast<AliRecoInputHandler*>(fAnalysis->GetInputEventHandler())) {
1852 AliError("Analysis manager used in reconstruction should use AliRecoInputHandler - \
1853 \n ->Replacing with AliRecoInputHandler instance.");
1854 delete fAnalysis->GetInputEventHandler();
1856 // Set the event and other data pointers
1857 fRecoHandler = new AliRecoInputHandler();
1858 // fRecoHandler->Init(ftree, "LOCAL");
1859 fRecoHandler->SetEvent(fesd);
1860 fRecoHandler->SetESDfriend(fesdf);
1861 fRecoHandler->SetHLTEvent(fhltesd);
1862 fRecoHandler->SetHLTTree(fhlttree);
1863 fAnalysis->SetInputEventHandler(fRecoHandler);
1864 // Enter external loop mode
1865 fAnalysis->SetExternalLoop(kTRUE);
1866 // Initialize analysis
1867 fAnalysis->SlaveBegin(ftree);
1868 fAnalysis->StartAnalysis("local", (TTree*)0);
1869 // Connect ESD tree with the input container
1870 fAnalysis->GetCommonInputContainer()->SetData(ftree);
1875 //_____________________________________________________________________________
1876 Bool_t AliReconstruction::Process(Long64_t entry)
1878 // run the reconstruction over a single entry
1879 // from the chain with raw data
1880 AliCodeTimerAuto("",0);
1882 TTree *currTree = fChain->GetTree();
1883 AliRawVEvent *event = NULL;
1884 currTree->SetBranchAddress("rawevent",&event);
1885 currTree->GetEntry(entry);
1886 fRawReader = new AliRawReaderRoot(event);
1887 // check if process has enough resources
1888 if (!HasEnoughResources(entry)) return kFALSE;
1889 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1897 //_____________________________________________________________________________
1898 void AliReconstruction::Init(TTree *tree)
1900 // Implementation of TSelector::Init()
1903 AliError("The input tree is not found!");
1909 //_____________________________________________________________________________
1910 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1912 // run the reconstruction over a single event
1913 // The event loop is steered in Run method
1916 static Long_t oldMres=0;
1917 static Long_t oldMvir=0;
1918 static Float_t oldCPU=0;
1919 static Long_t aveDMres=0;
1920 static Long_t aveDMvir=0;
1921 static Float_t aveDCPU=0;
1923 AliCodeTimerAuto("",0);
1925 AliSysInfo::AddStamp(Form("StartEv_%d",iEvent), 0,0,iEvent);
1927 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1928 fRunLoader->SetEventNumber(iEvent);
1930 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1932 fRunLoader->TreeE()->Fill();
1934 if (fRawReader && fRawReader->UseAutoSaveESD())
1935 fRunLoader->TreeE()->AutoSave("SaveSelf");
1938 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1943 fRunLoader->GetEvent(iEvent);
1945 // Fill Event-info object
1947 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
1949 ProcInfo_t procInfo;
1950 if(iEvent==fFirstEvent) {
1951 gSystem->GetProcInfo(&procInfo);
1952 oldMres=procInfo.fMemResident;
1953 oldMvir=procInfo.fMemVirtual;
1954 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
1956 AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
1958 AliSysInfo::AddStamp(Form("StartReco_%d",iEvent), 0,0,iEvent);
1960 // Set the reco-params
1962 TString detStr = fLoadCDB;
1963 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1964 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1965 AliReconstructor *reconstructor = GetReconstructor(iDet);
1966 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1967 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1968 reconstructor->SetRecoParam(par);
1969 reconstructor->GetPidSettings(fESDpid);
1970 reconstructor->SetEventInfo(&fEventInfo);
1972 AliQAManager::QAManager()->SetEventInfo(&fEventInfo) ;
1973 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
1974 if (par) AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
1979 if (fRunQA || fRunGlobalQA) AliQADataMaker::SetEventTrigClasses(fEventInfo.GetTriggerClasses()); // RS: select which histo clones are to be filled
1982 const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
1983 AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ;
1984 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
1989 if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
1990 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1991 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
1992 AliSysInfo::AddStamp(Form("RawQA_%d",iEvent), 0,0,iEvent);
1995 // fill Event header information from the RawEventHeader
1996 if (fRawReader){FillRawEventHeaderESD(fesd);}
1997 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
1999 // Store DAQ detector pattern and attributes
2000 fesd->SetDAQDetectorPattern(fRawReader->GetDetectorPattern()[0]);
2001 fesd->SetDAQAttributes(fRawReader->GetAttributes()[2]);
2004 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
2005 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
2007 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
2008 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInDAQ(fRunInfo->GetDetectorMask());
2009 ((AliESDRun*)fesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
2010 ((AliESDRun*)fhltesd->GetESDRun())->SetDetectorsInReco(AliDAQ::DetectorPatternOffline(fFillESD.Data()));
2012 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
2013 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
2015 fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
2016 fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
2018 // Set magnetic field from the tracker
2019 fesd->SetMagneticField(AliTracker::GetBz());
2020 fhltesd->SetMagneticField(AliTracker::GetBz());
2022 AliESDRun *esdRun,*esdRunH;
2023 esdRun = (AliESDRun*)fesd->GetESDRun();
2024 esdRunH = (AliESDRun*)fhltesd->GetESDRun();
2025 esdRun->SetBeamEnergyIsSqrtSHalfGeV();
2026 esdRunH->SetBeamEnergyIsSqrtSHalfGeV();
2028 for (int ib=2;ib--;) for (int it=2;it--;) {
2029 esdRun->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2030 esdRunH->SetMeanIntensity(ib,it, fBeamInt[ib][it]);
2033 fesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2034 fesd->SetBeamType(fGRPData->GetBeamType().Data());
2035 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2036 fesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2037 fhltesd->SetBeamEnergy(fGRPData->GetBeamEnergy());
2038 fhltesd->SetBeamType(fGRPData->GetBeamType().Data());
2039 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(0).Atoi(),0);
2040 fhltesd->SetBeamParticle(fGRPData->GetSingleBeamType(1).Atoi(),1);
2042 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
2043 if (fld) { // set info needed for field initialization
2044 fesd->SetCurrentL3(fld->GetCurrentSol());
2045 fesd->SetCurrentDip(fld->GetCurrentDip());
2046 fesd->SetUniformBMap(fld->IsUniform());
2047 fesd->SetBInfoStored();
2049 fhltesd->SetCurrentL3(fld->GetCurrentSol());
2050 fhltesd->SetCurrentDip(fld->GetCurrentDip());
2051 fhltesd->SetUniformBMap(fld->IsUniform());
2052 fhltesd->SetBInfoStored();
2056 // run full HLT reconstruction first
2059 TString detectors=fRunLocalReconstruction;
2060 if (IsSelected("HLT", detectors) &&
2061 !RunLocalEventReconstruction("HLT")) {
2062 if (fStopOnError) {CleanUp(); return kFALSE;}
2065 // run HLT on hltesd
2066 if (IsSelected("HLT", detectors) &&
2067 !FillESD(fhltesd, "HLT")) {
2068 if (fStopOnError) {CleanUp(); return kFALSE;}
2072 // local single event reconstruction
2073 if (!fRunLocalReconstruction.IsNull()) {
2074 TString detectors=fRunLocalReconstruction;
2075 // the logic for selection and correct sequence of reconstruction relies on the
2076 // full list of detectors. Keyword 'ALL' should have been replaced at this point.
2077 if (detectors.Contains("ALL")) {
2078 AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
2079 "fRunLocalReconstruction. This should have been done by the framework");
2081 detectors.ReplaceAll("HLT", "");
2082 if (!RunLocalEventReconstruction(detectors)) {
2092 // Set most probable pt, for B=0 tracking
2093 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
2094 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
2095 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
2097 // Fill raw-data error log into the ESD
2098 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
2100 AliSysInfo::AddStamp(Form("FillHeadErrs_%d",iEvent), 0,0,iEvent);
2103 if (fRunVertexFinder) {
2104 if (!RunVertexFinder(fesd)) {
2105 if (fStopOnError) {CleanUp(); return kFALSE;}
2107 AliSysInfo::AddStamp(Form("VtxFinder_%d",iEvent), 0,0,iEvent);
2110 // For Plane Efficiency: run the SPD trackleter
2111 if (fRunPlaneEff && fSPDTrackleter) {
2112 if (!RunSPDTrackleting(fesd)) {
2113 if (fStopOnError) {CleanUp(); return kFALSE;}
2115 AliSysInfo::AddStamp(Form("TrackletEff_%d",iEvent), 0,0,iEvent);
2119 if (!fRunTracking.IsNull()) {
2120 if (fRunMuonTracking) {
2121 if (!RunMuonTracking(fesd)) {
2122 if (fStopOnError) {CleanUp(); return kFALSE;}
2125 AliSysInfo::AddStamp(Form("TrackingMUON_%d",iEvent), 0,0,iEvent);
2128 //---------------- AU From here...
2130 // MFT tracking of MUON tracks
2131 if (!fRunTracking.IsNull()) {
2132 if (fRunMFTTrackingMU && fRunMuonTracking) {
2133 if (!RunMFTTrackingMU(fesd)) {
2134 if (fStopOnError) {CleanUp(); return kFALSE;}
2137 AliSysInfo::AddStamp(Form("TrackingMFT_MUON_%d",iEvent), 0,0,iEvent);
2140 //---------------- ...to here
2143 if (!fRunTracking.IsNull()) {
2144 if (!RunTracking(fesd,*fESDpid)) {
2145 if (fStopOnError) {CleanUp(); return kFALSE;}
2150 if (!fFillESD.IsNull()) {
2151 TString detectors=fFillESD;
2152 // the logic for selection and correct sequence of reconstruction relies on the
2153 // full list of detectors. Keyword 'ALL' should have been replaced at this point.
2154 if (detectors.Contains("ALL")) {
2155 AliFatal("Keyword 'ALL' needs to be replaced by the full list of detectors in "
2156 "fFillESD. This should have been done by the framework");
2158 // remove HLT as this has been executed at the beginning of the event reconstruction
2159 detectors.ReplaceAll("HLT", "");
2160 if (!FillESD(fesd, detectors)) {
2161 if (fStopOnError) {CleanUp(); return kFALSE;}
2168 // Propagate track to the beam pipe (if not already done by ITS)
2170 const Int_t ntracks = fesd->GetNumberOfTracks();
2171 const Double_t kRadius = 2.8; //something less than the beam pipe radius
2174 UShort_t selectedIdx[ntracks];
2176 for (Int_t itrack=0; itrack<ntracks; itrack++){
2177 const Double_t kMaxStep = 1; //max step over the material
2180 AliESDtrack *track = fesd->GetTrack(itrack);
2181 if (!track) continue;
2183 AliExternalTrackParam *tpcTrack =
2184 (AliExternalTrackParam *)track->GetTPCInnerParam();
2188 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
2191 Int_t n=trkArray.GetEntriesFast();
2192 selectedIdx[n]=track->GetID();
2193 trkArray.AddLast(tpcTrack);
2196 //Tracks refitted by ITS should already be at the SPD vertex
2197 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
2200 PropagateTrackToBxByBz(track,kRadius,track->GetMassForTracking(),kMaxStep,kFALSE);
2201 Double_t x[3]; track->GetXYZ(x);
2202 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2203 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
2206 AliSysInfo::AddStamp(Form("RelToSPDVtx_%d",iEvent), 0,0,iEvent);
2208 // Improve the reconstructed primary vertex position using the tracks
2210 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
2211 if(fesd->GetPrimaryVertexSPD()) {
2212 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
2213 if(vtitle.Contains("cosmics")) {
2214 runVertexFinderTracks=kFALSE;
2218 if (runVertexFinderTracks) {
2219 // TPC + ITS primary vertex
2220 ftVertexer->SetITSMode();
2221 ftVertexer->SetConstraintOff();
2222 // get cuts for vertexer from AliGRPRecoParam
2223 Bool_t constrSPD=kFALSE;
2225 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2226 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2227 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer,nCutsVertexer);
2228 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2229 delete [] cutsVertexer; cutsVertexer = NULL;
2230 if(grpRecoParam->GetVertexerTracksConstraintITS()) {
2231 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius){
2232 ftVertexer->SetVtxStart(fDiamondProfile); // apply constraint only if sigmax is smaller than the beam pipe radius
2234 if(fDiamondProfileSPD && fDiamondProfileSPD->GetXRes()<kRadius){
2235 ftVertexer->SetVtxStart(fDiamondProfileSPD);
2241 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
2244 TString title=pvtx->GetTitle();
2245 title.Append("SPD");
2246 pvtx->SetTitle(title);
2248 if (pvtx->GetStatus()) {
2249 fesd->SetPrimaryVertexTracks(pvtx);
2250 for (Int_t i=0; i<ntracks; i++) {
2251 AliESDtrack *t = fesd->GetTrack(i);
2252 Double_t x[3]; t->GetXYZ(x);
2253 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2254 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
2257 delete pvtx; pvtx=NULL;
2259 AliSysInfo::AddStamp(Form("VtxTrk_%d",iEvent), 0,0,iEvent);
2261 // TPC-only primary vertex
2262 ftVertexer->SetTPCMode();
2263 ftVertexer->SetConstraintOff();
2264 // get cuts for vertexer from AliGRPRecoParam
2266 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
2267 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
2268 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer,nCutsVertexer);
2269 ftVertexer->SetCuts(cutsVertexer,nCutsVertexer);
2270 delete [] cutsVertexer; cutsVertexer = NULL;
2271 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC()) {
2272 if(fDiamondProfileTPC->GetXRes()<kRadius) ftVertexer->SetVtxStart(fDiamondProfileTPC); // apply constraint only if sigmax is smaller than the beam pipe radius
2275 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
2277 if (pvtx->GetStatus()) {
2278 fesd->SetPrimaryVertexTPC(pvtx);
2279 for (Int_t i=0; i<ntracks; i++) {
2280 AliESDtrack *t = fesd->GetTrack(i);
2281 Double_t x[3]; t->GetXYZ(x);
2282 Double_t b[3]; AliTracker::GetBxByBz(x,b);
2283 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
2286 delete pvtx; pvtx=NULL;
2288 AliSysInfo::AddStamp(Form("VtxTPC_%d",iEvent), 0,0,iEvent);
2292 if(fDiamondProfile && fDiamondProfile->GetXRes()<kRadius) fesd->SetDiamond(fDiamondProfile);
2293 else fesd->SetDiamond(fDiamondProfileSPD);
2297 AliV0vertexer vtxer;
2298 // get cuts for V0vertexer from AliGRPRecoParam
2300 Int_t nCutsV0vertexer = grpRecoParam->GetVertexerV0NCuts();
2301 Double_t cutsV0vertexer[nCutsV0vertexer];
2302 grpRecoParam->GetVertexerV0Cuts(cutsV0vertexer);
2303 vtxer.SetCuts(cutsV0vertexer);
2305 vtxer.Tracks2V0vertices(fesd);
2306 AliSysInfo::AddStamp(Form("V0Finder_%d",iEvent), 0,0,iEvent);
2308 if (fRunCascadeFinder) {
2310 AliCascadeVertexer cvtxer;
2311 // get cuts for CascadeVertexer from AliGRPRecoParam
2313 Int_t nCutsCascadeVertexer = grpRecoParam->GetVertexerCascadeNCuts();
2314 Double_t cutsCascadeVertexer[nCutsCascadeVertexer];
2315 grpRecoParam->GetVertexerCascadeCuts(cutsCascadeVertexer);
2316 cvtxer.SetCuts(cutsCascadeVertexer);
2318 cvtxer.V0sTracks2CascadeVertices(fesd);
2319 AliSysInfo::AddStamp(Form("CascadeFinder_%d",iEvent), 0,0,iEvent);
2324 if (fReconstructor[3])
2325 GetReconstructor(3)->FillEventTimeWithTOF(fesd,fESDpid);
2328 // fESDpid->MakePID(fesd);
2330 if (fFillTriggerESD) {
2331 if (!FillTriggerESD(fesd)) {
2332 if (fStopOnError) {CleanUp(); return kFALSE;}
2335 // Always fill scalers
2336 if (!FillTriggerScalers(fesd)) {
2337 if (fStopOnError) {CleanUp(); return kFALSE;}
2340 AliSysInfo::AddStamp(Form("FillVaria_%d",iEvent), 0,0,iEvent);
2343 UInt_t specie = fesd->GetEventSpecie();
2344 Bool_t keepAll = (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib);
2345 if (fCleanESD && (!keepAll) ) {
2347 AliSysInfo::AddStamp(Form("CleanESD_%d",iEvent), 0,0,iEvent);
2350 // RS run updated trackleter: since we want to mark the clusters used by tracks and also mark the
2351 // tracks interpreted as primary, this step should be done in the very end, when full
2352 // ESD info is available (particulalry, V0s)
2354 if (fRunMultFinder) {
2355 if (!RunMultFinder(fesd)) {
2356 if (fStopOnError) {CleanUp(); return kFALSE;}
2358 AliSysInfo::AddStamp(Form("MultFinder_%d",iEvent), 0,0,iEvent);
2361 if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
2362 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2363 AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ;
2364 AliSysInfo::AddStamp(Form("RunQA_%d",iEvent), 0,0,iEvent);
2367 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2369 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2370 if (qadm && IsInTasks(AliQAv1::kESDS))
2371 qadm->Exec(AliQAv1::kESDS, fesd);
2372 AliSysInfo::AddStamp(Form("RunGlobQA_%d",iEvent), 0,0,iEvent);
2375 // copy HLT decision from HLTesd to esd
2376 // the most relevant information is stored in a reduced container in the esd,
2377 // while the full information can be found in the HLTesd
2378 TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
2379 TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
2380 if (pHLTSrc && pHLTTgt) {
2381 pHLTSrc->Copy(*pHLTTgt);
2384 // Perform analysis of this event if requested
2385 // RS: Should be done before WriteESDfriend, since the latter may clean the esdfriend
2387 fRecoHandler->BeginEvent(iEvent);
2388 fAnalysis->ExecAnalysis();
2389 fRecoHandler->FinishEvent();
2390 AliSysInfo::AddStamp(Form("Analysis_%d",iEvent), 0,0,iEvent);
2393 if (fWriteESDfriend) {
2394 fesd->GetESDfriend(fesdf);
2395 AliSysInfo::AddStamp(Form("CreateFriend_%d",iEvent), 0,0,iEvent);
2400 nbf = ftree->Fill();
2401 if (fTreeBuffSize>0 && ftree->GetAutoFlush()<0 && (fMemCountESD += nbf)>fTreeBuffSize ) { // default limit is still not reached
2402 nbf = ftree->GetZipBytes();
2403 if (nbf>0) nbf = -nbf;
2404 else nbf = ftree->GetEntries();
2405 ftree->SetAutoFlush(nbf);
2406 AliInfo(Form("Calling ftree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
2407 nbf,fMemCountESD,ftree->GetTotBytes(),ftree->GetZipBytes()));
2409 AliSysInfo::AddStamp(Form("ESDFill_%d",iEvent), 0,0,iEvent);
2411 if (fWriteESDfriend) {
2413 AliSysInfo::AddStamp(Form("WriteFriend_%d",iEvent), 0,0,iEvent);
2417 // Auto-save the ESD tree in case of prompt reco @P2
2418 if (fRawReader && fRawReader->UseAutoSaveESD()) {
2419 ftree->AutoSave("SaveSelf");
2420 if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
2424 nbf = fhlttree->Fill();
2425 if (fTreeBuffSize>0 && fhlttree->GetAutoFlush()<0 && (fMemCountESDHLT += nbf)>fTreeBuffSize ) { // default limit is still not reached
2426 nbf = fhlttree->GetZipBytes();
2427 if (nbf>0) nbf = -nbf;
2428 else nbf = fhlttree->GetEntries();
2429 fhlttree->SetAutoFlush(nbf);
2430 AliInfo(Form("Calling fhlttree->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
2431 nbf,fMemCountESDHLT,fhlttree->GetTotBytes(),fhlttree->GetZipBytes()));
2438 void AliReconstruction::CleanProcessedEvent()
2443 if (fWriteESDfriend) {
2444 fesdf->~AliESDfriend();
2445 new (fesdf) AliESDfriend(); // Reset...
2448 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2449 if (fReconstructor[iDet]) fReconstructor[iDet]->FinishEvent();
2452 AliInfo("======================= End Event ===================");
2455 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2456 if (fReconstructor[iDet]) {
2457 fReconstructor[iDet]->SetRecoParam(NULL);
2458 fReconstructor[iDet]->SetEventInfo(NULL);
2460 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
2463 if (fRunQA || fRunGlobalQA)
2464 AliQAManager::QAManager()->Increment() ;
2466 DeleteRecPoints(fDeleteRecPoints);
2467 DeleteDigits(fDeleteDigits);
2472 //_____________________________________________________________________________
2473 void AliReconstruction::SlaveTerminate()
2475 // Finalize the run on the slave side
2476 // Called after the exit
2477 // from the event loop
2478 AliCodeTimerAuto("",0);
2479 // If analysis was done during reconstruction, we need to call SlaveTerminate for it
2481 fAnalysis->PackOutput(fOutput);
2482 fAnalysis->SetSkipTerminate(kTRUE);
2483 fAnalysis->Terminate();
2486 if (fIsNewRunLoader) { // galice.root didn't exist
2487 fRunLoader->WriteHeader("OVERWRITE");
2488 fRunLoader->WriteTrigger("OVERWRITE");
2489 fRunLoader->CdGAFile();
2490 fRunLoader->Write(0, TObject::kOverwrite);
2493 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
2494 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
2496 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
2497 cdbMapCopy->SetOwner(1);
2498 cdbMapCopy->SetName("cdbMap");
2499 TIter iter(cdbMap->GetTable());
2502 while((pair = dynamic_cast<TPair*> (iter.Next()))){
2503 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
2504 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
2505 if (keyStr && valStr)
2506 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
2509 TList *cdbListCopy = new TList();
2510 cdbListCopy->SetOwner(1);
2511 cdbListCopy->SetName("cdbList");
2513 TIter iter2(cdbList);
2516 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
2517 cdbListCopy->Add(new TObjString(id->ToString().Data()));
2520 ftree->GetUserInfo()->Add(cdbMapCopy);
2521 ftree->GetUserInfo()->Add(cdbListCopy);
2523 // Add the AliRoot version that created this file
2524 TString sVersion("aliroot ");
2525 sVersion += ALIROOT_BRANCH;
2527 sVersion += ALIROOT_REVISION;
2528 sVersion += "; root ";
2529 #ifdef ROOT_SVN_BRANCH
2530 sVersion += ROOT_SVN_BRANCH;
2531 #elif defined(ROOT_GIT_BRANCH)
2532 sVersion += ROOT_GIT_BRANCH;
2537 #ifdef ROOT_SVN_REVSION
2538 sVersion += ROOT_SVN_REVISION;
2539 #elif defined(ROOT_GIT_COMMIT)
2540 sVersion += ROOT_GIT_COMMIT;
2544 sVersion += "; metadata ";
2545 sVersion += getenv("PRODUCTION_METADATA");
2548 TNamed * alirootVersion = new TNamed("alirootVersion",sVersion.Data());
2549 ftree->GetUserInfo()->Add(alirootVersion); // The list becomes owner of alirootVersion
2553 // we want to have only one tree version number
2554 ftree->Write(ftree->GetName(),TObject::kOverwrite);
2555 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
2557 if (fWriteESDfriend) {
2559 ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
2562 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
2563 if (fRunPlaneEff && !FinishPlaneEff()) {
2564 AliWarning("Finish PlaneEff evaluation failed");
2567 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2568 if (fReconstructor[iDet]) fReconstructor[iDet]->Terminate();
2570 // End of cycle for the in-loop
2572 if (fRunQA || fRunGlobalQA) {
2573 AliQAManager::QAManager()->EndOfCycle() ;
2575 !fProofOutputLocation.IsNull() &&
2576 fProofOutputArchive.IsNull() &&
2577 !fProofOutputDataset) {
2578 TString qaOutputFile(Form("%sMerged.%s.Data.root",
2579 fProofOutputLocation.Data(),
2580 AliQAv1::GetQADataFileName()));
2581 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
2582 AliQAv1::GetQADataFileName()));
2583 qaProofFile->SetOutputFileName(qaOutputFile.Data());
2584 if (AliDebugLevel() > 0) qaProofFile->Dump();
2585 fOutput->Add(qaProofFile);
2586 MergeQA(qaProofFile->GetFileName());
2597 if (!fProofOutputFileName.IsNull() &&
2598 !fProofOutputLocation.IsNull() &&
2599 fProofOutputDataset &&
2600 !fProofOutputArchive.IsNull()) {
2601 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2603 fProofOutputLocation.Data());
2604 if (AliDebugLevel() > 0) zipProofFile->Dump();
2605 fOutput->Add(zipProofFile);
2606 TString fileList(fProofOutputArchive.Data());
2607 fileList.ReplaceAll(","," ");
2609 #if ROOT_SVN_REVISION >= 30174
2610 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(kTRUE),zipProofFile->GetFileName(),fileList.Data());
2612 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(),zipProofFile->GetFileName(),fileList.Data());
2614 AliInfo(Form("Executing: %s",command.Data()));
2615 gSystem->Exec(command.Data());
2620 //_____________________________________________________________________________
2621 void AliReconstruction::Terminate()
2623 // Create tags for the events in the ESD tree (the ESD tree is always present)
2624 // In case of empty events the tags will contain dummy values
2625 AliCodeTimerAuto("",0);
2627 // Do not call the ESD tag creator in case of PROOF-based reconstruction
2629 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2630 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
2631 delete esdtagCreator;
2634 // Cleanup of CDB manager: cache and active storages!
2635 AliCDBManager::Instance()->ClearCache();
2638 //_____________________________________________________________________________
2639 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2641 // run the local reconstruction
2643 static Int_t eventNr=0;
2644 AliCodeTimerAuto("",0)
2646 TString detStr = detectors;
2647 // execute HLT reconstruction first since other detector reconstruction
2648 // might depend on HLT data
2649 // key 'HLT' is removed from detStr by IsSelected
2650 if (IsSelected("HLT", detStr)) {
2651 AliReconstructor* reconstructor = GetReconstructor(kNDetectors-1);
2652 if (reconstructor) {
2653 // there is no AliLoader for HLT, see
2654 // https://savannah.cern.ch/bugs/?35473
2655 AliInfo("running reconstruction for HLT");
2657 AliInfo("reconstructor->Reconstruct(fRawReader, NULL)");
2658 reconstructor->Reconstruct(fRawReader, NULL);
2661 AliInfo("reconstructor->Reconstruct(dummy, NULL)");
2663 reconstructor->Reconstruct(dummy, NULL);
2666 AliSysInfo::AddStamp(Form("LRecHLT_%d",eventNr), -1,1,eventNr);
2669 AliInfo(Form("kNDetectors = %d",kNDetectors));
2671 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2672 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2673 AliDebug(1, Form("Detector: %s", fgkDetectorName[iDet]));
2674 AliReconstructor* reconstructor = GetReconstructor(iDet);
2675 if (!reconstructor) continue;
2676 AliLoader* loader = fLoader[iDet];
2678 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2681 // conversion of digits
2682 if (fRawReader && reconstructor->HasDigitConversion()) {
2683 AliInfo(Form("converting raw data digits into root objects for %s",
2684 fgkDetectorName[iDet]));
2685 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
2686 // fgkDetectorName[iDet]),0);
2687 loader->LoadDigits("update");
2688 loader->CleanDigits();
2689 loader->MakeDigitsContainer();
2690 TTree* digitsTree = loader->TreeD();
2691 reconstructor->ConvertDigits(fRawReader, digitsTree);
2692 loader->WriteDigits("OVERWRITE");
2693 loader->UnloadDigits();
2695 // local reconstruction
2696 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
2697 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]),0);
2698 AliDebug(1, "Loading Rec Points");
2699 loader->LoadRecPoints("update");
2700 AliDebug(1, "Cleaning Rec Points");
2701 loader->CleanRecPoints();
2702 AliDebug(1, "Making Rec Points Container");
2703 loader->MakeRecPointsContainer();
2704 TTree* clustersTree = loader->TreeR();
2705 if (fRawReader && !reconstructor->HasDigitConversion()) {
2706 reconstructor->Reconstruct(fRawReader, clustersTree);
2709 AliDebug(1, "Loading Digits");
2710 loader->LoadDigits("read");
2711 TTree* digitsTree = loader->TreeD();
2712 AliDebug(1, Form("Digits Tree = %p",digitsTree));
2714 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
2719 AliDebug(1, "Digits -> Clusters");
2720 reconstructor->Reconstruct(digitsTree, clustersTree);
2721 if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
2722 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2723 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
2726 loader->UnloadDigits();
2728 if (fRunQA && IsInTasks(AliQAv1::kRECPOINTS)) {
2729 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2730 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
2732 loader->WriteRecPoints("OVERWRITE");
2733 loader->UnloadRecPoints();
2734 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2736 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
2737 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2738 AliError(Form("the following detectors were not found: %s",
2746 //_____________________________________________________________________________
2747 Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2749 // run the SPD trackleting (for SPD efficiency purpouses)
2751 AliCodeTimerAuto("",0)
2753 Double_t vtxPos[3] = {0, 0, 0};
2754 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2760 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2761 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2762 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2765 const AliESDVertex *vertex = esd->GetVertex();
2767 AliWarning("Vertex not found");
2770 vertex->GetXYZ(vtxPos);
2771 vertex->GetSigmaXYZ(vtxErr);
2772 if (fSPDTrackleter) {
2773 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2776 fLoader[0]->LoadRecPoints("read");
2777 TTree* tree = fLoader[0]->TreeR();
2779 AliError("Can't get the ITS cluster tree");
2782 fSPDTrackleter->LoadClusters(tree);
2783 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2785 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
2786 AliWarning("AliITSTrackleterSPDEff Clusters2Tracks failed");
2787 // fLoader[0]->UnloadRecPoints();
2790 //fSPDTrackleter->UnloadRecPoints();
2792 AliWarning("SPDTrackleter not available");
2798 //_____________________________________________________________________________
2799 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
2801 // run the barrel tracking
2803 AliCodeTimerAuto("",0)
2805 AliVertexer *vertexer = CreateVertexer();
2806 if (!vertexer) return kFALSE;
2808 AliInfo(Form("running the ITS vertex finder: %s",vertexer->ClassName()));
2809 AliESDVertex* vertex = NULL;
2811 fLoader[0]->LoadRecPoints();
2812 TTree* cltree = fLoader[0]->TreeR();
2814 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2815 vertex = vertexer->FindVertexForCurrentEvent(cltree);
2818 AliError("Can't get the ITS cluster tree");
2820 fLoader[0]->UnloadRecPoints();
2823 AliError("Can't get the ITS loader");
2826 AliWarning("Vertex not found");
2827 vertex = new AliESDVertex();
2828 vertex->SetName("default");
2831 vertex->SetName("reconstructed");
2836 vertex->GetXYZ(vtxPos);
2837 vertex->GetSigmaXYZ(vtxErr);
2839 esd->SetPrimaryVertexSPD(vertex);
2840 AliESDVertex *vpileup = NULL;
2841 Int_t novertices = 0;
2842 vpileup = vertexer->GetAllVertices(novertices);
2844 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2847 // if SPD multiplicity has been determined, it is stored in the ESD
2848 AliMultiplicity *mult = vertexer->GetMultiplicity();
2849 if(mult)esd->SetMultiplicity(mult);
2851 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2852 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2861 //_____________________________________________________________________________
2862 Bool_t AliReconstruction::RunMultFinder(AliESDEvent*& esd)
2864 // run the trackleter for multiplicity study
2866 AliCodeTimerAuto("",0)
2868 AliTrackleter *trackleter = CreateMultFinder();
2869 if (!trackleter) return kFALSE;
2871 AliInfo(Form("running the ITS multiplicity finder: %s",trackleter->ClassName()));
2874 fLoader[0]->LoadRecPoints();
2875 TTree* cltree = fLoader[0]->TreeR();
2877 trackleter->Reconstruct(esd,cltree);
2878 AliMultiplicity *mult = trackleter->GetMultiplicity();
2879 if(mult) esd->SetMultiplicity(mult);
2882 AliError("Can't get the ITS cluster tree");
2884 fLoader[0]->UnloadRecPoints();
2887 AliError("Can't get the ITS loader");
2895 //_____________________________________________________________________________
2896 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2898 // run the muon spectrometer tracking
2900 AliCodeTimerAuto("",0)
2903 AliError("Missing runLoader!");
2906 Int_t iDet = GetDetIndex("MUON"); // for MUON
2908 // Get a pointer to the MUON reconstructor
2909 AliReconstructor *reconstructor = GetReconstructor(iDet);
2910 if (!reconstructor) return kFALSE;
2913 TString detName = fgkDetectorName[iDet];
2914 AliDebug(1, Form("%s tracking", detName.Data()));
2915 AliTracker *tracker = reconstructor->CreateTracker();
2917 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2922 fLoader[iDet]->LoadRecPoints("read");
2924 tracker->LoadClusters(fLoader[iDet]->TreeR());
2926 Int_t rv = tracker->Clusters2Tracks(esd);
2928 fLoader[iDet]->UnloadRecPoints();
2930 tracker->UnloadClusters();
2934 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2942 //_____________________________________________________________________________
2943 Bool_t AliReconstruction::RunMFTTrackingMU(AliESDEvent*& esd) {
2947 // run the global muon tracking: matching the MUON tracks with the MFT clusters
2949 AliCodeTimerAuto("",0)
2952 AliError("Missing runLoader!");
2955 Int_t iDet = GetDetIndex("MFT"); // for MFT
2957 // Get a pointer to the MFT reconstructor
2958 AliReconstructor *reconstructor = GetReconstructor(iDet);
2959 if (!reconstructor) return kFALSE;
2961 TString detName = fgkDetectorName[iDet];
2962 AliDebug(1, Form("%s tracking for muon tracks", detName.Data()));
2963 AliTracker *tracker = reconstructor->CreateTracker();
2965 AliWarning(Form("couldn't create a Muon tracker for %s", detName.Data()));
2970 fLoader[iDet]->LoadRecPoints("read");
2972 tracker->LoadClusters(fLoader[iDet]->TreeR());
2974 Int_t rv = tracker->Clusters2Tracks(esd);
2976 fLoader[iDet]->UnloadRecPoints();
2978 tracker->UnloadClusters();
2981 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2989 //_____________________________________________________________________________
2990 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
2992 // run the barrel tracking
2993 static Int_t eventNr=0;
2994 AliCodeTimerAuto("",0)
2996 AliInfo("running tracking");
2998 // Set the event info which is used
2999 // by the trackers in order to obtain
3000 // information about read-out detectors,
3002 AliDebug(1, "Setting event info");
3003 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3004 if (!fTracker[iDet]) continue;
3005 fTracker[iDet]->SetEventInfo(&fEventInfo);
3008 //Fill the ESD with the T0 info (will be used by the TOF)
3009 if (fReconstructor[11] && fLoader[11]) {
3010 fLoader[11]->LoadRecPoints("READ");
3011 TTree *treeR = fLoader[11]->TreeR();
3013 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
3017 // pass 1: TPC + ITS inwards
3018 for (Int_t iDet = 1; iDet >= 0; iDet--) {
3019 if (!fTracker[iDet]) continue;
3020 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
3023 fLoader[iDet]->LoadRecPoints("read");
3024 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
3025 TTree* tree = fLoader[iDet]->TreeR();
3027 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
3030 fTracker[iDet]->LoadClusters(tree);
3031 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
3033 if (fTracker[iDet]->Clusters2TracksHLT(esd, fhltesd) != 0) {
3034 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
3037 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
3038 // preliminary PID in TPC needed by the ITS tracker
3040 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
3041 PID.MakePIDForTracking(esd);
3042 AliSysInfo::AddStamp(Form("MakePID0%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
3046 // pass 2: ALL backwards
3048 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3049 if (!fTracker[iDet]) continue;
3050 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
3053 if (iDet > 1) { // all except ITS, TPC
3055 fLoader[iDet]->LoadRecPoints("read");
3056 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
3057 tree = fLoader[iDet]->TreeR();
3059 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
3062 fTracker[iDet]->LoadClusters(tree);
3063 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
3067 if (iDet>1) // start filling residuals for the "outer" detectors
3069 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
3070 TObjArray ** arr = AliTracker::GetResidualsArray() ;
3072 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3073 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3074 if ( elem && (! elem->At(0)) ) {
3075 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3076 if (qadm) qadm->InitRecPointsForTracker() ;
3079 // AliSysInfo::AddStamp(Form("QAInitResid%s_%d",fgkDetectorName[iDet],eventNr), iDet,0, eventNr);
3081 if (fTracker[iDet]->PropagateBack(esd) != 0) {
3082 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
3085 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3088 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
3089 fTracker[iDet]->UnloadClusters();
3090 fLoader[iDet]->UnloadRecPoints();
3092 // updated PID in TPC needed by the ITS tracker -MI
3094 //GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
3095 //AliESDpid::MakePID(esd);
3096 PID.MakePIDForTracking(esd);
3097 AliSysInfo::AddStamp(Form("MakePID1%s_%d",fgkDetectorName[iDet],eventNr), iDet,4,eventNr);
3101 //stop filling residuals for the "outer" detectors
3102 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3104 // pass 3: TRD + TPC + ITS refit inwards
3106 for (Int_t iDet = 2; iDet >= 0; iDet--) {
3107 if (!fTracker[iDet]) continue;
3108 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
3111 if (iDet<2) // start filling residuals for TPC and ITS
3113 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
3114 TObjArray ** arr = AliTracker::GetResidualsArray() ;
3116 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
3117 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
3118 if ( elem && (! elem->At(0)) ) {
3119 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
3120 if (qadm) qadm->InitRecPointsForTracker() ;
3125 if (fTracker[iDet]->RefitInward(esd) != 0) {
3126 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
3129 // run postprocessing
3130 if (fTracker[iDet]->PostProcess(esd) != 0) {
3131 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
3134 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
3137 // write space-points to the ESD in case alignment data output
3139 if (fWriteAlignmentData) {
3140 WriteAlignmentData(esd);
3141 AliSysInfo::AddStamp(Form("WrtAlignData_%d",eventNr), 0,0, eventNr);
3144 for (Int_t iDet = 3; iDet >= 0; iDet--) {
3145 if (!fTracker[iDet]) continue;
3147 fTracker[iDet]->UnloadClusters();
3148 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
3149 fLoader[iDet]->UnloadRecPoints();
3150 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
3152 // stop filling residuals for TPC and ITS
3153 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
3159 //_____________________________________________________________________________
3160 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
3162 // Remove the data which are not needed for the physics analysis.
3165 Int_t nTracks=esd->GetNumberOfTracks();
3166 Int_t nV0s=esd->GetNumberOfV0s();
3168 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
3170 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
3171 Bool_t rc=esd->Clean(cleanPars);
3173 nTracks=esd->GetNumberOfTracks();
3174 nV0s=esd->GetNumberOfV0s();
3176 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
3181 //_____________________________________________________________________________
3182 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
3184 // fill the event summary data
3186 AliCodeTimerAuto("",0)
3187 static Int_t eventNr=0;
3188 TString detStr = detectors;
3190 AliSysInfo::AddStamp(Form("FillESDb%d",eventNr), -19,-19, eventNr);
3191 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3192 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3193 AliReconstructor* reconstructor = GetReconstructor(iDet);
3194 if (!reconstructor) continue;
3195 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
3196 TTree* clustersTree = NULL;
3197 if (fLoader[iDet]) {
3198 fLoader[iDet]->LoadRecPoints("read");
3199 clustersTree = fLoader[iDet]->TreeR();
3200 if (!clustersTree) {
3201 AliError(Form("Can't get the %s clusters tree",
3202 fgkDetectorName[iDet]));
3203 if (fStopOnError) return kFALSE;
3206 if (fRawReader && !reconstructor->HasDigitConversion()) {
3207 reconstructor->FillESD(fRawReader, clustersTree, esd);
3209 TTree* digitsTree = NULL;
3210 if (fLoader[iDet]) {
3211 fLoader[iDet]->LoadDigits("read");
3212 digitsTree = fLoader[iDet]->TreeD();
3214 AliError(Form("Can't get the %s digits tree",
3215 fgkDetectorName[iDet]));
3216 if (fStopOnError) return kFALSE;
3219 reconstructor->FillESD(digitsTree, clustersTree, esd);
3220 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
3222 if (fLoader[iDet]) {
3223 fLoader[iDet]->UnloadRecPoints();
3227 if (!IsSelected("CTP", detStr)) AliDebug(10,"No CTP");
3228 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
3229 AliError(Form("the following detectors were not found: %s",
3231 if (fStopOnError) return kFALSE;
3233 AliSysInfo::AddStamp(Form("FillESDe%d",eventNr), -20,-20, eventNr);
3238 //_____________________________________________________________________________
3239 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
3241 // Reads the trigger decision which is
3242 // stored in Trigger.root file and fills
3243 // the corresponding esd entries
3245 AliCodeTimerAuto("",0)
3247 AliInfo("Filling trigger information into the ESD");
3250 AliCTPRawStream input(fRawReader);
3251 if (!input.Next()) {
3252 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
3255 if (esd->GetTriggerMask() != input.GetClassMask())
3256 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
3257 input.GetClassMask(),esd->GetTriggerMask()));
3258 if (esd->GetOrbitNumber() != input.GetOrbitID())
3259 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
3260 input.GetOrbitID(),esd->GetOrbitNumber()));
3261 if (esd->GetBunchCrossNumber() != input.GetBCID())
3262 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
3263 input.GetBCID(),esd->GetBunchCrossNumber()));
3264 AliESDHeader* esdheader = esd->GetHeader();
3265 esdheader->SetL0TriggerInputs(input.GetL0Inputs());
3266 esdheader->SetL1TriggerInputs(input.GetL1Inputs());
3267 esdheader->SetL2TriggerInputs(input.GetL2Inputs());
3269 // UInt_t orbit=input.GetOrbitID();
3270 for(Int_t i=0 ; i<input.GetNIRs() ; i++ ) {
3271 esdheader->AddTriggerIR(input.GetIR(i));
3273 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
3275 rlCTP->SetL0TriggerInputs(input.GetL0Inputs());
3276 rlCTP->SetL1TriggerInputs(input.GetL1Inputs());
3277 rlCTP->SetL2TriggerInputs(input.GetL2Inputs());
3280 if (fIsNewRunLoader) fRunLoader->TreeCT()->Fill();
3284 //_____________________________________________________________________________
3285 Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
3288 //fRunScalers->Print();
3289 if(fRunScalers && fRunScalers->CheckRunScalers()){
3290 AliTimeStamp* timestamp = new AliTimeStamp(esd->GetOrbitNumber(), esd->GetPeriodNumber(), esd->GetBunchCrossNumber());
3291 //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
3292 AliESDHeader* esdheader = fesd->GetHeader();
3293 for(Int_t i=0;i<50;i++){
3294 if((1ull<<i) & esd->GetTriggerMask()){
3295 AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
3296 if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
3299 const AliTriggerScalersRecordESD* scalrecEvent = fRunScalers->GetScalersDeltaForEvent( timestamp);
3300 const AliTriggerScalersRecordESD* scalrecRun = fRunScalers->GetScalersDeltaForRun();
3301 if (scalrecEvent) esdheader->SetTriggerScalersDeltaEvent(scalrecEvent);
3302 if (scalrecRun) esdheader->SetTriggerScalersDeltaRun(scalrecRun);
3306 //_____________________________________________________________________________
3307 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
3310 // Filling information from RawReader Header
3313 if (!fRawReader) return kFALSE;
3315 AliInfo("Filling information from RawReader Header");
3317 esd->SetBunchCrossNumber(fRawReader->GetBCID());
3318 esd->SetOrbitNumber(fRawReader->GetOrbitID());
3319 esd->SetPeriodNumber(fRawReader->GetPeriod());
3321 esd->SetTimeStamp(fRawReader->GetTimestamp());
3322 esd->SetEventType(fRawReader->GetType());
3328 //_____________________________________________________________________________
3329 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
3331 // check whether detName is contained in detectors
3332 // if yes, it is removed from detectors
3334 // check if all detectors are selected
3335 if ((detectors.CompareTo("ALL") == 0) ||
3336 detectors.BeginsWith("ALL ") ||
3337 detectors.EndsWith(" ALL") ||
3338 detectors.Contains(" ALL ")) {
3343 // search for the given detector
3344 Bool_t result = kFALSE;
3345 if ((detectors.CompareTo(detName) == 0) ||
3346 detectors.BeginsWith(detName+" ") ||
3347 detectors.EndsWith(" "+detName) ||
3348 detectors.Contains(" "+detName+" ")) {
3349 detectors.ReplaceAll(detName, "");
3353 // clean up the detectors string
3354 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
3355 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
3356 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
3361 //_____________________________________________________________________________
3362 Bool_t AliReconstruction::InitRunLoader()
3364 // get or create the run loader
3366 if (gAlice) delete gAlice;
3369 TFile *gafile = TFile::Open(fGAliceFileName.Data());
3370 // if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
3371 if (gafile) { // galice.root exists
3375 // load all base libraries to get the loader classes
3376 TString libs = gSystem->GetLibraries();
3377 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3378 TString detName = fgkDetectorName[iDet];
3379 if (libs.Contains("lib" + detName + "base.so")) continue;
3380 gSystem->Load("lib" + detName + "base.so");
3382 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
3384 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
3389 fRunLoader->CdGAFile();
3390 fRunLoader->LoadgAlice();
3392 //PH This is a temporary fix to give access to the kinematics
3393 //PH that is needed for the labels of ITS clusters
3394 fRunLoader->LoadHeader();
3395 fRunLoader->LoadKinematics();
3397 } else { // galice.root does not exist
3399 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
3401 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
3402 AliConfig::GetDefaultEventFolderName(),
3405 AliError(Form("could not create run loader in file %s",
3406 fGAliceFileName.Data()));
3410 fIsNewRunLoader = kTRUE;
3411 fRunLoader->MakeTree("E");
3412 fRunLoader->MakeTree("GG");
3414 if (fNumberOfEventsPerFile > 0)
3415 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
3417 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
3423 //_____________________________________________________________________________
3424 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
3426 // get the reconstructor object and the loader for a detector
3428 if (fReconstructor[iDet]) {
3429 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3430 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3431 fReconstructor[iDet]->SetRecoParam(par);
3432 fReconstructor[iDet]->SetRunInfo(fRunInfo);
3434 return fReconstructor[iDet];
3437 // load the reconstructor object
3438 TPluginManager* pluginManager = gROOT->GetPluginManager();
3439 TString detName = fgkDetectorName[iDet];
3440 TString recName = "Ali" + detName + "Reconstructor";
3442 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
3444 AliReconstructor* reconstructor = NULL;
3445 // first check if a plugin is defined for the reconstructor
3446 TPluginHandler* pluginHandler =
3447 pluginManager->FindHandler("AliReconstructor", detName);
3448 // if not, add a plugin for it
3449 if (!pluginHandler) {
3450 AliDebug(1, Form("defining plugin for %s", recName.Data()));
3451 TString libs = gSystem->GetLibraries();
3452 if (libs.Contains("lib" + detName + "base.so") ||
3453 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
3454 pluginManager->AddHandler("AliReconstructor", detName,
3455 recName, detName + "rec", recName + "()");
3457 pluginManager->AddHandler("AliReconstructor", detName,
3458 recName, detName, recName + "()");
3460 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
3462 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3463 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
3466 // check if the upgrade reconstructor should be used instead of the standard one
3467 if(fUpgradeMask[iDet]) {
3468 if(reconstructor) delete reconstructor;
3469 TClass *cl = new TClass(Form("Ali%sUpgradeReconstructor",fgkDetectorName[iDet]));
3470 reconstructor = (AliReconstructor*)(cl->New());
3473 if (reconstructor) {
3474 TObject* obj = fOptions.FindObject(detName.Data());
3475 if (obj) reconstructor->SetOption(obj->GetTitle());
3476 reconstructor->SetRunInfo(fRunInfo);
3477 reconstructor->SetHLTESD(fhltesd);
3478 reconstructor->Init();
3479 fReconstructor[iDet] = reconstructor;
3482 // get or create the loader
3483 if (detName != "HLT") {
3484 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
3485 if (!fLoader[iDet]) {
3486 AliConfig::Instance()
3487 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
3489 // first check if a plugin is defined for the loader
3491 pluginManager->FindHandler("AliLoader", detName);
3492 // if not, add a plugin for it
3493 if (!pluginHandler) {
3494 TString loaderName = "Ali" + detName + "Loader";
3495 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
3496 pluginManager->AddHandler("AliLoader", detName,
3497 loaderName, detName + "base",
3498 loaderName + "(const char*, TFolder*)");
3499 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
3501 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
3503 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
3504 fRunLoader->GetEventFolder());
3506 if (!fLoader[iDet]) { // use default loader
3507 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
3509 if (!fLoader[iDet]) {
3510 AliWarning(Form("couldn't get loader for %s", detName.Data()));
3511 if (fStopOnError) return NULL;
3513 fRunLoader->AddLoader(fLoader[iDet]);
3514 fRunLoader->CdGAFile();
3515 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
3516 fRunLoader->Write(0, TObject::kOverwrite);
3521 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
3522 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
3523 if (reconstructor) {
3524 reconstructor->SetRecoParam(par);
3525 reconstructor->SetRunInfo(fRunInfo);
3528 return reconstructor;
3531 //_____________________________________________________________________________
3532 AliVertexer* AliReconstruction::CreateVertexer()
3534 // create the vertexer
3535 // Please note that the caller is the owner of the
3538 AliVertexer* vertexer = NULL;
3539 AliReconstructor* itsReconstructor = GetReconstructor(0);
3540 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3541 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3542 vertexer = itsReconstructor->CreateVertexer();
3545 AliWarning("couldn't create a vertexer for ITS");
3551 //_____________________________________________________________________________
3552 AliTrackleter* AliReconstruction::CreateMultFinder()
3554 // create the ITS trackleter for mult. estimation
3555 // Please note that the caller is the owner of the
3558 AliTrackleter* trackleter = NULL;
3559 AliReconstructor* itsReconstructor = GetReconstructor(0);
3560 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) ||
3561 fRunTracking.Contains("ITS") || fFillESD.Contains("ITS") )) {
3562 trackleter = itsReconstructor->CreateMultFinder();
3565 AliWarning("ITS is not in reconstruction, switching off RunMultFinder");
3566 fRunMultFinder = kFALSE;
3572 //_____________________________________________________________________________
3573 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
3575 // create the trackers
3576 AliInfo("Creating trackers");
3578 TString detStr = detectors;
3579 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3580 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3581 AliReconstructor* reconstructor = GetReconstructor(iDet);
3582 if (!reconstructor) continue;
3583 TString detName = fgkDetectorName[iDet];
3584 if (detName == "MUON") {
3585 fRunMuonTracking = kTRUE;
3588 if (detName == "MFT") { // AU
3589 fRunMFTTrackingMU = kTRUE; // AU
3593 fTracker[iDet] = reconstructor->CreateTracker();
3594 if (!fTracker[iDet] && (iDet < 7)) {
3595 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
3596 if (fStopOnError) return kFALSE;
3598 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
3604 //_____________________________________________________________________________
3605 void AliReconstruction::CleanUp()
3607 // delete trackers and the run loader and close and delete the file
3608 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3609 delete fReconstructor[iDet];
3610 fReconstructor[iDet] = NULL;
3611 fLoader[iDet] = NULL;
3612 delete fTracker[iDet];
3613 fTracker[iDet] = NULL;
3619 delete fSPDTrackleter;
3620 fSPDTrackleter = NULL;
3629 delete fParentRawReader;
3630 fParentRawReader=NULL;
3641 if (AliQAManager::QAManager())
3642 AliQAManager::QAManager()->ShowQA() ;
3643 // AliQAManager::Destroy() ;
3648 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
3650 // Write space-points which are then used in the alignment procedures
3651 // For the moment only ITS, TPC, TRD and TOF
3653 Int_t ntracks = esd->GetNumberOfTracks();
3654 for (Int_t itrack = 0; itrack < ntracks; itrack++)
3656 AliESDtrack *track = esd->GetTrack(itrack);
3659 for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
3660 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
3661 nsp += (iDet==GetDetIndex("TRD")) ? track->GetTRDntracklets():track->GetNcls(iDet);
3663 if (iDet==GetDetIndex("ITS")) { // ITS "extra" clusters
3664 track->GetClusters(iDet,idx);
3665 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
3670 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
3671 track->SetTrackPointArray(sp);
3673 for (Int_t iDet = 5; iDet >= 0; iDet--) {
3674 AliTracker *tracker = fTracker[iDet];
3675 if (!tracker) continue;
3676 Int_t nspdet = (iDet==GetDetIndex("TRD")) ? track->GetTRDtracklets(idx):track->GetClusters(iDet,idx);
3678 if (iDet==GetDetIndex("ITS")) // ITS "extra" clusters
3679 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
3681 if (nspdet <= 0) continue;
3685 while (isp2 < nspdet) {
3686 Bool_t isvalid=kTRUE;
3688 Int_t index=idx[isp++];
3689 if (index < 0) continue;
3691 TString dets = fgkDetectorName[iDet];
3692 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
3693 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
3694 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
3695 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
3696 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
3698 isvalid = tracker->GetTrackPoint(index,p);
3701 if (!isvalid) continue;
3702 if (iDet==GetDetIndex("ITS") && (isp-1)>=6) p.SetExtra();
3703 sp->AddPoint(isptrack,&p); isptrack++;
3710 //_____________________________________________________________________________
3711 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
3713 // The method reads the raw-data error log
3714 // accumulated within the rawReader.
3715 // It extracts the raw-data errors related to
3716 // the current event and stores them into
3717 // a TClonesArray inside the esd object.
3719 if (!fRawReader) return;
3721 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
3723 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
3725 if (iEvent != log->GetEventNumber()) continue;
3727 esd->AddRawDataErrorLog(log);
3732 //_____________________________________________________________________________
3733 // void AliReconstruction::CheckQA()
3735 // check the QA of SIM for this run and remove the detectors
3736 // with status Fatal
3738 // TString newRunLocalReconstruction ;
3739 // TString newRunTracking ;
3740 // TString newFillESD ;
3742 // for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
3743 // TString detName(AliQAv1::GetDetName(iDet)) ;
3744 // AliQAv1 * qa = AliQAv1::Instance(AliQAv1::DETECTORINDEX_t(iDet)) ;
3745 // if ( qa->IsSet(AliQAv1::DETECTORINDEX_t(iDet), AliQAv1::kSIM, specie, AliQAv1::kFATAL)) {
3746 // AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
3747 // detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
3749 // if ( fRunLocalReconstruction.Contains(AliQAv1::GetDetName(iDet)) ||
3750 // fRunLocalReconstruction.Contains("ALL") ) {
3751 // newRunLocalReconstruction += detName ;
3752 // newRunLocalReconstruction += " " ;
3754 // if ( fRunTracking.Contains(AliQAv1::GetDetName(iDet)) ||
3755 // fRunTracking.Contains("ALL") ) {
3756 // newRunTracking += detName ;
3757 // newRunTracking += " " ;
3759 // if ( fFillESD.Contains(AliQAv1::GetDetName(iDet)) ||
3760 // fFillESD.Contains("ALL") ) {
3761 // newFillESD += detName ;
3762 // newFillESD += " " ;
3766 // fRunLocalReconstruction = newRunLocalReconstruction ;
3767 // fRunTracking = newRunTracking ;
3768 // fFillESD = newFillESD ;
3771 //_____________________________________________________________________________
3772 Int_t AliReconstruction::GetDetIndex(const char* detector)
3774 // return the detector index corresponding to detector
3776 for (index = 0; index < kNDetectors ; index++) {
3777 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
3782 //_____________________________________________________________________________
3783 Bool_t AliReconstruction::FinishPlaneEff() {
3785 // Here execute all the necessary operationis, at the end of the tracking phase,
3786 // in case that evaluation of PlaneEfficiencies was required for some detector.
3787 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
3789 // This Preliminary version works only FOR ITS !!!!!
3790 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3793 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3796 TString detStr = fLoadCDB;
3797 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
3798 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
3799 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3800 if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
3801 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
3802 TString name=planeeff->GetName();
3804 TFile* pefile = TFile::Open(name, "RECREATE");
3805 ret=(Bool_t)planeeff->Write();
3807 if(planeeff->GetCreateHistos()) {
3808 TString hname=planeeff->GetName();
3809 hname+="Histo.root";
3810 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
3813 if(fSPDTrackleter) {
3814 AliPlaneEff *planeeff=fSPDTrackleter->GetPlaneEff();
3815 TString name="AliITSPlaneEffSPDtracklet.root";
3816 TFile* pefile = TFile::Open(name, "RECREATE");
3817 ret=(Bool_t)planeeff->Write();
3819 AliESDEvent *dummy=NULL;
3820 ret=(Bool_t)fSPDTrackleter->PostProcess(dummy); // take care of writing other files
3825 //_____________________________________________________________________________
3826 Bool_t AliReconstruction::InitPlaneEff() {
3828 // Here execute all the necessary operations, before of the tracking phase,
3829 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
3830 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
3831 // which should be updated/recalculated.
3833 // This Preliminary version will work only FOR ITS !!!!!
3834 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3837 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3840 fSPDTrackleter = NULL;
3841 TString detStr = fLoadCDB;
3842 if (IsSelected(fgkDetectorName[0], detStr)) {
3843 AliReconstructor* itsReconstructor = GetReconstructor(0);
3844 if (itsReconstructor) {
3845 fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
3847 if (fSPDTrackleter) {
3848 AliInfo("Trackleter for SPD has been created");
3854 //_____________________________________________________________________________
3855 Bool_t AliReconstruction::InitAliEVE()
3857 // This method should be called only in case
3858 // AliReconstruction is run
3859 // within the alieve environment.
3860 // It will initialize AliEVE in a way
3861 // so that it can visualize event processed
3862 // by AliReconstruction.
3863 // The return flag shows whenever the
3864 // AliEVE initialization was successful or not.
3866 TString macroStr(getenv("ALIEVE_ONLINE_MACRO"));
3868 if (macroStr.IsNull())
3869 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
3871 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
3873 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
3875 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
3876 gROOT->ProcessLine("alieve_online_init()");
3881 //_____________________________________________________________________________
3882 void AliReconstruction::RunAliEVE()
3884 // Runs AliEVE visualisation of
3885 // the current event.
3886 // Should be executed only after
3887 // successful initialization of AliEVE.
3889 AliInfo("Running AliEVE...");
3890 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)%p,(AliRawReader*)%p,(AliESDEvent*)%p,(AliESDfriend*)%p);",fRunLoader,fRawReader,fesd,fesdf));
3894 //_____________________________________________________________________________
3895 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
3897 // Allows to run QA for a selected set of detectors
3898 // and a selected set of tasks among RAWS, DIGITSR, RECPOINTS and ESDS
3899 // all selected detectors run the same selected tasks
3901 if (!detAndAction.Contains(":")) {
3902 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
3906 Int_t colon = detAndAction.Index(":") ;
3907 fQADetectors = detAndAction(0, colon) ;
3908 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
3909 if (fQATasks.Contains("ALL") ) {
3910 fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ;
3912 fQATasks.ToUpper() ;
3914 if ( fQATasks.Contains("RAW") )
3915 tempo = Form("%d ", AliQAv1::kRAWS) ;
3916 if ( fQATasks.Contains("DIGIT") )
3917 tempo += Form("%d ", AliQAv1::kDIGITSR) ;
3918 if ( fQATasks.Contains("RECPOINT") )
3919 tempo += Form("%d ", AliQAv1::kRECPOINTS) ;
3920 if ( fQATasks.Contains("ESD") )
3921 tempo += Form("%d ", AliQAv1::kESDS) ;
3923 if (fQATasks.IsNull()) {
3924 AliInfo("No QA requested\n") ;
3929 TString tempo(fQATasks) ;
3930 tempo.ReplaceAll(Form("%d", AliQAv1::kRAWS), AliQAv1::GetTaskName(AliQAv1::kRAWS)) ;
3931 tempo.ReplaceAll(Form("%d", AliQAv1::kDIGITSR), AliQAv1::GetTaskName(AliQAv1::kDIGITSR)) ;
3932 tempo.ReplaceAll(Form("%d", AliQAv1::kRECPOINTS), AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)) ;
3933 tempo.ReplaceAll(Form("%d", AliQAv1::kESDS), AliQAv1::GetTaskName(AliQAv1::kESDS)) ;
3934 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
3939 //_____________________________________________________________________________
3940 Bool_t AliReconstruction::InitRecoParams()
3942 // The method accesses OCDB and retrieves all
3943 // the available reco-param objects from there.
3945 Bool_t isOK = kTRUE;
3947 if (fRecoParam.GetDetRecoParamArray(kNDetectors)) {
3948 AliInfo("Using custom GRP reconstruction parameters");
3951 AliInfo("Loading GRP reconstruction parameter objects");
3953 AliCDBPath path("GRP","Calib","RecoParam");
3954 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3956 AliWarning("Couldn't find GRP RecoParam entry in OCDB");
3960 TObject *recoParamObj = entry->GetObject();
3961 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3962 // GRP has a normal TobjArray of AliDetectorRecoParam objects
3963 // Registering them in AliRecoParam
3964 fRecoParam.AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
3966 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3967 // GRP has only onse set of reco parameters
3968 // Registering it in AliRecoParam
3969 AliInfo("Single set of GRP reconstruction parameters found");
3970 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3971 fRecoParam.AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3974 AliError("No valid GRP RecoParam object found in the OCDB");
3981 TString detStr = fLoadCDB;
3982 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3984 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3986 if (fRecoParam.GetDetRecoParamArray(iDet)) {
3987 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
3991 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
3993 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
3994 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3996 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
4000 TObject *recoParamObj = entry->GetObject();
4001 if (dynamic_cast<TObjArray*>(recoParamObj)) {
4002 // The detector has a normal TobjArray of AliDetectorRecoParam objects
4003 // Registering them in AliRecoParam
4004 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
4006 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
4007 // The detector has only onse set of reco parameters
4008 // Registering it in AliRecoParam
4009 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
4010 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
4011 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
4014 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
4018 // FIX ME: We have to disable the unloading of reco-param CDB
4019 // entries because QA framework is using them. Has to be fix in
4020 // a way that the QA takes the objects already constructed in
4022 // AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
4026 if (AliDebugLevel() > 0) fRecoParam.Print();
4031 //_____________________________________________________________________________
4032 Bool_t AliReconstruction::GetEventInfo()
4034 // Fill the event info object
4036 AliCodeTimerAuto("",0)
4038 AliCentralTrigger *aCTP = NULL;
4040 fEventInfo.SetEventType(fRawReader->GetType());
4042 ULong64_t mask = fRawReader->GetClassMask();
4043 fEventInfo.SetTriggerMask(mask);
4044 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
4045 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
4047 aCTP = new AliCentralTrigger();
4048 TString configstr("");
4049 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
4050 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
4054 aCTP->SetClassMask(mask);
4055 aCTP->SetClusterMask(clmask);
4058 AliCentralTrigger* rlCTP = fRunLoader->GetTrigger();
4060 rlCTP->SetClassMask(mask);
4061 rlCTP->SetClusterMask(clmask);
4066 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
4068 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
4069 aCTP = fRunLoader->GetTrigger();
4070 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
4071 // get inputs from actp - just get
4072 AliESDHeader* esdheader = fesd->GetHeader();
4073 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
4074 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
4075 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
4076 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
4079 if (fStopOnMissingTriggerFile) AliFatal("No trigger can be loaded! Stopping reconstruction!");
4080 AliWarning("No trigger can be loaded! The trigger information will not be used!");
4085 AliTriggerConfiguration *config = aCTP->GetConfiguration();
4087 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
4088 if (fRawReader) delete aCTP;
4092 // Load trigger aliases and declare the trigger classes included in aliases
4093 //PH Why do we do it in each event and not only once in the beginning of the chunk??
4094 //PH Temporary fix for #99725: AliReconstruction::GetEventInfo bug
4095 fDeclTriggerClasses.Clear();
4096 AliCDBEntry * entry = AliCDBManager::Instance()->Get("GRP/CTP/Aliases");
4098 THashList * lst = dynamic_cast<THashList*>(entry->GetObject());
4100 lst->Sort(kSortDescending); // to avoid problems with substrungs
4101 if (fRawReader) fRawReader->LoadTriggerAlias(lst);
4102 // Now declare all the triggers present in the aliases
4105 while((nmd = dynamic_cast<TNamed*>(iter.Next()))){
4106 fDeclTriggerClasses += " ";
4107 fDeclTriggerClasses += nmd->GetName();
4111 AliError("Cannot cast the object with trigger aliases to THashList!");
4115 AliError("No OCDB ebtry for the trigger aliases!");
4117 // Load trigger classes for this run
4118 UChar_t clustmask = 0;
4120 ULong64_t trmask = fEventInfo.GetTriggerMask();
4121 const TObjArray& classesArray = config->GetClasses();
4122 Int_t nclasses = classesArray.GetEntriesFast();
4123 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
4124 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
4125 if (trclass && trclass->GetMask()>0) {
4126 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
4127 if (fesd) fesd->SetTriggerClass(trclass->GetName(),trindex);
4128 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
4129 if (trmask & (1ull << trindex)) {
4131 trclasses += trclass->GetName();
4133 clustmask |= trclass->GetCluster()->GetClusterMask();
4137 fEventInfo.SetTriggerClasses(trclasses);
4138 // Now put the declared trigger classes (not present in the run)
4139 // to 0/false in the event selection
4140 if (!fDeclTriggerClasses.IsNull()) {
4141 TObjArray *tokens = fDeclTriggerClasses.Tokenize(" ");
4142 Int_t ntokens = tokens->GetEntriesFast();
4143 for (Int_t itoken = 0; itoken < ntokens; ++itoken) {
4144 if (fRawReader) fRawReader->LoadTriggerClass((((TObjString*)tokens->At(itoken))->String()).Data(),-1);
4149 // Write names of active trigger inputs in ESD Header
4150 const TObjArray& inputsArray = config->GetInputs();
4151 Int_t ninputs = inputsArray.GetEntriesFast();
4152 for( Int_t iinput=0; iinput < ninputs; iinput++ ) {
4153 AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
4154 if (trginput && trginput->GetMask()>0) {
4155 Int_t inputIndex = (Int_t)TMath::Nint(TMath::Log2(trginput->GetMask()));
4156 AliESDHeader* headeresd = 0x0;
4157 if (fesd) headeresd = fesd->GetHeader();
4159 Int_t trglevel = (Int_t)trginput->GetLevel();
4160 if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
4161 if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
4162 if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
4167 // Set the information in ESD
4169 fesd->SetTriggerMask(trmask);
4170 fesd->SetTriggerCluster(clustmask);
4173 if (!aCTP->CheckTriggeredDetectors()) {
4174 if (fRawReader) delete aCTP;
4178 if (fRawReader) delete aCTP;
4180 // We have to fill also the HLT decision here!!
4186 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
4188 // Match the detector list found in the rec.C or the default 'ALL'
4189 // to the list found in the GRP (stored there by the shuttle PP which
4190 // gets the information from ECS)
4191 static TString resultList;
4192 TString detList = detectorList;
4196 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
4197 if ((detectorMask >> iDet) & 0x1) {
4198 TString det = AliDAQ::OfflineModuleName(iDet);
4199 if ((detList.CompareTo("ALL") == 0) ||
4200 ((detList.BeginsWith("ALL ") ||
4201 detList.EndsWith(" ALL") ||
4202 detList.Contains(" ALL ")) &&
4203 !(detList.BeginsWith("-"+det+" ") ||
4204 detList.EndsWith(" -"+det) ||
4205 detList.Contains(" -"+det+" "))) ||
4206 (detList.CompareTo(det) == 0) ||
4207 detList.BeginsWith(det+" ") ||
4208 detList.EndsWith(" "+det) ||
4209 detList.Contains( " "+det+" " )) {
4210 if (!resultList.EndsWith(det + " ")) {
4219 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
4220 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
4221 if ((detList.CompareTo("ALL") == 0) ||
4222 ((detList.BeginsWith("ALL ") ||
4223 detList.EndsWith(" ALL") ||
4224 detList.Contains(" ALL ")) &&
4225 !(detList.BeginsWith("-"+hltDet+" ") ||
4226 detList.EndsWith(" -"+hltDet) ||
4227 detList.Contains(" -"+hltDet+" "))) ||
4228 (detList.CompareTo(hltDet) == 0) ||
4229 detList.BeginsWith(hltDet+" ") ||
4230 detList.EndsWith(" "+hltDet) ||
4231 detList.Contains( " "+hltDet+" " )) {
4232 resultList += hltDet;
4236 return resultList.Data();
4240 //______________________________________________________________________________
4241 void AliReconstruction::Abort(const char *method, EAbort what)
4243 // Abort processing. If what = kAbortProcess, the Process() loop will be
4244 // aborted. If what = kAbortFile, the current file in a chain will be
4245 // aborted and the processing will continue with the next file, if there
4246 // is no next file then Process() will be aborted. Abort() can also be
4247 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
4248 // the SlaveTerminate() and Terminate() are always called. The abort flag
4249 // can be checked in these methods using GetAbort().
4251 // The method is overwritten in AliReconstruction for better handling of
4252 // reco specific errors
4254 if (!fStopOnError) return;
4258 TString whyMess = method;
4259 whyMess += " failed! Aborting...";
4261 AliError(whyMess.Data());
4264 TString mess = "Abort";
4265 if (fAbort == kAbortProcess)
4266 mess = "AbortProcess";
4267 else if (fAbort == kAbortFile)
4270 Info(mess.Data(), "%s", whyMess.Data());
4273 //______________________________________________________________________________
4274 Bool_t AliReconstruction::ProcessEvent(void* event)
4276 // Method that is used in case the event loop
4277 // is steered from outside, for example by AMORE
4278 // 'event' is a pointer to the DATE event in the memory
4280 if (fRawReader) delete fRawReader;
4281 fRawReader = new AliRawReaderDate(event);
4282 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
4289 //______________________________________________________________________________
4290 Bool_t AliReconstruction::ParseOutput()
4292 // The method parses the output file
4293 // location string in order to steer
4294 // properly the selector
4296 TPMERegexp re1("(\\w+\\.zip#\\w+\\.root):([,*\\w+\\.root,*]+)@dataset://(\\w++)");
4297 TPMERegexp re2("(\\w+\\.root)?@?dataset://(\\w++)");
4299 if (re1.Match(fESDOutput) == 4) {
4300 // root archive with output files stored and regustered
4302 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",re1[1].Data()));
4303 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re1[3].Data()));
4304 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4305 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_ARCHIVE",re1[2].Data()));
4306 AliInfo(Form("%s files will be stored within %s in dataset %s",
4311 else if (re2.Match(fESDOutput) == 3) {
4312 // output file stored and registered
4314 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",(re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data()));
4315 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re2[2].Data()));
4316 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
4317 AliInfo(Form("%s will be stored in dataset %s",
4318 (re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data(),
4322 if (fESDOutput.IsNull()) {
4323 // Output location not given.
4324 // Assuming xrootd has been already started and
4325 // the output file has to be sent back
4326 // to the client machine
4327 TString esdUrl(Form("root://%s/%s/",
4328 TUrl(gSystem->HostName()).GetHostFQDN(),
4330 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE","AliESDs.root"));
4331 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",esdUrl.Data()));
4332 AliInfo(Form("AliESDs.root will be stored in %s",
4336 // User specified an output location.
4337 // Ones has just to parse it here
4338 TUrl outputUrl(fESDOutput.Data());
4339 TString outputFile(gSystem->BaseName(outputUrl.GetFile()));
4340 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.IsNull() ? "AliESDs.root" : outputFile.Data()));
4341 TString outputLocation(outputUrl.GetUrl());
4342 outputLocation.ReplaceAll(outputFile.Data(),"");
4343 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",outputLocation.Data()));
4344 AliInfo(Form("%s will be stored in %s",
4345 outputFile.IsNull() ? "AliESDs.root" : outputFile.Data(),
4346 outputLocation.Data()));
4353 //______________________________________________________________________________
4354 Bool_t AliReconstruction::IsHighPt() const {
4355 // Selection of events containing "high" pT tracks
4356 // If at least one track is found within 1.5 and 100 GeV (pT)
4357 // that was reconstructed by both ITS and TPC, the event is accepted
4360 const Double_t pTmin = 1.5;
4361 const Double_t pTmax = 100;
4363 mask |= (AliESDtrack::kITSrefit);
4364 mask |= (AliESDtrack::kTPCrefit);
4365 const Double_t pTminCosmic = 5.;
4366 const Double_t pTmaxCosmic = 100;
4367 ULong_t maskCosmic = 0;
4368 Int_t cosmicCount=0;
4369 maskCosmic |= (AliESDtrack::kTPCrefit);
4371 Bool_t isOK = kFALSE;
4373 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4374 // Check if this ia a physics event (code 7)
4375 Int_t ntrk = fesd->GetNumberOfTracks();
4376 for (Int_t itrk=0; itrk<ntrk; ++itrk) {
4378 AliESDtrack * trk = fesd->GetTrack(itrk);
4380 && trk->Pt() > pTmin
4381 && trk->Pt() < pTmax
4382 && (trk->GetStatus() & mask) == mask ) {
4388 && trk->GetInnerParam()
4389 && trk->GetInnerParam()->Pt() > pTminCosmic
4390 && trk->GetInnerParam()->Pt() < pTmaxCosmic
4391 && (trk->GetStatus() & maskCosmic) == maskCosmic ) {
4397 if (cosmicCount>1) isOK=kTRUE;
4402 //______________________________________________________________________________
4403 Bool_t AliReconstruction::IsCosmicOrCalibSpecie() const {
4404 // Select cosmic or calibration events
4406 Bool_t isOK = kFALSE;
4408 if (fesd && fesd->GetEventType()==AliRawEventHeaderBase::kPhysicsEvent) {
4409 // Check if this ia a physics event (code 7)
4411 UInt_t specie = fesd->GetEventSpecie();
4412 if (specie==AliRecoParam::kCosmic || specie==AliRecoParam::kCalib) {
4419 //______________________________________________________________________________
4420 void AliReconstruction::WriteESDfriend() {
4421 // Fill the ESD friend in the tree. The required fraction of ESD friends is stored
4422 // in fFractionFriends. We select events where we store the ESD friends according
4423 // to the following algorithm:
4424 // 1. Store all Cosmic or Calibration events within the required fraction
4425 // 2. Sample "high Pt" events within the remaining fraction after step 1.
4426 // 3. Sample randomly events if we still have remaining slot
4429 Bool_t isSelected = kFALSE;
4431 // Store all friends for B field OFF
4432 if (TMath::Abs(AliTrackerBase::GetBz())<0.5) isSelected=kTRUE;
4434 if (IsCosmicOrCalibSpecie()) { // Selection of calib or cosmic events
4441 Double_t remainingFraction = fFractionFriends;
4442 remainingFraction -= ((Double_t)(fSspecie)/(Double_t)(fNall));
4444 if (IsHighPt()) { // Selection of "high Pt" events
4446 Double_t curentHighPtFraction = ((Double_t)(fNhighPt+1))/((Double_t)(fNall+1));
4447 // "Bayesian" estimate supposing that without events all the events are of the required type
4450 Double_t rnd = gRandom->Rndm()*curentHighPtFraction;
4451 if (rnd<remainingFraction) {
4457 remainingFraction -= ((Double_t)(fShighPt)/(Double_t)(fNall));
4459 // Random selection to fill the remaining fraction (if any)
4461 Double_t rnd = gRandom->Rndm();
4462 if (rnd<remainingFraction) {
4468 fesdf->~AliESDfriend();
4469 new (fesdf) AliESDfriend(); // Reset...
4470 fesdf->SetSkipBit(kTRUE);
4473 Long64_t nbf = ftreeF->Fill();
4474 if (fTreeBuffSize>0 && ftreeF->GetAutoFlush()<0 && (fMemCountESDF += nbf)>fTreeBuffSize ) { // default limit is still not reached
4475 nbf = ftreeF->GetZipBytes();
4476 if (nbf>0) nbf = -nbf;
4477 else nbf = ftreeF->GetEntries();
4478 ftreeF->SetAutoFlush(nbf);
4479 AliInfo(Form("Calling ftreeF->SetAutoFlush(%lld) | W:%lld T:%lld Z:%lld",
4480 nbf,fMemCountESDF,ftreeF->GetTotBytes(),ftreeF->GetZipBytes()));
4485 //_________________________________________________________________
4486 void AliReconstruction::DeleteDigits(const TString& detectors)
4488 // delete requested digit files produced at current event
4489 static int iEvent = 0;
4490 if (detectors.IsNull()) return;
4491 TString detStr = detectors;
4492 AliInfo(Form("Deleting Digits: %s",detectors.Data()));
4494 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4495 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
4496 unlink(Form("%s.Digits.root",fgkDetectorName[iDet]));
4498 AliSysInfo::AddStamp(Form("DelDigits_%d",iEvent), 0,0,iEvent);
4502 //_________________________________________________________________
4503 void AliReconstruction::DeleteRecPoints(const TString& detectors)
4505 // delete requested recpoint files produced at current event
4506 static int iEvent = 0;
4507 if (detectors.IsNull()) return;
4508 TString detStr = detectors;
4509 AliInfo(Form("Deleting Recpoints: %s",detectors.Data()));
4511 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
4512 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
4513 unlink(Form("%s.RecPoints.root",fgkDetectorName[iDet]));
4515 AliSysInfo::AddStamp(Form("DelRecPoints_%d",iEvent), 0,0,iEvent);
4519 //_________________________________________________________________
4520 void AliReconstruction::SetStopOnResourcesExcess(Int_t vRSS,Int_t vVMEM)
4522 // require checking the resources left and stopping on excess
4523 // if 0 : no check is done
4524 // if >0 : stop reconstruction if exceeds this value
4525 // if <0 : use as margin to system limits
4527 const int kKB2MB = 1024;
4528 const int kInfMem = 9999999;
4531 int pgSize = getpagesize();
4535 AliInfo(Form("Setting max. RSS usage to user value %d MB",fMaxRSS));
4538 getrlimit(RLIMIT_RSS,&r);
4539 fMaxRSS = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vRSS;
4540 AliInfo(Form("Setting max. RSS usage to system hard limit %d%s MB (%d margin)",fMaxRSS,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vRSS));
4542 else {AliInfo("No check on RSS memory usage will be applied");}
4546 AliInfo(Form("Setting max. VMEM usage to user value %d MB",fMaxVMEM));
4549 getrlimit(RLIMIT_AS,&r);
4550 fMaxVMEM = r.rlim_max==RLIM_INFINITY ? kInfMem : int(r.rlim_max*pgSize/kKB2MB/kKB2MB) + vVMEM;
4551 AliInfo(Form("Setting max. VMEM usage to system hard limit %d%s MB (%d margin)",fMaxVMEM,r.rlim_max==RLIM_INFINITY ? "(inf)":"",-vVMEM));
4553 else {AliInfo("No check on RSS memory usage will be applied");}
4557 //_________________________________________________________________
4558 Bool_t AliReconstruction::HasEnoughResources(int ev)
4560 // check if process consumed more than allowed resources
4561 const int kKB2MB = 1024;
4563 if (!fMaxRSS && !fMaxVMEM) return res;
4565 ProcInfo_t procInfo;
4566 gSystem->GetProcInfo(&procInfo);
4567 if (procInfo.fMemResident/kKB2MB > fMaxRSS) res = kFALSE;
4568 if (procInfo.fMemVirtual/kKB2MB > fMaxVMEM) res = kFALSE;
4571 AliInfo(Form("Job exceeded allowed limits: RSS:%d (%d) VMEM:%d (%d), will stop",
4572 int(procInfo.fMemResident/kKB2MB),fMaxRSS,
4573 int(procInfo.fMemVirtual/kKB2MB) ,fMaxVMEM));
4575 unlink(Form("%s",fgkStopEvFName));
4576 ofstream outfile(fgkStopEvFName);
4577 outfile << ev << std::endl;
4584 Bool_t AliReconstruction::HasNextEventAfter(Int_t eventId)
4586 return ( (eventId < fRunLoader->GetNumberOfEvents()) ||
4587 (fRawReader && fRawReader->NextEvent()) );