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 //_________________________________________________________________________
19 // RecPoint implementation for PHOS-EMC
20 // An EmcRecPoint is a cluster of digits
22 //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
25 // --- ROOT system ---
31 // --- Standard library ---
36 // --- AliRoot header files ---
38 #include "AliPHOSGeometry.h"
39 #include "AliPHOSEmcRecPoint.h"
42 ClassImp(AliPHOSEmcRecPoint)
44 //____________________________________________________________________________
45 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(Float_t W0, Float_t LocMaxCut)
52 fEnergyList = new Float_t[fMaxDigit];
53 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
54 fDelta = phosgeom->GetCrystalSize(0) ;
56 fLocMaxCut = LocMaxCut ;
57 fLocPos.SetX(1000000.) ; //Local position should be evaluated
60 //____________________________________________________________________________
61 void AliPHOSEmcRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
63 // Adds a digit to the RecPoint
64 // and accumulates the total amplitude and the multiplicity
66 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
68 int * tempo = new ( int[fMaxDigit] ) ;
69 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
72 for ( index = 0 ; index < fMulDigit ; index++ ){
73 tempo[index] = fDigitsList[index] ;
74 tempoE[index] = fEnergyList[index] ;
77 delete [] fDigitsList ;
78 fDigitsList = new ( int[fMaxDigit] ) ;
80 delete [] fEnergyList ;
81 fEnergyList = new ( Float_t[fMaxDigit] ) ;
83 for ( index = 0 ; index < fMulDigit ; index++ ){
84 fDigitsList[index] = tempo[index] ;
85 fEnergyList[index] = tempoE[index] ;
92 fDigitsList[fMulDigit] = (int) &digit ;
93 fEnergyList[fMulDigit++] = Energy ;
97 //____________________________________________________________________________
98 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 )
100 // Tells if (true) or not (false) two digits are neighbors)
102 Bool_t aren = kFALSE ;
104 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
106 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
109 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
111 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
112 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
114 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
120 //____________________________________________________________________________
121 Int_t AliPHOSEmcRecPoint::Compare(TObject * obj)
123 // Compares two RecPoints according to their position in the PHOS modules
127 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
130 Int_t phosmod1 = this->GetPHOSMod() ;
131 Int_t phosmod2 = clu->GetPHOSMod() ;
134 this->GetLocalPosition(locpos1) ;
136 clu->GetLocalPosition(locpos2) ;
138 if(phosmod1 == phosmod2 ) {
139 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/fDelta)-(Int_t)TMath::Ceil(locpos2.X()/fDelta) ;
144 else if(locpos1.Z()>locpos2.Z())
151 if(phosmod1 < phosmod2 )
160 //______________________________________________________________________________
161 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
163 // Execute action corresponding to one event
164 // This member function is called when a AliPHOSRecPoint is clicked with the locator
166 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
167 // and switched off when the mouse button is released.
170 // static Int_t pxold, pyold;
172 static TGraph * digitgraph = 0 ;
174 if (!gPad->IsEditable()) return;
177 TCanvas * histocanvas ;
182 AliPHOSDigit * digit ;
183 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
187 const Int_t fMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
188 Float_t * xi = new Float_t[fMulDigit] ;
189 Float_t * zi = new Float_t[fMulDigit] ;
191 // create the histogram for the single cluster
192 // 1. gets histogram boundaries
193 Float_t ximax = -999. ;
194 Float_t zimax = -999. ;
195 Float_t ximin = 999. ;
196 Float_t zimin = 999. ;
198 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
199 digit = (AliPHOSDigit *) fDigitsList[iDigit];
200 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
201 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
202 if ( xi[iDigit] > ximax )
204 if ( xi[iDigit] < ximin )
206 if ( zi[iDigit] > zimax )
208 if ( zi[iDigit] < zimin )
211 ximax += phosgeom->GetCrystalSize(0) / 2. ;
212 zimax += phosgeom->GetCrystalSize(2) / 2. ;
213 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
214 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
215 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
216 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
218 // 2. gets the histogram title
221 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
227 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
230 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
231 digit = (AliPHOSDigit *) fDigitsList[iDigit];
232 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
233 phosgeom->RelPosInModule(relid, x, z);
234 histo->Fill(x, z, fEnergyList[iDigit] ) ;
238 digitgraph = new TGraph(fMulDigit,xi,zi);
239 digitgraph-> SetMarkerStyle(5) ;
240 digitgraph-> SetMarkerSize(1.) ;
241 digitgraph-> SetMarkerColor(1) ;
242 digitgraph-> Paint("P") ;
246 histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ;
247 histocanvas->Draw() ;
248 histo->Draw("lego1") ;
266 //____________________________________________________________________________
267 Float_t AliPHOSEmcRecPoint::GetDispersion()
269 // Calculates the dispersion of the shower at the origine of the RecPoint
275 GetLocalPosition(locpos);
276 Float_t x = locpos.X() ;
277 Float_t z = locpos.Z() ;
279 AliPHOSDigit * digit ;
280 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
283 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
284 digit = (AliPHOSDigit *) fDigitsList[iDigit];
288 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
289 phosgeom->RelPosInModule(relid, xi, zi);
290 Float_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
291 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
297 return TMath::Sqrt(d) ;
300 //____________________________________________________________________________
301 void AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
303 // Calculates the axis of the shower ellipsoid
312 AliPHOSDigit * digit ;
313 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
316 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
317 digit = (AliPHOSDigit *) fDigitsList[iDigit];
321 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
322 phosgeom->RelPosInModule(relid, xi, zi);
323 Float_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
341 lambda[0] = TMath::Sqrt( 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ) ;
342 lambda[1] = TMath::Sqrt( 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ) ;
345 //____________________________________________________________________________
346 void AliPHOSEmcRecPoint::GetLocalPosition(TVector3 &LPos)
348 // Calculates the center of gravity in the local PHOS-module coordinates
350 if( fLocPos.X() < 1000000.) { // already evaluated
362 AliPHOSDigit * digit ;
364 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
369 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
370 digit = (AliPHOSDigit *) fDigitsList[iDigit];
374 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
375 phosgeom->RelPosInModule(relid, xi, zi);
376 Float_t w = TMath::Max( 0., fW0 + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
392 //____________________________________________________________________________
393 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void)
395 // Finds the maximum energy in the cluster
397 Float_t menergy = 0. ;
401 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
403 if(fEnergyList[iDigit] > menergy)
404 menergy = fEnergyList[iDigit] ;
409 //____________________________________________________________________________
410 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H)
412 // Calculates the multiplicity of digits with energy larger than H*energy
416 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
418 if(fEnergyList[iDigit] > H * fAmp)
424 //____________________________________________________________________________
425 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy)
427 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
428 // energy difference between two local maxima
430 AliPHOSDigit * digit ;
431 AliPHOSDigit * digitN ;
437 for(iDigit = 0; iDigit < fMulDigit; iDigit++){
438 maxAt[iDigit] = fDigitsList[iDigit] ;
441 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
442 if(maxAt[iDigit] != -1) {
443 digit = (AliPHOSDigit *) maxAt[iDigit] ;
445 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
446 digitN = (AliPHOSDigit *) fDigitsList[iDigitN] ;
448 if ( AreNeighbours(digit, digitN) ) {
449 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
450 maxAt[iDigitN] = -1 ;
451 // but may be digit too is not local max ?
452 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + fLocMaxCut)
457 // but may be digitN too is not local max ?
458 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - fLocMaxCut)
459 maxAt[iDigitN] = -1 ;
461 } // if Areneighbours
467 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
468 if(maxAt[iDigit] != -1){
469 maxAt[iDigitN] = maxAt[iDigit] ;
470 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
478 // //____________________________________________________________________________
479 // AliPHOSEmcRecPoint& AliPHOSEmcRecPoint::operator = (AliPHOSEmcRecPoint Clu)
481 // int * dl = Clu.GetDigitsList() ;
484 // delete fDigitsList ;
486 // AliPHOSDigit * digit ;
490 // for(iDigit=0; iDigit<fMulDigit; iDigit++) {
491 // digit = (AliPHOSDigit *) dl[iDigit];
492 // AddDigit(*digit) ;
495 // fAmp = Clu.GetTotalEnergy() ;
496 // fGeom = Clu.GetGeom() ;
498 // Clu.GetLocalPosition(locpos) ;
500 // fMulDigit = Clu.GetMultiplicity() ;
501 // fMaxDigit = Clu.GetMaximumMultiplicity() ;
502 // fPHOSMod = Clu.GetPHOSMod() ;
503 // fW0 = Clu.GetLogWeightCut() ;
504 // fDelta = Clu.GetDelta() ;
505 // fLocMaxCut = Clu.GetLocMaxCut() ;
512 //____________________________________________________________________________
513 void AliPHOSEmcRecPoint::Print(Option_t * option)
515 // Print the list of digits belonging to the cluster
517 cout << "AliPHOSEmcRecPoint: " << endl ;
519 AliPHOSDigit * digit ;
521 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
527 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
528 digit = (AliPHOSDigit *) fDigitsList[iDigit];
529 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
530 phosgeom->RelPosInModule(relid, xi, zi);
531 cout << " Id = " << digit->GetId() ;
532 cout << " module = " << relid[0] ;
533 cout << " x = " << xi ;
534 cout << " z = " << zi ;
535 cout << " Energy = " << fEnergyList[iDigit] << endl ;
537 cout << " Multiplicity = " << fMulDigit << endl ;
538 cout << " Cluster Energy = " << fAmp << endl ;
542 //______________________________________________________________________________
543 void AliPHOSEmcRecPoint::Streamer(TBuffer &R__b)
545 // Stream an object of class AliPHOSEmcRecPoint.
546 // Needed because of the array fEnergyList
549 if (R__b.IsReading()) {
550 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
551 AliPHOSRecPoint::Streamer(R__b);
554 R__b.ReadArray(fEnergyList);
557 R__b.WriteVersion(AliPHOSEmcRecPoint::IsA());
558 AliPHOSRecPoint::Streamer(R__b);
561 R__b.WriteArray(fEnergyList, GetMaximumDigitMultiplicity() );