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"
59 #include "AliPHOSReconstructor.h"
61 ClassImp(AliPHOSEmcRecPoint)
63 //____________________________________________________________________________
64 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
66 fCoreEnergy(0.), fDispersion(0.),
67 fEnergyList(0), fTime(-1.), fNExMax(0),
68 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
69 fPhixe(0.), fDistToBadCrystal(-1),fDebug(0)
74 fLocPos.SetX(1000000.) ; //Local position should be evaluated
81 //____________________________________________________________________________
82 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
84 fCoreEnergy(0.), fDispersion(0.),
85 fEnergyList(0), fTime(-1.), fNExMax(0),
86 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
87 fPhixe(0.), fDistToBadCrystal(-1), fDebug(0)
92 fLocPos.SetX(1000000.) ; //Local position should be evaluated
98 //____________________________________________________________________________
99 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
101 fCoreEnergy(rp.fCoreEnergy), fDispersion(rp.fDispersion),
102 fEnergyList(0), fTime(rp.fTime), fNExMax(rp.fNExMax),
103 fM2x(rp.fM2x), fM2z(rp.fM2z), fM3x(rp.fM3x), fM4z(rp.fM4z),
104 fPhixe(rp.fPhixe), fDistToBadCrystal(rp.fDistToBadCrystal), fDebug(rp.fDebug)
107 fMulDigit = rp.fMulDigit ;
109 if (rp.fMulDigit>0) fEnergyList = new Float_t[rp.fMulDigit] ;
110 for(Int_t index = 0 ; index < fMulDigit ; index++)
111 fEnergyList[index] = rp.fEnergyList[index] ;
113 for(Int_t i=0; i<2; i++) {
114 fLambda[i] = rp.fLambda[i];
118 //____________________________________________________________________________
119 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
123 delete[] fEnergyList ;
126 //____________________________________________________________________________
127 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy, Float_t time)
129 // Adds a digit to the RecPoint
130 // and accumulates the total amplitude and the multiplicity
133 fEnergyList = new Float_t[fMaxDigit];
135 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
137 Int_t * tempo = new Int_t[fMaxDigit];
138 Float_t * tempoE = new Float_t[fMaxDigit];
141 for ( index = 0 ; index < fMulDigit ; index++ ){
142 tempo[index] = fDigitsList[index] ;
143 tempoE[index] = fEnergyList[index] ;
146 delete [] fDigitsList ;
147 fDigitsList = new Int_t[fMaxDigit];
149 delete [] fEnergyList ;
150 fEnergyList = new Float_t[fMaxDigit];
152 for ( index = 0 ; index < fMulDigit ; index++ ){
153 fDigitsList[index] = tempo[index] ;
154 fEnergyList[index] = tempoE[index] ;
163 for(Int_t index = 0 ; index < fMulDigit ; index++ ){
164 if(fEnergyList[index]>Energy){
172 //Alternative time calculation - still to be validated
173 // fTime = (fTime*fAmp + time*Energy)/(fAmp+Energy) ;
175 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
176 fEnergyList[fMulDigit] = Energy ;
179 EvalPHOSMod(&digit) ;
182 //____________________________________________________________________________
183 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
185 // Tells if (true) or not (false) two digits are neighbors
187 Bool_t aren = kFALSE ;
189 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
192 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
195 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
197 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
198 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
200 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
206 //____________________________________________________________________________
207 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
209 // Compares two RecPoints according to their position in the PHOS modules
211 const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
212 //value (what is senseless) change as vell delta in
213 //AliPHOSTrackSegmentMakerv* and other RecPoints...
216 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
219 Int_t phosmod1 = GetPHOSMod() ;
220 Int_t phosmod2 = clu->GetPHOSMod() ;
223 GetLocalPosition(locpos1) ;
225 clu->GetLocalPosition(locpos2) ;
227 if(phosmod1 == phosmod2 ) {
228 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
233 else if(locpos1.Z()>locpos2.Z())
240 if(phosmod1 < phosmod2 )
248 //______________________________________________________________________________
249 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) /*const*/
252 // Execute action corresponding to one event
253 // This member function is called when a AliPHOSRecPoint is clicked with the locator
255 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
256 // and switched off when the mouse button is released.
259 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
261 static TGraph * digitgraph = 0 ;
263 if (!gPad->IsEditable()) return;
266 TCanvas * histocanvas ;
269 //try to get run loader from default event folder
270 AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
273 AliError(Form("Cannot find Run Loader in Default Event Folder"));
276 AliPHOSLoader* phosLoader = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
277 if (phosLoader == 0x0)
279 AliError(Form("Cannot find PHOS Loader from Run Loader"));
284 const TClonesArray * digits = phosLoader->Digits() ;
289 AliPHOSDigit * digit ;
293 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
294 Float_t * xi = new Float_t[kMulDigit] ;
295 Float_t * zi = new Float_t[kMulDigit] ;
297 // create the histogram for the single cluster
298 // 1. gets histogram boundaries
299 Float_t ximax = -999. ;
300 Float_t zimax = -999. ;
301 Float_t ximin = 999. ;
302 Float_t zimin = 999. ;
304 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
305 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
306 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
307 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
308 if ( xi[iDigit] > ximax )
310 if ( xi[iDigit] < ximin )
312 if ( zi[iDigit] > zimax )
314 if ( zi[iDigit] < zimin )
317 ximax += phosgeom->GetCrystalSize(0) / 2. ;
318 zimax += phosgeom->GetCrystalSize(2) / 2. ;
319 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
320 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
321 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
322 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
324 // 2. gets the histogram title
327 snprintf(title,100,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
333 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
336 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
337 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
338 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
339 phosgeom->RelPosInModule(relid, x, z);
340 histo->Fill(x, z, fEnergyList[iDigit] ) ;
344 digitgraph = new TGraph(kMulDigit,xi,zi);
345 digitgraph-> SetMarkerStyle(5) ;
346 digitgraph-> SetMarkerSize(1.) ;
347 digitgraph-> SetMarkerColor(1) ;
348 digitgraph-> Paint("P") ;
352 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
353 histocanvas->Draw() ;
354 histo->Draw("lego1") ;
372 //____________________________________________________________________________
373 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
375 // Calculates the dispersion of the shower at the origine of the RecPoint
376 //DP: should we correct dispersion for non-perpendicular hit????????
384 AliPHOSDigit * digit ;
386 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
388 // Calculates the center of gravity in the local PHOS-module coordinates
392 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
393 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
397 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
398 phosgeom->RelPosInModule(relid, xi, zi);
399 if (fAmp>0 && fEnergyList[iDigit]>0) {
400 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
406 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
413 AliError(Form("Wrong weight %f\n", wtot));
416 // Calculates the dispersion in coordinates
418 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
419 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
423 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
424 phosgeom->RelPosInModule(relid, xi, zi);
425 if (fAmp>0 && fEnergyList[iDigit]>0) {
426 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
427 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
431 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
439 AliError(Form("Wrong weight %f\n", wtot));
443 fDispersion = TMath::Sqrt(d) ;
447 //______________________________________________________________________________
448 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, Float_t coreRadius, TClonesArray * digits)
450 // This function calculates energy in the core,
451 // i.e. within a radius rad = 3cm around the center. Beyond this radius
452 // in accordance with shower profile the energy deposition
453 // should be less than 2%
454 //DP: non-perpendicular incidence??????????????
459 AliPHOSDigit * digit ;
461 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
465 // Calculates the center of gravity in the local PHOS-module coordinates
467 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
468 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
472 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
473 phosgeom->RelPosInModule(relid, xi, zi);
474 if (fAmp>0 && fEnergyList[iDigit]>0) {
475 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
481 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
488 AliError(Form("Wrong weight %f\n", wtot));
491 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
492 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
496 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
497 phosgeom->RelPosInModule(relid, xi, zi);
498 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
499 if(distance < coreRadius)
500 fCoreEnergy += fEnergyList[iDigit] ;
506 //____________________________________________________________________________
507 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
509 // Calculates the axis of the shower ellipsoid
518 AliPHOSDigit * digit ;
520 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
525 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
526 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
530 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
531 phosgeom->RelPosInModule(relid, xi, zi);
532 if (fAmp>0 && fEnergyList[iDigit]>0) {
533 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
542 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
554 // //Apply correction due to non-perpendicular incidence
557 // AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
558 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
560 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
561 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
563 // dxx = dxx/(CosX*CosX) ;
564 // dzz = dzz/(CosZ*CosZ) ;
565 // dxz = dxz/(CosX*CosZ) ;
568 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
570 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
572 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
573 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
574 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
579 AliError(Form("Wrong weight %f\n", wtot));
580 fLambda[0]=fLambda[1]=0.;
584 //____________________________________________________________________________
585 void AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
587 // Calculate the shower moments in the eigen reference system
588 // M2x, M2z, M3x, M4z
589 // Calculate the angle between the shower position vector and the eigen vector
597 Double_t lambda0=0, lambda1=0;
599 AliPHOSDigit * digit ;
601 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
605 // 1) Find covariance matrix elements:
613 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
614 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
615 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
616 phosgeom->RelPosInModule(relid, xi, zi);
617 if (fAmp>0 && fEnergyList[iDigit]>0) {
618 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
627 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
640 // 2) Find covariance matrix eigen values lambda0 and lambda1
642 lambda0 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
643 lambda1 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
646 AliError(Form("Wrong weight %f\n", wtot));
650 // 3) Find covariance matrix eigen vectors e0 and e1
654 e0.Set(1.,(lambda0-dxx)/dxz);
659 e1.Set(-e0.Y(),e0.X());
661 // 4) Rotate cluster tensor from (x,z) to (e0,e1) system
662 // and calculate moments M3x and M4z
664 Float_t cosPhi = e0.X();
665 Float_t sinPhi = e0.Y();
669 Double_t dx3, dz3, dz4;
679 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
680 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
681 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
682 phosgeom->RelPosInModule(relid, xiPHOS, ziPHOS);
683 xi = xiPHOS*cosPhi + ziPHOS*sinPhi;
684 zi = ziPHOS*cosPhi - xiPHOS*sinPhi;
685 if (fAmp>0 && fEnergyList[iDigit]>0) {
686 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
692 dx3 += w * xi * xi * xi;
693 dz3 += w * zi * zi * zi ;
694 dz4 += w * zi * zi * zi * zi ;
698 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
709 dx3 += -3*dxx*x + 2*x*x*x;
710 dz4 += -4*dz3*z + 6*dzz*z*z -3*z*z*z*z;
716 AliError(Form("Wrong weight %f\n", wtot));
718 // 5) Find an angle between cluster center vector and eigen vector e0
722 phi = TMath::ACos ((x*e0.X() + z*e0.Y()) / sqrt(x*x + z*z));
731 //______________________________________________________________________________
732 void AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
734 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
736 AliPHOSDigit * digit ;
737 Int_t * tempo = new Int_t[fMaxTrack] ;
739 //First find digit with maximal energy deposition and copy its primaries
742 for(Int_t id=0; id<GetDigitsMultiplicity(); id++){
743 if(emax<fEnergyList[id]){
745 emax=fEnergyList[id];
748 digit = static_cast<AliPHOSDigit *>(digits->At( fDigitsList[imaxDigit] )) ;
749 Int_t nprimaries = digit->GetNprimary() ;
750 if ( nprimaries > fMaxTrack ) {
752 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
753 nprimaries = fMaxTrack; //skip the rest
755 for(fMulTrack=0; fMulTrack<nprimaries ; fMulTrack++){
756 tempo[fMulTrack] = digit->GetPrimary(fMulTrack+1) ;
759 //Now add other digits contributions
760 for (Int_t index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
761 if(index==imaxDigit) //already in
763 digit = static_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
764 nprimaries = digit->GetNprimary() ;
765 for(Int_t ipr=0; ipr<nprimaries; ipr++){
766 Int_t iprimary = digit->GetPrimary(ipr+1) ;
768 for(Int_t kndex = 0 ; (kndex < fMulTrack)&& notIn ; kndex++ ) { //check if not already stored
769 if(iprimary == tempo[kndex]){
774 if(fMulTrack<fMaxTrack){
775 tempo[fMulTrack]=iprimary ;
779 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack!!!" ) ;
786 if(fTracksList)delete [] fTracksList;
787 fTracksList = new Int_t[fMulTrack] ;
789 for(Int_t index = 0; index < fMulTrack; index++){
790 fTracksList[index] = tempo[index] ;
797 //____________________________________________________________________________
798 void AliPHOSEmcRecPoint::EvalAll(TClonesArray * digits )
800 // EvalCoreEnergy(logWeight, digits);
802 EvalPrimaries(digits) ;
803 AliPHOSRecPoint::EvalAll(digits) ;
805 //____________________________________________________________________________
806 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TVector3 &vtx, TClonesArray * digits )
808 // Evaluates all shower parameters
810 EvalLocalPosition(logWeight, vtx, digits,vInc) ;
811 EvalElipsAxis(logWeight, digits, vInc) ; //they are evaluated with momenta
812 EvalMoments(logWeight, digits, vInc) ;
813 EvalDispersion(logWeight, digits, vInc) ;
815 //____________________________________________________________________________
816 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TVector3 &vtx, TClonesArray * digits, TVector3 &vInc)
818 // Calculates the center of gravity in the local PHOS-module coordinates
826 AliPHOSDigit * digit ;
828 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
832 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
833 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
837 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
838 phosgeom->RelPosInModule(relid, xi, zi);
839 if (fAmp>0 && fEnergyList[iDigit]>0) {
840 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
846 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
853 AliError(Form("Wrong weight %f\n", wtot));
855 // Correction for the depth of the shower starting point (TDR p 127)
856 Float_t para = 0.925 ;
857 Float_t parb = 6.52 ;
859 phosgeom->GetIncidentVector(vtx,GetPHOSMod(),x,z,vInc) ;
863 if (fAmp>0&&vInc.Y()!=0.) {
864 depthx = ( para * TMath::Log(fAmp) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
865 depthz = ( para * TMath::Log(fAmp) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
868 AliError(Form("Wrong amplitude %f\n", fAmp));
870 fLocPos.SetX(x - depthx) ;
872 fLocPos.SetZ(z - depthz) ;
876 //____________________________________________________________________________
877 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
879 // Finds the maximum energy in the cluster
881 Float_t menergy = 0. ;
885 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
887 if(fEnergyList[iDigit] > menergy)
888 menergy = fEnergyList[iDigit] ;
893 //____________________________________________________________________________
894 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
896 // Calculates the multiplicity of digits with energy larger than H*energy
900 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
902 if(fEnergyList[iDigit] > H * fAmp)
908 //____________________________________________________________________________
909 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
910 Float_t locMaxCut,TClonesArray * digits) const
912 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
913 // energy difference between two local maxima
915 AliPHOSDigit * digit ;
916 AliPHOSDigit * digitN ;
922 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
923 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
926 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
928 digit = maxAt[iDigit] ;
930 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
931 if(iDigit == iDigitN)
934 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
936 if ( AreNeighbours(digit, digitN) ) {
937 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
939 // but may be digit too is not local max ?
940 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
945 // but may be digitN too is not local max ?
946 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
949 } // if Areneighbours
955 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
957 maxAt[iDigitN] = maxAt[iDigit] ;
958 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
964 //____________________________________________________________________________
965 void AliPHOSEmcRecPoint::EvalTime(TClonesArray * /*digits*/)
967 // Define a rec.point time as a time in the cell with the maximum energy
968 //Time already evaluated during AddDigit()
973 for(Int_t idig=0; idig < fMulDigit; idig++){
974 if(fEnergyList[idig] > maxE){
975 maxE = fEnergyList[idig] ;
979 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
982 //____________________________________________________________________________
983 void AliPHOSEmcRecPoint::Purify(Float_t threshold, const TClonesArray * digits){
984 //Removes digits below threshold
986 Int_t tempo[fMaxDigit];
987 Float_t tempoE[fMaxDigit];
990 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
991 if(fEnergyList[iDigit] > threshold){
992 tempo[mult] = fDigitsList[iDigit] ;
993 tempoE[mult] = fEnergyList[iDigit] ;
998 if(mult==0){ //too soft cluster
1000 fAmp = 0.; //Recalculate total energy
1003 //Remove non-connected cells
1006 for(Int_t i=0; i<mult; i++) used[i]=0 ;
1010 for(Int_t iDigit=0; iDigit<mult; iDigit++) {
1011 if(eMax<tempoE[iDigit]){
1012 eMax=tempoE[iDigit];
1018 used[index[0]]=kTRUE ; //mark as used
1019 for(Int_t i=0; i<inClu; i++){
1020 AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(tempo[index[i]]) ;
1021 for(Int_t iDigit=0 ;iDigit<mult; iDigit++){
1022 if(used[iDigit]) //already used
1024 AliPHOSDigit * digitN = (AliPHOSDigit *) digits->At(tempo[iDigit]) ;
1025 if(AreNeighbours(digit,digitN)){
1026 index[inClu]= iDigit ;
1028 used[iDigit]=kTRUE ;
1034 delete [] fDigitsList ;
1035 delete [] fEnergyList ;
1036 fDigitsList = new Int_t[fMulDigit];
1037 fEnergyList = new Float_t[fMulDigit];
1039 fAmp = 0.; //Recalculate total energy
1040 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
1041 fDigitsList[iDigit] = tempo[index[iDigit]];
1042 fEnergyList[iDigit] = tempoE[index[iDigit]] ;
1043 fAmp+=tempoE[index[iDigit]];
1046 //____________________________________________________________________________
1047 void AliPHOSEmcRecPoint::Print(Option_t *) const
1049 // Print the list of digits belonging to the cluster
1052 message = "AliPHOSEmcRecPoint:\n" ;
1053 message += "Digit multiplicity = %d" ;
1054 message += ", cluster Energy = %f" ;
1055 message += ", number of primaries = %d" ;
1056 message += ", rec.point index = %d \n" ;
1057 printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
1060 printf(" digits ids = ") ;
1061 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1062 printf(" %d ", fDigitsList[iDigit] ) ;
1064 printf("\n digit energies = ") ;
1065 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1066 printf(" %f ", fEnergyList[iDigit] ) ;
1068 printf("\n digit primaries ") ;
1069 if (fMulTrack<1) printf("... no primaries");
1070 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1071 printf(" %d ", fTracksList[iDigit]) ;