]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSReconstructor.cxx
New data members: distance to bad channels from the center of a reconstructed cluster...
[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"
23904d16 35#include "AliPHOSTracker.h"
d22dd3b4 36#include "AliRawReader.h"
64df000d 37#include "AliPHOSTrigger.h"
38#include "AliPHOSGeometry.h"
e957fea8 39
f444a19f 40ClassImp(AliPHOSReconstructor)
d15a28e7 41
2e60107f 42Bool_t AliPHOSReconstructor::fgDebug = kFALSE ;
43
d15a28e7 44//____________________________________________________________________________
2e60107f 45 AliPHOSReconstructor::AliPHOSReconstructor()
d15a28e7 46{
b2a60966 47 // ctor
0379a13e 48
6ad0bfa0 49}
50
0379a13e 51//____________________________________________________________________________
52 AliPHOSReconstructor::~AliPHOSReconstructor()
53{
54 // dtor
55
56}
7acf6008 57
7acf6008 58//____________________________________________________________________________
772634e0 59void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader) const
35293055 60{
dfe0be07 61 // method called by AliReconstruction;
62 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
63 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
64 // the global tracking.
65
66 TString headerFile(runLoader->GetFileName()) ;
9ee4fde2 67 TString branchName(runLoader->GetEventFolder()->GetName()) ;
a68156e6 68
69 AliPHOSClusterizerv1 clu(headerFile, branchName);
70 clu.SetEventRange(0, -1) ; // do all the events
71 if ( Debug() )
72 clu.ExecuteTask("deb all") ;
73 else
74 clu.ExecuteTask("") ;
75
76}
77
78//____________________________________________________________________________
772634e0 79void AliPHOSReconstructor::Reconstruct(AliRunLoader* runLoader, AliRawReader* rawreader) const
a68156e6 80{
81 // method called by AliReconstruction;
82 // Only the clusterization is performed,; the rest of the reconstruction is done in FillESD because the track
83 // segment maker needs access to the AliESD object to retrieve the tracks reconstructed by
84 // the global tracking.
85 // Here we reconstruct from Raw Data
772634e0 86
a68156e6 87 rawreader->Reset() ;
88 TString headerFile(runLoader->GetFileName()) ;
89 TString branchName(runLoader->GetEventFolder()->GetName()) ;
35293055 90
dfe0be07 91 AliPHOSClusterizerv1 clu(headerFile, branchName);
f88e2313 92 clu.SetEventRange(0, -1) ; // do all the events
d22dd3b4 93 clu.SetRawReader(rawreader);
f5eaa851 94
95 TString option = GetOption();
96 if (option.Contains("OldRCUFormat"))
97 clu.SetOldRCUFormat(kTRUE);
98
dfe0be07 99 if ( Debug() )
100 clu.ExecuteTask("deb all") ;
101 else
d22dd3b4 102 clu.ExecuteTask("") ;
0379a13e 103
35293055 104}
7acf6008 105
7acf6008 106//____________________________________________________________________________
dfe0be07 107void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader, AliESD* esd) const
7acf6008 108{
23904d16 109 // This function creates AliESDtracks from AliPHOSRecParticles
110 // and
111 // writes them to the ESD
bf72996e 112
23904d16 113 Int_t eventNumber = runLoader->GetEventNumber() ;
dfe0be07 114
25ed816e 115 AliPHOSGetter *gime = AliPHOSGetter::Instance();
116 gime->Event(eventNumber, "DRTP") ;
117 TClonesArray *recParticles = gime->RecParticles();
dfe0be07 118 Int_t nOfRecParticles = recParticles->GetEntries();
25ed816e 119
85c60a8e 120 esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
dd7ee508 121 esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
122
123 AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
8013c27e 124
64df000d 125
126 //#########Calculate trigger and set trigger info###########
127
128 AliPHOSTrigger tr ;
129 // tr.SetPatchSize(1);//create 4x4 patches
130 tr.Trigger();
131
132 Float_t maxAmp2x2 = tr.Get2x2MaxAmplitude();
133 Float_t maxAmpnxn = tr.GetnxnMaxAmplitude();
134 Float_t ampOutOfPatch2x2 = tr.Get2x2AmpOutOfPatch() ;
135 Float_t ampOutOfPatchnxn = tr.GetnxnAmpOutOfPatch() ;
136
137 AliPHOSGeometry * geom = gime->PHOSGeometry();
138
139 Int_t iSM2x2 = tr.Get2x2SuperModule();
140 Int_t iSMnxn = tr.GetnxnSuperModule();
141 Int_t iCrystalPhi2x2 = tr.Get2x2CrystalPhi();
142 Int_t iCrystalPhinxn = tr.GetnxnCrystalPhi();
143 Int_t iCrystalEta2x2 = tr.Get2x2CrystalEta();
144 Int_t iCrystalEtanxn = tr.GetnxnCrystalEta();
145
146 AliDebug(2, Form("Trigger 2x2 max amp %f, out amp %f, SM %d, iphi %d ieta %d", maxAmp2x2, ampOutOfPatch2x2, iSM2x2,iCrystalPhi2x2, iCrystalEta2x2));
147 AliDebug(2, Form("Trigger 4x4 max amp %f , out amp %f, SM %d, iphi %d, ieta %d", maxAmpnxn, ampOutOfPatchnxn, iSMnxn,iCrystalPhinxn, iCrystalEtanxn));
148
24b8fcca 149 Int_t iRelId2x2 []= {iSM2x2+1,0,iCrystalPhi2x2,iCrystalEta2x2};// PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger.
64df000d 150 Int_t iAbsId2x2 =-1;
24b8fcca 151 Int_t iRelIdnxn []= {iSMnxn+1,0,iCrystalPhinxn,iCrystalEtanxn};// PHOS modules in order to calculate AbsId need to be 1-5 not 0-4 as returns trigger.
64df000d 152 Int_t iAbsIdnxn =-1;
153 TVector3 pos2x2(-1,-1,-1);
154 TVector3 posnxn(-1,-1,-1);
155 geom->RelToAbsNumbering(iRelId2x2, iAbsId2x2);
156 geom->RelToAbsNumbering(iRelIdnxn, iAbsIdnxn);
157 geom->RelPosInAlice(iAbsId2x2, pos2x2);
158 geom->RelPosInAlice(iAbsIdnxn, posnxn);
159
160 TArrayF triggerPosition(6);
161 triggerPosition[0] = pos2x2(0) ;
162 triggerPosition[1] = pos2x2(1) ;
163 triggerPosition[2] = pos2x2(2) ;
164 triggerPosition[3] = posnxn(0) ;
165 triggerPosition[4] = posnxn(1) ;
166 triggerPosition[5] = posnxn(2) ;
167
168 TArrayF triggerAmplitudes(4);
169 triggerAmplitudes[0] = maxAmp2x2 ;
170 triggerAmplitudes[1] = ampOutOfPatch2x2 ;
171 triggerAmplitudes[2] = maxAmpnxn ;
172 triggerAmplitudes[3] = ampOutOfPatchnxn ;
173
174 //esd->SetPHOSTriggerCells(triggerPosition);
175 esd->AddPHOSTriggerPosition(triggerPosition);
176 esd->AddPHOSTriggerAmplitudes(triggerAmplitudes);
177
178 //######################################
179
180 //Fill CaloClusters
dfe0be07 181 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
182 AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
183 if (Debug())
184 rp->Print();
25ed816e 185 // Get track segment and EMC rec.point associated with this rec.particle
186 AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
187 AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
188 AliESDCaloCluster *ec = new AliESDCaloCluster() ;
189
64df000d 190 // fills the ESDCaloCluster
85c60a8e 191 Float_t xyz[3];
8013c27e 192 for (Int_t ixyz=0; ixyz<3; ixyz++)
193 xyz[ixyz] = rp->GetPos()[ixyz];
dd7ee508 194
195 AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
196
64df000d 197
25ed816e 198 Int_t digitMult = emcRP->GetDigitsMultiplicity();
199 Int_t *digitsList = emcRP->GetDigitsList();
200 UShort_t *amplList = new UShort_t[digitMult];
201 UShort_t *timeList = new UShort_t[digitMult];
202 UShort_t *digiList = new UShort_t[digitMult];
203
204 // Convert Float_t* and Int_t* to UShort_t* to save memory
205 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
206 AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
ae3e6f29 207 amplList[iDigit] = (UShort_t)(digit->GetEnergy()*500); // Energy in units of GeV/500
208 timeList[iDigit] = (UShort_t)(digit->GetTime()*1e9*100); // time in units of 0.01 ns
25ed816e 209 digiList[iDigit] = (UShort_t)(digit->GetId());
210 }
34541ea2 211
212 ec->SetPHOS(kTRUE);
25ed816e 213 ec->SetGlobalPosition(xyz); //rec.point position in MARS
214 ec->SetClusterEnergy(rp->Energy()); //total particle energy
215 ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
216 ec->SetPid (rp->GetPID()) ; //array of particle identification
25ed816e 217 ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
218 ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
219 ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
220 ec->SetNumberOfDigits(digitMult); //digit multiplicity
221 ec->SetDigitAmplitude(amplList); //energies in 1/500 of GeV
222 ec->SetDigitTime(timeList); //times in 1/100 on ns
223 ec->SetDigitIndex(digiList); //abs id of the cell
224 ec->SetEmcCpvDistance(-1); //not yet implemented
225 ec->SetClusterChi2(-1); //not yet implemented
226 ec->SetM11(-1) ; //not yet implemented
227
64df000d 228 //Primaries
229 ec->SetPrimaryIndex(rp->GetPrimaryIndex());
230 Int_t primMult = 0;
231 Int_t *primInts = emcRP->GetPrimaries(primMult);
232 ec->SetNumberOfPrimaries(primMult); //primary multiplicity
233 UShort_t *primList = new UShort_t[primMult];
234 for (Int_t ipr=0; ipr<primMult; ipr++)
235 primList[ipr] = (UShort_t)(primInts[ipr]);
236 ec->SetListOfPrimaries(primList); //primary List for a cluster
237
dfe0be07 238 // add the track to the esd object
85c60a8e 239 esd->AddCaloCluster(ec);
dd7ee508 240 delete ec;
241 }
242}
243
34541ea2 244//____________________________________________________________________________
dd7ee508 245void AliPHOSReconstructor::FillESD(AliRunLoader* runLoader,
246 AliRawReader* rawReader, AliESD* esd) const
247{
248 //This function creates AliESDtracks from AliPHOSRecParticles
249 //and writes them to the ESD in the case of raw data reconstruction.
250
251 Int_t eventNumber = runLoader->GetEventNumber() ;
252
dd7ee508 253 AliPHOSGetter *gime = AliPHOSGetter::Instance();
cbddd97f 254 gime->Event(eventNumber, "DRTP") ;
dd7ee508 255
256 TClonesArray *recParticles = gime->RecParticles();
257 Int_t nOfRecParticles = recParticles->GetEntries();
258
259 esd->SetNumberOfPHOSClusters(nOfRecParticles) ;
260 esd->SetFirstPHOSCluster(esd->GetNumberOfCaloClusters()) ;
261
262 AliDebug(2,Form("%d digits and %d rec. particles in event %d, option %s",gime->Digits()->GetEntries(),nOfRecParticles,eventNumber,GetOption()));
263
264 for (Int_t recpart = 0 ; recpart < nOfRecParticles ; recpart++) {
265 AliPHOSRecParticle * rp = dynamic_cast<AliPHOSRecParticle*>(recParticles->At(recpart));
266
267 if(rp) {
268 Float_t xyz[3];
269 for (Int_t ixyz=0; ixyz<3; ixyz++)
270 xyz[ixyz] = rp->GetPos()[ixyz];
271
272 AliDebug(2,Form("Global position xyz=(%f,%f,%f)",xyz[0],xyz[1],xyz[2]));
273
274 AliPHOSTrackSegment *ts = gime->TrackSegment(rp->GetPHOSTSIndex());
275 AliPHOSEmcRecPoint *emcRP = gime->EmcRecPoint(ts->GetEmcIndex());
276 AliESDCaloCluster *ec = new AliESDCaloCluster() ;
277
278 Int_t digitMult = emcRP->GetDigitsMultiplicity();
279 Int_t *digitsList = emcRP->GetDigitsList();
280 UShort_t *amplList = new UShort_t[digitMult];
281 UShort_t *digiList = new UShort_t[digitMult];
282
283 // Convert Float_t* and Int_t* to UShort_t* to save memory
284 for (Int_t iDigit=0; iDigit<digitMult; iDigit++) {
285 AliPHOSDigit *digit = gime->Digit(digitsList[iDigit]);
286 if(!digit) {
287 AliFatal(Form("Digit not found at the expected position %d!",iDigit));
288 }
289 else {
cbddd97f 290 amplList[iDigit] = (UShort_t)digit->GetEnergy();
dd7ee508 291 digiList[iDigit] = (UShort_t)(digit->GetId());
292 }
293 }
294
34541ea2 295 ec->SetPHOS(kTRUE);
dd7ee508 296 ec->SetGlobalPosition(xyz); //rec.point position in MARS
297 ec->SetClusterEnergy(rp->Energy()); //total particle energy
298 ec->SetClusterDisp(emcRP->GetDispersion()); //cluster dispersion
299 ec->SetPid (rp->GetPID()) ; //array of particle identification
300 ec->SetM02(emcRP->GetM2x()) ; //second moment M2x
301 ec->SetM20(emcRP->GetM2z()) ; //second moment M2z
302 ec->SetNExMax(emcRP->GetNExMax()); //number of local maxima
303 ec->SetNumberOfDigits(digitMult); //digit multiplicity
cbddd97f 304 ec->SetDigitAmplitude(amplList); //digit energies
dd7ee508 305 ec->SetDigitIndex(digiList); //abs id of the cell
306 ec->SetEmcCpvDistance(-1); //not yet implemented
307 ec->SetClusterChi2(-1); //not yet implemented
308 ec->SetM11(-1) ; //not yet implemented
309
310 // add the track to the esd object
311 esd->AddCaloCluster(ec);
312 delete ec;
313
314 }
315 }
316
317
d7d3b67b 318}
23904d16 319
320AliTracker* AliPHOSReconstructor::CreateTracker(AliRunLoader* runLoader) const
321{
322// creates the PHOS tracker
323 if (!runLoader) return NULL;
324 return new AliPHOSTracker(runLoader);
325}
326