bugfix
[u/mrichter/AliRoot.git] / PHOS / AliPHOSReconstructor.cxx
CommitLineData
d15a28e7 1/**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
6 * *
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 **************************************************************************/
15
b2a60966 16/* $Id$ */
17
d15a28e7 18//_________________________________________________________________________
a3dfe79c 19//*--
dfe0be07 20//*-- Yves Schutz (SUBATECH)
21// Reconstruction class. Redesigned from the old AliReconstructionner class and
22// derived from STEER/AliReconstructor.
23//
d15a28e7 24// --- ROOT system ---
25
d15a28e7 26// --- Standard library ---
364de5c6 27
d15a28e7 28// --- AliRoot header files ---
35293055 29#include "AliESD.h"
f444a19f 30#include "AliPHOSReconstructor.h"
7acf6008 31#include "AliPHOSClusterizerv1.h"
7acf6008 32#include "AliPHOSTrackSegmentMakerv1.h"
33#include "AliPHOSPIDv1.h"
35293055 34#include "AliPHOSGetter.h"
a68156e6 35#include "AliRawReaderFile.h"
e957fea8 36
2e60107f 37
f444a19f 38ClassImp(AliPHOSReconstructor)
d15a28e7 39
2e60107f 40Bool_t AliPHOSReconstructor::fgDebug = kFALSE ;
41
d15a28e7 42//____________________________________________________________________________
2e60107f 43 AliPHOSReconstructor::AliPHOSReconstructor()
d15a28e7 44{
b2a60966 45 // ctor
0379a13e 46
6ad0bfa0 47}
48
0379a13e 49//____________________________________________________________________________
50 AliPHOSReconstructor::~AliPHOSReconstructor()
51{
52 // dtor
53
54}
7acf6008 55
7acf6008 56//____________________________________________________________________________
dfe0be07 57void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader) const
35293055 58{
dfe0be07 59 // method called by AliReconstruction;
60 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
61 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
62 // the global tracking.
63
64 TString headerFile(runLoader->GetFileName()) ;
9ee4fde2 65 TString branchName(runLoader->GetEventFolder()->GetName()) ;
a68156e6 66
67 AliPHOSClusterizerv1 clu(headerFile, branchName);
68 clu.SetEventRange(0, -1) ; // do all the events
69 if ( Debug() )
70 clu.ExecuteTask("deb all") ;
71 else
72 clu.ExecuteTask("") ;
73
74}
75
76//____________________________________________________________________________
77void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReaderFile* rawreader) const
78{
79 // method called by AliReconstruction;
80 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
81 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
82 // the global tracking.
83 // Here we reconstruct from Raw Data
84
85 rawreader->Reset() ;
86 TString headerFile(runLoader->GetFileName()) ;
87 TString branchName(runLoader->GetEventFolder()->GetName()) ;
35293055 88
dfe0be07 89 AliPHOSClusterizerv1 clu(headerFile, branchName);
90 clu.SetEventRange(0, -1) ; // do all the events
91 if ( Debug() )
92 clu.ExecuteTask("deb all") ;
93 else
94 clu.ExecuteTask("") ;
0379a13e 95
35293055 96}
7acf6008 97
7acf6008 98//____________________________________________________________________________
dfe0be07 99void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
7acf6008 100{
dfe0be07 101 // Called by AliReconstruct after Reconstruct() and global tracking and vertxing
102 //Creates the tracksegments and Recparticles
103
bf72996e 104 Int_t eventNumber = runLoader->GetEventNumber() ;
105
dfe0be07 106 TString headerFile(runLoader->GetFileName()) ;
bf72996e 107 TString branchName(runLoader->GetEventFolder()->GetName()) ;
dfe0be07 108
0379a13e 109 AliPHOSTrackSegmentMakerv1 tsm(headerFile, branchName);
8013c27e 110 tsm.SetESD(esd) ;
0379a13e 111 AliPHOSPIDv1 pid(headerFile, branchName);
dfe0be07 112
dfe0be07 113 // do current event; the loop over events is done by AliReconstruction::Run()
0379a13e 114 tsm.SetEventRange(eventNumber, eventNumber) ;
115 pid.SetEventRange(eventNumber, eventNumber) ;
dfe0be07 116 if ( Debug() ) {
0379a13e 117 tsm.ExecuteTask("deb all") ;
118 pid.ExecuteTask("deb all") ;
7acf6008 119 }
dfe0be07 120 else {
0379a13e 121 tsm.ExecuteTask("") ;
122 pid.ExecuteTask("") ;
7acf6008 123 }
dfe0be07 124
125 // Creates AliESDtrack from AliPHOSRecParticles
0379a13e 126 AliPHOSGetter::Instance()->Event(eventNumber, "P") ;
127 TClonesArray *recParticles = AliPHOSGetter::Instance()->RecParticles();
dfe0be07 128 Int_t nOfRecParticles = recParticles->GetEntries();
8013c27e 129 esd->SetNumberOfPHOSParticles(nOfRecParticles) ;
130 esd->SetFirstPHOSParticle(esd->GetNumberOfTracks()) ;
131
dfe0be07 132 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
133 AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
134 if (Debug())
135 rp->Print();
136 AliESDtrack * et = new AliESDtrack() ;
137 // fills the ESDtrack
138 Double_t xyz[3];
8013c27e 139 for (Int_t ixyz=0; ixyz<3; ixyz++)
140 xyz[ixyz] = rp->GetPos()[ixyz];
dfe0be07 141 et->SetPHOSposition(xyz) ;
142 et->SetPHOSsignal (rp->Energy()) ;
143 et->SetPHOSpid (rp->GetPID()) ;
144 // add the track to the esd object
145 esd->AddTrack(et);
146 delete et;
7acf6008 147 }
d7d3b67b 148}