1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ///////////////////////////////////////////////////////////////////////////////
20 // class for running the reconstruction //
22 // Clusters and tracks are created for all detectors and all events by //
25 // AliReconstruction rec; //
28 // The Run method returns kTRUE in case of successful execution. //
30 // If the input to the reconstruction are not simulated digits but raw data, //
31 // this can be specified by an argument of the Run method or by the method //
33 // rec.SetInput("..."); //
35 // The input formats and the corresponding argument are: //
36 // - DDL raw data files: directory name, ends with "/" //
37 // - raw data root file: root file name, extension ".root" //
38 // - raw data DATE file: DATE file name, any other non-empty string //
39 // - MC root files : empty string, default //
41 // By default all events are reconstructed. The reconstruction can be //
42 // limited to a range of events by giving the index of the first and the //
43 // last event as an argument to the Run method or by calling //
45 // rec.SetEventRange(..., ...); //
47 // The index -1 (default) can be used for the last event to indicate no //
48 // upper limit of the event range. //
50 // In case of raw-data reconstruction the user can modify the default //
51 // number of events per digits/clusters/tracks file. In case the option //
52 // is not used the number is set 1. In case the user provides 0, than //
53 // the number of events is equal to the number of events inside the //
54 // raw-data file (i.e. one digits/clusters/tracks file): //
56 // rec.SetNumberOfEventsPerFile(...); //
59 // The name of the galice file can be changed from the default //
60 // "galice.root" by passing it as argument to the AliReconstruction //
61 // constructor or by //
63 // rec.SetGAliceFile("..."); //
65 // The local reconstruction can be switched on or off for individual //
68 // rec.SetRunLocalReconstruction("..."); //
70 // The argument is a (case sensitive) string with the names of the //
71 // detectors separated by a space. The special string "ALL" selects all //
72 // available detectors. This is the default. //
74 // The reconstruction of the primary vertex position can be switched off by //
76 // rec.SetRunVertexFinder(kFALSE); //
78 // The tracking and the creation of ESD tracks can be switched on for //
79 // selected detectors by //
81 // rec.SetRunTracking("..."); //
83 // Uniform/nonuniform field tracking switches (default: uniform field) //
85 // rec.SetUniformFieldTracking(); ( rec.SetUniformFieldTracking(kFALSE); ) //
87 // The filling of additional ESD information can be steered by //
89 // rec.SetFillESD("..."); //
91 // Again, for both methods the string specifies the list of detectors. //
92 // The default is "ALL". //
94 // The call of the shortcut method //
96 // rec.SetRunReconstruction("..."); //
98 // is equivalent to calling SetRunLocalReconstruction, SetRunTracking and //
99 // SetFillESD with the same detector selecting string as argument. //
101 // The reconstruction requires digits or raw data as input. For the creation //
102 // of digits and raw data have a look at the class AliSimulation. //
104 // The input data of a detector can be replaced by the corresponding HLT //
105 // data by calling (usual detector string) //
106 // SetUseHLTData("..."); //
109 ///////////////////////////////////////////////////////////////////////////////
116 #include <TGeoGlobalMagField.h>
117 #include <TGeoManager.h>
119 #include <TLorentzVector.h>
121 #include <TObjArray.h>
122 #include <TPRegexp.h>
123 #include <TParameter.h>
124 #include <TPluginManager.h>
126 #include <TProofOutputFile.h>
129 #include <THashTable.h>
131 #include <TMessage.h>
133 #include "AliAlignObj.h"
134 #include "AliCDBEntry.h"
135 #include "AliCDBManager.h"
136 #include "AliCDBStorage.h"
137 #include "AliCTPRawStream.h"
138 #include "AliCascadeVertexer.h"
139 #include "AliCentralTrigger.h"
140 #include "AliCodeTimer.h"
142 #include "AliDetectorRecoParam.h"
143 #include "AliESDCaloCells.h"
144 #include "AliESDCaloCluster.h"
145 #include "AliESDEvent.h"
146 #include "AliESDMuonTrack.h"
147 #include "AliESDPmdTrack.h"
148 #include "AliESDTagCreator.h"
149 #include "AliESDVertex.h"
150 #include "AliESDcascade.h"
151 #include "AliESDfriend.h"
152 #include "AliESDkink.h"
153 #include "AliESDpid.h"
154 #include "AliESDtrack.h"
155 #include "AliESDtrack.h"
156 #include "AliEventInfo.h"
157 #include "AliGRPObject.h"
158 #include "AliGRPRecoParam.h"
159 #include "AliGenEventHeader.h"
160 #include "AliGeomManager.h"
161 #include "AliGlobalQADataMaker.h"
162 #include "AliHeader.h"
165 #include "AliMultiplicity.h"
167 #include "AliPlaneEff.h"
169 #include "AliQADataMakerRec.h"
170 #include "AliQAManager.h"
171 #include "AliRawVEvent.h"
172 #include "AliRawEventHeaderBase.h"
173 #include "AliRawHLTManager.h"
174 #include "AliRawReaderDate.h"
175 #include "AliRawReaderFile.h"
176 #include "AliRawReaderRoot.h"
177 #include "AliReconstruction.h"
178 #include "AliReconstructor.h"
180 #include "AliRunInfo.h"
181 #include "AliRunLoader.h"
182 #include "AliSysInfo.h" // memory snapshots
183 #include "AliTrackPointArray.h"
184 #include "AliTracker.h"
185 #include "AliTriggerClass.h"
186 #include "AliTriggerCluster.h"
187 #include "AliTriggerIR.h"
188 #include "AliTriggerConfiguration.h"
189 #include "AliV0vertexer.h"
190 #include "AliVertexer.h"
191 #include "AliVertexerTracks.h"
192 #include "AliTriggerRunScalers.h"
193 #include "AliCTPTimeParams.h"
194 #include "AliESDHLTDecision.h"
195 #include "AliTriggerInput.h"
196 ClassImp(AliReconstruction)
198 //_____________________________________________________________________________
199 const char* AliReconstruction::fgkDetectorName[AliReconstruction::kNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "HMPID", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "T0", "VZERO", "ACORDE", "HLT"};
201 //_____________________________________________________________________________
202 AliReconstruction::AliReconstruction(const char* gAliceFilename) :
204 fRunVertexFinder(kTRUE),
205 fRunVertexFinderTracks(kTRUE),
206 fRunHLTTracking(kFALSE),
207 fRunMuonTracking(kFALSE),
209 fRunCascadeFinder(kTRUE),
211 fWriteAlignmentData(kFALSE),
212 fWriteESDfriend(kFALSE),
213 fFillTriggerESD(kTRUE),
221 fRunLocalReconstruction("ALL"),
225 fUseTrackingErrorsForAlignment(""),
226 fGAliceFileName(gAliceFilename),
229 fProofOutputFileName(""),
230 fProofOutputLocation(""),
231 fProofOutputDataset(kFALSE),
232 fProofOutputArchive(""),
236 fNumberOfEventsPerFile((UInt_t)-1),
238 fLoadAlignFromCDB(kTRUE),
239 fLoadAlignData("ALL"),
244 fCTPTimeParams(NULL),
248 fParentRawReader(NULL),
252 fSPDTrackleter(NULL),
254 fDiamondProfileSPD(NULL),
255 fDiamondProfile(NULL),
256 fDiamondProfileTPC(NULL),
257 fListOfCosmicTriggers(NULL),
261 fAlignObjArray(NULL),
265 fInitCDBCalled(kFALSE),
266 fSetRunNumberFromDataCalled(kFALSE),
271 fSameQACycle(kFALSE),
272 fInitQACalled(kFALSE),
273 fWriteQAExpertData(kTRUE),
274 fRunPlaneEff(kFALSE),
285 fIsNewRunLoader(kFALSE),
289 // create reconstruction object with default parameters
292 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
293 fReconstructor[iDet] = NULL;
294 fLoader[iDet] = NULL;
295 fTracker[iDet] = NULL;
297 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
298 fQACycles[iDet] = 999999 ;
299 fQAWriteExpert[iDet] = kFALSE ;
305 //_____________________________________________________________________________
306 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
308 fRunVertexFinder(rec.fRunVertexFinder),
309 fRunVertexFinderTracks(rec.fRunVertexFinderTracks),
310 fRunHLTTracking(rec.fRunHLTTracking),
311 fRunMuonTracking(rec.fRunMuonTracking),
312 fRunV0Finder(rec.fRunV0Finder),
313 fRunCascadeFinder(rec.fRunCascadeFinder),
314 fStopOnError(rec.fStopOnError),
315 fWriteAlignmentData(rec.fWriteAlignmentData),
316 fWriteESDfriend(rec.fWriteESDfriend),
317 fFillTriggerESD(rec.fFillTriggerESD),
319 fCleanESD(rec.fCleanESD),
320 fV0DCAmax(rec.fV0DCAmax),
321 fV0CsPmin(rec.fV0CsPmin),
325 fRunLocalReconstruction(rec.fRunLocalReconstruction),
326 fRunTracking(rec.fRunTracking),
327 fFillESD(rec.fFillESD),
328 fLoadCDB(rec.fLoadCDB),
329 fUseTrackingErrorsForAlignment(rec.fUseTrackingErrorsForAlignment),
330 fGAliceFileName(rec.fGAliceFileName),
331 fRawInput(rec.fRawInput),
332 fESDOutput(rec.fESDOutput),
333 fProofOutputFileName(rec.fProofOutputFileName),
334 fProofOutputLocation(rec.fProofOutputLocation),
335 fProofOutputDataset(rec.fProofOutputDataset),
336 fProofOutputArchive(rec.fProofOutputArchive),
337 fEquipIdMap(rec.fEquipIdMap),
338 fFirstEvent(rec.fFirstEvent),
339 fLastEvent(rec.fLastEvent),
340 fNumberOfEventsPerFile(rec.fNumberOfEventsPerFile),
342 fLoadAlignFromCDB(rec.fLoadAlignFromCDB),
343 fLoadAlignData(rec.fLoadAlignData),
344 fUseHLTData(rec.fUseHLTData),
348 fCTPTimeParams(NULL),
352 fParentRawReader(NULL),
354 fRecoParam(rec.fRecoParam),
356 fSPDTrackleter(NULL),
358 fDiamondProfileSPD(rec.fDiamondProfileSPD),
359 fDiamondProfile(rec.fDiamondProfile),
360 fDiamondProfileTPC(rec.fDiamondProfileTPC),
361 fListOfCosmicTriggers(NULL),
365 fAlignObjArray(rec.fAlignObjArray),
366 fCDBUri(rec.fCDBUri),
367 fQARefUri(rec.fQARefUri),
369 fInitCDBCalled(rec.fInitCDBCalled),
370 fSetRunNumberFromDataCalled(rec.fSetRunNumberFromDataCalled),
371 fQADetectors(rec.fQADetectors),
372 fQATasks(rec.fQATasks),
374 fRunGlobalQA(rec.fRunGlobalQA),
375 fSameQACycle(rec.fSameQACycle),
376 fInitQACalled(rec.fInitQACalled),
377 fWriteQAExpertData(rec.fWriteQAExpertData),
378 fRunPlaneEff(rec.fRunPlaneEff),
389 fIsNewRunLoader(rec.fIsNewRunLoader),
395 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
396 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
398 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
399 fReconstructor[iDet] = NULL;
400 fLoader[iDet] = NULL;
401 fTracker[iDet] = NULL;
404 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
405 fQACycles[iDet] = rec.fQACycles[iDet];
406 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
409 for (Int_t i = 0; i < rec.fSpecCDBUri.GetEntriesFast(); i++) {
410 if (rec.fSpecCDBUri[i]) fSpecCDBUri.Add(rec.fSpecCDBUri[i]->Clone());
414 //_____________________________________________________________________________
415 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
417 // assignment operator
418 // Used in PROOF mode
419 // Be very careful while modifing it!
420 // Simple rules to follow:
421 // for persistent data members - use their assignment operators
422 // for non-persistent ones - do nothing or take the default values from constructor
423 // TSelector members should not be touched
424 if(&rec == this) return *this;
426 fRunVertexFinder = rec.fRunVertexFinder;
427 fRunVertexFinderTracks = rec.fRunVertexFinderTracks;
428 fRunHLTTracking = rec.fRunHLTTracking;
429 fRunMuonTracking = rec.fRunMuonTracking;
430 fRunV0Finder = rec.fRunV0Finder;
431 fRunCascadeFinder = rec.fRunCascadeFinder;
432 fStopOnError = rec.fStopOnError;
433 fWriteAlignmentData = rec.fWriteAlignmentData;
434 fWriteESDfriend = rec.fWriteESDfriend;
435 fFillTriggerESD = rec.fFillTriggerESD;
437 fCleanESD = rec.fCleanESD;
438 fV0DCAmax = rec.fV0DCAmax;
439 fV0CsPmin = rec.fV0CsPmin;
443 fRunLocalReconstruction = rec.fRunLocalReconstruction;
444 fRunTracking = rec.fRunTracking;
445 fFillESD = rec.fFillESD;
446 fLoadCDB = rec.fLoadCDB;
447 fUseTrackingErrorsForAlignment = rec.fUseTrackingErrorsForAlignment;
448 fGAliceFileName = rec.fGAliceFileName;
449 fRawInput = rec.fRawInput;
450 fESDOutput = rec.fESDOutput;
451 fProofOutputFileName = rec.fProofOutputFileName;
452 fProofOutputLocation = rec.fProofOutputLocation;
453 fProofOutputDataset = rec.fProofOutputDataset;
454 fProofOutputArchive = rec.fProofOutputArchive;
455 fEquipIdMap = rec.fEquipIdMap;
456 fFirstEvent = rec.fFirstEvent;
457 fLastEvent = rec.fLastEvent;
458 fNumberOfEventsPerFile = rec.fNumberOfEventsPerFile;
460 for (Int_t i = 0; i < rec.fOptions.GetEntriesFast(); i++) {
461 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
464 fLoadAlignFromCDB = rec.fLoadAlignFromCDB;
465 fLoadAlignData = rec.fLoadAlignData;
466 fUseHLTData = rec.fUseHLTData;
468 delete fRunInfo; fRunInfo = NULL;
469 if (rec.fRunInfo) fRunInfo = new AliRunInfo(*rec.fRunInfo);
471 fEventInfo = rec.fEventInfo;
473 delete fRunScalers; fRunScalers = NULL;
474 if (rec.fRunScalers) fRunScalers = new AliTriggerRunScalers(*rec.fRunScalers);
476 delete fCTPTimeParams; fCTPTimeParams = NULL;
477 if (rec.fCTPTimeParams) fCTPTimeParams = new AliCTPTimeParams(*rec.fCTPTimeParams);
481 fParentRawReader = NULL;
483 fRecoParam = rec.fRecoParam;
485 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
486 delete fReconstructor[iDet]; fReconstructor[iDet] = NULL;
487 delete fLoader[iDet]; fLoader[iDet] = NULL;
488 delete fTracker[iDet]; fTracker[iDet] = NULL;
491 for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
492 fQACycles[iDet] = rec.fQACycles[iDet];
493 fQAWriteExpert[iDet] = rec.fQAWriteExpert[iDet] ;
496 delete fSPDTrackleter; fSPDTrackleter = NULL;
498 delete fDiamondProfileSPD; fDiamondProfileSPD = NULL;
499 if (rec.fDiamondProfileSPD) fDiamondProfileSPD = new AliESDVertex(*rec.fDiamondProfileSPD);
500 delete fDiamondProfile; fDiamondProfile = NULL;
501 if (rec.fDiamondProfile) fDiamondProfile = new AliESDVertex(*rec.fDiamondProfile);
502 delete fDiamondProfileTPC; fDiamondProfileTPC = NULL;
503 if (rec.fDiamondProfileTPC) fDiamondProfileTPC = new AliESDVertex(*rec.fDiamondProfileTPC);
505 delete fListOfCosmicTriggers; fListOfCosmicTriggers = NULL;
506 if (rec.fListOfCosmicTriggers) fListOfCosmicTriggers = (THashTable*)((rec.fListOfCosmicTriggers)->Clone());
508 delete fGRPData; fGRPData = NULL;
509 // if (rec.fGRPData) fGRPData = (TMap*)((rec.fGRPData)->Clone());
510 if (rec.fGRPData) fGRPData = (AliGRPObject*)((rec.fGRPData)->Clone());
512 delete fAlignObjArray; fAlignObjArray = NULL;
515 fQARefUri = rec.fQARefUri;
516 fSpecCDBUri.Delete();
517 fInitCDBCalled = rec.fInitCDBCalled;
518 fSetRunNumberFromDataCalled = rec.fSetRunNumberFromDataCalled;
519 fQADetectors = rec.fQADetectors;
520 fQATasks = rec.fQATasks;
522 fRunGlobalQA = rec.fRunGlobalQA;
523 fSameQACycle = rec.fSameQACycle;
524 fInitQACalled = rec.fInitQACalled;
525 fWriteQAExpertData = rec.fWriteQAExpertData;
526 fRunPlaneEff = rec.fRunPlaneEff;
537 fIsNewRunLoader = rec.fIsNewRunLoader;
544 //_____________________________________________________________________________
545 AliReconstruction::~AliReconstruction()
550 if (fListOfCosmicTriggers) {
551 fListOfCosmicTriggers->Delete();
552 delete fListOfCosmicTriggers;
556 delete fCTPTimeParams;
558 if (fAlignObjArray) {
559 fAlignObjArray->Delete();
560 delete fAlignObjArray;
562 fSpecCDBUri.Delete();
564 AliCodeTimer::Instance()->Print();
567 //_____________________________________________________________________________
568 void AliReconstruction::InitQA()
570 //Initialize the QA and start of cycle
571 AliCodeTimerAuto("",0);
573 if (fInitQACalled) return;
574 fInitQACalled = kTRUE;
576 AliQAManager * qam = AliQAManager::QAManager(AliQAv1::kRECMODE) ;
577 if (fWriteQAExpertData)
578 qam->SetWriteExpert() ;
580 if (qam->IsDefaultStorageSet()) {
581 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
582 AliWarning("Default QA reference storage has been already set !");
583 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fQARefUri.Data()));
584 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
585 fQARefUri = qam->GetDefaultStorage()->GetURI();
587 if (fQARefUri.Length() > 0) {
588 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
589 AliDebug(2, Form("Default QA reference storage is set to: %s", fQARefUri.Data()));
590 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
592 fQARefUri="local://$ALICE_ROOT/QAref";
593 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
594 AliWarning("Default QA refeference storage not yet set !!!!");
595 AliWarning(Form("Setting it now to: %s", fQARefUri.Data()));
596 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
599 qam->SetDefaultStorage(fQARefUri);
603 qam->SetActiveDetectors(fQADetectors) ;
604 for (Int_t det = 0 ; det < AliQAv1::kNDET ; det++) {
605 qam->SetCycleLength(AliQAv1::DETECTORINDEX_t(det), fQACycles[det]) ;
606 qam->SetWriteExpert(AliQAv1::DETECTORINDEX_t(det)) ;
608 if (!fRawReader && !fInput && IsInTasks(AliQAv1::kRAWS))
609 fQATasks.ReplaceAll(Form("%d",AliQAv1::kRAWS), "") ;
610 qam->SetTasks(fQATasks) ;
611 qam->InitQADataMaker(AliCDBManager::Instance()->GetRun()) ;
614 Bool_t sameCycle = kFALSE ;
615 AliQADataMaker *qadm = qam->GetQADataMaker(AliQAv1::kGLOBAL);
616 AliInfo(Form("Initializing the global QA data maker"));
617 if (IsInTasks(AliQAv1::kRECPOINTS)) {
618 qadm->StartOfCycle(AliQAv1::kRECPOINTS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
619 TObjArray **arr=qadm->Init(AliQAv1::kRECPOINTS);
620 AliTracker::SetResidualsArray(arr);
623 if (IsInTasks(AliQAv1::kESDS)) {
624 qadm->StartOfCycle(AliQAv1::kESDS, AliCDBManager::Instance()->GetRun(), sameCycle) ;
625 qadm->Init(AliQAv1::kESDS);
628 AliSysInfo::AddStamp("InitQA") ;
631 //_____________________________________________________________________________
632 void AliReconstruction::MergeQA(const char *fileName)
634 //Initialize the QA and start of cycle
635 AliCodeTimerAuto("",0) ;
636 AliQAManager::QAManager()->Merge(AliCDBManager::Instance()->GetRun(),fileName) ;
637 AliSysInfo::AddStamp("MergeQA") ;
640 //_____________________________________________________________________________
641 void AliReconstruction::InitCDB()
643 // activate a default CDB storage
644 // First check if we have any CDB storage set, because it is used
645 // to retrieve the calibration and alignment constants
646 AliCodeTimerAuto("",0);
648 if (fInitCDBCalled) return;
649 fInitCDBCalled = kTRUE;
651 AliCDBManager* man = AliCDBManager::Instance();
652 if (man->IsDefaultStorageSet())
654 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
655 AliWarning("Default CDB storage has been already set !");
656 AliWarning(Form("Ignoring the default storage declared in AliReconstruction: %s",fCDBUri.Data()));
657 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
658 fCDBUri = man->GetDefaultStorage()->GetURI();
661 if (fCDBUri.Length() > 0)
663 AliDebug(2,"!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
664 AliDebug(2, Form("Default CDB storage is set to: %s", fCDBUri.Data()));
665 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
666 man->SetDefaultStorage(fCDBUri);
668 else if (!man->GetRaw()){
669 fCDBUri="local://$ALICE_ROOT/OCDB";
670 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
671 AliWarning("Default CDB storage not yet set !!!!");
672 AliWarning(Form("Setting it now to: %s", fCDBUri.Data()));
673 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
674 man->SetDefaultStorage(fCDBUri);
677 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
678 AliWarning("Default storage will be set after setting the Run Number!!!");
679 AliWarning("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
683 // Now activate the detector specific CDB storage locations
684 for (Int_t i = 0; i < fSpecCDBUri.GetEntriesFast(); i++) {
685 TObject* obj = fSpecCDBUri[i];
687 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
688 AliDebug(2, Form("Specific CDB storage for %s is set to: %s",obj->GetName(),obj->GetTitle()));
689 AliDebug(2, "!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
690 man->SetSpecificStorage(obj->GetName(), obj->GetTitle());
692 AliSysInfo::AddStamp("InitCDB");
695 //_____________________________________________________________________________
696 void AliReconstruction::SetDefaultStorage(const char* uri) {
697 // Store the desired default CDB storage location
698 // Activate it later within the Run() method
704 //_____________________________________________________________________________
705 void AliReconstruction::SetQARefDefaultStorage(const char* uri) {
706 // Store the desired default CDB storage location
707 // Activate it later within the Run() method
710 AliQAv1::SetQARefStorage(fQARefUri.Data()) ;
713 //_____________________________________________________________________________
714 void AliReconstruction::SetSpecificStorage(const char* calibType, const char* uri) {
715 // Store a detector-specific CDB storage location
716 // Activate it later within the Run() method
718 AliCDBPath aPath(calibType);
719 if(!aPath.IsValid()){
720 // if calibType is not wildcard but it is a valid detector, add "/*" to make it a valid path
721 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
722 if(!strcmp(calibType, fgkDetectorName[iDet])) {
723 aPath.SetPath(Form("%s/*", calibType));
724 AliInfo(Form("Path for specific storage set to %s", aPath.GetPath().Data()));
728 if(!aPath.IsValid()){
729 AliError(Form("Not a valid path or detector: %s", calibType));
734 // // check that calibType refers to a "valid" detector name
735 // Bool_t isDetector = kFALSE;
736 // for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
737 // TString detName = fgkDetectorName[iDet];
738 // if(aPath.GetLevel0() == detName) {
739 // isDetector = kTRUE;
745 // AliError(Form("Not a valid detector: %s", aPath.GetLevel0().Data()));
749 TObject* obj = fSpecCDBUri.FindObject(aPath.GetPath().Data());
750 if (obj) fSpecCDBUri.Remove(obj);
751 fSpecCDBUri.Add(new TNamed(aPath.GetPath().Data(), uri));
755 //_____________________________________________________________________________
756 Bool_t AliReconstruction::SetRunNumberFromData()
758 // The method is called in Run() in order
759 // to set a correct run number.
760 // In case of raw data reconstruction the
761 // run number is taken from the raw data header
763 if (fSetRunNumberFromDataCalled) return kTRUE;
764 fSetRunNumberFromDataCalled = kTRUE;
766 AliCDBManager* man = AliCDBManager::Instance();
769 if(fRawReader->NextEvent()) {
770 if(man->GetRun() > 0) {
771 AliWarning("Run number is taken from raw-event header! Ignoring settings in AliCDBManager!");
773 man->SetRun(fRawReader->GetRunNumber());
774 fRawReader->RewindEvents();
777 if(man->GetRun() > 0) {
778 AliWarning("No raw-data events are found ! Using settings in AliCDBManager !");
781 AliWarning("Neither raw events nor settings in AliCDBManager are found !");
787 AliRunLoader *rl = AliRunLoader::Open(fGAliceFileName.Data());
789 AliError(Form("No run loader found in file %s", fGAliceFileName.Data()));
794 // read run number from gAlice
795 if(rl->GetHeader()) {
796 man->SetRun(rl->GetHeader()->GetRun());
801 AliError("Neither run-loader header nor RawReader objects are found !");
813 //_____________________________________________________________________________
814 void AliReconstruction::SetCDBLock() {
815 // Set CDB lock: from now on it is forbidden to reset the run number
816 // or the default storage or to activate any further storage!
818 AliCDBManager::Instance()->SetLock(1);
821 //_____________________________________________________________________________
822 Bool_t AliReconstruction::MisalignGeometry(const TString& detectors)
824 // Read the alignment objects from CDB.
825 // Each detector is supposed to have the
826 // alignment objects in DET/Align/Data CDB path.
827 // All the detector objects are then collected,
828 // sorted by geometry level (starting from ALIC) and
829 // then applied to the TGeo geometry.
830 // Finally an overlaps check is performed.
832 // Load alignment data from CDB and fill fAlignObjArray
833 if(fLoadAlignFromCDB){
835 TString detStr = detectors;
836 TString loadAlObjsListOfDets = "";
838 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
839 if(!IsSelected(fgkDetectorName[iDet], detStr)) continue;
840 if(!strcmp(fgkDetectorName[iDet],"HLT")) continue;
842 if(AliGeomManager::GetNalignable(fgkDetectorName[iDet]) != 0)
844 loadAlObjsListOfDets += fgkDetectorName[iDet];
845 loadAlObjsListOfDets += " ";
847 } // end loop over detectors
849 if(AliGeomManager::GetNalignable("GRP") != 0)
850 loadAlObjsListOfDets.Prepend("GRP "); //add alignment objects for non-sensitive modules
851 AliGeomManager::ApplyAlignObjsFromCDB(loadAlObjsListOfDets.Data());
852 AliCDBManager::Instance()->UnloadFromCache("*/Align/*");
854 // Check if the array with alignment objects was
855 // provided by the user. If yes, apply the objects
856 // to the present TGeo geometry
857 if (fAlignObjArray) {
858 if (gGeoManager && gGeoManager->IsClosed()) {
859 if (AliGeomManager::ApplyAlignObjsToGeom(*fAlignObjArray) == kFALSE) {
860 AliError("The misalignment of one or more volumes failed!"
861 "Compare the list of simulated detectors and the list of detector alignment data!");
866 AliError("Can't apply the misalignment! gGeoManager doesn't exist or it is still opened!");
872 if (fAlignObjArray) {
873 fAlignObjArray->Delete();
874 delete fAlignObjArray; fAlignObjArray=NULL;
880 //_____________________________________________________________________________
881 void AliReconstruction::SetGAliceFile(const char* fileName)
883 // set the name of the galice file
885 fGAliceFileName = fileName;
888 //_____________________________________________________________________________
889 void AliReconstruction::SetInput(const char* input)
891 // In case the input string starts with 'mem://', we run in an online mode
892 // and AliRawReaderDateOnline object is created. In all other cases a raw-data
893 // file is assumed. One can give as an input:
894 // mem://: - events taken from DAQ monitoring libs online
896 // mem://<filename> - emulation of the above mode (via DATE monitoring libs)
897 if (input) fRawInput = input;
900 //_____________________________________________________________________________
901 void AliReconstruction::SetOutput(const char* output)
903 // Set the output ESD filename
904 // 'output' is a normalt ROOT url
905 // The method is used in case of raw-data reco with PROOF
906 if (output) fESDOutput = output;
909 //_____________________________________________________________________________
910 void AliReconstruction::SetOption(const char* detector, const char* option)
912 // set options for the reconstruction of a detector
914 TObject* obj = fOptions.FindObject(detector);
915 if (obj) fOptions.Remove(obj);
916 fOptions.Add(new TNamed(detector, option));
919 //_____________________________________________________________________________
920 void AliReconstruction::SetRecoParam(const char* detector, AliDetectorRecoParam *par)
922 // Set custom reconstruction parameters for a given detector
923 // Single set of parameters for all the events
925 // First check if the reco-params are global
926 if(!strcmp(detector, "GRP")) {
928 fRecoParam.AddDetRecoParam(kNDetectors,par);
932 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
933 if(!strcmp(detector, fgkDetectorName[iDet])) {
935 fRecoParam.AddDetRecoParam(iDet,par);
942 //_____________________________________________________________________________
943 Bool_t AliReconstruction::InitGRP() {
944 //------------------------------------
945 // Initialization of the GRP entry
946 //------------------------------------
947 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/GRP/Data");
951 TMap* m = dynamic_cast<TMap*>(entry->GetObject()); // old GRP entry
954 AliInfo("Found a TMap in GRP/GRP/Data, converting it into an AliGRPObject");
956 fGRPData = new AliGRPObject();
957 fGRPData->ReadValuesFromMap(m);
961 AliInfo("Found an AliGRPObject in GRP/GRP/Data, reading it");
962 fGRPData = dynamic_cast<AliGRPObject*>(entry->GetObject()); // new GRP entry
966 // FIX ME: The unloading of GRP entry is temporarily disabled
967 // because ZDC and VZERO are using it in order to initialize
968 // their reconstructor objects. In the future one has to think
969 // of propagating AliRunInfo to the reconstructors.
970 // AliCDBManager::Instance()->UnloadFromCache("GRP/GRP/Data");
974 AliError("No GRP entry found in OCDB!");
978 TString lhcState = fGRPData->GetLHCState();
979 if (lhcState==AliGRPObject::GetInvalidString()) {
980 AliError("GRP/GRP/Data entry: missing value for the LHC state ! Using UNKNOWN");
981 lhcState = "UNKNOWN";
984 TString beamType = fGRPData->GetBeamType();
985 if (beamType==AliGRPObject::GetInvalidString()) {
986 AliError("GRP/GRP/Data entry: missing value for the beam type ! Using UNKNOWN");
987 beamType = "UNKNOWN";
990 Float_t beamEnergy = fGRPData->GetBeamEnergy();
991 if (beamEnergy==AliGRPObject::GetInvalidFloat()) {
992 AliError("GRP/GRP/Data entry: missing value for the beam energy ! Using 0");
996 TString runType = fGRPData->GetRunType();
997 if (runType==AliGRPObject::GetInvalidString()) {
998 AliError("GRP/GRP/Data entry: missing value for the run type ! Using UNKNOWN");
1002 Int_t activeDetectors = fGRPData->GetDetectorMask();
1003 if (activeDetectors==AliGRPObject::GetInvalidUInt()) {
1004 AliError("GRP/GRP/Data entry: missing value for the detector mask ! Using 1074790399");
1005 activeDetectors = 1074790399;
1008 fRunInfo = new AliRunInfo(lhcState, beamType, beamEnergy, runType, activeDetectors);
1012 // Process the list of active detectors
1013 if (activeDetectors) {
1014 UInt_t detMask = activeDetectors;
1015 fRunLocalReconstruction = MatchDetectorList(fRunLocalReconstruction,detMask);
1016 fRunTracking = MatchDetectorList(fRunTracking,detMask);
1017 fFillESD = MatchDetectorList(fFillESD,detMask);
1018 fQADetectors = MatchDetectorList(fQADetectors,detMask);
1019 fLoadCDB.Form("%s %s %s %s",
1020 fRunLocalReconstruction.Data(),
1021 fRunTracking.Data(),
1023 fQADetectors.Data());
1024 fLoadCDB = MatchDetectorList(fLoadCDB,detMask);
1025 if (!((detMask >> AliDAQ::DetectorID("ITSSPD")) & 0x1) &&
1026 !((detMask >> AliDAQ::DetectorID("ITSSDD")) & 0x1) &&
1027 !((detMask >> AliDAQ::DetectorID("ITSSSD")) & 0x1) ) {
1028 // switch off the vertexer
1029 AliInfo("SPD,SDD,SSD is not in the list of active detectors. Vertexer switched off.");
1030 fRunVertexFinder = kFALSE;
1032 if (!((detMask >> AliDAQ::DetectorID("TRG")) & 0x1)) {
1033 // switch off the reading of CTP raw-data payload
1034 if (fFillTriggerESD) {
1035 AliInfo("CTP is not in the list of active detectors. CTP data reading switched off.");
1036 fFillTriggerESD = kFALSE;
1041 AliInfo("===================================================================================");
1042 AliInfo(Form("Running local reconstruction for detectors: %s",fRunLocalReconstruction.Data()));
1043 AliInfo(Form("Running tracking for detectors: %s",fRunTracking.Data()));
1044 AliInfo(Form("Filling ESD for detectors: %s",fFillESD.Data()));
1045 AliInfo(Form("Quality assurance is active for detectors: %s",fQADetectors.Data()));
1046 AliInfo(Form("CDB and reconstruction parameters are loaded for detectors: %s",fLoadCDB.Data()));
1047 AliInfo("===================================================================================");
1049 //*** Dealing with the magnetic field map
1050 if ( TGeoGlobalMagField::Instance()->IsLocked() ) {
1051 if (TGeoGlobalMagField::Instance()->GetField()->TestBit(AliMagF::kOverrideGRP)) {
1052 AliInfo("ExpertMode!!! GRP information will be ignored !");
1053 AliInfo("ExpertMode!!! Running with the externally locked B field !");
1056 AliInfo("Destroying existing B field instance!");
1057 delete TGeoGlobalMagField::Instance();
1060 if ( !TGeoGlobalMagField::Instance()->IsLocked() ) {
1061 // Construct the field map out of the information retrieved from GRP.
1064 Float_t l3Current = fGRPData->GetL3Current((AliGRPObject::Stats)0);
1065 if (l3Current == AliGRPObject::GetInvalidFloat()) {
1066 AliError("GRP/GRP/Data entry: missing value for the L3 current !");
1070 Char_t l3Polarity = fGRPData->GetL3Polarity();
1071 if (l3Polarity == AliGRPObject::GetInvalidChar()) {
1072 AliError("GRP/GRP/Data entry: missing value for the L3 polarity !");
1077 Float_t diCurrent = fGRPData->GetDipoleCurrent((AliGRPObject::Stats)0);
1078 if (diCurrent == AliGRPObject::GetInvalidFloat()) {
1079 AliError("GRP/GRP/Data entry: missing value for the dipole current !");
1083 Char_t diPolarity = fGRPData->GetDipolePolarity();
1084 if (diPolarity == AliGRPObject::GetInvalidChar()) {
1085 AliError("GRP/GRP/Data entry: missing value for the dipole polarity !");
1089 // read special bits for the polarity convention and map type
1090 Int_t polConvention = fGRPData->IsPolarityConventionLHC() ? AliMagF::kConvLHC : AliMagF::kConvDCS2008;
1091 Bool_t uniformB = fGRPData->IsUniformBMap();
1094 AliMagF* fld = AliMagF::CreateFieldMap(TMath::Abs(l3Current) * (l3Polarity ? -1:1),
1095 TMath::Abs(diCurrent) * (diPolarity ? -1:1),
1096 polConvention,uniformB,beamEnergy, beamType.Data());
1098 TGeoGlobalMagField::Instance()->SetField( fld );
1099 TGeoGlobalMagField::Instance()->Lock();
1100 AliInfo("Running with the B field constructed out of GRP !");
1102 else AliFatal("Failed to create a B field map !");
1104 else AliFatal("B field is neither set nor constructed from GRP ! Exitig...");
1107 //*** Get the diamond profiles from OCDB
1108 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexSPD");
1110 fDiamondProfileSPD = dynamic_cast<AliESDVertex*> (entry->GetObject());
1112 AliError("No SPD diamond profile found in OCDB!");
1115 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertex");
1117 fDiamondProfile = dynamic_cast<AliESDVertex*> (entry->GetObject());
1119 AliError("No diamond profile found in OCDB!");
1122 entry = AliCDBManager::Instance()->Get("GRP/Calib/MeanVertexTPC");
1124 fDiamondProfileTPC = dynamic_cast<AliESDVertex*> (entry->GetObject());
1126 AliError("No TPC diamond profile found in OCDB!");
1129 entry = AliCDBManager::Instance()->Get("GRP/Calib/CosmicTriggers");
1131 fListOfCosmicTriggers = dynamic_cast<THashTable*>(entry->GetObject());
1133 AliCDBManager::Instance()->UnloadFromCache("GRP/Calib/CosmicTriggers");
1136 if (!fListOfCosmicTriggers) {
1137 AliWarning("Can not get list of cosmic triggers from OCDB! Cosmic event specie will be effectively disabled!");
1143 //_____________________________________________________________________________
1144 Bool_t AliReconstruction::LoadCDB()
1146 AliCodeTimerAuto("",0);
1148 AliCDBManager::Instance()->Get("GRP/CTP/Config");
1150 TString detStr = fLoadCDB;
1151 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1152 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1153 AliCDBManager::Instance()->GetAll(Form("%s/Calib/*",fgkDetectorName[iDet]));
1156 // Temporary fix - one has to define the correct policy in order
1157 // to load the trigger OCDB entries only for the detectors that
1158 // in the trigger or that are needed in order to put correct
1159 // information in ESD
1160 AliCDBManager::Instance()->GetAll("TRIGGER/*/*");
1164 //_____________________________________________________________________________
1165 Bool_t AliReconstruction::LoadTriggerScalersCDB()
1167 AliCodeTimerAuto("",0);
1169 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/Scalers");
1173 AliInfo("Found an AliTriggerRunScalers in GRP/CTP/Scalers, reading it");
1174 fRunScalers = dynamic_cast<AliTriggerRunScalers*> (entry->GetObject());
1176 if (fRunScalers->CorrectScalersOverflow() == 0) AliInfo("32bit Trigger counters corrected for overflow");
1181 //_____________________________________________________________________________
1182 Bool_t AliReconstruction::LoadCTPTimeParamsCDB()
1184 AliCDBEntry* entry = AliCDBManager::Instance()->Get("GRP/CTP/CTPtiming");
1188 AliInfo("Found an AliCTPTimeParams in GRP/CTP/CTPtiming, reading it");
1189 fCTPTimeParams = dynamic_cast<AliCTPTimeParams*> (entry->GetObject());
1196 //_____________________________________________________________________________
1197 Bool_t AliReconstruction::Run(const char* input)
1200 AliCodeTimerAuto("",0);
1203 if (GetAbort() != TSelector::kContinue) return kFALSE;
1205 TChain *chain = NULL;
1206 if (fRawReader && (chain = fRawReader->GetChain())) {
1207 Long64_t nEntries = (fLastEvent < 0) ? (TChain::kBigNumber) : (fLastEvent - fFirstEvent + 1);
1210 // Temporary fix for long raw-data runs (until socket timeout handling in PROOF is revised)
1211 gProof->Exec("gEnv->SetValue(\"Proof.SocketActivityTimeout\",-1)", kTRUE);
1214 gProof->Exec("TGrid::Connect(\"alien://\")",kTRUE);
1216 TMessage::EnableSchemaEvolutionForAll(kTRUE);
1217 gProof->Exec("TMessage::EnableSchemaEvolutionForAll(kTRUE)",kTRUE);
1219 gProof->AddInput(this);
1221 if (!ParseOutput()) return kFALSE;
1223 gProof->SetParameter("PROOF_MaxSlavesPerNode", 9999);
1225 chain->Process("AliReconstruction","",nEntries,fFirstEvent);
1228 chain->Process(this,"",nEntries,fFirstEvent);
1233 if (GetAbort() != TSelector::kContinue) return kFALSE;
1235 if (GetAbort() != TSelector::kContinue) return kFALSE;
1236 //******* The loop over events
1237 AliInfo("Starting looping over events");
1239 while ((iEvent < fRunLoader->GetNumberOfEvents()) ||
1240 (fRawReader && fRawReader->NextEvent())) {
1241 if (!ProcessEvent(iEvent)) {
1242 Abort("ProcessEvent",TSelector::kAbortFile);
1248 if (GetAbort() != TSelector::kContinue) return kFALSE;
1250 if (GetAbort() != TSelector::kContinue) return kFALSE;
1256 //_____________________________________________________________________________
1257 void AliReconstruction::InitRawReader(const char* input)
1259 AliCodeTimerAuto("",0);
1261 // Init raw-reader and
1262 // set the input in case of raw data
1263 if (input) fRawInput = input;
1264 fRawReader = AliRawReader::Create(fRawInput.Data());
1266 if (fRawInput.IsNull()) {
1267 AliInfo("Reconstruction will run over digits");
1270 AliFatal("Can not create raw-data reader ! Exiting...");
1274 if (!fEquipIdMap.IsNull() && fRawReader)
1275 fRawReader->LoadEquipmentIdsMap(fEquipIdMap);
1277 if (!fUseHLTData.IsNull()) {
1278 // create the RawReaderHLT which performs redirection of HLT input data for
1279 // the specified detectors
1280 AliRawReader* pRawReader=AliRawHLTManager::CreateRawReaderHLT(fRawReader, fUseHLTData.Data());
1282 fParentRawReader=fRawReader;
1283 fRawReader=pRawReader;
1285 AliError(Form("can not create Raw Reader for HLT input %s", fUseHLTData.Data()));
1288 AliSysInfo::AddStamp("CreateRawReader");
1291 //_____________________________________________________________________________
1292 void AliReconstruction::InitRun(const char* input)
1294 // Initialization of raw-reader,
1295 // run number, CDB etc.
1296 AliCodeTimerAuto("",0);
1297 AliSysInfo::AddStamp("Start");
1299 // Initialize raw-reader if any
1300 InitRawReader(input);
1302 // Initialize the CDB storage
1305 // Set run number in CDBManager (if it is not already set by the user)
1306 if (!SetRunNumberFromData()) {
1307 Abort("SetRunNumberFromData", TSelector::kAbortProcess);
1311 // Set CDB lock: from now on it is forbidden to reset the run number
1312 // or the default storage or to activate any further storage!
1317 //_____________________________________________________________________________
1318 void AliReconstruction::Begin(TTree *)
1320 // Initialize AlReconstruction before
1321 // going into the event loop
1322 // Should follow the TSelector convention
1323 // i.e. initialize only the object on the client side
1324 AliCodeTimerAuto("",0);
1326 AliReconstruction *reco = NULL;
1328 if ((reco = (AliReconstruction*)fInput->FindObject("AliReconstruction"))) {
1331 AliSysInfo::AddStamp("ReadInputInBegin");
1334 // Import ideal TGeo geometry and apply misalignment
1336 TString geom(gSystem->DirName(fGAliceFileName));
1337 geom += "/geometry.root";
1338 AliGeomManager::LoadGeometry(geom.Data());
1340 Abort("LoadGeometry", TSelector::kAbortProcess);
1343 AliSysInfo::AddStamp("LoadGeom");
1344 TString detsToCheck=fRunLocalReconstruction;
1345 if(!AliGeomManager::CheckSymNamesLUT(detsToCheck.Data())) {
1346 Abort("CheckSymNamesLUT", TSelector::kAbortProcess);
1349 AliSysInfo::AddStamp("CheckGeom");
1352 if (!MisalignGeometry(fLoadAlignData)) {
1353 Abort("MisalignGeometry", TSelector::kAbortProcess);
1356 AliCDBManager::Instance()->UnloadFromCache("GRP/Geometry/Data");
1357 AliSysInfo::AddStamp("MisalignGeom");
1360 Abort("InitGRP", TSelector::kAbortProcess);
1363 AliSysInfo::AddStamp("InitGRP");
1366 Abort("LoadCDB", TSelector::kAbortProcess);
1369 AliSysInfo::AddStamp("LoadCDB");
1371 if (!LoadTriggerScalersCDB()) {
1372 Abort("LoadTriggerScalersCDB", TSelector::kAbortProcess);
1375 AliSysInfo::AddStamp("LoadTriggerScalersCDB");
1377 if (!LoadCTPTimeParamsCDB()) {
1378 Abort("LoadCTPTimeParamsCDB", TSelector::kAbortProcess);
1381 AliSysInfo::AddStamp("LoadCTPTimeParamsCDB");
1383 // Read the reconstruction parameters from OCDB
1384 if (!InitRecoParams()) {
1385 AliWarning("Not all detectors have correct RecoParam objects initialized");
1387 AliSysInfo::AddStamp("InitRecoParams");
1389 if (fInput && gProof) {
1390 if (reco) *reco = *this;
1392 gGeoManager->SetName("Geometry");
1393 gProof->AddInputData(gGeoManager,kTRUE);
1395 gProof->AddInputData(const_cast<TMap*>(AliCDBManager::Instance()->GetEntryCache()),kTRUE);
1396 fInput->Add(new TParameter<Int_t>("RunNumber",AliCDBManager::Instance()->GetRun()));
1397 AliMagF *magFieldMap = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1398 magFieldMap->SetName("MagneticFieldMap");
1399 gProof->AddInputData(magFieldMap,kTRUE);
1404 //_____________________________________________________________________________
1405 void AliReconstruction::SlaveBegin(TTree*)
1407 // Initialization related to run-loader,
1408 // vertexer, trackers, recontructors
1409 // In proof mode it is executed on the slave
1410 AliCodeTimerAuto("",0);
1412 TProofOutputFile *outProofFile = NULL;
1414 if (AliDebugLevel() > 0) fInput->Print();
1415 if (AliDebugLevel() > 10) fInput->Dump();
1416 if (AliReconstruction *reco = (AliReconstruction*)fInput->FindObject("AliReconstruction")) {
1419 if (TGeoManager *tgeo = (TGeoManager*)fInput->FindObject("Geometry")) {
1421 AliGeomManager::SetGeometry(tgeo);
1423 if (TMap *entryCache = (TMap*)fInput->FindObject("CDBEntryCache")) {
1424 Int_t runNumber = -1;
1425 if (TProof::GetParameter(fInput,"RunNumber",runNumber) == 0) {
1426 AliCDBManager *man = AliCDBManager::Instance(entryCache,runNumber);
1427 man->SetCacheFlag(kTRUE);
1428 man->SetLock(kTRUE);
1432 if (AliMagF *map = (AliMagF*)fInput->FindObject("MagneticFieldMap")) {
1433 AliMagF *newMap = new AliMagF(*map);
1434 if (!newMap->LoadParameterization()) {
1435 Abort("AliMagF::LoadParameterization", TSelector::kAbortProcess);
1438 TGeoGlobalMagField::Instance()->SetField(newMap);
1439 TGeoGlobalMagField::Instance()->Lock();
1441 if (TNamed *outputFileName = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE"))
1442 fProofOutputFileName = outputFileName->GetTitle();
1443 if (TNamed *outputLocation = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_LOCATION"))
1444 fProofOutputLocation = outputLocation->GetTitle();
1445 if (fInput->FindObject("PROOF_OUTPUTFILE_DATASET"))
1446 fProofOutputDataset = kTRUE;
1447 if (TNamed *archiveList = (TNamed*)fInput->FindObject("PROOF_OUTPUTFILE_ARCHIVE"))
1448 fProofOutputArchive = archiveList->GetTitle();
1449 if (!fProofOutputFileName.IsNull() &&
1450 !fProofOutputLocation.IsNull() &&
1451 fProofOutputArchive.IsNull()) {
1452 if (!fProofOutputDataset) {
1453 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"M");
1454 outProofFile->SetOutputFileName(Form("%s%s",fProofOutputLocation.Data(),fProofOutputFileName.Data()));
1457 outProofFile = new TProofOutputFile(fProofOutputFileName.Data(),"DROV",fProofOutputLocation.Data());
1459 if (AliDebugLevel() > 0) outProofFile->Dump();
1460 fOutput->Add(outProofFile);
1462 AliSysInfo::AddStamp("ReadInputInSlaveBegin");
1465 // get the run loader
1466 if (!InitRunLoader()) {
1467 Abort("InitRunLoader", TSelector::kAbortProcess);
1470 AliSysInfo::AddStamp("LoadLoader");
1472 ftVertexer = new AliVertexerTracks(AliTracker::GetBz());
1475 if (!fRunTracking.IsNull() && !CreateTrackers(fRunTracking)) {
1476 Abort("CreateTrackers", TSelector::kAbortProcess);
1479 AliSysInfo::AddStamp("CreateTrackers");
1481 // create the ESD output file and tree
1482 if (!outProofFile) {
1483 ffile = TFile::Open("AliESDs.root", "RECREATE");
1484 ffile->SetCompressionLevel(2);
1485 if (!ffile->IsOpen()) {
1486 Abort("OpenESDFile", TSelector::kAbortProcess);
1491 AliInfo(Form("Opening output PROOF file: %s/%s",
1492 outProofFile->GetDir(), outProofFile->GetFileName()));
1493 if (!(ffile = outProofFile->OpenFile("RECREATE"))) {
1494 Abort(Form("Problems opening output PROOF file: %s/%s",
1495 outProofFile->GetDir(), outProofFile->GetFileName()),
1496 TSelector::kAbortProcess);
1501 ftree = new TTree("esdTree", "Tree with ESD objects");
1502 fesd = new AliESDEvent();
1503 fesd->CreateStdContent();
1504 // add a so far non-std object to the ESD, this will
1505 // become part of the std content
1506 fesd->AddObject(new AliESDHLTDecision);
1508 fesd->WriteToTree(ftree);
1509 if (fWriteESDfriend) {
1510 ffileF = TFile::Open("AliESDfriends.root", "RECREATE");
1511 ftreeF = new TTree("esdFriendTree", "Tree with ESD Friend objects");
1512 fesdf = new AliESDfriend();
1513 ftreeF->Branch("ESDfriend.","AliESDfriend", &fesdf);
1514 fesd->AddObject(fesdf);
1517 ftree->GetUserInfo()->Add(fesd);
1519 fhlttree = new TTree("HLTesdTree", "Tree with HLT ESD objects");
1520 fhltesd = new AliESDEvent();
1521 fhltesd->CreateStdContent();
1522 // read the ESD template from CDB
1523 // HLT is allowed to put non-std content to its ESD, the non-std
1524 // objects need to be created before invocation of WriteToTree in
1525 // order to create all branches. Initialization is done from an
1526 // ESD layout template in CDB
1527 AliCDBManager* man = AliCDBManager::Instance();
1528 AliCDBPath hltESDConfigPath("HLT/ConfigHLT/esdLayout");
1529 AliCDBEntry* hltESDConfig=NULL;
1530 if (man->GetId(hltESDConfigPath)!=NULL &&
1531 (hltESDConfig=man->Get(hltESDConfigPath))!=NULL) {
1532 AliESDEvent* pESDLayout=dynamic_cast<AliESDEvent*>(hltESDConfig->GetObject());
1534 // init all internal variables from the list of objects
1535 pESDLayout->GetStdContent();
1537 // copy content and create non-std objects
1538 *fhltesd=*pESDLayout;
1541 AliError(Form("error setting hltEsd layout from %s: invalid object type",
1542 hltESDConfigPath.GetPath().Data()));
1546 fhltesd->WriteToTree(fhlttree);
1547 fhlttree->GetUserInfo()->Add(fhltesd);
1549 ProcInfo_t procInfo;
1550 gSystem->GetProcInfo(&procInfo);
1551 AliInfo(Form("Current memory usage %d %d", procInfo.fMemResident, procInfo.fMemVirtual));
1554 //Initialize the QA and start of cycle
1555 if (fRunQA || fRunGlobalQA)
1558 //Initialize the Plane Efficiency framework
1559 if (fRunPlaneEff && !InitPlaneEff()) {
1560 Abort("InitPlaneEff", TSelector::kAbortProcess);
1564 if (strcmp(gProgName,"alieve") == 0)
1565 fRunAliEVE = InitAliEVE();
1570 //_____________________________________________________________________________
1571 Bool_t AliReconstruction::Process(Long64_t entry)
1573 // run the reconstruction over a single entry
1574 // from the chain with raw data
1575 AliCodeTimerAuto("",0);
1577 TTree *currTree = fChain->GetTree();
1578 AliRawVEvent *event = NULL;
1579 currTree->SetBranchAddress("rawevent",&event);
1580 currTree->GetEntry(entry);
1581 fRawReader = new AliRawReaderRoot(event);
1582 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
1590 //_____________________________________________________________________________
1591 void AliReconstruction::Init(TTree *tree)
1594 AliError("The input tree is not found!");
1600 //_____________________________________________________________________________
1601 Bool_t AliReconstruction::ProcessEvent(Int_t iEvent)
1603 // run the reconstruction over a single event
1604 // The event loop is steered in Run method
1607 static Long_t oldMres=0;
1608 static Long_t oldMvir=0;
1609 static Float_t oldCPU=0;
1610 static Long_t aveDMres=0;
1611 static Long_t aveDMvir=0;
1612 static Float_t aveDCPU=0;
1614 AliCodeTimerAuto("",0);
1618 if (iEvent >= fRunLoader->GetNumberOfEvents()) {
1619 fRunLoader->SetEventNumber(iEvent);
1620 fRunLoader->GetHeader()->Reset(fRawReader->GetRunNumber(),
1622 fRunLoader->TreeE()->Fill();
1623 if (fRawReader && fRawReader->UseAutoSaveESD())
1624 fRunLoader->TreeE()->AutoSave("SaveSelf");
1627 if ((iEvent < fFirstEvent) || ((fLastEvent >= 0) && (iEvent > fLastEvent))) {
1632 fRunLoader->GetEvent(iEvent);
1634 // Fill Event-info object
1636 fRecoParam.SetEventSpecie(fRunInfo,fEventInfo,fListOfCosmicTriggers);
1638 ProcInfo_t procInfo;
1639 if(iEvent==fFirstEvent) {
1640 gSystem->GetProcInfo(&procInfo);
1641 oldMres=procInfo.fMemResident;
1642 oldMvir=procInfo.fMemVirtual;
1643 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
1645 AliInfo(Form("================================= Processing event %d of type %-10s ==================================", iEvent,fRecoParam.PrintEventSpecie()));
1647 // Set the reco-params
1649 TString detStr = fLoadCDB;
1650 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1651 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
1652 AliReconstructor *reconstructor = GetReconstructor(iDet);
1653 if (reconstructor && fRecoParam.GetDetRecoParamArray(iDet)) {
1654 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
1655 reconstructor->SetRecoParam(par);
1656 reconstructor->GetPidSettings(&PID);
1657 reconstructor->SetEventInfo(&fEventInfo);
1659 AliQAManager::QAManager()->SetRecoParam(iDet, par) ;
1660 if (par) AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(par->GetEventSpecie())) ;
1665 const AliDetectorRecoParam *grppar = fRecoParam.GetDetRecoParam(kNDetectors);
1666 AliQAManager::QAManager()->SetRecoParam(AliQAv1::kGLOBAL, grppar) ;
1667 AliQAManager::QAManager()->SetEventSpecie(AliRecoParam::Convert(grppar->GetEventSpecie())) ;
1672 if (fRunQA && IsInTasks(AliQAv1::kRAWS)) {
1673 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1674 AliQAManager::QAManager()->RunOneEvent(fRawReader) ;
1676 // local single event reconstruction
1677 if (!fRunLocalReconstruction.IsNull()) {
1678 TString detectors=fRunLocalReconstruction;
1679 // run HLT event reconstruction first
1680 // ;-( IsSelected changes the string
1681 if (IsSelected("HLT", detectors) &&
1682 !RunLocalEventReconstruction("HLT")) {
1683 if (fStopOnError) {CleanUp(); return kFALSE;}
1685 detectors=fRunLocalReconstruction;
1686 detectors.ReplaceAll("HLT", "");
1687 if (!RunLocalEventReconstruction(detectors)) {
1696 // fill Event header information from the RawEventHeader
1697 if (fRawReader){FillRawEventHeaderESD(fesd);}
1698 if (fRawReader){FillRawEventHeaderESD(fhltesd);}
1700 fesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1701 fhltesd->SetRunNumber(fRunLoader->GetHeader()->GetRun());
1702 fesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1703 fhltesd->SetEventNumberInFile(fRunLoader->GetHeader()->GetEventNrInRun());
1705 fesd->SetEventSpecie(fRecoParam.GetEventSpecie());
1706 fhltesd->SetEventSpecie(fRecoParam.GetEventSpecie());
1708 // Set magnetic field from the tracker
1709 fesd->SetMagneticField(AliTracker::GetBz());
1710 fhltesd->SetMagneticField(AliTracker::GetBz());
1712 ((AliESDRun*)fesd->GetESDRun())->SetBeamEnergyIsSqrtSHalfGeV();
1713 ((AliESDRun*)fhltesd->GetESDRun())->SetBeamEnergyIsSqrtSHalfGeV();
1715 AliMagF* fld = (AliMagF*)TGeoGlobalMagField::Instance()->GetField();
1716 if (fld) { // set info needed for field initialization
1717 fesd->SetCurrentL3(fld->GetCurrentSol());
1718 fesd->SetCurrentDip(fld->GetCurrentDip());
1719 fesd->SetBeamEnergy(fld->GetBeamEnergy());
1720 fesd->SetBeamType(fld->GetBeamTypeText());
1721 fesd->SetUniformBMap(fld->IsUniform());
1722 fesd->SetBInfoStored();
1724 fhltesd->SetCurrentL3(fld->GetCurrentSol());
1725 fhltesd->SetCurrentDip(fld->GetCurrentDip());
1726 fhltesd->SetBeamEnergy(fld->GetBeamEnergy());
1727 fhltesd->SetBeamType(fld->GetBeamTypeText());
1728 fhltesd->SetUniformBMap(fld->IsUniform());
1729 fhltesd->SetBInfoStored();
1732 // Set most probable pt, for B=0 tracking
1733 // Get the global reco-params. They are atposition 16 inside the array of detectors in fRecoParam
1734 const AliGRPRecoParam *grpRecoParam = dynamic_cast<const AliGRPRecoParam*>(fRecoParam.GetDetRecoParam(kNDetectors));
1735 if (grpRecoParam) AliExternalTrackParam::SetMostProbablePt(grpRecoParam->GetMostProbablePt());
1737 // Fill raw-data error log into the ESD
1738 if (fRawReader) FillRawDataErrorLog(iEvent,fesd);
1741 if (fRunVertexFinder) {
1742 if (!RunVertexFinder(fesd)) {
1743 if (fStopOnError) {CleanUp(); return kFALSE;}
1747 // For Plane Efficiency: run the SPD trackleter
1748 if (fRunPlaneEff && fSPDTrackleter) {
1749 if (!RunSPDTrackleting(fesd)) {
1750 if (fStopOnError) {CleanUp(); return kFALSE;}
1755 if (!fRunTracking.IsNull()) {
1756 if (fRunMuonTracking) {
1757 if (!RunMuonTracking(fesd)) {
1758 if (fStopOnError) {CleanUp(); return kFALSE;}
1764 if (!fRunTracking.IsNull()) {
1765 if (!RunTracking(fesd,PID)) {
1766 if (fStopOnError) {CleanUp(); return kFALSE;}
1771 if (!fFillESD.IsNull()) {
1772 TString detectors=fFillESD;
1773 // run HLT first and on hltesd
1774 // ;-( IsSelected changes the string
1775 if (IsSelected("HLT", detectors) &&
1776 !FillESD(fhltesd, "HLT")) {
1777 if (fStopOnError) {CleanUp(); return kFALSE;}
1780 // Temporary fix to avoid problems with HLT that overwrites the offline ESDs
1781 if (detectors.Contains("ALL")) {
1783 for (Int_t idet=0; idet<kNDetectors; ++idet){
1784 detectors += fgkDetectorName[idet];
1788 detectors.ReplaceAll("HLT", "");
1789 if (!FillESD(fesd, detectors)) {
1790 if (fStopOnError) {CleanUp(); return kFALSE;}
1797 if (fFillTriggerESD) {
1798 if (!FillTriggerESD(fesd)) {
1799 if (fStopOnError) {CleanUp(); return kFALSE;}
1802 // Always fill scalers
1803 if (!FillTriggerScalers(fesd)) {
1804 if (fStopOnError) {CleanUp(); return kFALSE;}
1811 // Propagate track to the beam pipe (if not already done by ITS)
1813 const Int_t ntracks = fesd->GetNumberOfTracks();
1814 const Double_t kRadius = 2.8; //something less than the beam pipe radius
1817 UShort_t *selectedIdx=new UShort_t[ntracks];
1819 for (Int_t itrack=0; itrack<ntracks; itrack++){
1820 const Double_t kMaxStep = 1; //max step over the material
1823 AliESDtrack *track = fesd->GetTrack(itrack);
1824 if (!track) continue;
1826 AliExternalTrackParam *tpcTrack =
1827 (AliExternalTrackParam *)track->GetTPCInnerParam();
1831 PropagateTrackToBxByBz(tpcTrack,kRadius,track->GetMass(),kMaxStep,kFALSE);
1834 Int_t n=trkArray.GetEntriesFast();
1835 selectedIdx[n]=track->GetID();
1836 trkArray.AddLast(tpcTrack);
1839 //Tracks refitted by ITS should already be at the SPD vertex
1840 if (track->IsOn(AliESDtrack::kITSrefit)) continue;
1843 PropagateTrackToBxByBz(track,kRadius,track->GetMass(),kMaxStep,kFALSE);
1844 Double_t x[3]; track->GetXYZ(x);
1845 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1846 track->RelateToVertexBxByBz(fesd->GetPrimaryVertexSPD(), b, kVeryBig);
1851 // Improve the reconstructed primary vertex position using the tracks
1853 Bool_t runVertexFinderTracks = fRunVertexFinderTracks;
1854 if(fesd->GetPrimaryVertexSPD()) {
1855 TString vtitle = fesd->GetPrimaryVertexSPD()->GetTitle();
1856 if(vtitle.Contains("cosmics")) {
1857 runVertexFinderTracks=kFALSE;
1861 if (runVertexFinderTracks) {
1862 // TPC + ITS primary vertex
1863 ftVertexer->SetITSMode();
1864 ftVertexer->SetConstraintOff();
1865 // get cuts for vertexer from AliGRPRecoParam
1867 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1868 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1869 grpRecoParam->GetVertexerTracksCutsITS(cutsVertexer);
1870 ftVertexer->SetCuts(cutsVertexer);
1871 delete [] cutsVertexer; cutsVertexer = NULL;
1872 if(fDiamondProfile && grpRecoParam->GetVertexerTracksConstraintITS())
1873 ftVertexer->SetVtxStart(fDiamondProfile);
1875 AliESDVertex *pvtx=ftVertexer->FindPrimaryVertex(fesd);
1877 if (pvtx->GetStatus()) {
1878 fesd->SetPrimaryVertexTracks(pvtx);
1879 for (Int_t i=0; i<ntracks; i++) {
1880 AliESDtrack *t = fesd->GetTrack(i);
1881 Double_t x[3]; t->GetXYZ(x);
1882 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1883 t->RelateToVertexBxByBz(pvtx, b, kVeryBig);
1886 delete pvtx; pvtx=NULL;
1889 // TPC-only primary vertex
1890 ftVertexer->SetTPCMode();
1891 ftVertexer->SetConstraintOff();
1892 // get cuts for vertexer from AliGRPRecoParam
1894 Int_t nCutsVertexer = grpRecoParam->GetVertexerTracksNCuts();
1895 Double_t *cutsVertexer = new Double_t[nCutsVertexer];
1896 grpRecoParam->GetVertexerTracksCutsTPC(cutsVertexer);
1897 ftVertexer->SetCuts(cutsVertexer);
1898 delete [] cutsVertexer; cutsVertexer = NULL;
1899 if(fDiamondProfileTPC && grpRecoParam->GetVertexerTracksConstraintTPC())
1900 ftVertexer->SetVtxStart(fDiamondProfileTPC);
1902 pvtx=ftVertexer->FindPrimaryVertex(&trkArray,selectedIdx);
1904 if (pvtx->GetStatus()) {
1905 fesd->SetPrimaryVertexTPC(pvtx);
1906 for (Int_t i=0; i<ntracks; i++) {
1907 AliESDtrack *t = fesd->GetTrack(i);
1908 Double_t x[3]; t->GetXYZ(x);
1909 Double_t b[3]; AliTracker::GetBxByBz(x,b);
1910 t->RelateToVertexTPCBxByBz(pvtx, b, kVeryBig);
1913 delete pvtx; pvtx=NULL;
1917 delete[] selectedIdx;
1919 if(fDiamondProfile) fesd->SetDiamond(fDiamondProfile);
1924 AliV0vertexer vtxer;
1925 vtxer.Tracks2V0vertices(fesd);
1927 if (fRunCascadeFinder) {
1929 AliCascadeVertexer cvtxer;
1930 cvtxer.V0sTracks2CascadeVertices(fesd);
1935 if (fCleanESD) CleanESD(fesd);
1937 if (fRunQA && IsInTasks(AliQAv1::kESDS)) {
1938 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1939 AliQAManager::QAManager()->RunOneEvent(fesd, fhltesd) ;
1942 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
1943 qadm->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
1944 if (qadm && IsInTasks(AliQAv1::kESDS))
1945 qadm->Exec(AliQAv1::kESDS, fesd);
1948 // copy HLT decision from HLTesd to esd
1949 // the most relevant information is stored in a reduced container in the esd,
1950 // while the full information can be found in the HLTesd
1951 TObject* pHLTSrc=fhltesd->FindListObject(AliESDHLTDecision::Name());
1952 TObject* pHLTTgt=fesd->FindListObject(AliESDHLTDecision::Name());
1953 if (pHLTSrc && pHLTTgt) {
1954 pHLTSrc->Copy(*pHLTTgt);
1957 if (fWriteESDfriend)
1958 fesd->GetESDfriend(fesdf);
1961 if (fWriteESDfriend) ftreeF->Fill();
1963 // Auto-save the ESD tree in case of prompt reco @P2
1964 if (fRawReader && fRawReader->UseAutoSaveESD()) {
1965 ftree->AutoSave("SaveSelf");
1966 if (fWriteESDfriend) ftreeF->AutoSave("SaveSelf");
1967 TFile *friendfile = (TFile *)(gROOT->GetListOfFiles()->FindObject("AliESDfriends.root"));
1968 if (friendfile) friendfile->Save();
1975 if (fRunAliEVE) RunAliEVE();
1979 if (fWriteESDfriend) {
1980 fesdf->~AliESDfriend();
1981 new (fesdf) AliESDfriend(); // Reset...
1984 gSystem->GetProcInfo(&procInfo);
1985 Long_t dMres=(procInfo.fMemResident-oldMres)/1024;
1986 Long_t dMvir=(procInfo.fMemVirtual-oldMvir)/1024;
1987 Float_t dCPU=procInfo.fCpuUser+procInfo.fCpuSys-oldCPU;
1988 aveDMres+=(dMres-aveDMres)/(iEvent-fFirstEvent+1);
1989 aveDMvir+=(dMvir-aveDMvir)/(iEvent-fFirstEvent+1);
1990 aveDCPU+=(dCPU-aveDCPU)/(iEvent-fFirstEvent+1);
1991 AliInfo(Form("======================= End Event %d: Res %d(%3d <%3d>) Vir %d(%3d <%3d>) CPU %5.2f <%5.2f> ===================",
1992 iEvent, procInfo.fMemResident/1024, dMres, aveDMres, procInfo.fMemVirtual/1024, dMvir, aveDMvir, dCPU, aveDCPU));
1993 oldMres=procInfo.fMemResident;
1994 oldMvir=procInfo.fMemVirtual;
1995 oldCPU=procInfo.fCpuUser+procInfo.fCpuSys;
1998 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
1999 if (fReconstructor[iDet]) {
2000 fReconstructor[iDet]->SetRecoParam(NULL);
2001 fReconstructor[iDet]->SetEventInfo(NULL);
2003 if (fTracker[iDet]) fTracker[iDet]->SetEventInfo(NULL);
2006 if (fRunQA || fRunGlobalQA)
2007 AliQAManager::QAManager()->Increment() ;
2012 //_____________________________________________________________________________
2013 void AliReconstruction::SlaveTerminate()
2015 // Finalize the run on the slave side
2016 // Called after the exit
2017 // from the event loop
2018 AliCodeTimerAuto("",0);
2020 if (fIsNewRunLoader) { // galice.root didn't exist
2021 fRunLoader->WriteHeader("OVERWRITE");
2022 fRunLoader->CdGAFile();
2023 fRunLoader->Write(0, TObject::kOverwrite);
2026 const TMap *cdbMap = AliCDBManager::Instance()->GetStorageMap();
2027 const TList *cdbList = AliCDBManager::Instance()->GetRetrievedIds();
2029 TMap *cdbMapCopy = new TMap(cdbMap->GetEntries());
2030 cdbMapCopy->SetOwner(1);
2031 cdbMapCopy->SetName("cdbMap");
2032 TIter iter(cdbMap->GetTable());
2035 while((pair = dynamic_cast<TPair*> (iter.Next()))){
2036 TObjString* keyStr = dynamic_cast<TObjString*> (pair->Key());
2037 TObjString* valStr = dynamic_cast<TObjString*> (pair->Value());
2038 cdbMapCopy->Add(new TObjString(keyStr->GetName()), new TObjString(valStr->GetName()));
2041 TList *cdbListCopy = new TList();
2042 cdbListCopy->SetOwner(1);
2043 cdbListCopy->SetName("cdbList");
2045 TIter iter2(cdbList);
2048 while((id = dynamic_cast<AliCDBId*> (iter2.Next()))){
2049 cdbListCopy->Add(new TObjString(id->ToString().Data()));
2052 ftree->GetUserInfo()->Add(cdbMapCopy);
2053 ftree->GetUserInfo()->Add(cdbListCopy);
2058 // we want to have only one tree version number
2059 ftree->Write(ftree->GetName(),TObject::kOverwrite);
2060 fhlttree->Write(fhlttree->GetName(),TObject::kOverwrite);
2062 if (fWriteESDfriend) {
2064 ftreeF->Write(ftreeF->GetName(),TObject::kOverwrite);
2067 // Finish with Plane Efficiency evaluation: before of CleanUp !!!
2068 if (fRunPlaneEff && !FinishPlaneEff()) {
2069 AliWarning("Finish PlaneEff evaluation failed");
2072 // End of cycle for the in-loop
2074 if (fRunQA || fRunGlobalQA) {
2075 AliQAManager::QAManager()->EndOfCycle() ;
2077 !fProofOutputLocation.IsNull() &&
2078 fProofOutputArchive.IsNull() &&
2079 !fProofOutputDataset) {
2080 TString qaOutputFile(Form("%sMerged.%s.Data.root",
2081 fProofOutputLocation.Data(),
2082 AliQAv1::GetQADataFileName()));
2083 TProofOutputFile *qaProofFile = new TProofOutputFile(Form("Merged.%s.Data.root",
2084 AliQAv1::GetQADataFileName()));
2085 qaProofFile->SetOutputFileName(qaOutputFile.Data());
2086 if (AliDebugLevel() > 0) qaProofFile->Dump();
2087 fOutput->Add(qaProofFile);
2088 MergeQA(qaProofFile->GetFileName());
2099 if (!fProofOutputFileName.IsNull() &&
2100 !fProofOutputLocation.IsNull() &&
2101 fProofOutputDataset &&
2102 !fProofOutputArchive.IsNull()) {
2103 TProofOutputFile *zipProofFile = new TProofOutputFile(fProofOutputFileName.Data(),
2105 fProofOutputLocation.Data());
2106 if (AliDebugLevel() > 0) zipProofFile->Dump();
2107 fOutput->Add(zipProofFile);
2108 TString fileList(fProofOutputArchive.Data());
2109 fileList.ReplaceAll(","," ");
2111 #if ROOT_SVN_REVISION >= 30174
2112 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(kTRUE),zipProofFile->GetFileName(),fileList.Data());
2114 command.Form("zip -n root %s/%s %s",zipProofFile->GetDir(),zipProofFile->GetFileName(),fileList.Data());
2116 AliInfo(Form("Executing: %s",command.Data()));
2117 gSystem->Exec(command.Data());
2122 //_____________________________________________________________________________
2123 void AliReconstruction::Terminate()
2125 // Create tags for the events in the ESD tree (the ESD tree is always present)
2126 // In case of empty events the tags will contain dummy values
2127 AliCodeTimerAuto("",0);
2129 // Do not call the ESD tag creator in case of PROOF-based reconstruction
2131 AliESDTagCreator *esdtagCreator = new AliESDTagCreator();
2132 esdtagCreator->CreateESDTags(fFirstEvent,fLastEvent,fGRPData, AliQAv1::Instance()->GetQA(), AliQAv1::Instance()->GetEventSpecies(), AliQAv1::kNDET, AliRecoParam::kNSpecies);
2133 delete esdtagCreator;
2136 // Cleanup of CDB manager: cache and active storages!
2137 AliCDBManager::Instance()->ClearCache();
2140 //_____________________________________________________________________________
2141 Bool_t AliReconstruction::RunLocalEventReconstruction(const TString& detectors)
2143 // run the local reconstruction
2145 static Int_t eventNr=0;
2146 AliCodeTimerAuto("",0)
2148 TString detStr = detectors;
2149 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2150 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2151 AliReconstructor* reconstructor = GetReconstructor(iDet);
2152 if (!reconstructor) continue;
2153 AliLoader* loader = fLoader[iDet];
2154 // Matthias April 2008: temporary fix to run HLT reconstruction
2155 // although the HLT loader is missing
2156 if (strcmp(fgkDetectorName[iDet], "HLT")==0) {
2158 reconstructor->Reconstruct(fRawReader, NULL);
2161 reconstructor->Reconstruct(dummy, NULL);
2166 AliWarning(Form("No loader is defined for %s!",fgkDetectorName[iDet]));
2169 // conversion of digits
2170 if (fRawReader && reconstructor->HasDigitConversion()) {
2171 AliInfo(Form("converting raw data digits into root objects for %s",
2172 fgkDetectorName[iDet]));
2173 // AliCodeTimerAuto(Form("converting raw data digits into root objects for %s",
2174 // fgkDetectorName[iDet]),0);
2175 loader->LoadDigits("update");
2176 loader->CleanDigits();
2177 loader->MakeDigitsContainer();
2178 TTree* digitsTree = loader->TreeD();
2179 reconstructor->ConvertDigits(fRawReader, digitsTree);
2180 loader->WriteDigits("OVERWRITE");
2181 loader->UnloadDigits();
2183 // local reconstruction
2184 AliInfo(Form("running reconstruction for %s", fgkDetectorName[iDet]));
2185 //AliCodeTimerAuto(Form("running reconstruction for %s", fgkDetectorName[iDet]),0);
2186 loader->LoadRecPoints("update");
2187 loader->CleanRecPoints();
2188 loader->MakeRecPointsContainer();
2189 TTree* clustersTree = loader->TreeR();
2190 if (fRawReader && !reconstructor->HasDigitConversion()) {
2191 reconstructor->Reconstruct(fRawReader, clustersTree);
2193 loader->LoadDigits("read");
2194 TTree* digitsTree = loader->TreeD();
2196 AliError(Form("Can't get the %s digits tree", fgkDetectorName[iDet]));
2200 reconstructor->Reconstruct(digitsTree, clustersTree);
2201 if (fRunQA && IsInTasks(AliQAv1::kDIGITSR)) {
2202 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2203 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, digitsTree) ;
2206 loader->UnloadDigits();
2208 if (fRunQA && IsInTasks(AliQAv1::kRECPOINTS)) {
2209 AliQAManager::QAManager()->SetEventSpecie(fRecoParam.GetEventSpecie()) ;
2210 AliQAManager::QAManager()->RunOneEventInOneDetector(iDet, clustersTree) ;
2212 loader->WriteRecPoints("OVERWRITE");
2213 loader->UnloadRecPoints();
2214 AliSysInfo::AddStamp(Form("LRec%s_%d",fgkDetectorName[iDet],eventNr), iDet,1,eventNr);
2216 IsSelected("CTP", detStr);
2217 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2218 AliError(Form("the following detectors were not found: %s",
2226 //_____________________________________________________________________________
2227 Bool_t AliReconstruction::RunSPDTrackleting(AliESDEvent*& esd)
2229 // run the SPD trackleting (for SPD efficiency purpouses)
2231 AliCodeTimerAuto("",0)
2233 Double_t vtxPos[3] = {0, 0, 0};
2234 Double_t vtxErr[3] = {0.0, 0.0, 0.0};
2236 TArrayF mcVertex(3);
2238 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
2239 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
2240 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
2243 const AliESDVertex *vertex = esd->GetVertex();
2245 AliWarning("Vertex not found");
2248 vertex->GetXYZ(vtxPos);
2249 vertex->GetSigmaXYZ(vtxErr);
2250 if (fSPDTrackleter) {
2251 AliInfo("running the SPD Trackleter for Plane Efficiency Evaluation");
2254 fLoader[0]->LoadRecPoints("read");
2255 TTree* tree = fLoader[0]->TreeR();
2257 AliError("Can't get the ITS cluster tree");
2260 fSPDTrackleter->LoadClusters(tree);
2261 fSPDTrackleter->SetVertex(vtxPos, vtxErr);
2263 if (fSPDTrackleter->Clusters2Tracks(esd) != 0) {
2264 AliWarning("AliITSTrackleterSPDEff Clusters2Tracks failed");
2265 // fLoader[0]->UnloadRecPoints();
2268 //fSPDTrackleter->UnloadRecPoints();
2270 AliWarning("SPDTrackleter not available");
2276 //_____________________________________________________________________________
2277 Bool_t AliReconstruction::RunVertexFinder(AliESDEvent*& esd)
2279 // run the barrel tracking
2281 AliCodeTimerAuto("",0)
2283 AliVertexer *vertexer = CreateVertexer();
2284 if (!vertexer) return kFALSE;
2286 AliInfo("running the ITS vertex finder");
2287 AliESDVertex* vertex = NULL;
2289 fLoader[0]->LoadRecPoints();
2290 TTree* cltree = fLoader[0]->TreeR();
2292 if(fDiamondProfileSPD) vertexer->SetVtxStart(fDiamondProfileSPD);
2293 vertex = vertexer->FindVertexForCurrentEvent(cltree);
2296 AliError("Can't get the ITS cluster tree");
2298 fLoader[0]->UnloadRecPoints();
2301 AliError("Can't get the ITS loader");
2304 AliWarning("Vertex not found");
2305 vertex = new AliESDVertex();
2306 vertex->SetName("default");
2309 vertex->SetName("reconstructed");
2314 vertex->GetXYZ(vtxPos);
2315 vertex->GetSigmaXYZ(vtxErr);
2317 esd->SetPrimaryVertexSPD(vertex);
2318 AliESDVertex *vpileup = NULL;
2319 Int_t novertices = 0;
2320 vpileup = vertexer->GetAllVertices(novertices);
2322 for (Int_t kk=1; kk<novertices; kk++)esd->AddPileupVertexSPD(&vpileup[kk]);
2324 // if SPD multiplicity has been determined, it is stored in the ESD
2325 AliMultiplicity *mult = vertexer->GetMultiplicity();
2326 if(mult)esd->SetMultiplicity(mult);
2328 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2329 if (fTracker[iDet]) fTracker[iDet]->SetVertex(vtxPos, vtxErr);
2338 //_____________________________________________________________________________
2339 Bool_t AliReconstruction::RunHLTTracking(AliESDEvent*& esd)
2341 // run the HLT barrel tracking
2343 AliCodeTimerAuto("",0)
2346 AliError("Missing runLoader!");
2350 AliInfo("running HLT tracking");
2352 // Get a pointer to the HLT reconstructor
2353 AliReconstructor *reconstructor = GetReconstructor(kNDetectors-1);
2354 if (!reconstructor) return kFALSE;
2357 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2358 TString detName = fgkDetectorName[iDet];
2359 AliDebug(1, Form("%s HLT tracking", detName.Data()));
2360 reconstructor->SetOption(detName.Data());
2361 AliTracker *tracker = reconstructor->CreateTracker();
2363 AliWarning(Form("couldn't create a HLT tracker for %s", detName.Data()));
2364 if (fStopOnError) return kFALSE;
2368 Double_t vtxErr[3]={0.005,0.005,0.010};
2369 const AliESDVertex *vertex = esd->GetVertex();
2370 vertex->GetXYZ(vtxPos);
2371 tracker->SetVertex(vtxPos,vtxErr);
2373 fLoader[iDet]->LoadRecPoints("read");
2374 TTree* tree = fLoader[iDet]->TreeR();
2376 AliError(Form("Can't get the %s cluster tree", detName.Data()));
2379 tracker->LoadClusters(tree);
2381 if (tracker->Clusters2Tracks(esd) != 0) {
2382 AliError(Form("HLT %s Clusters2Tracks failed", fgkDetectorName[iDet]));
2386 tracker->UnloadClusters();
2394 //_____________________________________________________________________________
2395 Bool_t AliReconstruction::RunMuonTracking(AliESDEvent*& esd)
2397 // run the muon spectrometer tracking
2399 AliCodeTimerAuto("",0)
2402 AliError("Missing runLoader!");
2405 Int_t iDet = 7; // for MUON
2407 AliInfo("is running...");
2409 // Get a pointer to the MUON reconstructor
2410 AliReconstructor *reconstructor = GetReconstructor(iDet);
2411 if (!reconstructor) return kFALSE;
2414 TString detName = fgkDetectorName[iDet];
2415 AliDebug(1, Form("%s tracking", detName.Data()));
2416 AliTracker *tracker = reconstructor->CreateTracker();
2418 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
2423 fLoader[iDet]->LoadRecPoints("read");
2425 tracker->LoadClusters(fLoader[iDet]->TreeR());
2427 Int_t rv = tracker->Clusters2Tracks(esd);
2429 fLoader[iDet]->UnloadRecPoints();
2431 tracker->UnloadClusters();
2437 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2445 //_____________________________________________________________________________
2446 Bool_t AliReconstruction::RunTracking(AliESDEvent*& esd,AliESDpid &PID)
2448 // run the barrel tracking
2449 static Int_t eventNr=0;
2450 AliCodeTimerAuto("",0)
2452 AliInfo("running tracking");
2454 // Set the event info which is used
2455 // by the trackers in order to obtain
2456 // information about read-out detectors,
2458 AliDebug(1, "Setting event info");
2459 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2460 if (!fTracker[iDet]) continue;
2461 fTracker[iDet]->SetEventInfo(&fEventInfo);
2464 //Fill the ESD with the T0 info (will be used by the TOF)
2465 if (fReconstructor[11] && fLoader[11]) {
2466 fLoader[11]->LoadRecPoints("READ");
2467 TTree *treeR = fLoader[11]->TreeR();
2469 GetReconstructor(11)->FillESD((TTree *)NULL,treeR,esd);
2473 // pass 1: TPC + ITS inwards
2474 for (Int_t iDet = 1; iDet >= 0; iDet--) {
2475 if (!fTracker[iDet]) continue;
2476 AliDebug(1, Form("%s tracking", fgkDetectorName[iDet]));
2479 fLoader[iDet]->LoadRecPoints("read");
2480 AliSysInfo::AddStamp(Form("RLoadCluster%s_%d",fgkDetectorName[iDet],eventNr),iDet,1, eventNr);
2481 TTree* tree = fLoader[iDet]->TreeR();
2483 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2486 fTracker[iDet]->LoadClusters(tree);
2487 AliSysInfo::AddStamp(Form("TLoadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2489 if (fTracker[iDet]->Clusters2Tracks(esd) != 0) {
2490 AliError(Form("%s Clusters2Tracks failed", fgkDetectorName[iDet]));
2493 // preliminary PID in TPC needed by the ITS tracker
2495 GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2496 PID.MakePID(esd,kTRUE);
2498 AliSysInfo::AddStamp(Form("Tracking0%s_%d",fgkDetectorName[iDet],eventNr), iDet,3,eventNr);
2501 // pass 2: ALL backwards
2503 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2504 if (!fTracker[iDet]) continue;
2505 AliDebug(1, Form("%s back propagation", fgkDetectorName[iDet]));
2508 if (iDet > 1) { // all except ITS, TPC
2510 fLoader[iDet]->LoadRecPoints("read");
2511 AliSysInfo::AddStamp(Form("RLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,1, eventNr);
2512 tree = fLoader[iDet]->TreeR();
2514 AliError(Form("Can't get the %s cluster tree", fgkDetectorName[iDet]));
2517 fTracker[iDet]->LoadClusters(tree);
2518 AliSysInfo::AddStamp(Form("TLoadCluster0%s_%d",fgkDetectorName[iDet],eventNr), iDet,2, eventNr);
2522 if (iDet>1) // start filling residuals for the "outer" detectors
2524 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2525 TObjArray ** arr = AliTracker::GetResidualsArray() ;
2527 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
2528 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
2529 if ( elem && (! elem->At(0)) ) {
2530 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2531 if (qadm) qadm->InitRecPointsForTracker() ;
2535 if (fTracker[iDet]->PropagateBack(esd) != 0) {
2536 AliError(Form("%s backward propagation failed", fgkDetectorName[iDet]));
2541 if (iDet > 3) { // all except ITS, TPC, TRD and TOF
2542 fTracker[iDet]->UnloadClusters();
2543 fLoader[iDet]->UnloadRecPoints();
2545 // updated PID in TPC needed by the ITS tracker -MI
2547 //GetReconstructor(1)->FillESD((TTree*)NULL, (TTree*)NULL, esd);
2548 //AliESDpid::MakePID(esd);
2549 PID.MakePID(esd,kTRUE);
2551 AliSysInfo::AddStamp(Form("Tracking1%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2553 //stop filling residuals for the "outer" detectors
2554 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
2556 // pass 3: TRD + TPC + ITS refit inwards
2558 for (Int_t iDet = 2; iDet >= 0; iDet--) {
2559 if (!fTracker[iDet]) continue;
2560 AliDebug(1, Form("%s inward refit", fgkDetectorName[iDet]));
2563 if (iDet<2) // start filling residuals for TPC and ITS
2565 AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kTRUE);
2566 TObjArray ** arr = AliTracker::GetResidualsArray() ;
2568 AliRecoParam::EventSpecie_t es=fRecoParam.GetEventSpecie();
2569 TObjArray * elem = arr[AliRecoParam::AConvert(es)];
2570 if ( elem && (! elem->At(0)) ) {
2571 AliQADataMaker *qadm = AliQAManager::QAManager()->GetQADataMaker(AliQAv1::kGLOBAL);
2572 if (qadm) qadm->InitRecPointsForTracker() ;
2577 if (fTracker[iDet]->RefitInward(esd) != 0) {
2578 AliError(Form("%s inward refit failed", fgkDetectorName[iDet]));
2581 // run postprocessing
2582 if (fTracker[iDet]->PostProcess(esd) != 0) {
2583 AliError(Form("%s postprocessing failed", fgkDetectorName[iDet]));
2586 AliSysInfo::AddStamp(Form("Tracking2%s_%d",fgkDetectorName[iDet],eventNr), iDet,3, eventNr);
2589 // write space-points to the ESD in case alignment data output
2591 if (fWriteAlignmentData)
2592 WriteAlignmentData(esd);
2594 for (Int_t iDet = 3; iDet >= 0; iDet--) {
2595 if (!fTracker[iDet]) continue;
2597 fTracker[iDet]->UnloadClusters();
2598 AliSysInfo::AddStamp(Form("TUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,4, eventNr);
2599 fLoader[iDet]->UnloadRecPoints();
2600 AliSysInfo::AddStamp(Form("RUnloadCluster%s_%d",fgkDetectorName[iDet],eventNr), iDet,5, eventNr);
2602 // stop filling residuals for TPC and ITS
2603 if (fRunGlobalQA) AliTracker::SetFillResiduals(fRecoParam.GetEventSpecie(), kFALSE);
2609 //_____________________________________________________________________________
2610 Bool_t AliReconstruction::CleanESD(AliESDEvent *esd){
2612 // Remove the data which are not needed for the physics analysis.
2615 Int_t nTracks=esd->GetNumberOfTracks();
2616 Int_t nV0s=esd->GetNumberOfV0s();
2618 (Form("Number of ESD tracks and V0s before cleaning: %d %d",nTracks,nV0s));
2620 Float_t cleanPars[]={fV0DCAmax,fV0CsPmin,fDmax,fZmax};
2621 Bool_t rc=esd->Clean(cleanPars);
2623 nTracks=esd->GetNumberOfTracks();
2624 nV0s=esd->GetNumberOfV0s();
2626 (Form("Number of ESD tracks and V0s after cleaning %d %d",nTracks,nV0s));
2631 //_____________________________________________________________________________
2632 Bool_t AliReconstruction::FillESD(AliESDEvent*& esd, const TString& detectors)
2634 // fill the event summary data
2636 AliCodeTimerAuto("",0)
2637 static Int_t eventNr=0;
2638 TString detStr = detectors;
2640 AliSysInfo::AddStamp(Form("FillESDb%d",eventNr), -19,-19, eventNr);
2641 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2642 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2643 AliReconstructor* reconstructor = GetReconstructor(iDet);
2644 if (!reconstructor) continue;
2645 AliDebug(1, Form("filling ESD for %s", fgkDetectorName[iDet]));
2646 TTree* clustersTree = NULL;
2647 if (fLoader[iDet]) {
2648 fLoader[iDet]->LoadRecPoints("read");
2649 clustersTree = fLoader[iDet]->TreeR();
2650 if (!clustersTree) {
2651 AliError(Form("Can't get the %s clusters tree",
2652 fgkDetectorName[iDet]));
2653 if (fStopOnError) return kFALSE;
2656 if (fRawReader && !reconstructor->HasDigitConversion()) {
2657 reconstructor->FillESD(fRawReader, clustersTree, esd);
2659 TTree* digitsTree = NULL;
2660 if (fLoader[iDet]) {
2661 fLoader[iDet]->LoadDigits("read");
2662 digitsTree = fLoader[iDet]->TreeD();
2664 AliError(Form("Can't get the %s digits tree",
2665 fgkDetectorName[iDet]));
2666 if (fStopOnError) return kFALSE;
2669 reconstructor->FillESD(digitsTree, clustersTree, esd);
2670 if (fLoader[iDet]) fLoader[iDet]->UnloadDigits();
2672 if (fLoader[iDet]) {
2673 fLoader[iDet]->UnloadRecPoints();
2677 IsSelected("CTP", detStr);
2678 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
2679 AliError(Form("the following detectors were not found: %s",
2681 if (fStopOnError) return kFALSE;
2683 AliSysInfo::AddStamp(Form("FillESDe%d",eventNr), -20,-20, eventNr);
2688 //_____________________________________________________________________________
2689 Bool_t AliReconstruction::FillTriggerESD(AliESDEvent*& esd)
2691 // Reads the trigger decision which is
2692 // stored in Trigger.root file and fills
2693 // the corresponding esd entries
2695 AliCodeTimerAuto("",0)
2697 AliInfo("Filling trigger information into the ESD");
2700 AliCTPRawStream input(fRawReader);
2701 if (!input.Next()) {
2702 AliWarning("No valid CTP (trigger) DDL raw data is found ! The trigger info is taken from the event header!");
2705 if (esd->GetTriggerMask() != input.GetClassMask())
2706 AliError(Form("Invalid trigger pattern found in CTP raw-data: %llx %llx",
2707 input.GetClassMask(),esd->GetTriggerMask()));
2708 if (esd->GetOrbitNumber() != input.GetOrbitID())
2709 AliError(Form("Invalid orbit id found in CTP raw-data: %x %x",
2710 input.GetOrbitID(),esd->GetOrbitNumber()));
2711 if (esd->GetBunchCrossNumber() != input.GetBCID())
2712 AliError(Form("Invalid bunch-crossing id found in CTP raw-data: %x %x",
2713 input.GetBCID(),esd->GetBunchCrossNumber()));
2714 AliESDHeader* esdheader = esd->GetHeader();
2715 esdheader->SetL0TriggerInputs(input.GetL0Inputs());
2716 esdheader->SetL1TriggerInputs(input.GetL1Inputs());
2717 esdheader->SetL2TriggerInputs(input.GetL2Inputs());
2719 UInt_t orbit=input.GetOrbitID();
2720 for(Int_t i=0 ; i<input.GetNIRs() ; i++ )
2721 if(TMath::Abs(Int_t(orbit-(input.GetIR(i))->GetOrbit()))<=1){
2722 esdheader->AddTriggerIR(input.GetIR(i));
2728 //_____________________________________________________________________________
2729 Bool_t AliReconstruction::FillTriggerScalers(AliESDEvent*& esd)
2732 //fRunScalers->Print();
2733 if(fRunScalers && fRunScalers->CheckRunScalers()){
2734 AliTimeStamp* timestamp = new AliTimeStamp(esd->GetOrbitNumber(), esd->GetPeriodNumber(), esd->GetBunchCrossNumber());
2735 //AliTimeStamp* timestamp = new AliTimeStamp(10308000, 0, (ULong64_t)486238);
2736 AliESDHeader* esdheader = fesd->GetHeader();
2737 for(Int_t i=0;i<50;i++){
2738 if((1ull<<i) & esd->GetTriggerMask()){
2739 AliTriggerScalersESD* scalesd = fRunScalers->GetScalersForEventClass( timestamp, i+1);
2740 if(scalesd)esdheader->SetTriggerScalersRecord(scalesd);
2746 //_____________________________________________________________________________
2747 Bool_t AliReconstruction::FillRawEventHeaderESD(AliESDEvent*& esd)
2750 // Filling information from RawReader Header
2753 if (!fRawReader) return kFALSE;
2755 AliInfo("Filling information from RawReader Header");
2757 esd->SetBunchCrossNumber(fRawReader->GetBCID());
2758 esd->SetOrbitNumber(fRawReader->GetOrbitID());
2759 esd->SetPeriodNumber(fRawReader->GetPeriod());
2761 esd->SetTimeStamp(fRawReader->GetTimestamp());
2762 esd->SetEventType(fRawReader->GetType());
2768 //_____________________________________________________________________________
2769 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
2771 // check whether detName is contained in detectors
2772 // if yes, it is removed from detectors
2774 // check if all detectors are selected
2775 if ((detectors.CompareTo("ALL") == 0) ||
2776 detectors.BeginsWith("ALL ") ||
2777 detectors.EndsWith(" ALL") ||
2778 detectors.Contains(" ALL ")) {
2783 // search for the given detector
2784 Bool_t result = kFALSE;
2785 if ((detectors.CompareTo(detName) == 0) ||
2786 detectors.BeginsWith(detName+" ") ||
2787 detectors.EndsWith(" "+detName) ||
2788 detectors.Contains(" "+detName+" ")) {
2789 detectors.ReplaceAll(detName, "");
2793 // clean up the detectors string
2794 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
2795 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
2796 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
2801 //_____________________________________________________________________________
2802 Bool_t AliReconstruction::InitRunLoader()
2804 // get or create the run loader
2806 if (gAlice) delete gAlice;
2809 TFile *gafile = TFile::Open(fGAliceFileName.Data());
2810 // if (!gSystem->AccessPathName(fGAliceFileName.Data())) { // galice.root exists
2811 if (gafile) { // galice.root exists
2815 // load all base libraries to get the loader classes
2816 TString libs = gSystem->GetLibraries();
2817 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2818 TString detName = fgkDetectorName[iDet];
2819 if (detName == "HLT") continue;
2820 if (libs.Contains("lib" + detName + "base.so")) continue;
2821 gSystem->Load("lib" + detName + "base.so");
2823 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
2825 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
2830 fRunLoader->CdGAFile();
2831 fRunLoader->LoadgAlice();
2833 //PH This is a temporary fix to give access to the kinematics
2834 //PH that is needed for the labels of ITS clusters
2835 fRunLoader->LoadHeader();
2836 fRunLoader->LoadKinematics();
2838 } else { // galice.root does not exist
2840 AliError(Form("the file %s does not exist", fGAliceFileName.Data()));
2842 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data(),
2843 AliConfig::GetDefaultEventFolderName(),
2846 AliError(Form("could not create run loader in file %s",
2847 fGAliceFileName.Data()));
2851 fIsNewRunLoader = kTRUE;
2852 fRunLoader->MakeTree("E");
2854 if (fNumberOfEventsPerFile > 0)
2855 fRunLoader->SetNumberOfEventsPerFile(fNumberOfEventsPerFile);
2857 fRunLoader->SetNumberOfEventsPerFile((UInt_t)-1);
2863 //_____________________________________________________________________________
2864 AliReconstructor* AliReconstruction::GetReconstructor(Int_t iDet)
2866 // get the reconstructor object and the loader for a detector
2868 if (fReconstructor[iDet]) {
2869 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2870 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2871 fReconstructor[iDet]->SetRecoParam(par);
2872 fReconstructor[iDet]->SetRunInfo(fRunInfo);
2874 return fReconstructor[iDet];
2877 // load the reconstructor object
2878 TPluginManager* pluginManager = gROOT->GetPluginManager();
2879 TString detName = fgkDetectorName[iDet];
2880 TString recName = "Ali" + detName + "Reconstructor";
2882 if (!fIsNewRunLoader && !fRunLoader->GetLoader(detName+"Loader") && (detName != "HLT")) return NULL;
2884 AliReconstructor* reconstructor = NULL;
2885 // first check if a plugin is defined for the reconstructor
2886 TPluginHandler* pluginHandler =
2887 pluginManager->FindHandler("AliReconstructor", detName);
2888 // if not, add a plugin for it
2889 if (!pluginHandler) {
2890 AliDebug(1, Form("defining plugin for %s", recName.Data()));
2891 TString libs = gSystem->GetLibraries();
2892 if (libs.Contains("lib" + detName + "base.so") ||
2893 (gSystem->Load("lib" + detName + "base.so") >= 0)) {
2894 pluginManager->AddHandler("AliReconstructor", detName,
2895 recName, detName + "rec", recName + "()");
2897 pluginManager->AddHandler("AliReconstructor", detName,
2898 recName, detName, recName + "()");
2900 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
2902 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2903 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
2905 if (reconstructor) {
2906 TObject* obj = fOptions.FindObject(detName.Data());
2907 if (obj) reconstructor->SetOption(obj->GetTitle());
2908 reconstructor->SetRunInfo(fRunInfo);
2909 reconstructor->Init();
2910 fReconstructor[iDet] = reconstructor;
2913 // get or create the loader
2914 if (detName != "HLT") {
2915 fLoader[iDet] = fRunLoader->GetLoader(detName + "Loader");
2916 if (!fLoader[iDet]) {
2917 AliConfig::Instance()
2918 ->CreateDetectorFolders(fRunLoader->GetEventFolder(),
2920 // first check if a plugin is defined for the loader
2922 pluginManager->FindHandler("AliLoader", detName);
2923 // if not, add a plugin for it
2924 if (!pluginHandler) {
2925 TString loaderName = "Ali" + detName + "Loader";
2926 AliDebug(1, Form("defining plugin for %s", loaderName.Data()));
2927 pluginManager->AddHandler("AliLoader", detName,
2928 loaderName, detName + "base",
2929 loaderName + "(const char*, TFolder*)");
2930 pluginHandler = pluginManager->FindHandler("AliLoader", detName);
2932 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
2934 (AliLoader*) pluginHandler->ExecPlugin(2, detName.Data(),
2935 fRunLoader->GetEventFolder());
2937 if (!fLoader[iDet]) { // use default loader
2938 fLoader[iDet] = new AliLoader(detName, fRunLoader->GetEventFolder());
2940 if (!fLoader[iDet]) {
2941 AliWarning(Form("couldn't get loader for %s", detName.Data()));
2942 if (fStopOnError) return NULL;
2944 fRunLoader->AddLoader(fLoader[iDet]);
2945 fRunLoader->CdGAFile();
2946 if (gFile && !gFile->IsWritable()) gFile->ReOpen("UPDATE");
2947 fRunLoader->Write(0, TObject::kOverwrite);
2952 if (fRecoParam.GetDetRecoParamArray(iDet) && !AliReconstructor::GetRecoParam(iDet)) {
2953 const AliDetectorRecoParam *par = fRecoParam.GetDetRecoParam(iDet);
2954 reconstructor->SetRecoParam(par);
2955 reconstructor->SetRunInfo(fRunInfo);
2957 return reconstructor;
2960 //_____________________________________________________________________________
2961 AliVertexer* AliReconstruction::CreateVertexer()
2963 // create the vertexer
2964 // Please note that the caller is the owner of the
2967 AliVertexer* vertexer = NULL;
2968 AliReconstructor* itsReconstructor = GetReconstructor(0);
2969 if (itsReconstructor && ((fRunLocalReconstruction.Contains("ITS")) || fRunTracking.Contains("ITS"))) {
2970 vertexer = itsReconstructor->CreateVertexer();
2973 AliWarning("couldn't create a vertexer for ITS");
2979 //_____________________________________________________________________________
2980 Bool_t AliReconstruction::CreateTrackers(const TString& detectors)
2982 // create the trackers
2983 AliInfo("Creating trackers");
2985 TString detStr = detectors;
2986 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
2987 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
2988 AliReconstructor* reconstructor = GetReconstructor(iDet);
2989 if (!reconstructor) continue;
2990 TString detName = fgkDetectorName[iDet];
2991 if (detName == "HLT") {
2992 fRunHLTTracking = kTRUE;
2995 if (detName == "MUON") {
2996 fRunMuonTracking = kTRUE;
3001 fTracker[iDet] = reconstructor->CreateTracker();
3002 if (!fTracker[iDet] && (iDet < 7)) {
3003 AliWarning(Form("couldn't create a tracker for %s", detName.Data()));
3004 if (fStopOnError) return kFALSE;
3006 AliSysInfo::AddStamp(Form("LTracker%s",fgkDetectorName[iDet]), iDet,0);
3012 //_____________________________________________________________________________
3013 void AliReconstruction::CleanUp()
3015 // delete trackers and the run loader and close and delete the file
3017 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3018 delete fReconstructor[iDet];
3019 fReconstructor[iDet] = NULL;
3020 fLoader[iDet] = NULL;
3021 delete fTracker[iDet];
3022 fTracker[iDet] = NULL;
3027 delete fSPDTrackleter;
3028 fSPDTrackleter = NULL;
3037 delete fParentRawReader;
3038 fParentRawReader=NULL;
3046 if (AliQAManager::QAManager())
3047 AliQAManager::QAManager()->ShowQA() ;
3048 AliQAManager::Destroy() ;
3052 void AliReconstruction::WriteAlignmentData(AliESDEvent* esd)
3054 // Write space-points which are then used in the alignment procedures
3055 // For the moment only ITS, TPC, TRD and TOF
3057 Int_t ntracks = esd->GetNumberOfTracks();
3058 for (Int_t itrack = 0; itrack < ntracks; itrack++)
3060 AliESDtrack *track = esd->GetTrack(itrack);
3063 for (Int_t i=0; i<200; ++i) idx[i] = -1; //PH avoid uninitialized values
3064 for (Int_t iDet = 5; iDet >= 0; iDet--) {// TOF, TRD, TPC, ITS clusters
3065 nsp += (iDet==GetDetIndex("TRD")) ? track->GetTRDntracklets():track->GetNcls(iDet);
3067 if (iDet==GetDetIndex("ITS")) { // ITS "extra" clusters
3068 track->GetClusters(iDet,idx);
3069 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nsp++;
3074 AliTrackPointArray *sp = new AliTrackPointArray(nsp);
3075 track->SetTrackPointArray(sp);
3077 for (Int_t iDet = 5; iDet >= 0; iDet--) {
3078 AliTracker *tracker = fTracker[iDet];
3079 if (!tracker) continue;
3080 Int_t nspdet = (iDet==GetDetIndex("TRD")) ? track->GetTRDtracklets(idx):track->GetClusters(iDet,idx);
3082 if (iDet==GetDetIndex("ITS")) // ITS "extra" clusters
3083 for (Int_t i=6; i<12; i++) if(idx[i] >= 0) nspdet++;
3085 if (nspdet <= 0) continue;
3089 while (isp2 < nspdet) {
3090 Bool_t isvalid=kTRUE;
3092 Int_t index=idx[isp++];
3093 if (index < 0) continue;
3095 TString dets = fgkDetectorName[iDet];
3096 if ((fUseTrackingErrorsForAlignment.CompareTo(dets) == 0) ||
3097 fUseTrackingErrorsForAlignment.BeginsWith(dets+" ") ||
3098 fUseTrackingErrorsForAlignment.EndsWith(" "+dets) ||
3099 fUseTrackingErrorsForAlignment.Contains(" "+dets+" ")) {
3100 isvalid = tracker->GetTrackPointTrackingError(index,p,track);
3102 isvalid = tracker->GetTrackPoint(index,p);
3105 if (!isvalid) continue;
3106 if (iDet==GetDetIndex("ITS") && (isp-1)>=6) p.SetExtra();
3107 sp->AddPoint(isptrack,&p); isptrack++;
3114 //_____________________________________________________________________________
3115 void AliReconstruction::FillRawDataErrorLog(Int_t iEvent, AliESDEvent* esd)
3117 // The method reads the raw-data error log
3118 // accumulated within the rawReader.
3119 // It extracts the raw-data errors related to
3120 // the current event and stores them into
3121 // a TClonesArray inside the esd object.
3123 if (!fRawReader) return;
3125 for(Int_t i = 0; i < fRawReader->GetNumberOfErrorLogs(); i++) {
3127 AliRawDataErrorLog *log = fRawReader->GetErrorLog(i);
3129 if (iEvent != log->GetEventNumber()) continue;
3131 esd->AddRawDataErrorLog(log);
3136 //_____________________________________________________________________________
3137 void AliReconstruction::CheckQA()
3139 // check the QA of SIM for this run and remove the detectors
3140 // with status Fatal
3142 // TString newRunLocalReconstruction ;
3143 // TString newRunTracking ;
3144 // TString newFillESD ;
3146 // for (Int_t iDet = 0; iDet < AliQAv1::kNDET; iDet++) {
3147 // TString detName(AliQAv1::GetDetName(iDet)) ;
3148 // AliQAv1 * qa = AliQAv1::Instance(AliQAv1::DETECTORINDEX_t(iDet)) ;
3149 // if ( qa->IsSet(AliQAv1::DETECTORINDEX_t(iDet), AliQAv1::kSIM, specie, AliQAv1::kFATAL)) {
3150 // AliInfo(Form("QA status for %s %s in Hits and/or SDIGITS and/or Digits was Fatal; No reconstruction performed",
3151 // detName.Data(), AliRecoParam::GetEventSpecieName(es))) ;
3153 // if ( fRunLocalReconstruction.Contains(AliQAv1::GetDetName(iDet)) ||
3154 // fRunLocalReconstruction.Contains("ALL") ) {
3155 // newRunLocalReconstruction += detName ;
3156 // newRunLocalReconstruction += " " ;
3158 // if ( fRunTracking.Contains(AliQAv1::GetDetName(iDet)) ||
3159 // fRunTracking.Contains("ALL") ) {
3160 // newRunTracking += detName ;
3161 // newRunTracking += " " ;
3163 // if ( fFillESD.Contains(AliQAv1::GetDetName(iDet)) ||
3164 // fFillESD.Contains("ALL") ) {
3165 // newFillESD += detName ;
3166 // newFillESD += " " ;
3170 // fRunLocalReconstruction = newRunLocalReconstruction ;
3171 // fRunTracking = newRunTracking ;
3172 // fFillESD = newFillESD ;
3175 //_____________________________________________________________________________
3176 Int_t AliReconstruction::GetDetIndex(const char* detector)
3178 // return the detector index corresponding to detector
3180 for (index = 0; index < kNDetectors ; index++) {
3181 if ( strcmp(detector, fgkDetectorName[index]) == 0 )
3186 //_____________________________________________________________________________
3187 Bool_t AliReconstruction::FinishPlaneEff() {
3189 // Here execute all the necessary operationis, at the end of the tracking phase,
3190 // in case that evaluation of PlaneEfficiencies was required for some detector.
3191 // E.g., write into a DataBase file the PlaneEfficiency which have been evaluated.
3193 // This Preliminary version works only FOR ITS !!!!!
3194 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3197 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3200 TString detStr = fLoadCDB;
3201 //for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
3202 for (Int_t iDet = 0; iDet < 1; iDet++) { // for the time being only ITS
3203 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3204 if(fTracker[iDet] && fTracker[iDet]->GetPlaneEff()) {
3205 AliPlaneEff *planeeff=fTracker[iDet]->GetPlaneEff();
3206 TString name=planeeff->GetName();
3208 TFile* pefile = TFile::Open(name, "RECREATE");
3209 ret=(Bool_t)planeeff->Write();
3211 if(planeeff->GetCreateHistos()) {
3212 TString hname=planeeff->GetName();
3213 hname+="Histo.root";
3214 ret*=planeeff->WriteHistosToFile(hname,"RECREATE");
3217 if(fSPDTrackleter) {
3218 AliPlaneEff *planeeff=fSPDTrackleter->GetPlaneEff();
3219 TString name="AliITSPlaneEffSPDtracklet.root";
3220 TFile* pefile = TFile::Open(name, "RECREATE");
3221 ret=(Bool_t)planeeff->Write();
3223 AliESDEvent *dummy=NULL;
3224 ret=(Bool_t)fSPDTrackleter->PostProcess(dummy); // take care of writing other files
3229 //_____________________________________________________________________________
3230 Bool_t AliReconstruction::InitPlaneEff() {
3232 // Here execute all the necessary operations, before of the tracking phase,
3233 // for the evaluation of PlaneEfficiencies, in case required for some detectors.
3234 // E.g., read from a DataBase file a first evaluation of the PlaneEfficiency
3235 // which should be updated/recalculated.
3237 // This Preliminary version will work only FOR ITS !!!!!
3238 // other detectors (TOF,TRD, etc. have to develop their specific codes)
3241 // Return: kTRUE if all operations have been done properly, kFALSE otherwise
3243 AliWarning(Form("Implementation of this method not yet completed !! Method return kTRUE"));
3245 fSPDTrackleter = NULL;
3246 TString detStr = fLoadCDB;
3247 if (IsSelected(fgkDetectorName[0], detStr)) {
3248 AliReconstructor* itsReconstructor = GetReconstructor(0);
3249 if (itsReconstructor) {
3250 fSPDTrackleter = itsReconstructor->CreateTrackleter(); // this is NULL unless required in RecoParam
3252 if (fSPDTrackleter) {
3253 AliInfo("Trackleter for SPD has been created");
3259 //_____________________________________________________________________________
3260 Bool_t AliReconstruction::InitAliEVE()
3262 // This method should be called only in case
3263 // AliReconstruction is run
3264 // within the alieve environment.
3265 // It will initialize AliEVE in a way
3266 // so that it can visualize event processed
3267 // by AliReconstruction.
3268 // The return flag shows whenever the
3269 // AliEVE initialization was successful or not.
3272 macroStr.Form("%s/EVE/macros/alieve_online.C",gSystem->ExpandPathName("$ALICE_ROOT"));
3273 AliInfo(Form("Loading AliEVE macro: %s",macroStr.Data()));
3274 if (gROOT->LoadMacro(macroStr.Data()) != 0) return kFALSE;
3276 gROOT->ProcessLine("if (!AliEveEventManager::GetMaster()){new AliEveEventManager();AliEveEventManager::GetMaster()->AddNewEventCommand(\"alieve_online_on_new_event()\");gEve->AddEvent(AliEveEventManager::GetMaster());};");
3277 gROOT->ProcessLine("alieve_online_init()");
3282 //_____________________________________________________________________________
3283 void AliReconstruction::RunAliEVE()
3285 // Runs AliEVE visualisation of
3286 // the current event.
3287 // Should be executed only after
3288 // successful initialization of AliEVE.
3290 AliInfo("Running AliEVE...");
3291 gROOT->ProcessLine(Form("AliEveEventManager::GetMaster()->SetEvent((AliRunLoader*)0x%lx,(AliRawReader*)0x%lx,(AliESDEvent*)0x%lx,(AliESDfriend*)0x%lx);",fRunLoader,fRawReader,fesd,fesdf));
3295 //_____________________________________________________________________________
3296 Bool_t AliReconstruction::SetRunQA(TString detAndAction)
3298 // Allows to run QA for a selected set of detectors
3299 // and a selected set of tasks among RAWS, DIGITSR, RECPOINTS and ESDS
3300 // all selected detectors run the same selected tasks
3302 if (!detAndAction.Contains(":")) {
3303 AliError( Form("%s is a wrong syntax, use \"DetectorList:ActionList\" \n", detAndAction.Data()) ) ;
3307 Int_t colon = detAndAction.Index(":") ;
3308 fQADetectors = detAndAction(0, colon) ;
3309 fQATasks = detAndAction(colon+1, detAndAction.Sizeof() ) ;
3310 if (fQATasks.Contains("ALL") ) {
3311 fQATasks = Form("%d %d %d %d", AliQAv1::kRAWS, AliQAv1::kDIGITSR, AliQAv1::kRECPOINTS, AliQAv1::kESDS) ;
3313 fQATasks.ToUpper() ;
3315 if ( fQATasks.Contains("RAW") )
3316 tempo = Form("%d ", AliQAv1::kRAWS) ;
3317 if ( fQATasks.Contains("DIGIT") )
3318 tempo += Form("%d ", AliQAv1::kDIGITSR) ;
3319 if ( fQATasks.Contains("RECPOINT") )
3320 tempo += Form("%d ", AliQAv1::kRECPOINTS) ;
3321 if ( fQATasks.Contains("ESD") )
3322 tempo += Form("%d ", AliQAv1::kESDS) ;
3324 if (fQATasks.IsNull()) {
3325 AliInfo("No QA requested\n") ;
3330 TString tempo(fQATasks) ;
3331 tempo.ReplaceAll(Form("%d", AliQAv1::kRAWS), AliQAv1::GetTaskName(AliQAv1::kRAWS)) ;
3332 tempo.ReplaceAll(Form("%d", AliQAv1::kDIGITSR), AliQAv1::GetTaskName(AliQAv1::kDIGITSR)) ;
3333 tempo.ReplaceAll(Form("%d", AliQAv1::kRECPOINTS), AliQAv1::GetTaskName(AliQAv1::kRECPOINTS)) ;
3334 tempo.ReplaceAll(Form("%d", AliQAv1::kESDS), AliQAv1::GetTaskName(AliQAv1::kESDS)) ;
3335 AliInfo( Form("QA will be done on \"%s\" for \"%s\"\n", fQADetectors.Data(), tempo.Data()) ) ;
3340 //_____________________________________________________________________________
3341 Bool_t AliReconstruction::InitRecoParams()
3343 // The method accesses OCDB and retrieves all
3344 // the available reco-param objects from there.
3346 Bool_t isOK = kTRUE;
3348 if (fRecoParam.GetDetRecoParamArray(kNDetectors)) {
3349 AliInfo("Using custom GRP reconstruction parameters");
3352 AliInfo("Loading GRP reconstruction parameter objects");
3354 AliCDBPath path("GRP","Calib","RecoParam");
3355 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3357 AliWarning("Couldn't find GRP RecoParam entry in OCDB");
3361 TObject *recoParamObj = entry->GetObject();
3362 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3363 // GRP has a normal TobjArray of AliDetectorRecoParam objects
3364 // Registering them in AliRecoParam
3365 fRecoParam.AddDetRecoParamArray(kNDetectors,dynamic_cast<TObjArray*>(recoParamObj));
3367 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3368 // GRP has only onse set of reco parameters
3369 // Registering it in AliRecoParam
3370 AliInfo("Single set of GRP reconstruction parameters found");
3371 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3372 fRecoParam.AddDetRecoParam(kNDetectors,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3375 AliError("No valid GRP RecoParam object found in the OCDB");
3382 TString detStr = fLoadCDB;
3383 for (Int_t iDet = 0; iDet < kNDetectors; iDet++) {
3385 if (!IsSelected(fgkDetectorName[iDet], detStr)) continue;
3387 if (fRecoParam.GetDetRecoParamArray(iDet)) {
3388 AliInfo(Form("Using custom reconstruction parameters for detector %s",fgkDetectorName[iDet]));
3392 AliInfo(Form("Loading reconstruction parameter objects for detector %s",fgkDetectorName[iDet]));
3394 AliCDBPath path(fgkDetectorName[iDet],"Calib","RecoParam");
3395 AliCDBEntry *entry=AliCDBManager::Instance()->Get(path.GetPath());
3397 AliWarning(Form("Couldn't find RecoParam entry in OCDB for detector %s",fgkDetectorName[iDet]));
3401 TObject *recoParamObj = entry->GetObject();
3402 if (dynamic_cast<TObjArray*>(recoParamObj)) {
3403 // The detector has a normal TobjArray of AliDetectorRecoParam objects
3404 // Registering them in AliRecoParam
3405 fRecoParam.AddDetRecoParamArray(iDet,dynamic_cast<TObjArray*>(recoParamObj));
3407 else if (dynamic_cast<AliDetectorRecoParam*>(recoParamObj)) {
3408 // The detector has only onse set of reco parameters
3409 // Registering it in AliRecoParam
3410 AliInfo(Form("Single set of reconstruction parameters found for detector %s",fgkDetectorName[iDet]));
3411 dynamic_cast<AliDetectorRecoParam*>(recoParamObj)->SetAsDefault();
3412 fRecoParam.AddDetRecoParam(iDet,dynamic_cast<AliDetectorRecoParam*>(recoParamObj));
3415 AliError(Form("No valid RecoParam object found in the OCDB for detector %s",fgkDetectorName[iDet]));
3419 // FIX ME: We have to disable the unloading of reco-param CDB
3420 // entries because QA framework is using them. Has to be fix in
3421 // a way that the QA takes the objects already constructed in
3423 // AliCDBManager::Instance()->UnloadFromCache(path.GetPath());
3427 if (AliDebugLevel() > 0) fRecoParam.Print();
3432 //_____________________________________________________________________________
3433 Bool_t AliReconstruction::GetEventInfo()
3435 // Fill the event info object
3437 AliCodeTimerAuto("",0)
3439 AliCentralTrigger *aCTP = NULL;
3441 fEventInfo.SetEventType(fRawReader->GetType());
3443 ULong64_t mask = fRawReader->GetClassMask();
3444 fEventInfo.SetTriggerMask(mask);
3445 UInt_t clmask = fRawReader->GetDetectorPattern()[0];
3446 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(clmask));
3448 aCTP = new AliCentralTrigger();
3449 TString configstr("");
3450 if (!aCTP->LoadConfiguration(configstr)) { // Load CTP config from OCDB
3451 AliError("No trigger configuration found in OCDB! The trigger configuration information will not be used!");
3455 aCTP->SetClassMask(mask);
3456 aCTP->SetClusterMask(clmask);
3459 fEventInfo.SetEventType(AliRawEventHeaderBase::kPhysicsEvent);
3461 if (fRunLoader && (!fRunLoader->LoadTrigger())) {
3462 aCTP = fRunLoader->GetTrigger();
3463 fEventInfo.SetTriggerMask(aCTP->GetClassMask());
3464 // get inputs from actp - just get
3465 AliESDHeader* esdheader = fesd->GetHeader();
3466 esdheader->SetL0TriggerInputs(aCTP->GetL0TriggerInputs());
3467 esdheader->SetL1TriggerInputs(aCTP->GetL1TriggerInputs());
3468 esdheader->SetL2TriggerInputs(aCTP->GetL2TriggerInputs());
3469 fEventInfo.SetTriggerCluster(AliDAQ::ListOfTriggeredDetectors(aCTP->GetClusterMask()));
3472 AliWarning("No trigger can be loaded! The trigger information will not be used!");
3477 AliTriggerConfiguration *config = aCTP->GetConfiguration();
3479 AliError("No trigger configuration has been found! The trigger configuration information will not be used!");
3480 if (fRawReader) delete aCTP;
3484 UChar_t clustmask = 0;
3486 ULong64_t trmask = fEventInfo.GetTriggerMask();
3487 const TObjArray& classesArray = config->GetClasses();
3488 Int_t nclasses = classesArray.GetEntriesFast();
3489 for( Int_t iclass=0; iclass < nclasses; iclass++ ) {
3490 AliTriggerClass* trclass = (AliTriggerClass*)classesArray.At(iclass);
3491 if (trclass && trclass->GetMask()>0) {
3492 Int_t trindex = TMath::Nint(TMath::Log2(trclass->GetMask()));
3493 fesd->SetTriggerClass(trclass->GetName(),trindex);
3494 if (fRawReader) fRawReader->LoadTriggerClass(trclass->GetName(),trindex);
3495 if (trmask & (1ull << trindex)) {
3497 trclasses += trclass->GetName();
3499 clustmask |= trclass->GetCluster()->GetClusterMask();
3503 fEventInfo.SetTriggerClasses(trclasses);
3505 // Write names of active trigger inputs in ESD Header
3506 const TObjArray& inputsArray = config->GetInputs();
3507 Int_t ninputs = inputsArray.GetEntriesFast();
3508 for( Int_t iinput=0; iinput < ninputs; iinput++ ) {
3509 AliTriggerInput* trginput = (AliTriggerInput*)inputsArray.At(iinput);
3510 if (trginput && trginput->GetMask()>0) {
3511 Int_t inputIndex = (Int_t)TMath::Nint(TMath::Log2(trginput->GetMask()));
3512 AliESDHeader* headeresd = fesd->GetHeader();
3513 Int_t trglevel = (Int_t)trginput->GetLevel();
3514 if (trglevel == 0) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex);
3515 if (trglevel == 1) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+24);
3516 if (trglevel == 2) headeresd->SetActiveTriggerInputs(trginput->GetInputName(), inputIndex+48);
3520 // Set the information in ESD
3521 fesd->SetTriggerMask(trmask);
3522 fesd->SetTriggerCluster(clustmask);
3524 if (!aCTP->CheckTriggeredDetectors()) {
3525 if (fRawReader) delete aCTP;
3529 if (fRawReader) delete aCTP;
3531 // We have to fill also the HLT decision here!!
3537 const char *AliReconstruction::MatchDetectorList(const char *detectorList, UInt_t detectorMask)
3539 // Match the detector list found in the rec.C or the default 'ALL'
3540 // to the list found in the GRP (stored there by the shuttle PP which
3541 // gets the information from ECS)
3542 static TString resultList;
3543 TString detList = detectorList;
3547 for(Int_t iDet = 0; iDet < (AliDAQ::kNDetectors-1); iDet++) {
3548 if ((detectorMask >> iDet) & 0x1) {
3549 TString det = AliDAQ::OfflineModuleName(iDet);
3550 if ((detList.CompareTo("ALL") == 0) ||
3551 ((detList.BeginsWith("ALL ") ||
3552 detList.EndsWith(" ALL") ||
3553 detList.Contains(" ALL ")) &&
3554 !(detList.BeginsWith("-"+det+" ") ||
3555 detList.EndsWith(" -"+det) ||
3556 detList.Contains(" -"+det+" "))) ||
3557 (detList.CompareTo(det) == 0) ||
3558 detList.BeginsWith(det+" ") ||
3559 detList.EndsWith(" "+det) ||
3560 detList.Contains( " "+det+" " )) {
3561 if (!resultList.EndsWith(det + " ")) {
3570 if ((detectorMask >> AliDAQ::kHLTId) & 0x1) {
3571 TString hltDet = AliDAQ::OfflineModuleName(AliDAQ::kNDetectors-1);
3572 if ((detList.CompareTo("ALL") == 0) ||
3573 ((detList.BeginsWith("ALL ") ||
3574 detList.EndsWith(" ALL") ||
3575 detList.Contains(" ALL ")) &&
3576 !(detList.BeginsWith("-"+hltDet+" ") ||
3577 detList.EndsWith(" -"+hltDet) ||
3578 detList.Contains(" -"+hltDet+" "))) ||
3579 (detList.CompareTo(hltDet) == 0) ||
3580 detList.BeginsWith(hltDet+" ") ||
3581 detList.EndsWith(" "+hltDet) ||
3582 detList.Contains( " "+hltDet+" " )) {
3583 resultList += hltDet;
3587 return resultList.Data();
3591 //______________________________________________________________________________
3592 void AliReconstruction::Abort(const char *method, EAbort what)
3594 // Abort processing. If what = kAbortProcess, the Process() loop will be
3595 // aborted. If what = kAbortFile, the current file in a chain will be
3596 // aborted and the processing will continue with the next file, if there
3597 // is no next file then Process() will be aborted. Abort() can also be
3598 // called from Begin(), SlaveBegin(), Init() and Notify(). After abort
3599 // the SlaveTerminate() and Terminate() are always called. The abort flag
3600 // can be checked in these methods using GetAbort().
3602 // The method is overwritten in AliReconstruction for better handling of
3603 // reco specific errors
3605 if (!fStopOnError) return;
3609 TString whyMess = method;
3610 whyMess += " failed! Aborting...";
3612 AliError(whyMess.Data());
3615 TString mess = "Abort";
3616 if (fAbort == kAbortProcess)
3617 mess = "AbortProcess";
3618 else if (fAbort == kAbortFile)
3621 Info(mess, whyMess.Data());
3624 //______________________________________________________________________________
3625 Bool_t AliReconstruction::ProcessEvent(void* event)
3627 // Method that is used in case the event loop
3628 // is steered from outside, for example by AMORE
3629 // 'event' is a pointer to the DATE event in the memory
3631 if (fRawReader) delete fRawReader;
3632 fRawReader = new AliRawReaderDate(event);
3633 fStatus = ProcessEvent(fRunLoader->GetNumberOfEvents());
3640 //______________________________________________________________________________
3641 Bool_t AliReconstruction::ParseOutput()
3643 // The method parses the output file
3644 // location string in order to steer
3645 // properly the selector
3647 TPMERegexp re1("(\\w+\\.zip#\\w+\\.root):([,*\\w+\\.root,*]+)@dataset://(\\w++)");
3648 TPMERegexp re2("(\\w+\\.root)?@?dataset://(\\w++)");
3650 if (re1.Match(fESDOutput) == 4) {
3651 // root archive with output files stored and regustered
3653 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",re1[1].Data()));
3654 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re1[3].Data()));
3655 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
3656 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_ARCHIVE",re1[2].Data()));
3657 AliInfo(Form("%s files will be stored within %s in dataset %s",
3662 else if (re2.Match(fESDOutput) == 3) {
3663 // output file stored and registered
3665 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",(re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data()));
3666 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",re2[2].Data()));
3667 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_DATASET",""));
3668 AliInfo(Form("%s will be stored in dataset %s",
3669 (re2[1].IsNull()) ? "AliESDs.root" : re2[1].Data(),
3673 if (fESDOutput.IsNull()) {
3674 // Output location not given.
3675 // Assuming xrootd has been already started and
3676 // the output file has to be sent back
3677 // to the client machine
3678 TString esdUrl(Form("root://%s/%s/",
3679 TUrl(gSystem->HostName()).GetHostFQDN(),
3681 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE","AliESDs.root"));
3682 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",esdUrl.Data()));
3683 AliInfo(Form("AliESDs.root will be stored in %s",
3687 // User specified an output location.
3688 // Ones has just to parse it here
3689 TUrl outputUrl(fESDOutput.Data());
3690 TString outputFile(gSystem->BaseName(outputUrl.GetFile()));
3691 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE",outputFile.IsNull() ? "AliESDs.root" : outputFile.Data()));
3692 TString outputLocation(outputUrl.GetUrl());
3693 outputLocation.ReplaceAll(outputFile.Data(),"");
3694 gProof->AddInput(new TNamed("PROOF_OUTPUTFILE_LOCATION",outputLocation.Data()));
3695 AliInfo(Form("%s will be stored in %s",
3696 outputFile.IsNull() ? "AliESDs.root" : outputFile.Data(),
3697 outputLocation.Data()));