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