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 Long64_t AliPHOSEmcRecPoint::fgInstCount=0;
66 //____________________________________________________________________________
67 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() :
69 fCoreEnergy(0.), fDispersion(0.),
70 fEnergyList(0), fTime(-1.), fNExMax(0),
71 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
72 fPhixe(0.), fDistToBadCrystal(-1),fDebug(0)
78 fLocPos.SetX(1000000.) ; //Local position should be evaluated
82 fInstCount=fgInstCount++;
83 if (gDebug==-10) AliInfo(Form("0Create instance %lld",fInstCount));
86 //____________________________________________________________________________
87 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) :
89 fCoreEnergy(0.), fDispersion(0.),
90 fEnergyList(0), fTime(-1.), fNExMax(0),
91 fM2x(0.), fM2z(0.), fM3x(0.), fM4z(0.),
92 fPhixe(0.), fDistToBadCrystal(-1), fDebug(0)
98 fLocPos.SetX(1000000.) ; //Local position should be evaluated
102 fInstCount=fgInstCount++;
103 if (gDebug==-10) AliInfo(Form("1Create instance %lld",fInstCount));
106 //____________________________________________________________________________
107 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const AliPHOSEmcRecPoint & rp) :
109 fCoreEnergy(rp.fCoreEnergy), fDispersion(rp.fDispersion),
110 fEnergyList(0), fTime(rp.fTime), fNExMax(rp.fNExMax),
111 fM2x(rp.fM2x), fM2z(rp.fM2z), fM3x(rp.fM3x), fM4z(rp.fM4z),
112 fPhixe(rp.fPhixe), fDistToBadCrystal(rp.fDistToBadCrystal), fDebug(rp.fDebug)
116 fMulDigit = rp.fMulDigit ;
118 if (rp.fMulDigit>0) fEnergyList = new Float_t[rp.fMulDigit] ;
119 for(Int_t index = 0 ; index < fMulDigit ; index++)
120 fEnergyList[index] = rp.fEnergyList[index] ;
122 for(Int_t i=0; i<2; i++) {
123 fLambda[i] = rp.fLambda[i];
125 fInstCount=fgInstCount++;
126 if (gDebug==-10) AliInfo(Form("2Create instance %lld",fInstCount));
129 //____________________________________________________________________________
130 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
134 delete[] fEnergyList ;
135 if (gDebug==-10) AliInfo(Form("Delete instance %lld (%lld)",fInstCount, fgInstCount));
136 if (fInstCount>=fgInstCount-1) fgInstCount--;
140 //____________________________________________________________________________
141 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy, Float_t time)
143 // Adds a digit to the RecPoint
144 // and accumulates the total amplitude and the multiplicity
147 fEnergyList = new Float_t[fMaxDigit];
149 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
151 Int_t * tempo = new Int_t[fMaxDigit];
152 Float_t * tempoE = new Float_t[fMaxDigit];
155 for ( index = 0 ; index < fMulDigit ; index++ ){
156 tempo[index] = fDigitsList[index] ;
157 tempoE[index] = fEnergyList[index] ;
160 delete [] fDigitsList ;
161 fDigitsList = new Int_t[fMaxDigit];
163 delete [] fEnergyList ;
164 fEnergyList = new Float_t[fMaxDigit];
166 for ( index = 0 ; index < fMulDigit ; index++ ){
167 fDigitsList[index] = tempo[index] ;
168 fEnergyList[index] = tempoE[index] ;
177 for(Int_t index = 0 ; index < fMulDigit ; index++ ){
178 if(fEnergyList[index]>Energy){
186 //Alternative time calculation - still to be validated
187 // fTime = (fTime*fAmp + time*Energy)/(fAmp+Energy) ;
189 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
190 fEnergyList[fMulDigit] = Energy ;
193 EvalPHOSMod(&digit) ;
196 //____________________________________________________________________________
197 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
199 // Tells if (true) or not (false) two digits are neighbors
201 Bool_t aren = kFALSE ;
203 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
206 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
209 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
211 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
212 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
214 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
220 //____________________________________________________________________________
221 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
223 // Compares two RecPoints according to their position in the PHOS modules
225 const Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
226 //value (what is senseless) change as vell delta in
227 //AliPHOSTrackSegmentMakerv* and other RecPoints...
230 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
233 Int_t phosmod1 = GetPHOSMod() ;
234 Int_t phosmod2 = clu->GetPHOSMod() ;
237 GetLocalPosition(locpos1) ;
239 clu->GetLocalPosition(locpos2) ;
241 if(phosmod1 == phosmod2 ) {
242 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
247 else if(locpos1.Z()>locpos2.Z())
254 if(phosmod1 < phosmod2 )
262 //______________________________________________________________________________
263 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t, Int_t) /*const*/
266 // Execute action corresponding to one event
267 // This member function is called when a AliPHOSRecPoint is clicked with the locator
269 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
270 // and switched off when the mouse button is released.
273 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
275 static TGraph * digitgraph = 0 ;
277 if (!gPad->IsEditable()) return;
280 TCanvas * histocanvas ;
283 //try to get run loader from default event folder
284 AliRunLoader* rn = AliRunLoader::GetRunLoader(AliConfig::GetDefaultEventFolderName());
287 AliError(Form("Cannot find Run Loader in Default Event Folder"));
290 AliPHOSLoader* phosLoader = dynamic_cast<AliPHOSLoader*>(rn->GetLoader("PHOSLoader"));
291 if (phosLoader == 0x0)
293 AliError(Form("Cannot find PHOS Loader from Run Loader"));
298 const TClonesArray * digits = phosLoader->Digits() ;
303 AliPHOSDigit * digit ;
307 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
308 Float_t * xi = new Float_t[kMulDigit] ;
309 Float_t * zi = new Float_t[kMulDigit] ;
311 // create the histogram for the single cluster
312 // 1. gets histogram boundaries
313 Float_t ximax = -999. ;
314 Float_t zimax = -999. ;
315 Float_t ximin = 999. ;
316 Float_t zimin = 999. ;
318 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
319 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
320 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
321 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
322 if ( xi[iDigit] > ximax )
324 if ( xi[iDigit] < ximin )
326 if ( zi[iDigit] > zimax )
328 if ( zi[iDigit] < zimin )
331 ximax += phosgeom->GetCrystalSize(0) / 2. ;
332 zimax += phosgeom->GetCrystalSize(2) / 2. ;
333 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
334 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
335 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
336 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
338 // 2. gets the histogram title
341 snprintf(title,100,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
347 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
350 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
351 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
352 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
353 phosgeom->RelPosInModule(relid, x, z);
354 histo->Fill(x, z, fEnergyList[iDigit] ) ;
358 digitgraph = new TGraph(kMulDigit,xi,zi);
359 digitgraph-> SetMarkerStyle(5) ;
360 digitgraph-> SetMarkerSize(1.) ;
361 digitgraph-> SetMarkerColor(1) ;
362 digitgraph-> Paint("P") ;
366 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
367 histocanvas->Draw() ;
368 histo->Draw("lego1") ;
386 //____________________________________________________________________________
387 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
389 // Calculates the dispersion of the shower at the origine of the RecPoint
390 //DP: should we correct dispersion for non-perpendicular hit????????
398 AliPHOSDigit * digit ;
400 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
402 // Calculates the center of gravity in the local PHOS-module coordinates
406 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
407 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
411 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
412 phosgeom->RelPosInModule(relid, xi, zi);
413 if (fAmp>0 && fEnergyList[iDigit]>0) {
414 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
420 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
427 AliError(Form("Wrong weight %f\n", wtot));
430 // Calculates the dispersion in coordinates
432 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
433 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
437 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
438 phosgeom->RelPosInModule(relid, xi, zi);
439 if (fAmp>0 && fEnergyList[iDigit]>0) {
440 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
441 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
445 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
453 AliError(Form("Wrong weight %f\n", wtot));
457 fDispersion = TMath::Sqrt(d) ;
461 //______________________________________________________________________________
462 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, Float_t coreRadius, TClonesArray * digits)
464 // This function calculates energy in the core,
465 // i.e. within a radius rad = 3cm around the center. Beyond this radius
466 // in accordance with shower profile the energy deposition
467 // should be less than 2%
468 //DP: non-perpendicular incidence??????????????
473 AliPHOSDigit * digit ;
475 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
479 // Calculates the center of gravity in the local PHOS-module coordinates
481 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
482 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
486 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
487 phosgeom->RelPosInModule(relid, xi, zi);
488 if (fAmp>0 && fEnergyList[iDigit]>0) {
489 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
495 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
502 AliError(Form("Wrong weight %f\n", wtot));
505 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
506 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
510 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
511 phosgeom->RelPosInModule(relid, xi, zi);
512 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
513 if(distance < coreRadius)
514 fCoreEnergy += fEnergyList[iDigit] ;
520 //____________________________________________________________________________
521 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
523 // Calculates the axis of the shower ellipsoid
532 AliPHOSDigit * digit ;
534 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance();
539 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
540 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
544 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
545 phosgeom->RelPosInModule(relid, xi, zi);
546 if (fAmp>0 && fEnergyList[iDigit]>0) {
547 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
556 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
568 // //Apply correction due to non-perpendicular incidence
571 // AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
572 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
574 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
575 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
577 // dxx = dxx/(CosX*CosX) ;
578 // dzz = dzz/(CosZ*CosZ) ;
579 // dxz = dxz/(CosX*CosZ) ;
582 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
584 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
586 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
587 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
588 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
593 AliError(Form("Wrong weight %f\n", wtot));
594 fLambda[0]=fLambda[1]=0.;
598 //____________________________________________________________________________
599 void AliPHOSEmcRecPoint::EvalMoments(Float_t logWeight,TClonesArray * digits, TVector3 & /* vInc */)
601 // Calculate the shower moments in the eigen reference system
602 // M2x, M2z, M3x, M4z
603 // Calculate the angle between the shower position vector and the eigen vector
611 Double_t lambda0=0, lambda1=0;
613 AliPHOSDigit * digit ;
615 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
619 // 1) Find covariance matrix elements:
627 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
628 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
629 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
630 phosgeom->RelPosInModule(relid, xi, zi);
631 if (fAmp>0 && fEnergyList[iDigit]>0) {
632 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
641 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
654 // 2) Find covariance matrix eigen values lambda0 and lambda1
656 lambda0 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
657 lambda1 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
660 AliError(Form("Wrong weight %f\n", wtot));
664 // 3) Find covariance matrix eigen vectors e0 and e1
668 e0.Set(1.,(lambda0-dxx)/dxz);
673 e1.Set(-e0.Y(),e0.X());
675 // 4) Rotate cluster tensor from (x,z) to (e0,e1) system
676 // and calculate moments M3x and M4z
678 Float_t cosPhi = e0.X();
679 Float_t sinPhi = e0.Y();
683 Double_t dx3, dz3, dz4;
693 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
694 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
695 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
696 phosgeom->RelPosInModule(relid, xiPHOS, ziPHOS);
697 xi = xiPHOS*cosPhi + ziPHOS*sinPhi;
698 zi = ziPHOS*cosPhi - xiPHOS*sinPhi;
699 if (fAmp>0 && fEnergyList[iDigit]>0) {
700 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
706 dx3 += w * xi * xi * xi;
707 dz3 += w * zi * zi * zi ;
708 dz4 += w * zi * zi * zi * zi ;
712 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
723 dx3 += -3*dxx*x + 2*x*x*x;
724 dz4 += -4*dz3*z + 6*dzz*z*z -3*z*z*z*z;
730 AliError(Form("Wrong weight %f\n", wtot));
732 // 5) Find an angle between cluster center vector and eigen vector e0
736 phi = TMath::ACos ((x*e0.X() + z*e0.Y()) / sqrt(x*x + z*z));
745 //______________________________________________________________________________
746 void AliPHOSEmcRecPoint::EvalPrimaries(TClonesArray * digits)
748 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
750 AliPHOSDigit * digit ;
751 Int_t * tempo = new Int_t[fMaxTrack] ;
753 //First find digit with maximal energy deposition and copy its primaries
756 for(Int_t id=0; id<GetDigitsMultiplicity(); id++){
757 if(emax<fEnergyList[id]){
759 emax=fEnergyList[id];
762 digit = static_cast<AliPHOSDigit *>(digits->At( fDigitsList[imaxDigit] )) ;
763 Int_t nprimaries = digit->GetNprimary() ;
764 if ( nprimaries > fMaxTrack ) {
766 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack" ) ;
767 nprimaries = fMaxTrack; //skip the rest
769 for(fMulTrack=0; fMulTrack<nprimaries ; fMulTrack++){
770 tempo[fMulTrack] = digit->GetPrimary(fMulTrack+1) ;
773 //Now add other digits contributions
774 for (Int_t index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
775 if(index==imaxDigit) //already in
777 digit = static_cast<AliPHOSDigit *>(digits->At( fDigitsList[index] )) ;
778 nprimaries = digit->GetNprimary() ;
779 for(Int_t ipr=0; ipr<nprimaries; ipr++){
780 Int_t iprimary = digit->GetPrimary(ipr+1) ;
782 for(Int_t kndex = 0 ; (kndex < fMulTrack)&& notIn ; kndex++ ) { //check if not already stored
783 if(iprimary == tempo[kndex]){
788 if(fMulTrack<fMaxTrack){
789 tempo[fMulTrack]=iprimary ;
793 Error("EvalPrimaries", "GetNprimaries ERROR > increase fMaxTrack!!!" ) ;
800 if(fTracksList)delete [] fTracksList;
801 fTracksList = new Int_t[fMulTrack] ;
803 for(Int_t index = 0; index < fMulTrack; index++){
804 fTracksList[index] = tempo[index] ;
811 //____________________________________________________________________________
812 void AliPHOSEmcRecPoint::EvalAll(TClonesArray * digits )
814 // EvalCoreEnergy(logWeight, digits);
816 EvalPrimaries(digits) ;
817 AliPHOSRecPoint::EvalAll(digits) ;
819 //____________________________________________________________________________
820 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TVector3 &vtx, TClonesArray * digits )
822 // Evaluates all shower parameters
824 EvalLocalPosition(logWeight, vtx, digits,vInc) ;
825 EvalElipsAxis(logWeight, digits, vInc) ; //they are evaluated with momenta
826 EvalMoments(logWeight, digits, vInc) ;
827 EvalDispersion(logWeight, digits, vInc) ;
829 //____________________________________________________________________________
830 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TVector3 &vtx, TClonesArray * digits, TVector3 &vInc)
832 // Calculates the center of gravity in the local PHOS-module coordinates
840 AliPHOSDigit * digit ;
842 AliPHOSGeometry * phosgeom = AliPHOSGeometry::GetInstance() ;
846 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
847 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
851 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
852 phosgeom->RelPosInModule(relid, xi, zi);
853 if (fAmp>0 && fEnergyList[iDigit]>0) {
854 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
860 AliError(Form("Wrong energy %f and/or amplitude %f\n", fEnergyList[iDigit], fAmp));
867 AliError(Form("Wrong weight %f\n", wtot));
869 // Correction for the depth of the shower starting point (TDR p 127)
870 Float_t para = 0.925 ;
871 Float_t parb = 6.52 ;
873 phosgeom->GetIncidentVector(vtx,GetPHOSMod(),x,z,vInc) ;
877 if (fAmp>0&&vInc.Y()!=0.) {
878 depthx = ( para * TMath::Log(fAmp) + parb ) * vInc.X()/TMath::Abs(vInc.Y()) ;
879 depthz = ( para * TMath::Log(fAmp) + parb ) * vInc.Z()/TMath::Abs(vInc.Y()) ;
882 AliError(Form("Wrong amplitude %f\n", fAmp));
884 fLocPos.SetX(x - depthx) ;
886 fLocPos.SetZ(z - depthz) ;
890 //____________________________________________________________________________
891 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
893 // Finds the maximum energy in the cluster
895 Float_t menergy = 0. ;
899 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
901 if(fEnergyList[iDigit] > menergy)
902 menergy = fEnergyList[iDigit] ;
907 //____________________________________________________________________________
908 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H) const
910 // Calculates the multiplicity of digits with energy larger than H*energy
914 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
916 if(fEnergyList[iDigit] > H * fAmp)
922 //____________________________________________________________________________
923 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
924 Float_t locMaxCut,TClonesArray * digits) const
926 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
927 // energy difference between two local maxima
929 AliPHOSDigit * digit ;
930 AliPHOSDigit * digitN ;
936 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
937 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
940 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
942 digit = maxAt[iDigit] ;
944 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
945 if(iDigit == iDigitN)
948 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
950 if ( AreNeighbours(digit, digitN) ) {
951 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
953 // but may be digit too is not local max ?
954 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
959 // but may be digitN too is not local max ?
960 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
963 } // if Areneighbours
969 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
971 maxAt[iDigitN] = maxAt[iDigit] ;
972 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
978 //____________________________________________________________________________
979 void AliPHOSEmcRecPoint::EvalTime(TClonesArray * /*digits*/)
981 // Define a rec.point time as a time in the cell with the maximum energy
982 //Time already evaluated during AddDigit()
987 for(Int_t idig=0; idig < fMulDigit; idig++){
988 if(fEnergyList[idig] > maxE){
989 maxE = fEnergyList[idig] ;
993 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
996 //____________________________________________________________________________
997 void AliPHOSEmcRecPoint::Purify(Float_t threshold, const TClonesArray * digits){
998 //Removes digits below threshold
1000 Int_t tempo[fMaxDigit];
1001 Float_t tempoE[fMaxDigit];
1004 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
1005 if(fEnergyList[iDigit] > threshold){
1006 tempo[mult] = fDigitsList[iDigit] ;
1007 tempoE[mult] = fEnergyList[iDigit] ;
1012 if(mult==0){ //too soft cluster
1014 fAmp = 0.; //Recalculate total energy
1017 //Remove non-connected cells
1020 for(Int_t i=0; i<mult; i++) used[i]=0 ;
1024 for(Int_t iDigit=0; iDigit<mult; iDigit++) {
1025 if(eMax<tempoE[iDigit]){
1026 eMax=tempoE[iDigit];
1032 used[index[0]]=kTRUE ; //mark as used
1033 for(Int_t i=0; i<inClu; i++){
1034 AliPHOSDigit * digit = (AliPHOSDigit *) digits->At(tempo[index[i]]) ;
1035 for(Int_t iDigit=0 ;iDigit<mult; iDigit++){
1036 if(used[iDigit]) //already used
1038 AliPHOSDigit * digitN = (AliPHOSDigit *) digits->At(tempo[iDigit]) ;
1039 if(AreNeighbours(digit,digitN)){
1040 index[inClu]= iDigit ;
1042 used[iDigit]=kTRUE ;
1048 delete [] fDigitsList ;
1049 delete [] fEnergyList ;
1050 fDigitsList = new Int_t[fMulDigit];
1051 fEnergyList = new Float_t[fMulDigit];
1053 fAmp = 0.; //Recalculate total energy
1054 for(Int_t iDigit=0;iDigit< fMulDigit ;iDigit++){
1055 fDigitsList[iDigit] = tempo[index[iDigit]];
1056 fEnergyList[iDigit] = tempoE[index[iDigit]] ;
1057 fAmp+=tempoE[index[iDigit]];
1060 //____________________________________________________________________________
1061 void AliPHOSEmcRecPoint::Print(Option_t *) const
1063 // Print the list of digits belonging to the cluster
1066 message = "AliPHOSEmcRecPoint:\n" ;
1067 message += "Digit multiplicity = %d" ;
1068 message += ", cluster Energy = %f" ;
1069 message += ", number of primaries = %d" ;
1070 message += ", rec.point index = %d \n" ;
1071 printf(message.Data(), fMulDigit, fAmp, fMulTrack,GetIndexInList() ) ;
1074 printf(" digits ids = ") ;
1075 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1076 printf(" %d ", fDigitsList[iDigit] ) ;
1078 printf("\n digit energies = ") ;
1079 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1080 printf(" %f ", fEnergyList[iDigit] ) ;
1082 printf("\n digit primaries ") ;
1083 if (fMulTrack<1) printf("... no primaries");
1084 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1085 printf(" %d ", fTracksList[iDigit]) ;