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 ---
35 // --- AliRoot header files ---
37 #include "AliPHOSGeometry.h"
38 #include "AliPHOSEmcRecPoint.h"
41 ClassImp(AliPHOSEmcRecPoint)
43 //____________________________________________________________________________
44 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(Float_t W0, Float_t LocMaxCut)
51 fEnergyList = new Float_t[fMaxDigit];
52 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
53 fDelta = phosgeom->GetCrystalSize(0) ;
55 fLocMaxCut = LocMaxCut ;
56 fLocPos.SetX(1000000.) ; //Local position should be evaluated
59 //____________________________________________________________________________
60 void AliPHOSEmcRecPoint::AddDigit(AliDigitNew & digit, Float_t Energy)
62 // Adds a digit to the RecPoint
63 // and accumulates the total amplitude and the multiplicity
65 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
67 int * tempo = new ( int[fMaxDigit] ) ;
68 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
71 for ( index = 0 ; index < fMulDigit ; index++ ){
72 tempo[index] = fDigitsList[index] ;
73 tempoE[index] = fEnergyList[index] ;
76 delete [] fDigitsList ;
77 fDigitsList = new ( int[fMaxDigit] ) ;
79 delete [] fEnergyList ;
80 fEnergyList = new ( Float_t[fMaxDigit] ) ;
82 for ( index = 0 ; index < fMulDigit ; index++ ){
83 fDigitsList[index] = tempo[index] ;
84 fEnergyList[index] = tempoE[index] ;
91 fDigitsList[fMulDigit] = (int) &digit ;
92 fEnergyList[fMulDigit++] = Energy ;
96 //____________________________________________________________________________
97 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 )
99 // Tells if (true) or not (false) two digits are neighbors)
101 Bool_t aren = kFALSE ;
103 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
105 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
108 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
110 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
111 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
113 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
119 //____________________________________________________________________________
120 Int_t AliPHOSEmcRecPoint::Compare(TObject * obj)
122 // Compares two RecPoints according to their position in the PHOS modules
126 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
129 Int_t phosmod1 = this->GetPHOSMod() ;
130 Int_t phosmod2 = clu->GetPHOSMod() ;
133 this->GetLocalPosition(locpos1) ;
135 clu->GetLocalPosition(locpos2) ;
137 if(phosmod1 == phosmod2 ) {
138 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/fDelta)-(Int_t)TMath::Ceil(locpos2.X()/fDelta) ;
143 else if(locpos1.Z()>locpos2.Z())
150 if(phosmod1 < phosmod2 )
159 //______________________________________________________________________________
160 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
162 // Execute action corresponding to one event
163 // This member function is called when a AliPHOSRecPoint is clicked with the locator
165 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
166 // and switched off when the mouse button is released.
169 // static Int_t pxold, pyold;
171 static TGraph * digitgraph = 0 ;
173 if (!gPad->IsEditable()) return;
176 TCanvas * histocanvas ;
181 AliPHOSDigit * digit ;
182 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
185 Float_t xi[fMulDigit] ;
186 Float_t zi[fMulDigit] ;
188 // create the histogram for the single cluster
189 // 1. gets histogram boundaries
190 Float_t ximax = -999. ;
191 Float_t zimax = -999. ;
192 Float_t ximin = 999. ;
193 Float_t zimin = 999. ;
195 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
196 digit = (AliPHOSDigit *) fDigitsList[iDigit];
197 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
198 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
199 if ( xi[iDigit] > ximax )
201 if ( xi[iDigit] < ximin )
203 if ( zi[iDigit] > zimax )
205 if ( zi[iDigit] < zimin )
208 ximax += phosgeom->GetCrystalSize(0) / 2. ;
209 zimax += phosgeom->GetCrystalSize(2) / 2. ;
210 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
211 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
212 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
213 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
215 // 2. gets the histogram title
218 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
224 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
227 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
228 digit = (AliPHOSDigit *) fDigitsList[iDigit];
229 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
230 phosgeom->RelPosInModule(relid, x, z);
231 histo->Fill(x, z, fEnergyList[iDigit] ) ;
235 digitgraph = new TGraph(fMulDigit,xi,zi);
236 digitgraph-> SetMarkerStyle(5) ;
237 digitgraph-> SetMarkerSize(1.) ;
238 digitgraph-> SetMarkerColor(1) ;
239 digitgraph-> Paint("P") ;
243 histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ;
244 histocanvas->Draw() ;
245 histo->Draw("lego1") ;
260 //____________________________________________________________________________
261 Float_t AliPHOSEmcRecPoint::GetDispersion()
263 // Calculates the dispersion of the shower at the origine of the RecPoint
269 GetLocalPosition(locpos);
270 Float_t x = locpos.X() ;
271 Float_t z = locpos.Z() ;
273 AliPHOSDigit * digit ;
274 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
277 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
278 digit = (AliPHOSDigit *) fDigitsList[iDigit];
282 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
283 phosgeom->RelPosInModule(relid, xi, zi);
284 Float_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
285 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
291 return TMath::Sqrt(d) ;
294 //____________________________________________________________________________
295 void AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
297 // Calculates the axis of the shower ellipsoid
306 AliPHOSDigit * digit ;
307 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
310 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
311 digit = (AliPHOSDigit *) fDigitsList[iDigit];
315 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
316 phosgeom->RelPosInModule(relid, xi, zi);
317 Float_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
335 lambda[0] = TMath::Sqrt( 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ) ;
336 lambda[1] = TMath::Sqrt( 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ) ;
339 //____________________________________________________________________________
340 void AliPHOSEmcRecPoint::GetLocalPosition(TVector3 &LPos)
342 // Calculates the center of gravity in the local PHOS-module coordinates
344 if( fLocPos.X() < 1000000.) { // already evaluated
356 AliPHOSDigit * digit ;
358 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
363 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
364 digit = (AliPHOSDigit *) fDigitsList[iDigit];
368 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
369 phosgeom->RelPosInModule(relid, xi, zi);
370 Float_t w = TMath::Max( 0., fW0 + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
386 //____________________________________________________________________________
387 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void)
389 // Finds the maximum energy in the cluster
391 Float_t menergy = 0. ;
395 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
397 if(fEnergyList[iDigit] > menergy)
398 menergy = fEnergyList[iDigit] ;
403 //____________________________________________________________________________
404 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(Float_t H)
406 // Calculates the multiplicity of digits with energy larger than H*energy
410 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
412 if(fEnergyList[iDigit] > H * fAmp)
418 //____________________________________________________________________________
419 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy)
421 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
422 // energy difference between two local maxima
424 AliPHOSDigit * digit ;
425 AliPHOSDigit * digitN ;
431 for(iDigit = 0; iDigit < fMulDigit; iDigit++){
432 maxAt[iDigit] = fDigitsList[iDigit] ;
435 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
436 if(maxAt[iDigit] != -1) {
437 digit = (AliPHOSDigit *) maxAt[iDigit] ;
439 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
440 digitN = (AliPHOSDigit *) fDigitsList[iDigitN] ;
442 if ( AreNeighbours(digit, digitN) ) {
443 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
444 maxAt[iDigitN] = -1 ;
445 // but may be digit too is not local max ?
446 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + fLocMaxCut)
451 // but may be digitN too is not local max ?
452 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - fLocMaxCut)
453 maxAt[iDigitN] = -1 ;
455 } // if Areneighbours
461 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
462 if(maxAt[iDigit] != -1){
463 maxAt[iDigitN] = maxAt[iDigit] ;
464 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
472 // //____________________________________________________________________________
473 // AliPHOSEmcRecPoint& AliPHOSEmcRecPoint::operator = (AliPHOSEmcRecPoint Clu)
475 // int * dl = Clu.GetDigitsList() ;
478 // delete fDigitsList ;
480 // AliPHOSDigit * digit ;
484 // for(iDigit=0; iDigit<fMulDigit; iDigit++) {
485 // digit = (AliPHOSDigit *) dl[iDigit];
486 // AddDigit(*digit) ;
489 // fAmp = Clu.GetTotalEnergy() ;
490 // fGeom = Clu.GetGeom() ;
492 // Clu.GetLocalPosition(locpos) ;
494 // fMulDigit = Clu.GetMultiplicity() ;
495 // fMaxDigit = Clu.GetMaximumMultiplicity() ;
496 // fPHOSMod = Clu.GetPHOSMod() ;
497 // fW0 = Clu.GetLogWeightCut() ;
498 // fDelta = Clu.GetDelta() ;
499 // fLocMaxCut = Clu.GetLocMaxCut() ;
506 //____________________________________________________________________________
507 void AliPHOSEmcRecPoint::Print(Option_t * option)
509 // Print the list of digits belonging to the cluster
511 cout << "AliPHOSEmcRecPoint: " << endl ;
513 AliPHOSDigit * digit ;
515 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
521 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
522 digit = (AliPHOSDigit *) fDigitsList[iDigit];
523 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
524 phosgeom->RelPosInModule(relid, xi, zi);
525 cout << " Id = " << digit->GetId() ;
526 cout << " module = " << relid[0] ;
527 cout << " x = " << xi ;
528 cout << " z = " << zi ;
529 cout << " Energy = " << fEnergyList[iDigit] << endl ;
531 cout << " Multiplicity = " << fMulDigit << endl ;
532 cout << " Cluster Energy = " << fAmp << endl ;
536 //______________________________________________________________________________
537 void AliPHOSEmcRecPoint::Streamer(TBuffer &R__b)
539 // Stream an object of class AliPHOSEmcRecPoint.
540 // Needed because of the array fEnergyList
542 if (R__b.IsReading()) {
543 Version_t R__v = R__b.ReadVersion(); if (R__v) { }
544 AliPHOSRecPoint::Streamer(R__b);
547 R__b.ReadArray(fEnergyList);
550 R__b.WriteVersion(AliPHOSEmcRecPoint::IsA());
551 AliPHOSRecPoint::Streamer(R__b);
554 R__b.WriteArray(fEnergyList, GetMaximumDigitMultiplicity() );