]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSEmcRecPoint.cxx
Copy constructor is corrected (by T.P.)
[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 "TH2.h"
d15a28e7 27#include "TMath.h"
9f616d61 28#include "TCanvas.h"
55fe9d13 29#include "TGraph.h"
d15a28e7 30
31// --- Standard library ---
32
d15a28e7 33// --- AliRoot header files ---
351dd634 34#include "AliLog.h"
e957fea8 35#include "AliPHOSLoader.h"
88cb7938 36#include "AliGenerator.h"
d15a28e7 37#include "AliPHOSGeometry.h"
e957fea8 38#include "AliPHOSDigit.h"
d15a28e7 39#include "AliPHOSEmcRecPoint.h"
e957fea8 40
d15a28e7 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
ce2a9a95 55 fDebug=0;
7b7c1533 56
83974468 57}
58
73a68ccb 59//____________________________________________________________________________
60AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) : AliPHOSRecPoint(opt)
61{
62 // ctor
63
64 fMulDigit = 0 ;
65 fAmp = 0. ;
94256c23 66 fNExMax = 0 ; //Not unfolded yet
73a68ccb 67 fCoreEnergy = 0 ;
68 fEnergyList = 0 ;
69 fTime = -1. ;
70 fLocPos.SetX(1000000.) ; //Local position should be evaluated
ce2a9a95 71 fDebug=0;
73a68ccb 72
73}
74
55fe9d13 75//____________________________________________________________________________
76AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) : AliPHOSRecPoint(rp)
77{
78 // cpy ctor
79
80 fMulDigit = rp.fMulDigit ;
81 fAmp = rp.fAmp ;
82 fCoreEnergy = rp.fCoreEnergy ;
83 fEnergyList = new Float_t[rp.fMulDigit] ;
84 Int_t index ;
85 for(index = 0 ; index < fMulDigit ; index++)
86 fEnergyList[index] = rp.fEnergyList[index] ;
87 fNExMax = rp.fNExMax ;
88 fTime = rp.fTime ;
89}
90
83974468 91//____________________________________________________________________________
92AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
93{
88714635 94 // dtor
a4e98857 95
83974468 96 if ( fEnergyList )
97 delete[] fEnergyList ;
d15a28e7 98}
99
d15a28e7 100//____________________________________________________________________________
83974468 101void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
d15a28e7 102{
b2a60966 103 // Adds a digit to the RecPoint
a4e98857 104 // and accumulates the total amplitude and the multiplicity
d15a28e7 105
7932f811 106 if(fEnergyList == 0)
107 fEnergyList = new Float_t[fMaxDigit];
108
d15a28e7 109 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
9f616d61 110 fMaxDigit*=2 ;
0fbb8738 111 Int_t * tempo = new Int_t[fMaxDigit];
112 Float_t * tempoE = new Float_t[fMaxDigit];
9f616d61 113
114 Int_t index ;
d15a28e7 115 for ( index = 0 ; index < fMulDigit ; index++ ){
83974468 116 tempo[index] = fDigitsList[index] ;
d15a28e7 117 tempoE[index] = fEnergyList[index] ;
118 }
119
9f616d61 120 delete [] fDigitsList ;
0fbb8738 121 fDigitsList = new Int_t[fMaxDigit];
9f616d61 122
123 delete [] fEnergyList ;
0fbb8738 124 fEnergyList = new Float_t[fMaxDigit];
9f616d61 125
126 for ( index = 0 ; index < fMulDigit ; index++ ){
127 fDigitsList[index] = tempo[index] ;
128 fEnergyList[index] = tempoE[index] ;
129 }
130
131 delete [] tempo ;
132 delete [] tempoE ;
133 } // if
d15a28e7 134
83974468 135 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
136 fEnergyList[fMulDigit] = Energy ;
137 fMulDigit++ ;
d15a28e7 138 fAmp += Energy ;
7932f811 139
140 EvalPHOSMod(&digit) ;
d15a28e7 141}
142
143//____________________________________________________________________________
ad8cfaf4 144Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
d15a28e7 145{
a4e98857 146 // Tells if (true) or not (false) two digits are neighbors
d15a28e7 147
148 Bool_t aren = kFALSE ;
149
686b771f 150 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
7b7c1533 151
d15a28e7 152 Int_t relid1[4] ;
92862013 153 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
d15a28e7 154
155 Int_t relid2[4] ;
92862013 156 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
d15a28e7 157
92862013 158 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
159 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
d15a28e7 160
92862013 161 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
d15a28e7 162 aren = kTRUE ;
163
164 return aren ;
165}
166
167//____________________________________________________________________________
2a941f4e 168Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
d15a28e7 169{
b2a60966 170 // Compares two RecPoints according to their position in the PHOS modules
686b771f 171
172 const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
7932f811 173 //value (what is senseless) change as vell delta in
174 //AliPHOSTrackSegmentMakerv* and other RecPoints...
d15a28e7 175 Int_t rv ;
176
177 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
178
179
ad8cfaf4 180 Int_t phosmod1 = GetPHOSMod() ;
92862013 181 Int_t phosmod2 = clu->GetPHOSMod() ;
d15a28e7 182
92862013 183 TVector3 locpos1;
7932f811 184 GetLocalPosition(locpos1) ;
92862013 185 TVector3 locpos2;
186 clu->GetLocalPosition(locpos2) ;
d15a28e7 187
92862013 188 if(phosmod1 == phosmod2 ) {
7932f811 189 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
d15a28e7 190 if (rowdif> 0)
7932f811 191 rv = 1 ;
d15a28e7 192 else if(rowdif < 0)
7932f811 193 rv = -1 ;
92862013 194 else if(locpos1.Z()>locpos2.Z())
d15a28e7 195 rv = -1 ;
196 else
197 rv = 1 ;
198 }
199
200 else {
92862013 201 if(phosmod1 < phosmod2 )
d15a28e7 202 rv = -1 ;
203 else
204 rv = 1 ;
205 }
206
207 return rv ;
208}
9f616d61 209//______________________________________________________________________________
8f2a3661 210void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) const
9f616d61 211{
9f616d61 212
9688c1dd 213 // Execute action corresponding to one event
214 // This member function is called when a AliPHOSRecPoint is clicked with the locator
215 //
216 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
217 // and switched off when the mouse button is released.
218
88cb7938 219
686b771f 220 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
83974468 221
9688c1dd 222 static TGraph * digitgraph = 0 ;
83974468 223
9688c1dd 224 if (!gPad->IsEditable()) return;
83974468 225
9688c1dd 226 TH2F * histo = 0 ;
227 TCanvas * histocanvas ;
228
88cb7938 229
230 //try to get run loader from default event folder
e191bb57 231 AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
88cb7938 232 if (rn == 0x0)
233 {
351dd634 234 AliError(Form("Cannot find Run Loader in Default Event Folder"));
88cb7938 235 return;
236 }
237 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
238 if (gime == 0x0)
239 {
351dd634 240 AliError(Form("Cannot find PHOS Loader from Run Loader"));
88cb7938 241 return;
242 }
243
244
afa51c4e 245 const TClonesArray * digits = gime->Digits() ;
9688c1dd 246
247 switch (event) {
83974468 248
9688c1dd 249 case kButton1Down: {
250 AliPHOSDigit * digit ;
251 Int_t iDigit;
252 Int_t relid[4] ;
83974468 253
9688c1dd 254 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
255 Float_t * xi = new Float_t[kMulDigit] ;
256 Float_t * zi = new Float_t[kMulDigit] ;
83974468 257
9688c1dd 258 // create the histogram for the single cluster
259 // 1. gets histogram boundaries
260 Float_t ximax = -999. ;
261 Float_t zimax = -999. ;
262 Float_t ximin = 999. ;
263 Float_t zimin = 999. ;
83974468 264
9688c1dd 265 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
266 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
267 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
268 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
269 if ( xi[iDigit] > ximax )
270 ximax = xi[iDigit] ;
271 if ( xi[iDigit] < ximin )
272 ximin = xi[iDigit] ;
273 if ( zi[iDigit] > zimax )
274 zimax = zi[iDigit] ;
275 if ( zi[iDigit] < zimin )
276 zimin = zi[iDigit] ;
277 }
278 ximax += phosgeom->GetCrystalSize(0) / 2. ;
279 zimax += phosgeom->GetCrystalSize(2) / 2. ;
280 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
281 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
282 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
283 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
83974468 284
9688c1dd 285 // 2. gets the histogram title
83974468 286
9688c1dd 287 Text_t title[100] ;
288 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
83974468 289
9688c1dd 290 if (!histo) {
291 delete histo ;
292 histo = 0 ;
293 }
294 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
83974468 295
9688c1dd 296 Float_t x, z ;
297 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
298 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
299 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
300 phosgeom->RelPosInModule(relid, x, z);
301 histo->Fill(x, z, fEnergyList[iDigit] ) ;
302 }
83974468 303
9688c1dd 304 if (!digitgraph) {
305 digitgraph = new TGraph(kMulDigit,xi,zi);
306 digitgraph-> SetMarkerStyle(5) ;
307 digitgraph-> SetMarkerSize(1.) ;
308 digitgraph-> SetMarkerColor(1) ;
309 digitgraph-> Paint("P") ;
310 }
83974468 311
9688c1dd 312 // Print() ;
313 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
314 histocanvas->Draw() ;
315 histo->Draw("lego1") ;
83974468 316
9688c1dd 317 delete[] xi ;
318 delete[] zi ;
83974468 319
9688c1dd 320 break;
321 }
83974468 322
9688c1dd 323 case kButton1Up:
324 if (digitgraph) {
325 delete digitgraph ;
326 digitgraph = 0 ;
327 }
328 break;
9f616d61 329
9688c1dd 330 }
9f616d61 331}
332
d15a28e7 333//____________________________________________________________________________
7932f811 334void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
d15a28e7 335{
b2a60966 336 // Calculates the dispersion of the shower at the origine of the RecPoint
337
e5b16749 338 Float_t d = 0. ;
339 Float_t wtot = 0. ;
d15a28e7 340
d084d50d 341 Float_t x = 0.;
342 Float_t z = 0.;
d15a28e7 343
344 AliPHOSDigit * digit ;
7b7c1533 345
686b771f 346 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
e5b16749 347
348 // Calculates the center of gravity in the local PHOS-module coordinates
349
d15a28e7 350 Int_t iDigit;
e5b16749 351
352 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
353 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
354 Int_t relid[4] ;
355 Float_t xi ;
356 Float_t zi ;
357 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
358 phosgeom->RelPosInModule(relid, xi, zi);
359 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
360 x += xi * w ;
361 z += zi * w ;
362 wtot += w ;
363 }
364 x /= wtot ;
365 z /= wtot ;
366
367
368// Calculates the dispersion in coordinates
369 wtot = 0.;
88714635 370 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
7932f811 371 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
d15a28e7 372 Int_t relid[4] ;
373 Float_t xi ;
374 Float_t zi ;
92862013 375 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
376 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 377 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
92862013 378 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
d15a28e7 379 wtot+=w ;
d084d50d 380
381
d15a28e7 382 }
e5b16749 383
7932f811 384
92862013 385 d /= wtot ;
d15a28e7 386
7932f811 387 fDispersion = TMath::Sqrt(d) ;
c63c49e9 388
d15a28e7 389}
fad3e5b9 390//______________________________________________________________________________
e5b16749 391void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
fad3e5b9 392{
a4e98857 393 // This function calculates energy in the core,
394 // i.e. within a radius rad = 3cm around the center. Beyond this radius
395 // in accordance with shower profile the energy deposition
fad3e5b9 396 // should be less than 2%
397
fad3e5b9 398 Float_t coreRadius = 3 ;
399
e5b16749 400 Float_t x = 0 ;
401 Float_t z = 0 ;
fad3e5b9 402
403 AliPHOSDigit * digit ;
7b7c1533 404
686b771f 405 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
88cb7938 406
fad3e5b9 407 Int_t iDigit;
e5b16749 408
409// Calculates the center of gravity in the local PHOS-module coordinates
410 Float_t wtot = 0;
411 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
412 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
413 Int_t relid[4] ;
414 Float_t xi ;
415 Float_t zi ;
416 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
417 phosgeom->RelPosInModule(relid, xi, zi);
418 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
419 x += xi * w ;
420 z += zi * w ;
421 wtot += w ;
422 }
423 x /= wtot ;
424 z /= wtot ;
425
426
fad3e5b9 427 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
7932f811 428 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
fad3e5b9 429 Int_t relid[4] ;
430 Float_t xi ;
431 Float_t zi ;
432 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
433 phosgeom->RelPosInModule(relid, xi, zi);
434 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
435 if(distance < coreRadius)
7932f811 436 fCoreEnergy += fEnergyList[iDigit] ;
fad3e5b9 437 }
438
fad3e5b9 439}
d15a28e7 440
441//____________________________________________________________________________
7932f811 442void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
d15a28e7 443{
b2a60966 444 // Calculates the axis of the shower ellipsoid
83974468 445
e8dbb96e 446 Double_t wtot = 0. ;
447 Double_t x = 0.;
448 Double_t z = 0.;
449 Double_t dxx = 0.;
450 Double_t dzz = 0.;
451 Double_t dxz = 0.;
d15a28e7 452
453 AliPHOSDigit * digit ;
7b7c1533 454
686b771f 455 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
7b7c1533 456
d15a28e7 457 Int_t iDigit;
458
e5b16749 459
d15a28e7 460 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
7932f811 461 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
d15a28e7 462 Int_t relid[4] ;
463 Float_t xi ;
464 Float_t zi ;
92862013 465 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
466 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 467 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
92862013 468 dxx += w * xi * xi ;
d15a28e7 469 x += w * xi ;
92862013 470 dzz += w * zi * zi ;
d15a28e7 471 z += w * zi ;
92862013 472 dxz += w * xi * zi ;
d15a28e7 473 wtot += w ;
474 }
92862013 475 dxx /= wtot ;
d15a28e7 476 x /= wtot ;
92862013 477 dxx -= x * x ;
478 dzz /= wtot ;
d15a28e7 479 z /= wtot ;
92862013 480 dzz -= z * z ;
481 dxz /= wtot ;
482 dxz -= x * z ;
d15a28e7 483
69183710 484// //Apply correction due to non-perpendicular incidence
485// Double_t CosX ;
486// Double_t CosZ ;
88cb7938 487// AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
7b7c1533 488// AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
489 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
69183710 490
491// CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
492// CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
493
494// dxx = dxx/(CosX*CosX) ;
495// dzz = dzz/(CosZ*CosZ) ;
496// dxz = dxz/(CosX*CosZ) ;
497
498
7932f811 499 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
500 if(fLambda[0] > 0)
501 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
e8dbb96e 502
7932f811 503 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
504 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
505 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
e8dbb96e 506 else
7932f811 507 fLambda[1]= 0. ;
d15a28e7 508}
509
ce2a9a95 510//____________________________________________________________________________
511void AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits)
512{
513 // Calculate the shower moments in the eigen reference system
514 // M2x, M2z, M3x, M4z
515 // Calculate the angle between the shower position vector and the eigen vector
516
517 Double_t wtot = 0. ;
518 Double_t x = 0.;
519 Double_t z = 0.;
520 Double_t dxx = 0.;
521 Double_t dzz = 0.;
522 Double_t dxz = 0.;
523 Double_t lambda0=0, lambda1=0;
524
525 AliPHOSDigit * digit ;
526
686b771f 527 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
ce2a9a95 528
529 Int_t iDigit;
530
531 // 1) Find covariance matrix elements:
532 // || dxx dxz ||
533 // || dxz dzz ||
534
535 Float_t xi ;
536 Float_t zi ;
537 Int_t relid[4] ;
538 Double_t w;
539 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
540 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
541 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
542 phosgeom->RelPosInModule(relid, xi, zi);
543 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
544 x += w * xi ;
545 z += w * zi ;
546 dxx += w * xi * xi ;
547 dzz += w * zi * zi ;
548 dxz += w * xi * zi ;
549 wtot += w ;
550 }
551 x /= wtot ;
552 z /= wtot ;
553 dxx /= wtot ;
554 dzz /= wtot ;
555 dxz /= wtot ;
556 dxx -= x * x ;
557 dzz -= z * z ;
558 dxz -= x * z ;
559
560 // 2) Find covariance matrix eigen values lambda0 and lambda1
561
562 lambda0 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
563 lambda1 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
564
565 // 3) Find covariance matrix eigen vectors e0 and e1
566
567 TVector2 e0,e1;
568 if (dxz != 0)
569 e0.Set(1.,(lambda0-dxx)/dxz);
570 else
571 e0.Set(0.,1.);
572
573 e0 = e0.Unit();
574 e1.Set(-e0.Y(),e0.X());
575
576 // 4) Rotate cluster tensor from (x,z) to (e0,e1) system
577 // and calculate moments M3x and M4z
578
579 Float_t cosPhi = e0.X();
580 Float_t sinPhi = e0.Y();
581
582 Float_t xiPHOS ;
583 Float_t ziPHOS ;
584 Double_t dx3, dz3, dz4;
585 wtot = 0.;
586 x = 0.;
587 z = 0.;
588 dxx = 0.;
589 dzz = 0.;
590 dxz = 0.;
591 dx3 = 0.;
592 dz3 = 0.;
593 dz4 = 0.;
594 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
595 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
596 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
597 phosgeom->RelPosInModule(relid, xiPHOS, ziPHOS);
598 xi = xiPHOS*cosPhi + ziPHOS*sinPhi;
599 zi = ziPHOS*cosPhi - xiPHOS*sinPhi;
600 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
601 x += w * xi ;
602 z += w * zi ;
603 dxx += w * xi * xi ;
604 dzz += w * zi * zi ;
605 dxz += w * xi * zi ;
606 dx3 += w * xi * xi * xi;
607 dz3 += w * zi * zi * zi ;
608 dz4 += w * zi * zi * zi * zi ;
609 wtot += w ;
610 }
611 x /= wtot ;
612 z /= wtot ;
613 dxx /= wtot ;
614 dzz /= wtot ;
615 dxz /= wtot ;
616 dx3 /= wtot ;
617 dz3 /= wtot ;
618 dz4 /= wtot ;
619 dx3 += -3*dxx*x + 2*x*x*x;
620 dz4 += -4*dz3*z + 6*dzz*z*z -3*z*z*z*z;
621 dxx -= x * x ;
622 dzz -= z * z ;
623 dxz -= x * z ;
624
625 // 5) Find an angle between cluster center vector and eigen vector e0
626
627 Float_t phi = TMath::ACos ((x*e0.X() + z*e0.Y()) / sqrt(x*x + z*z));
628
629 fM2x = lambda0;
630 fM2z = lambda1;
631 fM3x = dx3;
632 fM4z = dz4;
633 fPhixe = phi;
634
635}
b2a60966 636//____________________________________________________________________________
7932f811 637void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
ad8cfaf4 638{
baef0810 639 // Evaluates all shower parameters
7932f811 640 EvalLocalPosition(logWeight, digits) ;
641 EvalElipsAxis(logWeight, digits) ;
ce2a9a95 642 EvalMoments(logWeight, digits) ;
7932f811 643 EvalDispersion(logWeight, digits) ;
e5b16749 644 EvalCoreEnergy(logWeight, digits);
a6eedfad 645 EvalTime(digits) ;
e957fea8 646 AliPHOSRecPoint::EvalAll(digits) ;
ad8cfaf4 647}
648//____________________________________________________________________________
7932f811 649void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
b2a60966 650{
651 // Calculates the center of gravity in the local PHOS-module coordinates
b2a60966 652 Float_t wtot = 0. ;
653
654 Int_t relid[4] ;
655
656 Float_t x = 0. ;
657 Float_t z = 0. ;
658
659 AliPHOSDigit * digit ;
660
686b771f 661 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
b2a60966 662
663 Int_t iDigit;
664
b2a60966 665 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
7932f811 666 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
b2a60966 667
668 Float_t xi ;
669 Float_t zi ;
670 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
671 phosgeom->RelPosInModule(relid, xi, zi);
7932f811 672 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
b2a60966 673 x += xi * w ;
674 z += zi * w ;
675 wtot += w ;
b2a60966 676
9ce1a8d9 677 }
69183710 678 x /= wtot ;
679 z /= wtot ;
ad8cfaf4 680
681 // Correction for the depth of the shower starting point (TDR p 127)
682 Float_t para = 0.925 ;
683 Float_t parb = 6.52 ;
684
1b799736 685 Float_t xo,yo,zo ; //Coordinates of the origin
686b771f 686 //We should check all 3 possibilities to avoid seg.v.
687 if(gAlice && gAlice->GetMCApp() && gAlice->Generator())
688 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
689 else{
690 xo=yo=zo=0.;
691 }
5830e1d9 692 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
1b799736 693
694 //Transform to the local ref.frame
695 Float_t xoL,yoL ;
696 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
697 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
698
fd84cb73 699 Float_t radius = phosgeom->GetIPtoCrystalSurface()-yoL;
1b799736 700
701 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
702 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
ad8cfaf4 703
704 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
705 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
ad8cfaf4 706
707 fLocPos.SetX(x - depthx) ;
b2a60966 708 fLocPos.SetY(0.) ;
ad8cfaf4 709 fLocPos.SetZ(z - depthz) ;
b2a60966 710
a6eedfad 711 fLocPosM = 0 ;
b2a60966 712}
713
d15a28e7 714//____________________________________________________________________________
ad8cfaf4 715Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
d15a28e7 716{
b2a60966 717 // Finds the maximum energy in the cluster
718
d15a28e7 719 Float_t menergy = 0. ;
720
721 Int_t iDigit;
722
723 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
724
725 if(fEnergyList[iDigit] > menergy)
726 menergy = fEnergyList[iDigit] ;
727 }
728 return menergy ;
729}
730
731//____________________________________________________________________________
fc7e2f43 732Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
d15a28e7 733{
b2a60966 734 // Calculates the multiplicity of digits with energy larger than H*energy
735
d15a28e7 736 Int_t multipl = 0 ;
737 Int_t iDigit ;
738 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
739
740 if(fEnergyList[iDigit] > H * fAmp)
741 multipl++ ;
742 }
743 return multipl ;
744}
745
746//____________________________________________________________________________
a0636361 747Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
7932f811 748 Float_t locMaxCut,TClonesArray * digits) const
d15a28e7 749{
b2a60966 750 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
a4e98857 751 // energy difference between two local maxima
b2a60966 752
d15a28e7 753 AliPHOSDigit * digit ;
754 AliPHOSDigit * digitN ;
755
756
757 Int_t iDigitN ;
758 Int_t iDigit ;
759
7932f811 760 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
a0636361 761 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
7932f811 762
d15a28e7 763
6ad0bfa0 764 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
a0636361 765 if(maxAt[iDigit]) {
766 digit = maxAt[iDigit] ;
83974468 767
6ad0bfa0 768 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
686b771f 769 if(iDigit == iDigitN)
770 continue ;
771
7932f811 772 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
d15a28e7 773
9f616d61 774 if ( AreNeighbours(digit, digitN) ) {
d15a28e7 775 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
a0636361 776 maxAt[iDigitN] = 0 ;
6ad0bfa0 777 // but may be digit too is not local max ?
7932f811 778 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
a0636361 779 maxAt[iDigit] = 0 ;
d15a28e7 780 }
781 else {
a0636361 782 maxAt[iDigit] = 0 ;
6ad0bfa0 783 // but may be digitN too is not local max ?
7932f811 784 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
a0636361 785 maxAt[iDigitN] = 0 ;
d15a28e7 786 }
787 } // if Areneighbours
788 } // while digitN
789 } // slot not empty
790 } // while digit
791
792 iDigitN = 0 ;
6ad0bfa0 793 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
a0636361 794 if(maxAt[iDigit]){
d15a28e7 795 maxAt[iDigitN] = maxAt[iDigit] ;
9f616d61 796 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
797 iDigitN++ ;
d15a28e7 798 }
799 }
800 return iDigitN ;
801}
9688c1dd 802//____________________________________________________________________________
0bc3b8ed 803void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits)
804{
805 // Define a rec.point time as a time in the cell with the maximum energy
806
9688c1dd 807 Float_t maxE = 0;
808 Int_t maxAt = 0;
809 for(Int_t idig=0; idig < fMulDigit; idig++){
810 if(fEnergyList[idig] > maxE){
811 maxE = fEnergyList[idig] ;
812 maxAt = idig;
813 }
814 }
815 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
816
817}
d15a28e7 818//____________________________________________________________________________
092b50ba 819void AliPHOSEmcRecPoint::Purify(Float_t threshold){
820 //Removes digits below threshold
821
0fbb8738 822 Int_t * tempo = new Int_t[fMaxDigit];
823 Float_t * tempoE = new Float_t[fMaxDigit];
092b50ba 824
825 Int_t mult = 0 ;
826 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
827 if(fEnergyList[iDigit] > threshold){
828 tempo[mult] = fDigitsList[iDigit] ;
829 tempoE[mult] = fEnergyList[iDigit] ;
830 mult++ ;
831 }
832 }
833
834 fMulDigit = mult ;
835 delete [] fDigitsList ;
836 delete [] fEnergyList ;
0fbb8738 837 fDigitsList = new Int_t[fMulDigit];
838 fEnergyList = new Float_t[fMulDigit];
092b50ba 839
0458aa58 840 fAmp = 0.; //Recalculate total energy
092b50ba 841 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
0458aa58 842 fDigitsList[iDigit] = tempo[iDigit];
843 fEnergyList[iDigit] = tempoE[iDigit] ;
844 fAmp+=tempoE[iDigit];
092b50ba 845 }
846
847 delete [] tempo ;
848 delete [] tempoE ;
849
850}
851//____________________________________________________________________________
a8c47ab6 852void AliPHOSEmcRecPoint::Print(Option_t *) const
d15a28e7 853{
b2a60966 854 // Print the list of digits belonging to the cluster
855
21cd0c07 856 TString message ;
857 message = "AliPHOSEmcRecPoint:\n" ;
858 message += " digits # = " ;
351dd634 859 AliInfo(Form(message.Data())) ;
d15a28e7 860
d15a28e7 861 Int_t iDigit;
7932f811 862 for(iDigit=0; iDigit<fMulDigit; iDigit++)
53ad38d8 863 printf(" %d ", fDigitsList[iDigit] ) ;
7932f811 864
351dd634 865 printf(" Energies = ") ;
7932f811 866 for(iDigit=0; iDigit<fMulDigit; iDigit++)
53ad38d8 867 printf(" %f ", fEnergyList[iDigit] ) ;
868 printf("\n") ;
351dd634 869 printf(" Primaries ") ;
bc68d12c 870 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
53ad38d8 871 printf(" %d ", fTracksList[iDigit]) ;
872 printf("\n") ;
21cd0c07 873 message = " Multiplicity = %d" ;
874 message += " Cluster Energy = %f" ;
875 message += " Number of primaries %d" ;
876 message += " Stored at position %d" ;
83974468 877
351dd634 878 printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
d15a28e7 879}
88714635 880
7932f811 881