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.58 2007/04/16 09:03:37 kharlov
22 * Incedent angle correction fixed
24 * Revision 1.57 2007/04/05 10:18:58 policheh
25 * Introduced distance to nearest bad crystal.
27 * Revision 1.56 2007/03/06 06:47:28 kharlov
28 * DP:Possibility to use actual vertex position added
30 * Revision 1.55 2007/01/19 20:31:19 kharlov
31 * Improved formatting for Print()
33 * Revision 1.54 2006/08/28 10:01:56 kharlov
34 * Effective C++ warnings fixed (Timur Pocheptsov)
36 * Revision 1.53 2005/12/20 14:28:47 hristov
37 * Additional protection
39 * Revision 1.52 2005/05/28 14:19:04 schutz
40 * Compilation warnings fixed by T.P.
44 //_________________________________________________________________________
45 // RecPoint implementation for PHOS-EMC
46 // An EmcRecPoint is a cluster of digits
48 //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
51 // --- ROOT system ---
57 // --- Standard library ---
59 // --- AliRoot header files ---
61 #include "AliPHOSLoader.h"
62 #include "AliGenerator.h"
63 #include "AliPHOSGeometry.h"
64 #include "AliPHOSDigit.h"
65 #include "AliPHOSEmcRecPoint.h"
67 ClassImp(AliPHOSEmcRecPoint)
69 //____________________________________________________________________________
70 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
72 fCoreEnergy(0.), fDispersion(0.),
73 fEnergyList(0), fTime(-1.), fNExMax(0),
74 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
75 fPhixe(0.), fDistToBadCrystal(-1),fDebug(0)
80 fLocPos.SetX(1000000.) ; //Local position should be evaluated
83 //____________________________________________________________________________
84 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
86 fCoreEnergy(0.), fDispersion(0.),
87 fEnergyList(0), fTime(-1.), fNExMax(0),
88 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
89 fPhixe(0.), fDistToBadCrystal(-1), fDebug(0)
94 fLocPos.SetX(1000000.) ; //Local position should be evaluated
97 //____________________________________________________________________________
98 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
100 fCoreEnergy(rp.fCoreEnergy), fDispersion(rp.fDispersion),
101 fEnergyList(0), fTime(rp.fTime), fNExMax(rp.fNExMax),
102 fM2x(rp.fM2x), fM2z(rp.fM2z), fM3x(rp.fM3x), fM4z(rp.fM4z),
103 fPhixe(rp.fPhixe), fDistToBadCrystal(rp.fDistToBadCrystal), fDebug(rp.fDebug)
106 fMulDigit = rp.fMulDigit ;
108 fEnergyList = new Float_t[rp.fMulDigit] ;
110 for(index = 0 ; index < fMulDigit ; index++)
111 fEnergyList[index] = rp.fEnergyList[index] ;
114 //____________________________________________________________________________
115 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
119 delete[] fEnergyList ;
122 //____________________________________________________________________________
123 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
125 // Adds a digit to the RecPoint
126 // and accumulates the total amplitude and the multiplicity
129 fEnergyList = new Float_t[fMaxDigit];
131 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
133 Int_t * tempo = new Int_t[fMaxDigit];
134 Float_t * tempoE = new Float_t[fMaxDigit];
137 for ( index = 0 ; index < fMulDigit ; index++ ){
138 tempo[index] = fDigitsList[index] ;
139 tempoE[index] = fEnergyList[index] ;
142 delete [] fDigitsList ;
143 fDigitsList = new Int_t[fMaxDigit];
145 delete [] fEnergyList ;
146 fEnergyList = new Float_t[fMaxDigit];
148 for ( index = 0 ; index < fMulDigit ; index++ ){
149 fDigitsList[index] = tempo[index] ;
150 fEnergyList[index] = tempoE[index] ;
157 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
158 fEnergyList[fMulDigit] = Energy ;
162 EvalPHOSMod(&digit) ;
165 //____________________________________________________________________________
166 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
168 // Tells if (true) or not (false) two digits are neighbors
170 Bool_t aren = kFALSE ;
172 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
175 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
178 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
180 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
181 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
183 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
189 //____________________________________________________________________________
190 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
192 // Compares two RecPoints according to their position in the PHOS modules
194 const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
195 //value (what is senseless) change as vell delta in
196 //AliPHOSTrackSegmentMakerv* and other RecPoints...
199 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
202 Int_t phosmod1 = GetPHOSMod() ;
203 Int_t phosmod2 = clu->GetPHOSMod() ;
206 GetLocalPosition(locpos1) ;
208 clu->GetLocalPosition(locpos2) ;
210 if(phosmod1 == phosmod2 ) {
211 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
216 else if(locpos1.Z()>locpos2.Z())
223 if(phosmod1 < phosmod2 )
231 //______________________________________________________________________________
232 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) /*const*/
235 // Execute action corresponding to one event
236 // This member function is called when a AliPHOSRecPoint is clicked with the locator
238 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
239 // and switched off when the mouse button is released.
242 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
244 static TGraph * digitgraph = 0 ;
246 if (!gPad->IsEditable()) return;
249 TCanvas * histocanvas ;
252 //try to get run loader from default event folder
253 AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
256 AliError(Form("Cannot find Run Loader in Default Event Folder"));
259 AliPHOSLoader* gime = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
262 AliError(Form("Cannot find PHOS Loader from Run Loader"));
267 const TClonesArray * digits = gime->Digits() ;
272 AliPHOSDigit * digit ;
276 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
277 Float_t * xi = new Float_t[kMulDigit] ;
278 Float_t * zi = new Float_t[kMulDigit] ;
280 // create the histogram for the single cluster
281 // 1. gets histogram boundaries
282 Float_t ximax = -999. ;
283 Float_t zimax = -999. ;
284 Float_t ximin = 999. ;
285 Float_t zimin = 999. ;
287 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
288 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
289 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
290 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
291 if ( xi[iDigit] > ximax )
293 if ( xi[iDigit] < ximin )
295 if ( zi[iDigit] > zimax )
297 if ( zi[iDigit] < zimin )
300 ximax += phosgeom->GetCrystalSize(0) / 2. ;
301 zimax += phosgeom->GetCrystalSize(2) / 2. ;
302 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
303 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
304 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
305 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
307 // 2. gets the histogram title
310 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
316 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
319 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
320 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
321 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
322 phosgeom->RelPosInModule(relid, x, z);
323 histo->Fill(x, z, fEnergyList[iDigit] ) ;
327 digitgraph = new TGraph(kMulDigit,xi,zi);
328 digitgraph-> SetMarkerStyle(5) ;
329 digitgraph-> SetMarkerSize(1.) ;
330 digitgraph-> SetMarkerColor(1) ;
331 digitgraph-> Paint("P") ;
335 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
336 histocanvas->Draw() ;
337 histo->Draw("lego1") ;
355 //____________________________________________________________________________
356 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits, TVector3 &vInc)
358 // Calculates the dispersion of the shower at the origine of the RecPoint
359 //DP: should we correct dispersion for non-perpendicular hit????????
367 AliPHOSDigit * digit ;
369 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
371 // Calculates the center of gravity in the local PHOS-module coordinates
375 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
376 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
380 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
381 phosgeom->RelPosInModule(relid, xi, zi);
382 if (fAmp>0 && fEnergyList[iDigit]>0) {
383 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
389 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
396 AliError(Form("Wrong weight %f\n", wtot));
399 // Calculates the dispersion in coordinates
401 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
402 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
406 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
407 phosgeom->RelPosInModule(relid, xi, zi);
408 if (fAmp>0 && fEnergyList[iDigit]>0) {
409 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
410 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
414 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
422 AliError(Form("Wrong weight %f\n", wtot));
426 fDispersion = TMath::Sqrt(d) ;
430 //______________________________________________________________________________
431 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
433 // This function calculates energy in the core,
434 // i.e. within a radius rad = 3cm around the center. Beyond this radius
435 // in accordance with shower profile the energy deposition
436 // should be less than 2%
437 //DP: non-perpendicular incidence??????????????
439 Float_t coreRadius = 3 ;
444 AliPHOSDigit * digit ;
446 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
450 // Calculates the center of gravity in the local PHOS-module coordinates
452 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
453 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
457 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
458 phosgeom->RelPosInModule(relid, xi, zi);
459 if (fAmp>0 && fEnergyList[iDigit]>0) {
460 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
466 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
473 AliError(Form("Wrong weight %f\n", wtot));
476 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
477 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
481 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
482 phosgeom->RelPosInModule(relid, xi, zi);
483 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
484 if(distance < coreRadius)
485 fCoreEnergy += fEnergyList[iDigit] ;
491 //____________________________________________________________________________
492 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits, TVector3 &vInc)
494 // Calculates the axis of the shower ellipsoid
503 AliPHOSDigit * digit ;
505 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
510 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
511 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
515 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
516 phosgeom->RelPosInModule(relid, xi, zi);
517 if (fAmp>0 && fEnergyList[iDigit]>0) {
518 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
527 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
539 // //Apply correction due to non-perpendicular incidence
542 // AliPHOSGetter * gime = AliPHOSGetter::Instance() ;
543 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
544 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
546 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
547 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
549 // dxx = dxx/(CosX*CosX) ;
550 // dzz = dzz/(CosZ*CosZ) ;
551 // dxz = dxz/(CosX*CosZ) ;
554 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
556 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
558 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
559 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
560 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
565 AliError(Form("Wrong weight %f\n", wtot));
566 fLambda[0]=fLambda[1]=0.;
570 //____________________________________________________________________________
571 void AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits, TVector3 &vInc)
573 // Calculate the shower moments in the eigen reference system
574 // M2x, M2z, M3x, M4z
575 // Calculate the angle between the shower position vector and the eigen vector
583 Double_t lambda0=0, lambda1=0;
585 AliPHOSDigit * digit ;
587 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
591 // 1) Find covariance matrix elements:
599 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
600 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
601 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
602 phosgeom->RelPosInModule(relid, xi, zi);
603 if (fAmp>0 && fEnergyList[iDigit]>0) {
604 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
613 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
626 // 2) Find covariance matrix eigen values lambda0 and lambda1
628 lambda0 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
629 lambda1 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
632 AliError(Form("Wrong weight %f\n", wtot));
636 // 3) Find covariance matrix eigen vectors e0 and e1
640 e0.Set(1.,(lambda0-dxx)/dxz);
645 e1.Set(-e0.Y(),e0.X());
647 // 4) Rotate cluster tensor from (x,z) to (e0,e1) system
648 // and calculate moments M3x and M4z
650 Float_t cosPhi = e0.X();
651 Float_t sinPhi = e0.Y();
655 Double_t dx3, dz3, dz4;
665 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
666 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
667 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
668 phosgeom->RelPosInModule(relid, xiPHOS, ziPHOS);
669 xi = xiPHOS*cosPhi + ziPHOS*sinPhi;
670 zi = ziPHOS*cosPhi - xiPHOS*sinPhi;
671 if (fAmp>0 && fEnergyList[iDigit]>0) {
672 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
678 dx3 += w * xi * xi * xi;
679 dz3 += w * zi * zi * zi ;
680 dz4 += w * zi * zi * zi * zi ;
684 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
695 dx3 += -3*dxx*x + 2*x*x*x;
696 dz4 += -4*dz3*z + 6*dzz*z*z -3*z*z*z*z;
702 AliError(Form("Wrong weight %f\n", wtot));
704 // 5) Find an angle between cluster center vector and eigen vector e0
708 phi = TMath::ACos ((x*e0.X() + z*e0.Y()) / sqrt(x*x + z*z));
717 //______________________________________________________________________________
718 void AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
720 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
722 AliPHOSDigit * digit ;
723 Int_t * tempo = new Int_t[fMaxTrack] ;
725 //First find digit with maximal energy deposition and copy its primaries
728 for(Int_t id=0; id<GetDigitsMultiplicity(); id++){
729 if(emax<fEnergyList[id])
732 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[imaxDigit] )) ;
733 Int_t nprimaries = digit->GetNprimary() ;
734 if ( nprimaries > fMaxTrack ) {
736 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
737 nprimaries = fMaxTrack; //skip the rest
739 for(fMulTrack=1; fMulTrack<=nprimaries ; fMulTrack++){
740 tempo[fMulTrack-1] = digit->GetPrimary(fMulTrack) ;
743 //Now add other digits contributions
744 for (Int_t index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
745 if(index==imaxDigit) //already in
747 digit = dynamic_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
748 nprimaries = digit->GetNprimary() ;
749 for(Int_t ipr=0; ipr<nprimaries; ipr++){
750 Int_t iprimary = digit->GetPrimary(ipr+1) ;
752 for(Int_t kndex = 0 ; (kndex < fMulTrack)&& notIn ; kndex++ ) { //check if not already stored
753 if(iprimary == tempo[kndex]){
758 if(fMulTrack<fMaxTrack){
759 tempo[fMulTrack]=iprimary ;
763 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack!!!" ) ;
771 if(fTracksList)delete [] fTracksList;
772 fTracksList = new Int_t[fMulTrack] ;
774 for(Int_t index = 0; index < fMulTrack; index++)
775 fTracksList[index] = tempo[index] ;
781 //____________________________________________________________________________
782 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
784 EvalCoreEnergy(logWeight, digits);
786 EvalPrimaries(digits) ;
787 AliPHOSRecPoint::EvalAll(digits) ;
789 //____________________________________________________________________________
790 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TVector3 &vtx, TClonesArray * digits )
792 // Evaluates all shower parameters
794 EvalLocalPosition(logWeight, vtx, digits,vInc) ;
795 EvalElipsAxis(logWeight, digits, vInc) ; //they are evaluated with momenta
796 EvalMoments(logWeight, digits, vInc) ;
797 EvalDispersion(logWeight, digits, vInc) ;
799 //____________________________________________________________________________
800 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TVector3 &vtx, TClonesArray * digits, TVector3 &vInc)
802 // Calculates the center of gravity in the local PHOS-module coordinates
810 AliPHOSDigit * digit ;
812 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
816 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
817 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
821 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
822 phosgeom->RelPosInModule(relid, xi, zi);
823 if (fAmp>0 && fEnergyList[iDigit]>0) {
824 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
830 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
837 AliError(Form("Wrong weight %f\n", wtot));
839 // Correction for the depth of the shower starting point (TDR p 127)
840 Float_t para = 0.925 ;
841 Float_t parb = 6.52 ;
843 phosgeom->GetIncidentVector(vtx,GetPHOSMod(),x,z,vInc) ;
847 if (fAmp>0&&vInc.Y()!=0.) {
848 depthx = ( para * TMath::Log(fAmp) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
849 depthz = ( para * TMath::Log(fAmp) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
852 AliError(Form("Wrong amplitude %f\n", fAmp));
854 fLocPos.SetX(x - depthx) ;
856 fLocPos.SetZ(z - depthz) ;
861 //____________________________________________________________________________
862 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
864 // Finds the maximum energy in the cluster
866 Float_t menergy = 0. ;
870 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
872 if(fEnergyList[iDigit] > menergy)
873 menergy = fEnergyList[iDigit] ;
878 //____________________________________________________________________________
879 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
881 // Calculates the multiplicity of digits with energy larger than H*energy
885 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
887 if(fEnergyList[iDigit] > H * fAmp)
893 //____________________________________________________________________________
894 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
895 Float_t locMaxCut,TClonesArray * digits) const
897 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
898 // energy difference between two local maxima
900 AliPHOSDigit * digit ;
901 AliPHOSDigit * digitN ;
907 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
908 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
911 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
913 digit = maxAt[iDigit] ;
915 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
916 if(iDigit == iDigitN)
919 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
921 if ( AreNeighbours(digit, digitN) ) {
922 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
924 // but may be digit too is not local max ?
925 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
930 // but may be digitN too is not local max ?
931 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
934 } // if Areneighbours
940 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
942 maxAt[iDigitN] = maxAt[iDigit] ;
943 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
949 //____________________________________________________________________________
950 void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits)
952 // Define a rec.point time as a time in the cell with the maximum energy
956 for(Int_t idig=0; idig < fMulDigit; idig++){
957 if(fEnergyList[idig] > maxE){
958 maxE = fEnergyList[idig] ;
962 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
965 //____________________________________________________________________________
966 void AliPHOSEmcRecPoint::Purify(Float_t threshold){
967 //Removes digits below threshold
969 Int_t * tempo = new Int_t[fMaxDigit];
970 Float_t * tempoE = new Float_t[fMaxDigit];
973 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
974 if(fEnergyList[iDigit] > threshold){
975 tempo[mult] = fDigitsList[iDigit] ;
976 tempoE[mult] = fEnergyList[iDigit] ;
982 delete [] fDigitsList ;
983 delete [] fEnergyList ;
984 fDigitsList = new Int_t[fMulDigit];
985 fEnergyList = new Float_t[fMulDigit];
987 fAmp = 0.; //Recalculate total energy
988 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
989 fDigitsList[iDigit] = tempo[iDigit];
990 fEnergyList[iDigit] = tempoE[iDigit] ;
991 fAmp+=tempoE[iDigit];
998 //____________________________________________________________________________
999 void AliPHOSEmcRecPoint::Print(Option_t *) const
1001 // Print the list of digits belonging to the cluster
1004 message = "AliPHOSEmcRecPoint:\n" ;
1005 message += "Digit multiplicity = %d" ;
1006 message += ", cluster Energy = %f" ;
1007 message += ", number of primaries = %d" ;
1008 message += ", rec.point index = %d \n" ;
1009 printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
1012 printf(" digits ids = ") ;
1013 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1014 printf(" %d ", fDigitsList[iDigit] ) ;
1016 printf("\n digit energies = ") ;
1017 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1018 printf(" %f ", fEnergyList[iDigit] ) ;
1020 printf("\n digit primaries ") ;
1021 if (fMulTrack<1) printf("... no primaries");
1022 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1023 printf(" %d ", fTracksList[iDigit]) ;