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 // The name of the galice file can be changed from the default //
42 // "galice.root" by passing it as argument to the AliReconstruction //
43 // constructor or by //
45 // rec.SetGAliceFile("..."); //
47 // The local reconstruction can be switched on or off for individual //
50 // rec.SetRunLocalReconstruction("..."); //
52 // The argument is a (case sensitive) string with the names of the //
53 // detectors separated by a space. The special string "ALL" selects all //
54 // available detectors. This is the default. //
56 // The reconstruction of the primary vertex position can be switched off by //
58 // rec.SetRunVertexFinder(kFALSE); //
60 // The tracking in ITS, TPC and TRD and the creation of ESD tracks can be //
63 // rec.SetRunTracking(kFALSE); //
65 // The filling of additional ESD information can be steered by //
67 // rec.SetFillESD("..."); //
69 // Again, the string specifies the list of detectors. The default is "ALL". //
71 // The reconstruction requires digits or raw data as input. For the creation //
72 // of digits and raw data have a look at the class AliSimulation. //
74 // For debug purposes the method SetCheckPointLevel can be used. If the //
75 // argument is greater than 0, files with ESD events will be written after //
76 // selected steps of the reconstruction for each event: //
77 // level 1: after tracking and after filling of ESD (final) //
78 // level 2: in addition after each tracking step //
79 // level 3: in addition after the filling of ESD for each detector //
80 // If a final check point file exists for an event, this event will be //
81 // skipped in the reconstruction. The tracking and the filling of ESD for //
82 // a detector will be skipped as well, if the corresponding check point //
83 // file exists. The ESD event will then be loaded from the file instead. //
85 ///////////////////////////////////////////////////////////////////////////////
91 #include <TPluginManager.h>
92 #include <TStopwatch.h>
94 #include "AliReconstruction.h"
96 #include "AliRunLoader.h"
98 #include "AliRawReaderFile.h"
99 #include "AliRawReaderDate.h"
100 #include "AliRawReaderRoot.h"
101 #include "AliTracker.h"
103 #include "AliESDVertex.h"
104 #include "AliVertexer.h"
105 #include "AliHeader.h"
106 #include "AliGenEventHeader.h"
107 #include "AliESDpid.h"
110 ClassImp(AliReconstruction)
113 //_____________________________________________________________________________
114 const char* AliReconstruction::fgkDetectorName[AliReconstruction::fgkNDetectors] = {"ITS", "TPC", "TRD", "TOF", "PHOS", "RICH", "EMCAL", "MUON", "FMD", "ZDC", "PMD", "START", "VZERO", "CRT", "HLT"};
116 //_____________________________________________________________________________
117 AliReconstruction::AliReconstruction(const char* gAliceFilename,
118 const char* name, const char* title) :
121 fRunLocalReconstruction("ALL"),
122 fRunVertexFinder(kTRUE),
125 fGAliceFileName(gAliceFilename),
127 fStopOnError(kFALSE),
151 // create reconstruction object with default parameters
155 //_____________________________________________________________________________
156 AliReconstruction::AliReconstruction(const AliReconstruction& rec) :
159 fRunLocalReconstruction(rec.fRunLocalReconstruction),
160 fRunVertexFinder(rec.fRunVertexFinder),
161 fRunTracking(rec.fRunTracking),
162 fFillESD(rec.fFillESD),
163 fGAliceFileName(rec.fGAliceFileName),
165 fStopOnError(rec.fStopOnError),
191 for (Int_t i = 0; i < fOptions.GetEntriesFast(); i++) {
192 if (rec.fOptions[i]) fOptions.Add(rec.fOptions[i]->Clone());
196 //_____________________________________________________________________________
197 AliReconstruction& AliReconstruction::operator = (const AliReconstruction& rec)
199 // assignment operator
201 this->~AliReconstruction();
202 new(this) AliReconstruction(rec);
206 //_____________________________________________________________________________
207 AliReconstruction::~AliReconstruction()
216 //_____________________________________________________________________________
217 void AliReconstruction::SetGAliceFile(const char* fileName)
219 // set the name of the galice file
221 fGAliceFileName = fileName;
224 //_____________________________________________________________________________
225 void AliReconstruction::SetOption(const char* detector, const char* option)
227 // set options for the reconstruction of a detector
229 TObject* obj = fOptions.FindObject(detector);
230 if (obj) fOptions.Remove(obj);
231 fOptions.Add(new TNamed(detector, option));
235 //_____________________________________________________________________________
236 Bool_t AliReconstruction::Run(const char* input)
238 // run the reconstruction
241 if (!input) input = fInput.Data();
242 TString fileName(input);
243 if (fileName.EndsWith("/")) {
244 fRawReader = new AliRawReaderFile(fileName);
245 } else if (fileName.EndsWith(".root")) {
246 fRawReader = new AliRawReaderRoot(fileName);
247 } else if (!fileName.IsNull()) {
248 fRawReader = new AliRawReaderDate(fileName);
249 fRawReader->SelectEvents(7);
252 // open the run loader
253 fRunLoader = AliRunLoader::Open(fGAliceFileName.Data());
255 AliError(Form("no run loader found in file %s", fGAliceFileName.Data()));
259 fRunLoader->LoadgAlice();
260 AliRun* aliRun = fRunLoader->GetAliRun();
262 AliError(Form("no gAlice object found in file %s",
263 fGAliceFileName.Data()));
268 AliTracker::SetFieldMap(gAlice->Field());
270 // load the reconstructor objects
271 TPluginManager* pluginManager = gROOT->GetPluginManager();
272 for (Int_t iDet = 0; iDet < fgkNDetectors; iDet++) {
273 TString detName = fgkDetectorName[iDet];
274 TString recName = "Ali" + detName + "Reconstructor";
275 if (!gAlice->GetDetector(detName) && detName != "HLT") continue;
277 if(detName == "HLT") {
278 if (!gROOT->GetClass("AliLevel3")) {
279 gSystem->Load("libAliL3Src.so");
280 gSystem->Load("libAliL3Misc.so");
281 gSystem->Load("libAliL3Hough.so");
282 gSystem->Load("libAliL3Comp.so");
286 AliReconstructor* reconstructor = NULL;
287 // first check if a plugin is defined for the reconstructor
288 TPluginHandler* pluginHandler =
289 pluginManager->FindHandler("AliReconstructor", detName);
290 // if not, but the reconstructor class is implemented, add a plugin for it
291 if (!pluginHandler && gROOT->GetClass(recName.Data())) {
292 AliDebug(1, Form("defining plugin for %s", recName.Data()));
293 pluginManager->AddHandler("AliReconstructor", detName,
294 recName, detName, recName + "()");
295 pluginHandler = pluginManager->FindHandler("AliReconstructor", detName);
297 if (pluginHandler && (pluginHandler->LoadPlugin() == 0)) {
298 reconstructor = (AliReconstructor*) pluginHandler->ExecPlugin(0);
300 // if there is no reconstructor class for the detector use the dummy one
301 if (!reconstructor && gAlice->GetDetector(detName)) {
302 AliDebug(1, Form("using dummy reconstructor for %s", detName.Data()));
303 reconstructor = new AliDummyReconstructor(gAlice->GetDetector(detName));
306 TObject* obj = fOptions.FindObject(detName.Data());
307 if (obj) reconstructor->SetOption(obj->GetTitle());
308 fReconstructors.Add(reconstructor);
312 // local reconstruction
313 if (!fRunLocalReconstruction.IsNull()) {
314 if (!RunLocalReconstruction(fRunLocalReconstruction)) {
315 if (fStopOnError) {CleanUp(); return kFALSE;}
318 if (!fRunVertexFinder && !fRunTracking && fFillESD.IsNull()) return kTRUE;
321 if (fRunVertexFinder && !CreateVertexer()) {
328 // get loaders and trackers
329 if (fRunTracking && !CreateTrackers()) {
336 // create the ESD output file and tree
337 TFile* file = TFile::Open("AliESDs.root", "RECREATE");
338 if (!file->IsOpen()) {
339 AliError("opening AliESDs.root failed");
340 if (fStopOnError) {CleanUp(file); return kFALSE;}
342 AliESD* esd = new AliESD;
343 TTree* tree = new TTree("esdTree", "Tree with ESD objects");
344 tree->Branch("ESD", "AliESD", &esd);
349 if (fRawReader) fRawReader->RewindEvents();
350 for (Int_t iEvent = 0; iEvent < fRunLoader->GetNumberOfEvents(); iEvent++) {
351 AliInfo(Form("processing event %d", iEvent));
352 fRunLoader->GetEvent(iEvent);
353 if (fRawReader) fRawReader->NextEvent();
356 sprintf(fileName, "ESD_%d.%d_final.root",
357 aliRun->GetRunNumber(), aliRun->GetEvNumber());
358 if (!gSystem->AccessPathName(fileName)) continue;
361 esd->SetRunNumber(aliRun->GetRunNumber());
362 esd->SetEventNumber(aliRun->GetEvNumber());
363 esd->SetMagneticField(aliRun->Field()->SolenoidField());
366 if (fRunVertexFinder) {
367 if (!ReadESD(esd, "vertex")) {
368 if (!RunVertexFinder(esd)) {
369 if (fStopOnError) {CleanUp(file); return kFALSE;}
371 if (fCheckPointLevel > 0) WriteESD(esd, "vertex");
377 if (!ReadESD(esd, "tracking")) {
378 if (!RunTracking(esd)) {
379 if (fStopOnError) {CleanUp(file); return kFALSE;}
381 if (fCheckPointLevel > 0) WriteESD(esd, "tracking");
386 if (!fFillESD.IsNull()) {
387 if (!FillESD(esd, fFillESD)) {
388 if (fStopOnError) {CleanUp(file); return kFALSE;}
393 AliESDpid::MakePID(esd);
394 if (fCheckPointLevel > 1) WriteESD(esd, "PID");
399 if (fCheckPointLevel > 0) WriteESD(esd, "final");
411 //_____________________________________________________________________________
412 Bool_t AliReconstruction::RunLocalReconstruction(const TString& detectors)
414 // run the local reconstruction
416 TStopwatch stopwatch;
419 TString detStr = detectors;
420 for (Int_t iDet = 0; iDet < fReconstructors.GetEntriesFast(); iDet++) {
421 AliReconstructor* reconstructor =
422 (AliReconstructor*) fReconstructors[iDet];
423 TString detName = reconstructor->GetDetectorName();
424 if (IsSelected(detName, detStr)) {
425 AliInfo(Form("running reconstruction for %s", detName.Data()));
426 TStopwatch stopwatchDet;
427 stopwatchDet.Start();
429 fRawReader->RewindEvents();
430 reconstructor->Reconstruct(fRunLoader, fRawReader);
432 reconstructor->Reconstruct(fRunLoader);
434 AliInfo(Form("execution time for %s:", detName.Data()));
435 ToAliInfo(stopwatchDet.Print());
439 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
440 AliError(Form("the following detectors were not found: %s",
442 if (fStopOnError) return kFALSE;
445 AliInfo("execution time:");
446 ToAliInfo(stopwatch.Print());
451 //_____________________________________________________________________________
452 Bool_t AliReconstruction::RunVertexFinder(AliESD*& esd)
454 // run the barrel tracking
456 TStopwatch stopwatch;
459 AliESDVertex* vertex = NULL;
460 Double_t vtxPos[3] = {0, 0, 0};
461 Double_t vtxErr[3] = {0.07, 0.07, 0.1};
463 if (fRunLoader->GetHeader() && fRunLoader->GetHeader()->GenEventHeader()) {
464 fRunLoader->GetHeader()->GenEventHeader()->PrimaryVertex(mcVertex);
465 for (Int_t i = 0; i < 3; i++) vtxPos[i] = mcVertex[i];
469 AliInfo("running the ITS vertex finder");
470 vertex = fITSVertexer->FindVertexForCurrentEvent(fRunLoader->GetEventNumber());
472 AliWarning("Vertex not found");
473 vertex = new AliESDVertex();
476 vertex->SetTruePos(vtxPos); // store also the vertex from MC
480 AliInfo("getting the primary vertex from MC");
481 vertex = new AliESDVertex(vtxPos, vtxErr);
485 vertex->GetXYZ(vtxPos);
486 vertex->GetSigmaXYZ(vtxErr);
488 AliWarning("no vertex reconstructed");
489 vertex = new AliESDVertex(vtxPos, vtxErr);
491 esd->SetVertex(vertex);
492 if (fITSTracker) fITSTracker->SetVertex(vtxPos, vtxErr);
493 if (fTPCTracker) fTPCTracker->SetVertex(vtxPos, vtxErr);
494 if (fTRDTracker) fTRDTracker->SetVertex(vtxPos, vtxErr);
497 AliInfo("execution time:");
498 ToAliInfo(stopwatch.Print());
503 //_____________________________________________________________________________
504 Bool_t AliReconstruction::RunTracking(AliESD*& esd)
506 // run the barrel tracking
508 TStopwatch stopwatch;
512 AliError("no TPC tracker");
515 AliInfo("running tracking");
518 AliDebug(1, "TPC tracking");
519 fTPCLoader->LoadRecPoints("read");
520 TTree* tpcTree = fTPCLoader->TreeR();
522 AliError("Can't get the TPC cluster tree");
525 fTPCTracker->LoadClusters(tpcTree);
526 if (fTPCTracker->Clusters2Tracks(esd) != 0) {
527 AliError("TPC Clusters2Tracks failed");
530 if (fCheckPointLevel > 1) WriteESD(esd, "TPC.tracking");
533 AliWarning("no ITS tracker");
536 GetReconstructor("TPC")->FillESD(fRunLoader, esd); // preliminary
537 AliESDpid::MakePID(esd); // PID for the ITS tracker
540 AliDebug(1, "ITS tracking");
541 fITSLoader->LoadRecPoints("read");
542 TTree* itsTree = fITSLoader->TreeR();
544 Error("RunTracking", "Can't get the ITS cluster tree");
547 fITSTracker->LoadClusters(itsTree);
548 if (fITSTracker->Clusters2Tracks(esd) != 0) {
549 AliError("ITS Clusters2Tracks failed");
552 if (fCheckPointLevel > 1) WriteESD(esd, "ITS.tracking");
554 if (fTRDTracker||fTOFTracker||fPHOSTracker||fEMCALTracker||fRICHTracker) {
555 // ITS back propagation
556 AliDebug(1, "ITS back propagation");
557 if (fITSTracker->PropagateBack(esd) != 0) {
558 AliError("ITS backward propagation failed");
561 if (fCheckPointLevel > 1) WriteESD(esd, "ITS.back");
563 // TPC back propagation
564 AliDebug(1, "TPC back propagation");
565 if (fTPCTracker->PropagateBack(esd) != 0) {
566 AliError("TPC backward propagation failed");
569 if (fCheckPointLevel > 1) WriteESD(esd, "TPC.back");
572 AliWarning("no TRD tracker");
574 // TRD back propagation
575 AliDebug(1, "TRD back propagation");
576 fTRDLoader->LoadRecPoints("read");
577 TTree* trdTree = fTRDLoader->TreeR();
579 AliError("Can't get the TRD cluster tree");
582 fTRDTracker->LoadClusters(trdTree);
583 if (fTRDTracker->PropagateBack(esd) != 0) {
584 AliError("TRD backward propagation failed");
587 if (fCheckPointLevel > 1) WriteESD(esd, "TRD.back");
591 AliWarning("no TOF tracker");
593 // TOF back propagation
594 AliDebug(1, "TOF back propagation");
595 fTOFLoader->LoadDigits("read");
596 TTree* tofTree = fTOFLoader->TreeD();
598 AliError("Can't get the TOF digits tree");
601 fTOFTracker->LoadClusters(tofTree);
602 if (fTOFTracker->PropagateBack(esd) != 0) {
603 AliError("TOF backward propagation failed");
606 if (fCheckPointLevel > 1) WriteESD(esd, "TOF.back");
607 fTOFTracker->UnloadClusters();
608 fTOFLoader->UnloadDigits();
611 AliWarning("no PHOS tracker");
613 // PHOS back propagation
614 AliDebug(1, "PHOS back propagation");
615 fPHOSLoader->LoadRecPoints("read");
616 TTree* phosTree = fPHOSLoader->TreeR();
618 AliError("Can't get the PHOS cluster tree");
621 fPHOSTracker->LoadClusters(phosTree);
622 if (fPHOSTracker->PropagateBack(esd) != 0) {
623 AliError("PHOS backward propagation failed");
626 if (fCheckPointLevel > 1) WriteESD(esd, "PHOS.back");
627 fPHOSTracker->UnloadClusters();
628 fPHOSLoader->UnloadRecPoints();
631 if (!fEMCALTracker) {
632 AliWarning("no EMCAL tracker");
634 // EMCAL back propagation
635 AliDebug(1, "EMCAL back propagation");
636 fEMCALLoader->LoadRecPoints("read");
637 TTree* emcalTree = fEMCALLoader->TreeR();
639 AliError("Can't get the EMCAL cluster tree");
642 fEMCALTracker->LoadClusters(emcalTree);
643 if (fEMCALTracker->PropagateBack(esd) != 0) {
644 AliError("EMCAL backward propagation failed");
647 if (fCheckPointLevel > 1) WriteESD(esd, "EMCAL.back");
648 fEMCALTracker->UnloadClusters();
649 fEMCALLoader->UnloadRecPoints();
653 AliWarning("no RICH tracker");
655 // RICH back propagation
656 AliDebug(1, "RICH back propagation");
657 fRICHLoader->LoadRecPoints("read");
658 TTree* richTree = fRICHLoader->TreeR();
660 AliError("Can't get the RICH cluster tree");
663 fRICHTracker->LoadClusters(richTree);
664 if (fRICHTracker->PropagateBack(esd) != 0) {
665 AliError("RICH backward propagation failed");
668 if (fCheckPointLevel > 1) WriteESD(esd, "RICH.back");
669 fRICHTracker->UnloadClusters();
670 fRICHLoader->UnloadRecPoints();
676 AliDebug(1, "TRD inward refit");
677 if (fTRDTracker->RefitInward(esd) != 0) {
678 AliError("TRD inward refit failed");
681 if (fCheckPointLevel > 1) WriteESD(esd, "TRD.refit");
682 fTRDTracker->UnloadClusters();
683 fTRDLoader->UnloadRecPoints();
687 AliInfo("TPC inward refit");
688 if (fTPCTracker->RefitInward(esd) != 0) {
689 AliError("TPC inward refit failed");
692 if (fCheckPointLevel > 1) WriteESD(esd, "TPC.refit");
695 AliInfo("ITS inward refit");
696 if (fITSTracker->RefitInward(esd) != 0) {
697 AliError("ITS inward refit failed");
700 if (fCheckPointLevel > 1) WriteESD(esd, "ITS.refit");
702 } // if TRD tracker or TOF tracker or PHOS tracker ...
703 fITSTracker->UnloadClusters();
704 fITSLoader->UnloadRecPoints();
707 fTPCTracker->UnloadClusters();
708 fTPCLoader->UnloadRecPoints();
710 AliInfo("execution time:");
711 ToAliInfo(stopwatch.Print());
716 //_____________________________________________________________________________
717 Bool_t AliReconstruction::FillESD(AliESD*& esd, const TString& detectors)
719 // fill the event summary data
721 TStopwatch stopwatch;
723 AliInfo("filling ESD");
725 TString detStr = detectors;
726 for (Int_t iDet = 0; iDet < fReconstructors.GetEntriesFast(); iDet++) {
727 AliReconstructor* reconstructor =
728 (AliReconstructor*) fReconstructors[iDet];
729 TString detName = reconstructor->GetDetectorName();
730 if (IsSelected(detName, detStr)) {
731 if (!ReadESD(esd, detName.Data())) {
732 AliDebug(1, Form("filling ESD for %s", detName.Data()));
734 reconstructor->FillESD(fRunLoader, fRawReader, esd);
736 reconstructor->FillESD(fRunLoader, esd);
738 if (fCheckPointLevel > 2) WriteESD(esd, detName.Data());
743 if ((detStr.CompareTo("ALL") != 0) && !detStr.IsNull()) {
744 AliError(Form("the following detectors were not found: %s",
746 if (fStopOnError) return kFALSE;
749 AliInfo("execution time:");
750 ToAliInfo(stopwatch.Print());
756 //_____________________________________________________________________________
757 Bool_t AliReconstruction::IsSelected(TString detName, TString& detectors) const
759 // check whether detName is contained in detectors
760 // if yes, it is removed from detectors
762 // check if all detectors are selected
763 if ((detectors.CompareTo("ALL") == 0) ||
764 detectors.BeginsWith("ALL ") ||
765 detectors.EndsWith(" ALL") ||
766 detectors.Contains(" ALL ")) {
771 // search for the given detector
772 Bool_t result = kFALSE;
773 if ((detectors.CompareTo(detName) == 0) ||
774 detectors.BeginsWith(detName+" ") ||
775 detectors.EndsWith(" "+detName) ||
776 detectors.Contains(" "+detName+" ")) {
777 detectors.ReplaceAll(detName, "");
781 // clean up the detectors string
782 while (detectors.Contains(" ")) detectors.ReplaceAll(" ", " ");
783 while (detectors.BeginsWith(" ")) detectors.Remove(0, 1);
784 while (detectors.EndsWith(" ")) detectors.Remove(detectors.Length()-1, 1);
789 //_____________________________________________________________________________
790 AliReconstructor* AliReconstruction::GetReconstructor(const char* detName) const
792 // get the reconstructor object for a detector
794 for (Int_t iDet = 0; iDet < fReconstructors.GetEntriesFast(); iDet++) {
795 AliReconstructor* reconstructor =
796 (AliReconstructor*) fReconstructors[iDet];
797 if (strcmp(reconstructor->GetDetectorName(), detName) == 0) {
798 return reconstructor;
804 //_____________________________________________________________________________
805 Bool_t AliReconstruction::CreateVertexer()
807 // create the vertexer
810 AliReconstructor* itsReconstructor = GetReconstructor("ITS");
811 if (itsReconstructor) {
812 fITSVertexer = itsReconstructor->CreateVertexer(fRunLoader);
815 AliWarning("couldn't create a vertexer for ITS");
816 if (fStopOnError) return kFALSE;
822 //_____________________________________________________________________________
823 Bool_t AliReconstruction::CreateTrackers()
825 // get the loaders and create the trackers
828 fITSLoader = fRunLoader->GetLoader("ITSLoader");
830 AliWarning("no ITS loader found");
831 if (fStopOnError) return kFALSE;
833 AliReconstructor* itsReconstructor = GetReconstructor("ITS");
834 if (itsReconstructor) {
835 fITSTracker = itsReconstructor->CreateTracker(fRunLoader);
838 AliWarning("couldn't create a tracker for ITS");
839 if (fStopOnError) return kFALSE;
844 fTPCLoader = fRunLoader->GetLoader("TPCLoader");
846 AliError("no TPC loader found");
847 if (fStopOnError) return kFALSE;
849 AliReconstructor* tpcReconstructor = GetReconstructor("TPC");
850 if (tpcReconstructor) {
851 fTPCTracker = tpcReconstructor->CreateTracker(fRunLoader);
854 AliError("couldn't create a tracker for TPC");
855 if (fStopOnError) return kFALSE;
860 fTRDLoader = fRunLoader->GetLoader("TRDLoader");
862 AliWarning("no TRD loader found");
863 if (fStopOnError) return kFALSE;
865 AliReconstructor* trdReconstructor = GetReconstructor("TRD");
866 if (trdReconstructor) {
867 fTRDTracker = trdReconstructor->CreateTracker(fRunLoader);
870 AliWarning("couldn't create a tracker for TRD");
871 if (fStopOnError) return kFALSE;
876 fTOFLoader = fRunLoader->GetLoader("TOFLoader");
878 AliWarning("no TOF loader found");
879 if (fStopOnError) return kFALSE;
881 AliReconstructor* tofReconstructor = GetReconstructor("TOF");
882 if (tofReconstructor) {
883 fTOFTracker = tofReconstructor->CreateTracker(fRunLoader);
886 AliWarning("couldn't create a tracker for TOF");
887 if (fStopOnError) return kFALSE;
892 fPHOSLoader = fRunLoader->GetLoader("PHOSLoader");
894 AliWarning("no PHOS loader found");
895 if (fStopOnError) return kFALSE;
897 AliReconstructor* phosReconstructor = GetReconstructor("PHOS");
898 if (phosReconstructor) {
899 fPHOSTracker = phosReconstructor->CreateTracker(fRunLoader);
902 AliWarning("couldn't create a tracker for PHOS");
903 if (fStopOnError) return kFALSE;
907 fEMCALTracker = NULL;
908 fEMCALLoader = fRunLoader->GetLoader("EMCALLoader");
910 AliWarning("no EMCAL loader found");
911 if (fStopOnError) return kFALSE;
913 AliReconstructor* emcalReconstructor = GetReconstructor("EMCAL");
914 if (emcalReconstructor) {
915 fEMCALTracker = emcalReconstructor->CreateTracker(fRunLoader);
917 if (!fEMCALTracker) {
918 AliWarning("couldn't create a tracker for EMCAL");
919 if (fStopOnError) return kFALSE;
924 fRICHLoader = fRunLoader->GetLoader("RICHLoader");
926 AliWarning("no RICH loader found");
927 if (fStopOnError) return kFALSE;
929 AliReconstructor* tofReconstructor = GetReconstructor("RICH");
930 if (tofReconstructor) {
931 fRICHTracker = tofReconstructor->CreateTracker(fRunLoader);
934 AliWarning("couldn't create a tracker for RICH");
935 if (fStopOnError) return kFALSE;
942 //_____________________________________________________________________________
943 void AliReconstruction::CleanUp(TFile* file)
945 // delete trackers and the run loader and close and delete the file
947 fReconstructors.Delete();
961 delete fEMCALTracker;
962 fEMCALTracker = NULL;
978 //_____________________________________________________________________________
979 Bool_t AliReconstruction::ReadESD(AliESD*& esd, const char* recStep) const
981 // read the ESD event from a file
983 if (!esd) return kFALSE;
985 sprintf(fileName, "ESD_%d.%d_%s.root",
986 esd->GetRunNumber(), esd->GetEventNumber(), recStep);
987 if (gSystem->AccessPathName(fileName)) return kFALSE;
989 AliDebug(1, Form("reading ESD from file %s", fileName));
990 TFile* file = TFile::Open(fileName);
991 if (!file || !file->IsOpen()) {
992 AliError(Form("opening %s failed", fileName));
999 esd = (AliESD*) file->Get("ESD");
1005 //_____________________________________________________________________________
1006 void AliReconstruction::WriteESD(AliESD* esd, const char* recStep) const
1008 // write the ESD event to a file
1012 sprintf(fileName, "ESD_%d.%d_%s.root",
1013 esd->GetRunNumber(), esd->GetEventNumber(), recStep);
1015 AliDebug(1, Form("writing ESD to file %s", fileName));
1016 TFile* file = TFile::Open(fileName, "recreate");
1017 if (!file || !file->IsOpen()) {
1018 AliError(Form("opening %s failed", fileName));