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"
40 #include "AliPHOSIndexToObject.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
61 //____________________________________________________________________________
62 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
66 delete[] fEnergyList ;
69 //____________________________________________________________________________
70 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
72 // Adds a digit to the RecPoint
73 // and accumulates the total amplitude and the multiplicity
75 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
77 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
78 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
81 for ( index = 0 ; index < fMulDigit ; index++ ){
82 tempo[index] = fDigitsList[index] ;
83 tempoE[index] = fEnergyList[index] ;
86 delete [] fDigitsList ;
87 fDigitsList = new ( Int_t[fMaxDigit] ) ;
89 delete [] fEnergyList ;
90 fEnergyList = new ( Float_t[fMaxDigit] ) ;
92 for ( index = 0 ; index < fMulDigit ; index++ ){
93 fDigitsList[index] = tempo[index] ;
94 fEnergyList[index] = tempoE[index] ;
101 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
102 fEnergyList[fMulDigit] = Energy ;
107 //____________________________________________________________________________
108 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 )
110 // Tells if (true) or not (false) two digits are neighbors)
112 Bool_t aren = kFALSE ;
114 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
116 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
119 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
121 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
122 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
124 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
130 //____________________________________________________________________________
131 Int_t AliPHOSEmcRecPoint::Compare(TObject * obj)
133 // Compares two RecPoints according to their position in the PHOS modules
137 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
140 Int_t phosmod1 = this->GetPHOSMod() ;
141 Int_t phosmod2 = clu->GetPHOSMod() ;
144 this->GetLocalPosition(locpos1) ;
146 clu->GetLocalPosition(locpos2) ;
148 if(phosmod1 == phosmod2 ) {
149 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/fDelta)-(Int_t)TMath::Ceil(locpos2.X()/fDelta) ;
154 else if(locpos1.Z()>locpos2.Z())
161 if(phosmod1 < phosmod2 )
170 //______________________________________________________________________________
171 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
173 // Execute action corresponding to one event
174 // This member function is called when a AliPHOSRecPoint is clicked with the locator
176 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
177 // and switched off when the mouse button is released.
180 // static Int_t pxold, pyold;
182 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
184 static TGraph * digitgraph = 0 ;
186 if (!gPad->IsEditable()) return;
189 TCanvas * histocanvas ;
194 AliPHOSDigit * digit ;
195 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
199 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
200 Float_t * xi = new Float_t[kMulDigit] ;
201 Float_t * zi = new Float_t[kMulDigit] ;
203 // create the histogram for the single cluster
204 // 1. gets histogram boundaries
205 Float_t ximax = -999. ;
206 Float_t zimax = -999. ;
207 Float_t ximin = 999. ;
208 Float_t zimin = 999. ;
210 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
211 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
212 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
213 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
214 if ( xi[iDigit] > ximax )
216 if ( xi[iDigit] < ximin )
218 if ( zi[iDigit] > zimax )
220 if ( zi[iDigit] < zimin )
223 ximax += phosgeom->GetCrystalSize(0) / 2. ;
224 zimax += phosgeom->GetCrystalSize(2) / 2. ;
225 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
226 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
227 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
228 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
230 // 2. gets the histogram title
233 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
239 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
242 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
243 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
244 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
245 phosgeom->RelPosInModule(relid, x, z);
246 histo->Fill(x, z, fEnergyList[iDigit] ) ;
250 digitgraph = new TGraph(kMulDigit,xi,zi);
251 digitgraph-> SetMarkerStyle(5) ;
252 digitgraph-> SetMarkerSize(1.) ;
253 digitgraph-> SetMarkerColor(1) ;
254 digitgraph-> Paint("P") ;
258 histocanvas = new TCanvas("cluser", "a single cluster", 600, 500) ;
259 histocanvas->Draw() ;
260 histo->Draw("lego1") ;
278 //____________________________________________________________________________
279 Float_t AliPHOSEmcRecPoint::GetDispersion()
281 // Calculates the dispersion of the shower at the origine of the RecPoint
283 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
289 GetLocalPosition(locpos);
290 Float_t x = locpos.X() ;
291 Float_t z = locpos.Z() ;
293 AliPHOSDigit * digit ;
294 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
297 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
298 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
302 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
303 phosgeom->RelPosInModule(relid, xi, zi);
304 Float_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
305 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
311 return TMath::Sqrt(d) ;
314 //____________________________________________________________________________
315 void AliPHOSEmcRecPoint::GetElipsAxis(Float_t * lambda)
317 // Calculates the axis of the shower ellipsoid
319 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
328 AliPHOSDigit * digit ;
329 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
332 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
333 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
337 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
338 phosgeom->RelPosInModule(relid, xi, zi);
339 Double_t w = TMath::Max(0.,fW0+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
356 lambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
358 lambda[0] = TMath::Sqrt(lambda[0]) ;
360 lambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
361 if(lambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
362 lambda[1] = TMath::Sqrt(lambda[1]) ;
367 //____________________________________________________________________________
368 void AliPHOSEmcRecPoint::GetLocalPosition(TVector3 &LPos)
370 // Calculates the center of gravity in the local PHOS-module coordinates
372 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
374 if( fLocPos.X() < 1000000.) { // already evaluated
386 AliPHOSDigit * digit ;
388 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
393 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
394 digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) );
398 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
399 phosgeom->RelPosInModule(relid, xi, zi);
400 Float_t w = TMath::Max( 0., fW0 + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
416 //____________________________________________________________________________
417 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void)
419 // Finds the maximum energy in the cluster
421 Float_t menergy = 0. ;
425 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
427 if(fEnergyList[iDigit] > menergy)
428 menergy = fEnergyList[iDigit] ;
433 //____________________________________________________________________________
434 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H)
436 // Calculates the multiplicity of digits with energy larger than H*energy
440 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
442 if(fEnergyList[iDigit] > H * fAmp)
448 //____________________________________________________________________________
449 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy)
451 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
452 // energy difference between two local maxima
454 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
456 AliPHOSDigit * digit ;
457 AliPHOSDigit * digitN ;
463 for(iDigit = 0; iDigit < fMulDigit; iDigit++){
464 maxAt[iDigit] = (Int_t) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
467 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
468 if(maxAt[iDigit] != -1) {
469 digit = (AliPHOSDigit *) maxAt[iDigit] ;
471 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
472 digitN = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigitN]) ) ;
474 if ( AreNeighbours(digit, digitN) ) {
475 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
476 maxAt[iDigitN] = -1 ;
477 // but may be digit too is not local max ?
478 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + fLocMaxCut)
483 // but may be digitN too is not local max ?
484 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - fLocMaxCut)
485 maxAt[iDigitN] = -1 ;
487 } // if Areneighbours
493 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
494 if(maxAt[iDigit] != -1){
495 maxAt[iDigitN] = maxAt[iDigit] ;
496 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
504 // //____________________________________________________________________________
505 // AliPHOSEmcRecPoint& AliPHOSEmcRecPoint::operator = (AliPHOSEmcRecPoint Clu)
507 // int * dl = Clu.GetDigitsList() ;
510 // delete fDigitsList ;
512 // AliPHOSDigit * digit ;
516 // for(iDigit=0; iDigit<fMulDigit; iDigit++) {
517 // digit = (AliPHOSDigit *) dl[iDigit];
518 // AddDigit(*digit) ;
521 // fAmp = Clu.GetTotalEnergy() ;
522 // fGeom = Clu.GetGeom() ;
524 // Clu.GetLocalPosition(locpos) ;
526 // fMulDigit = Clu.GetMultiplicity() ;
527 // fMaxDigit = Clu.GetMaximumMultiplicity() ;
528 // fPHOSMod = Clu.GetPHOSMod() ;
529 // fW0 = Clu.GetLogWeightCut() ;
530 // fDelta = Clu.GetDelta() ;
531 // fLocMaxCut = Clu.GetLocMaxCut() ;
538 //____________________________________________________________________________
539 void AliPHOSEmcRecPoint::Print(Option_t * option)
541 // Print the list of digits belonging to the cluster
543 cout << "AliPHOSEmcRecPoint: " << endl ;
545 AliPHOSDigit * digit ;
547 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
553 AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
555 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
556 digit = please->GimeDigit( fDigitsList[iDigit] ) ;
557 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
558 phosgeom->RelPosInModule(relid, xi, zi);
559 cout << " Id = " << digit->GetId() ;
560 cout << " module = " << relid[0] ;
561 cout << " x = " << xi ;
562 cout << " z = " << zi ;
563 cout << " Energy = " << fEnergyList[iDigit] << endl ;
565 cout << " Multiplicity = " << fMulDigit << endl ;
566 cout << " Cluster Energy = " << fAmp << endl ;
567 cout << " Stored at position " << GetIndexInList() << endl ;
570 //______________________________________________________________________________
571 // void AliPHOSEmcRecPoint::Streamer(TBuffer &R__b)
573 // // Stream an object of class AliPHOSEmcRecPoint.
575 // if (R__b.IsReading()) {
576 // Version_t R__v = R__b.ReadVersion(); if (R__v) { }
577 // AliPHOSRecPoint::Streamer(R__b);
579 // fEnergyList = new Float_t[fMulDigit] ;
580 // R__b.ReadFastArray(fEnergyList, fMulDigit);
581 // R__b >> fLocMaxCut;
584 // R__b.WriteVersion(AliPHOSEmcRecPoint::IsA());
585 // AliPHOSRecPoint::Streamer(R__b);
587 // R__b.WriteFastArray(fEnergyList, fMulDigit);
588 // R__b << fLocMaxCut;