TPrincipal for the pi0 identification
[u/mrichter/AliRoot.git] / PHOS / AliPHOSEmcRecPoint.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//_________________________________________________________________________
b2a60966 19// RecPoint implementation for PHOS-EMC
20// An EmcRecPoint is a cluster of digits
baef0810 21//*--
b2a60966 22//*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
23
d15a28e7 24
25// --- ROOT system ---
9f616d61 26#include "TPad.h"
27#include "TH2.h"
d15a28e7 28#include "TMath.h"
9f616d61 29#include "TCanvas.h"
d15a28e7 30
31// --- Standard library ---
32
d15a28e7 33// --- AliRoot header files ---
34
a6eedfad 35 #include "AliGenerator.h"
d15a28e7 36#include "AliPHOSGeometry.h"
37#include "AliPHOSEmcRecPoint.h"
38#include "AliRun.h"
7b7c1533 39#include "AliPHOSGetter.h"
d15a28e7 40
41ClassImp(AliPHOSEmcRecPoint)
42
43//____________________________________________________________________________
7932f811 44AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() : AliPHOSRecPoint()
d15a28e7 45{
46 // ctor
47
48 fMulDigit = 0 ;
49 fAmp = 0. ;
7932f811 50 fCoreEnergy = 0 ;
51 fEnergyList = 0 ;
94256c23 52 fNExMax = 0 ; //Not unfolded yet
9688c1dd 53 fTime = -1. ;
a6eedfad 54 fLocPos.SetX(1000000.) ; //Local position should be evaluated
7b7c1533 55
83974468 56}
57
58//____________________________________________________________________________
73a68ccb 59AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) : AliPHOSRecPoint(opt)
60{
61 // ctor
62
63 fMulDigit = 0 ;
64 fAmp = 0. ;
94256c23 65 fNExMax = 0 ; //Not unfolded yet
73a68ccb 66 fCoreEnergy = 0 ;
67 fEnergyList = 0 ;
68 fTime = -1. ;
69 fLocPos.SetX(1000000.) ; //Local position should be evaluated
70
71}
72
73//____________________________________________________________________________
83974468 74AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
75{
88714635 76 // dtor
a4e98857 77
83974468 78 if ( fEnergyList )
79 delete[] fEnergyList ;
d15a28e7 80}
81
9f616d61 82//____________________________________________________________________________
83974468 83void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
d15a28e7 84{
b2a60966 85 // Adds a digit to the RecPoint
a4e98857 86 // and accumulates the total amplitude and the multiplicity
d15a28e7 87
7932f811 88 if(fEnergyList == 0)
89 fEnergyList = new Float_t[fMaxDigit];
90
d15a28e7 91 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
9f616d61 92 fMaxDigit*=2 ;
83974468 93 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
9f616d61 94 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
95
96 Int_t index ;
d15a28e7 97 for ( index = 0 ; index < fMulDigit ; index++ ){
83974468 98 tempo[index] = fDigitsList[index] ;
d15a28e7 99 tempoE[index] = fEnergyList[index] ;
100 }
101
9f616d61 102 delete [] fDigitsList ;
83974468 103 fDigitsList = new ( Int_t[fMaxDigit] ) ;
9f616d61 104
105 delete [] fEnergyList ;
106 fEnergyList = new ( Float_t[fMaxDigit] ) ;
107
108 for ( index = 0 ; index < fMulDigit ; index++ ){
109 fDigitsList[index] = tempo[index] ;
110 fEnergyList[index] = tempoE[index] ;
111 }
112
113 delete [] tempo ;
114 delete [] tempoE ;
115 } // if
d15a28e7 116
83974468 117 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
118 fEnergyList[fMulDigit] = Energy ;
119 fMulDigit++ ;
d15a28e7 120 fAmp += Energy ;
7932f811 121
122 EvalPHOSMod(&digit) ;
d15a28e7 123}
124
125//____________________________________________________________________________
ad8cfaf4 126Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
d15a28e7 127{
a4e98857 128 // Tells if (true) or not (false) two digits are neighbors
d15a28e7 129
130 Bool_t aren = kFALSE ;
131
7b7c1533 132 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
133 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
134
d15a28e7 135 Int_t relid1[4] ;
92862013 136 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
d15a28e7 137
138 Int_t relid2[4] ;
92862013 139 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
d15a28e7 140
92862013 141 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
142 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
d15a28e7 143
92862013 144 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
d15a28e7 145 aren = kTRUE ;
146
147 return aren ;
148}
149
150//____________________________________________________________________________
2a941f4e 151Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
d15a28e7 152{
b2a60966 153 // Compares two RecPoints according to their position in the PHOS modules
154
7932f811 155 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
156 //value (what is senseless) change as vell delta in
157 //AliPHOSTrackSegmentMakerv* and other RecPoints...
d15a28e7 158 Int_t rv ;
159
160 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
161
162
ad8cfaf4 163 Int_t phosmod1 = GetPHOSMod() ;
92862013 164 Int_t phosmod2 = clu->GetPHOSMod() ;
d15a28e7 165
92862013 166 TVector3 locpos1;
7932f811 167 GetLocalPosition(locpos1) ;
92862013 168 TVector3 locpos2;
169 clu->GetLocalPosition(locpos2) ;
d15a28e7 170
92862013 171 if(phosmod1 == phosmod2 ) {
7932f811 172 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
d15a28e7 173 if (rowdif> 0)
7932f811 174 rv = 1 ;
d15a28e7 175 else if(rowdif < 0)
7932f811 176 rv = -1 ;
92862013 177 else if(locpos1.Z()>locpos2.Z())
d15a28e7 178 rv = -1 ;
179 else
180 rv = 1 ;
181 }
182
183 else {
92862013 184 if(phosmod1 < phosmod2 )
d15a28e7 185 rv = -1 ;
186 else
187 rv = 1 ;
188 }
189
190 return rv ;
191}
9f616d61 192//______________________________________________________________________________
baef0810 193void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
9f616d61 194{
9f616d61 195
9688c1dd 196 // Execute action corresponding to one event
197 // This member function is called when a AliPHOSRecPoint is clicked with the locator
198 //
199 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
200 // and switched off when the mouse button is released.
201
202
203 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
204 if(!gime) return ;
205 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
83974468 206
9688c1dd 207 static TGraph * digitgraph = 0 ;
83974468 208
9688c1dd 209 if (!gPad->IsEditable()) return;
83974468 210
9688c1dd 211 TH2F * histo = 0 ;
212 TCanvas * histocanvas ;
213
afa51c4e 214 const TClonesArray * digits = gime->Digits() ;
9688c1dd 215
216 switch (event) {
83974468 217
9688c1dd 218 case kButton1Down: {
219 AliPHOSDigit * digit ;
220 Int_t iDigit;
221 Int_t relid[4] ;
83974468 222
9688c1dd 223 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
224 Float_t * xi = new Float_t[kMulDigit] ;
225 Float_t * zi = new Float_t[kMulDigit] ;
83974468 226
9688c1dd 227 // create the histogram for the single cluster
228 // 1. gets histogram boundaries
229 Float_t ximax = -999. ;
230 Float_t zimax = -999. ;
231 Float_t ximin = 999. ;
232 Float_t zimin = 999. ;
83974468 233
9688c1dd 234 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
235 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
236 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
237 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
238 if ( xi[iDigit] > ximax )
239 ximax = xi[iDigit] ;
240 if ( xi[iDigit] < ximin )
241 ximin = xi[iDigit] ;
242 if ( zi[iDigit] > zimax )
243 zimax = zi[iDigit] ;
244 if ( zi[iDigit] < zimin )
245 zimin = zi[iDigit] ;
246 }
247 ximax += phosgeom->GetCrystalSize(0) / 2. ;
248 zimax += phosgeom->GetCrystalSize(2) / 2. ;
249 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
250 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
251 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
252 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
83974468 253
9688c1dd 254 // 2. gets the histogram title
83974468 255
9688c1dd 256 Text_t title[100] ;
257 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
83974468 258
9688c1dd 259 if (!histo) {
260 delete histo ;
261 histo = 0 ;
262 }
263 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
83974468 264
9688c1dd 265 Float_t x, z ;
266 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
267 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
268 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
269 phosgeom->RelPosInModule(relid, x, z);
270 histo->Fill(x, z, fEnergyList[iDigit] ) ;
271 }
83974468 272
9688c1dd 273 if (!digitgraph) {
274 digitgraph = new TGraph(kMulDigit,xi,zi);
275 digitgraph-> SetMarkerStyle(5) ;
276 digitgraph-> SetMarkerSize(1.) ;
277 digitgraph-> SetMarkerColor(1) ;
278 digitgraph-> Paint("P") ;
279 }
83974468 280
9688c1dd 281 // Print() ;
282 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
283 histocanvas->Draw() ;
284 histo->Draw("lego1") ;
83974468 285
9688c1dd 286 delete[] xi ;
287 delete[] zi ;
83974468 288
9688c1dd 289 break;
290 }
83974468 291
9688c1dd 292 case kButton1Up:
293 if (digitgraph) {
294 delete digitgraph ;
295 digitgraph = 0 ;
296 }
297 break;
9f616d61 298
9688c1dd 299 }
9f616d61 300}
301
d15a28e7 302//____________________________________________________________________________
7932f811 303void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
d15a28e7 304{
b2a60966 305 // Calculates the dispersion of the shower at the origine of the RecPoint
306
e5b16749 307 Float_t d = 0. ;
308 Float_t wtot = 0. ;
d15a28e7 309
d084d50d 310 Float_t x = 0.;
311 Float_t z = 0.;
d15a28e7 312
313 AliPHOSDigit * digit ;
7b7c1533 314
315 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
316 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
d15a28e7 317
e5b16749 318
319 // Calculates the center of gravity in the local PHOS-module coordinates
320
d15a28e7 321 Int_t iDigit;
e5b16749 322
323 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
324 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
325 Int_t relid[4] ;
326 Float_t xi ;
327 Float_t zi ;
328 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
329 phosgeom->RelPosInModule(relid, xi, zi);
330 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
331 x += xi * w ;
332 z += zi * w ;
333 wtot += w ;
334 }
335 x /= wtot ;
336 z /= wtot ;
337
338
339// Calculates the dispersion in coordinates
340 wtot = 0.;
88714635 341 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
7932f811 342 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
d15a28e7 343 Int_t relid[4] ;
344 Float_t xi ;
345 Float_t zi ;
92862013 346 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
347 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 348 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
92862013 349 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
d15a28e7 350 wtot+=w ;
d084d50d 351
352
d15a28e7 353 }
e5b16749 354
7932f811 355
92862013 356 d /= wtot ;
d15a28e7 357
7932f811 358 fDispersion = TMath::Sqrt(d) ;
c63c49e9 359
d15a28e7 360}
fad3e5b9 361//______________________________________________________________________________
e5b16749 362void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
fad3e5b9 363{
a4e98857 364 // This function calculates energy in the core,
365 // i.e. within a radius rad = 3cm around the center. Beyond this radius
366 // in accordance with shower profile the energy deposition
fad3e5b9 367 // should be less than 2%
368
fad3e5b9 369 Float_t coreRadius = 3 ;
370
e5b16749 371 Float_t x = 0 ;
372 Float_t z = 0 ;
fad3e5b9 373
374 AliPHOSDigit * digit ;
7b7c1533 375
376 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
377 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
378
fad3e5b9 379 Int_t iDigit;
e5b16749 380
381// Calculates the center of gravity in the local PHOS-module coordinates
382 Float_t wtot = 0;
383 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
384 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
385 Int_t relid[4] ;
386 Float_t xi ;
387 Float_t zi ;
388 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
389 phosgeom->RelPosInModule(relid, xi, zi);
390 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
391 x += xi * w ;
392 z += zi * w ;
393 wtot += w ;
394 }
395 x /= wtot ;
396 z /= wtot ;
397
398
fad3e5b9 399 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
7932f811 400 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
fad3e5b9 401 Int_t relid[4] ;
402 Float_t xi ;
403 Float_t zi ;
404 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
405 phosgeom->RelPosInModule(relid, xi, zi);
406 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
407 if(distance < coreRadius)
7932f811 408 fCoreEnergy += fEnergyList[iDigit] ;
fad3e5b9 409 }
410
fad3e5b9 411}
d15a28e7 412
413//____________________________________________________________________________
7932f811 414void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
d15a28e7 415{
b2a60966 416 // Calculates the axis of the shower ellipsoid
83974468 417
e8dbb96e 418 Double_t wtot = 0. ;
419 Double_t x = 0.;
420 Double_t z = 0.;
421 Double_t dxx = 0.;
422 Double_t dzz = 0.;
423 Double_t dxz = 0.;
d15a28e7 424
425 AliPHOSDigit * digit ;
7b7c1533 426
427 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
428 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
429
d15a28e7 430 Int_t iDigit;
431
e5b16749 432
d15a28e7 433 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
7932f811 434 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
d15a28e7 435 Int_t relid[4] ;
436 Float_t xi ;
437 Float_t zi ;
92862013 438 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
439 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 440 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
92862013 441 dxx += w * xi * xi ;
d15a28e7 442 x += w * xi ;
92862013 443 dzz += w * zi * zi ;
d15a28e7 444 z += w * zi ;
92862013 445 dxz += w * xi * zi ;
d15a28e7 446 wtot += w ;
447 }
92862013 448 dxx /= wtot ;
d15a28e7 449 x /= wtot ;
92862013 450 dxx -= x * x ;
451 dzz /= wtot ;
d15a28e7 452 z /= wtot ;
92862013 453 dzz -= z * z ;
454 dxz /= wtot ;
455 dxz -= x * z ;
d15a28e7 456
69183710 457// //Apply correction due to non-perpendicular incidence
458// Double_t CosX ;
459// Double_t CosZ ;
7b7c1533 460// AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
461// AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
462 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
69183710 463
464// CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
465// CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
466
467// dxx = dxx/(CosX*CosX) ;
468// dzz = dzz/(CosZ*CosZ) ;
469// dxz = dxz/(CosX*CosZ) ;
470
471
7932f811 472 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
473 if(fLambda[0] > 0)
474 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
e8dbb96e 475
7932f811 476 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
477 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
478 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
e8dbb96e 479 else
7932f811 480 fLambda[1]= 0. ;
d15a28e7 481}
482
483//____________________________________________________________________________
7932f811 484void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
ad8cfaf4 485{
baef0810 486 // Evaluates all shower parameters
487
7932f811 488 EvalLocalPosition(logWeight, digits) ;
489 EvalElipsAxis(logWeight, digits) ;
490 EvalDispersion(logWeight, digits) ;
e5b16749 491 EvalCoreEnergy(logWeight, digits);
a6eedfad 492 EvalTime(digits) ;
bb53c80c 493 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
ad8cfaf4 494}
495//____________________________________________________________________________
7932f811 496void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
b2a60966 497{
498 // Calculates the center of gravity in the local PHOS-module coordinates
b2a60966 499 Float_t wtot = 0. ;
500
501 Int_t relid[4] ;
502
503 Float_t x = 0. ;
504 Float_t z = 0. ;
505
506 AliPHOSDigit * digit ;
507
7b7c1533 508 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
509 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
b2a60966 510
511 Int_t iDigit;
512
b2a60966 513 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
7932f811 514 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
b2a60966 515
516 Float_t xi ;
517 Float_t zi ;
518 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
519 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 520 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
b2a60966 521 x += xi * w ;
522 z += zi * w ;
523 wtot += w ;
b2a60966 524
9ce1a8d9 525 }
69183710 526
527 x /= wtot ;
528 z /= wtot ;
ad8cfaf4 529
530 // Correction for the depth of the shower starting point (TDR p 127)
531 Float_t para = 0.925 ;
532 Float_t parb = 6.52 ;
533
1b799736 534 Float_t xo,yo,zo ; //Coordinates of the origin
535 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
536
5830e1d9 537 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
1b799736 538
539 //Transform to the local ref.frame
540 Float_t xoL,yoL ;
541 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
542 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
543
fd84cb73 544 Float_t radius = phosgeom->GetIPtoCrystalSurface()-yoL;
1b799736 545
546 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
547 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
ad8cfaf4 548
549 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
550 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
ad8cfaf4 551
552 fLocPos.SetX(x - depthx) ;
b2a60966 553 fLocPos.SetY(0.) ;
ad8cfaf4 554 fLocPos.SetZ(z - depthz) ;
b2a60966 555
a6eedfad 556 fLocPosM = 0 ;
b2a60966 557}
558
559//____________________________________________________________________________
ad8cfaf4 560Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
d15a28e7 561{
b2a60966 562 // Finds the maximum energy in the cluster
563
d15a28e7 564 Float_t menergy = 0. ;
565
566 Int_t iDigit;
567
568 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
569
570 if(fEnergyList[iDigit] > menergy)
571 menergy = fEnergyList[iDigit] ;
572 }
573 return menergy ;
574}
575
576//____________________________________________________________________________
ad8cfaf4 577Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
d15a28e7 578{
b2a60966 579 // Calculates the multiplicity of digits with energy larger than H*energy
580
d15a28e7 581 Int_t multipl = 0 ;
582 Int_t iDigit ;
583 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
584
585 if(fEnergyList[iDigit] > H * fAmp)
586 multipl++ ;
587 }
588 return multipl ;
589}
590
591//____________________________________________________________________________
a0636361 592Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
7932f811 593 Float_t locMaxCut,TClonesArray * digits) const
d15a28e7 594{
b2a60966 595 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
a4e98857 596 // energy difference between two local maxima
b2a60966 597
d15a28e7 598 AliPHOSDigit * digit ;
599 AliPHOSDigit * digitN ;
600
601
602 Int_t iDigitN ;
603 Int_t iDigit ;
604
7932f811 605 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
a0636361 606 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
7932f811 607
d15a28e7 608
6ad0bfa0 609 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
a0636361 610 if(maxAt[iDigit]) {
611 digit = maxAt[iDigit] ;
83974468 612
6ad0bfa0 613 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
7932f811 614 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
d15a28e7 615
9f616d61 616 if ( AreNeighbours(digit, digitN) ) {
d15a28e7 617 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
a0636361 618 maxAt[iDigitN] = 0 ;
6ad0bfa0 619 // but may be digit too is not local max ?
7932f811 620 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
a0636361 621 maxAt[iDigit] = 0 ;
d15a28e7 622 }
623 else {
a0636361 624 maxAt[iDigit] = 0 ;
6ad0bfa0 625 // but may be digitN too is not local max ?
7932f811 626 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
a0636361 627 maxAt[iDigitN] = 0 ;
d15a28e7 628 }
629 } // if Areneighbours
630 } // while digitN
631 } // slot not empty
632 } // while digit
633
634 iDigitN = 0 ;
6ad0bfa0 635 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
a0636361 636 if(maxAt[iDigit]){
d15a28e7 637 maxAt[iDigitN] = maxAt[iDigit] ;
9f616d61 638 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
639 iDigitN++ ;
d15a28e7 640 }
641 }
642 return iDigitN ;
643}
9688c1dd 644//____________________________________________________________________________
645void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits){
646
647 Float_t maxE = 0;
648 Int_t maxAt = 0;
649 for(Int_t idig=0; idig < fMulDigit; idig++){
650 if(fEnergyList[idig] > maxE){
651 maxE = fEnergyList[idig] ;
652 maxAt = idig;
653 }
654 }
655 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
656
657}
d15a28e7 658//____________________________________________________________________________
092b50ba 659void AliPHOSEmcRecPoint::Purify(Float_t threshold){
660 //Removes digits below threshold
661
662 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
663 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
664
665 Int_t mult = 0 ;
666 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
667 if(fEnergyList[iDigit] > threshold){
668 tempo[mult] = fDigitsList[iDigit] ;
669 tempoE[mult] = fEnergyList[iDigit] ;
670 mult++ ;
671 }
672 }
673
674 fMulDigit = mult ;
675 delete [] fDigitsList ;
676 delete [] fEnergyList ;
677 fDigitsList = new (Int_t[fMulDigit]) ;
678 fEnergyList = new ( Float_t[fMulDigit]) ;
679
680 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
681 fDigitsList[iDigit] = tempo[iDigit];
682 fEnergyList[iDigit] = tempoE[iDigit] ;
683 }
684
685 delete [] tempo ;
686 delete [] tempoE ;
687
688}
689//____________________________________________________________________________
690void AliPHOSEmcRecPoint::Print(Option_t * option) const
d15a28e7 691{
b2a60966 692 // Print the list of digits belonging to the cluster
693
21cd0c07 694 TString message ;
695 message = "AliPHOSEmcRecPoint:\n" ;
696 message += " digits # = " ;
697 Info("Print", message.Data()) ;
d15a28e7 698
d15a28e7 699 Int_t iDigit;
7932f811 700 for(iDigit=0; iDigit<fMulDigit; iDigit++)
21cd0c07 701 Info("Print", " %d ", fDigitsList[iDigit] ) ;
7932f811 702
21cd0c07 703 Info("Print", " Energies = ") ;
7932f811 704 for(iDigit=0; iDigit<fMulDigit; iDigit++)
21cd0c07 705 Info("Print", " %f ", fEnergyList[iDigit] ) ;
83974468 706
21cd0c07 707 Info("Print", " Primaries ") ;
bc68d12c 708 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
21cd0c07 709 Info("Print", " %d ", fTracksList[iDigit]) ;
bc68d12c 710
21cd0c07 711 message = " Multiplicity = %d" ;
712 message += " Cluster Energy = %f" ;
713 message += " Number of primaries %d" ;
714 message += " Stored at position %d" ;
83974468 715
21cd0c07 716 Info("Print", message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
d15a28e7 717}
88714635 718
7932f811 719