1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 /* History of cvs commits:
21 * Revision 1.59 2007/10/18 15:12:22 kharlov
22 * Moved MakePrimary to EMCRecPoint to rpduce correct order of primaries
24 * Revision 1.58 2007/04/16 09:03:37 kharlov
25 * Incedent angle correction fixed
27 * Revision 1.57 2007/04/05 10:18:58 policheh
28 * Introduced distance to nearest bad crystal.
30 * Revision 1.56 2007/03/06 06:47:28 kharlov
31 * DP:Possibility to use actual vertex position added
33 * Revision 1.55 2007/01/19 20:31:19 kharlov
34 * Improved formatting for Print()
37 //_________________________________________________________________________
38 // RecPoint implementation for PHOS-EMC
39 // An EmcRecPoint is a cluster of digits
41 //-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
44 // --- ROOT system ---
50 // --- Standard library ---
52 // --- AliRoot header files ---
54 #include "AliPHOSLoader.h"
55 #include "AliGenerator.h"
56 #include "AliPHOSGeometry.h"
57 #include "AliPHOSDigit.h"
58 #include "AliPHOSEmcRecPoint.h"
60 ClassImp(AliPHOSEmcRecPoint)
62 //____________________________________________________________________________
63 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
65 fCoreEnergy(0.), fDispersion(0.),
66 fEnergyList(0), fTime(-1.), fNExMax(0),
67 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
68 fPhixe(0.), fDistToBadCrystal(-1),fDebug(0)
73 fLocPos.SetX(1000000.) ; //Local position should be evaluated
76 //____________________________________________________________________________
77 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
79 fCoreEnergy(0.), fDispersion(0.),
80 fEnergyList(0), fTime(-1.), fNExMax(0),
81 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
82 fPhixe(0.), fDistToBadCrystal(-1), fDebug(0)
87 fLocPos.SetX(1000000.) ; //Local position should be evaluated
90 //____________________________________________________________________________
91 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
93 fCoreEnergy(rp.fCoreEnergy), fDispersion(rp.fDispersion),
94 fEnergyList(0), fTime(rp.fTime), fNExMax(rp.fNExMax),
95 fM2x(rp.fM2x), fM2z(rp.fM2z), fM3x(rp.fM3x), fM4z(rp.fM4z),
96 fPhixe(rp.fPhixe), fDistToBadCrystal(rp.fDistToBadCrystal), fDebug(rp.fDebug)
99 fMulDigit = rp.fMulDigit ;
101 if (rp.fMulDigit>0) fEnergyList = new Float_t[rp.fMulDigit] ;
102 for(Int_t index = 0 ; index < fMulDigit ; index++)
103 fEnergyList[index] = rp.fEnergyList[index] ;
106 //____________________________________________________________________________
107 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
111 delete[] fEnergyList ;
114 //____________________________________________________________________________
115 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
117 // Adds a digit to the RecPoint
118 // and accumulates the total amplitude and the multiplicity
121 fEnergyList = new Float_t[fMaxDigit];
123 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
125 Int_t * tempo = new Int_t[fMaxDigit];
126 Float_t * tempoE = new Float_t[fMaxDigit];
129 for ( index = 0 ; index < fMulDigit ; index++ ){
130 tempo[index] = fDigitsList[index] ;
131 tempoE[index] = fEnergyList[index] ;
134 delete [] fDigitsList ;
135 fDigitsList = new Int_t[fMaxDigit];
137 delete [] fEnergyList ;
138 fEnergyList = new Float_t[fMaxDigit];
140 for ( index = 0 ; index < fMulDigit ; index++ ){
141 fDigitsList[index] = tempo[index] ;
142 fEnergyList[index] = tempoE[index] ;
149 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
150 fEnergyList[fMulDigit] = Energy ;
154 EvalPHOSMod(&digit) ;
157 //____________________________________________________________________________
158 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
160 // Tells if (true) or not (false) two digits are neighbors
162 Bool_t aren = kFALSE ;
164 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
167 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
170 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
172 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
173 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
175 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
181 //____________________________________________________________________________
182 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
184 // Compares two RecPoints according to their position in the PHOS modules
186 const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
187 //value (what is senseless) change as vell delta in
188 //AliPHOSTrackSegmentMakerv* and other RecPoints...
191 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
194 Int_t phosmod1 = GetPHOSMod() ;
195 Int_t phosmod2 = clu->GetPHOSMod() ;
198 GetLocalPosition(locpos1) ;
200 clu->GetLocalPosition(locpos2) ;
202 if(phosmod1 == phosmod2 ) {
203 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
208 else if(locpos1.Z()>locpos2.Z())
215 if(phosmod1 < phosmod2 )
223 //______________________________________________________________________________
224 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) /*const*/
227 // Execute action corresponding to one event
228 // This member function is called when a AliPHOSRecPoint is clicked with the locator
230 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
231 // and switched off when the mouse button is released.
234 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
236 static TGraph * digitgraph = 0 ;
238 if (!gPad->IsEditable()) return;
241 TCanvas * histocanvas ;
244 //try to get run loader from default event folder
245 AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
248 AliError(Form("Cannot find Run Loader in Default Event Folder"));
251 AliPHOSLoader* phosLoader = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
252 if (phosLoader == 0x0)
254 AliError(Form("Cannot find PHOS Loader from Run Loader"));
259 const TClonesArray * digits = phosLoader->Digits() ;
264 AliPHOSDigit * digit ;
268 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
269 Float_t * xi = new Float_t[kMulDigit] ;
270 Float_t * zi = new Float_t[kMulDigit] ;
272 // create the histogram for the single cluster
273 // 1. gets histogram boundaries
274 Float_t ximax = -999. ;
275 Float_t zimax = -999. ;
276 Float_t ximin = 999. ;
277 Float_t zimin = 999. ;
279 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
280 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
281 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
282 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
283 if ( xi[iDigit] > ximax )
285 if ( xi[iDigit] < ximin )
287 if ( zi[iDigit] > zimax )
289 if ( zi[iDigit] < zimin )
292 ximax += phosgeom->GetCrystalSize(0) / 2. ;
293 zimax += phosgeom->GetCrystalSize(2) / 2. ;
294 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
295 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
296 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
297 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
299 // 2. gets the histogram title
302 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
308 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
311 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
312 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
313 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
314 phosgeom->RelPosInModule(relid, x, z);
315 histo->Fill(x, z, fEnergyList[iDigit] ) ;
319 digitgraph = new TGraph(kMulDigit,xi,zi);
320 digitgraph-> SetMarkerStyle(5) ;
321 digitgraph-> SetMarkerSize(1.) ;
322 digitgraph-> SetMarkerColor(1) ;
323 digitgraph-> Paint("P") ;
327 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
328 histocanvas->Draw() ;
329 histo->Draw("lego1") ;
347 //____________________________________________________________________________
348 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
350 // Calculates the dispersion of the shower at the origine of the RecPoint
351 //DP: should we correct dispersion for non-perpendicular hit????????
359 AliPHOSDigit * digit ;
361 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
363 // Calculates the center of gravity in the local PHOS-module coordinates
367 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
368 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
372 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
373 phosgeom->RelPosInModule(relid, xi, zi);
374 if (fAmp>0 && fEnergyList[iDigit]>0) {
375 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
381 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
388 AliError(Form("Wrong weight %f\n", wtot));
391 // Calculates the dispersion in coordinates
393 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
394 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
398 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
399 phosgeom->RelPosInModule(relid, xi, zi);
400 if (fAmp>0 && fEnergyList[iDigit]>0) {
401 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
402 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
406 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
414 AliError(Form("Wrong weight %f\n", wtot));
418 fDispersion = TMath::Sqrt(d) ;
422 //______________________________________________________________________________
423 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
425 // This function calculates energy in the core,
426 // i.e. within a radius rad = 3cm around the center. Beyond this radius
427 // in accordance with shower profile the energy deposition
428 // should be less than 2%
429 //DP: non-perpendicular incidence??????????????
431 Float_t coreRadius = 3 ;
436 AliPHOSDigit * digit ;
438 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
442 // Calculates the center of gravity in the local PHOS-module coordinates
444 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
445 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
449 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
450 phosgeom->RelPosInModule(relid, xi, zi);
451 if (fAmp>0 && fEnergyList[iDigit]>0) {
452 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
458 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
465 AliError(Form("Wrong weight %f\n", wtot));
468 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
469 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
473 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
474 phosgeom->RelPosInModule(relid, xi, zi);
475 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
476 if(distance < coreRadius)
477 fCoreEnergy += fEnergyList[iDigit] ;
483 //____________________________________________________________________________
484 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
486 // Calculates the axis of the shower ellipsoid
495 AliPHOSDigit * digit ;
497 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
502 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
503 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
507 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
508 phosgeom->RelPosInModule(relid, xi, zi);
509 if (fAmp>0 && fEnergyList[iDigit]>0) {
510 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
519 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
531 // //Apply correction due to non-perpendicular incidence
534 // AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
535 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
537 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
538 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
540 // dxx = dxx/(CosX*CosX) ;
541 // dzz = dzz/(CosZ*CosZ) ;
542 // dxz = dxz/(CosX*CosZ) ;
545 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
547 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
549 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
550 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
551 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
556 AliError(Form("Wrong weight %f\n", wtot));
557 fLambda[0]=fLambda[1]=0.;
561 //____________________________________________________________________________
562 void AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
564 // Calculate the shower moments in the eigen reference system
565 // M2x, M2z, M3x, M4z
566 // Calculate the angle between the shower position vector and the eigen vector
574 Double_t lambda0=0, lambda1=0;
576 AliPHOSDigit * digit ;
578 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
582 // 1) Find covariance matrix elements:
590 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
591 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
592 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
593 phosgeom->RelPosInModule(relid, xi, zi);
594 if (fAmp>0 && fEnergyList[iDigit]>0) {
595 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
604 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
617 // 2) Find covariance matrix eigen values lambda0 and lambda1
619 lambda0 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
620 lambda1 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
623 AliError(Form("Wrong weight %f\n", wtot));
627 // 3) Find covariance matrix eigen vectors e0 and e1
631 e0.Set(1.,(lambda0-dxx)/dxz);
636 e1.Set(-e0.Y(),e0.X());
638 // 4) Rotate cluster tensor from (x,z) to (e0,e1) system
639 // and calculate moments M3x and M4z
641 Float_t cosPhi = e0.X();
642 Float_t sinPhi = e0.Y();
646 Double_t dx3, dz3, dz4;
656 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
657 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
658 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
659 phosgeom->RelPosInModule(relid, xiPHOS, ziPHOS);
660 xi = xiPHOS*cosPhi + ziPHOS*sinPhi;
661 zi = ziPHOS*cosPhi - xiPHOS*sinPhi;
662 if (fAmp>0 && fEnergyList[iDigit]>0) {
663 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
669 dx3 += w * xi * xi * xi;
670 dz3 += w * zi * zi * zi ;
671 dz4 += w * zi * zi * zi * zi ;
675 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
686 dx3 += -3*dxx*x + 2*x*x*x;
687 dz4 += -4*dz3*z + 6*dzz*z*z -3*z*z*z*z;
693 AliError(Form("Wrong weight %f\n", wtot));
695 // 5) Find an angle between cluster center vector and eigen vector e0
699 phi = TMath::ACos ((x*e0.X() + z*e0.Y()) / sqrt(x*x + z*z));
708 //______________________________________________________________________________
709 void AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
711 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
713 AliPHOSDigit * digit ;
714 Int_t * tempo = new Int_t[fMaxTrack] ;
716 //First find digit with maximal energy deposition and copy its primaries
719 for(Int_t id=0; id<GetDigitsMultiplicity(); id++){
720 if(emax<fEnergyList[id])
723 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[imaxDigit] )) ;
724 Int_t nprimaries = digit->GetNprimary() ;
725 if ( nprimaries > fMaxTrack ) {
727 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
728 nprimaries = fMaxTrack; //skip the rest
730 for(fMulTrack=0; fMulTrack<nprimaries ; fMulTrack++){
731 tempo[fMulTrack] = digit->GetPrimary(fMulTrack+1) ;
734 //Now add other digits contributions
735 for (Int_t index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
736 if(index==imaxDigit) //already in
738 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
739 nprimaries = digit->GetNprimary() ;
740 for(Int_t ipr=0; ipr<nprimaries; ipr++){
741 Int_t iprimary = digit->GetPrimary(ipr+1) ;
743 for(Int_t kndex = 0 ; (kndex < fMulTrack)&& notIn ; kndex++ ) { //check if not already stored
744 if(iprimary == tempo[kndex]){
749 if(fMulTrack<fMaxTrack){
750 tempo[fMulTrack]=iprimary ;
754 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack!!!" ) ;
761 if(fTracksList)delete [] fTracksList;
762 fTracksList = new Int_t[fMulTrack] ;
764 for(Int_t index = 0; index < fMulTrack; index++)
765 fTracksList[index] = tempo[index] ;
771 //____________________________________________________________________________
772 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
774 EvalCoreEnergy(logWeight, digits);
776 EvalPrimaries(digits) ;
777 AliPHOSRecPoint::EvalAll(digits) ;
779 //____________________________________________________________________________
780 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TVector3 &vtx, TClonesArray * digits )
782 // Evaluates all shower parameters
784 EvalLocalPosition(logWeight, vtx, digits,vInc) ;
785 EvalElipsAxis(logWeight, digits, vInc) ; //they are evaluated with momenta
786 EvalMoments(logWeight, digits, vInc) ;
787 EvalDispersion(logWeight, digits, vInc) ;
789 //____________________________________________________________________________
790 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TVector3 &vtx, TClonesArray * digits, TVector3 &vInc)
792 // Calculates the center of gravity in the local PHOS-module coordinates
800 AliPHOSDigit * digit ;
802 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
806 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
807 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
811 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
812 phosgeom->RelPosInModule(relid, xi, zi);
813 if (fAmp>0 && fEnergyList[iDigit]>0) {
814 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
820 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
827 AliError(Form("Wrong weight %f\n", wtot));
829 // Correction for the depth of the shower starting point (TDR p 127)
830 Float_t para = 0.925 ;
831 Float_t parb = 6.52 ;
833 phosgeom->GetIncidentVector(vtx,GetPHOSMod(),x,z,vInc) ;
837 if (fAmp>0&&vInc.Y()!=0.) {
838 depthx = ( para * TMath::Log(fAmp) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
839 depthz = ( para * TMath::Log(fAmp) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
842 AliError(Form("Wrong amplitude %f\n", fAmp));
844 fLocPos.SetX(x - depthx) ;
846 fLocPos.SetZ(z - depthz) ;
851 //____________________________________________________________________________
852 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
854 // Finds the maximum energy in the cluster
856 Float_t menergy = 0. ;
860 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
862 if(fEnergyList[iDigit] > menergy)
863 menergy = fEnergyList[iDigit] ;
868 //____________________________________________________________________________
869 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
871 // Calculates the multiplicity of digits with energy larger than H*energy
875 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
877 if(fEnergyList[iDigit] > H * fAmp)
883 //____________________________________________________________________________
884 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
885 Float_t locMaxCut,TClonesArray * digits) const
887 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
888 // energy difference between two local maxima
890 AliPHOSDigit * digit ;
891 AliPHOSDigit * digitN ;
897 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
898 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
901 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
903 digit = maxAt[iDigit] ;
905 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
906 if(iDigit == iDigitN)
909 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
911 if ( AreNeighbours(digit, digitN) ) {
912 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
914 // but may be digit too is not local max ?
915 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
920 // but may be digitN too is not local max ?
921 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
924 } // if Areneighbours
930 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
932 maxAt[iDigitN] = maxAt[iDigit] ;
933 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
939 //____________________________________________________________________________
940 void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits)
942 // Define a rec.point time as a time in the cell with the maximum energy
946 for(Int_t idig=0; idig < fMulDigit; idig++){
947 if(fEnergyList[idig] > maxE){
948 maxE = fEnergyList[idig] ;
952 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
955 //____________________________________________________________________________
956 void AliPHOSEmcRecPoint::Purify(Float_t threshold){
957 //Removes digits below threshold
959 Int_t * tempo = new Int_t[fMaxDigit];
960 Float_t * tempoE = new Float_t[fMaxDigit];
963 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
964 if(fEnergyList[iDigit] > threshold){
965 tempo[mult] = fDigitsList[iDigit] ;
966 tempoE[mult] = fEnergyList[iDigit] ;
972 delete [] fDigitsList ;
973 delete [] fEnergyList ;
974 fDigitsList = new Int_t[fMulDigit];
975 fEnergyList = new Float_t[fMulDigit];
977 fAmp = 0.; //Recalculate total energy
978 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
979 fDigitsList[iDigit] = tempo[iDigit];
980 fEnergyList[iDigit] = tempoE[iDigit] ;
981 fAmp+=tempoE[iDigit];
988 //____________________________________________________________________________
989 void AliPHOSEmcRecPoint::Print(Option_t *) const
991 // Print the list of digits belonging to the cluster
994 message = "AliPHOSEmcRecPoint:\n" ;
995 message += "Digit multiplicity = %d" ;
996 message += ", cluster Energy = %f" ;
997 message += ", number of primaries = %d" ;
998 message += ", rec.point index = %d \n" ;
999 printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
1002 printf(" digits ids = ") ;
1003 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1004 printf(" %d ", fDigitsList[iDigit] ) ;
1006 printf("\n digit energies = ") ;
1007 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1008 printf(" %f ", fEnergyList[iDigit] ) ;
1010 printf("\n digit primaries ") ;
1011 if (fMulTrack<1) printf("... no primaries");
1012 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1013 printf(" %d ", fTracksList[iDigit]) ;