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 "AliGenerator.h"
38 #include "AliPHOSGeometry.h"
39 #include "AliPHOSEmcRecPoint.h"
42 ClassImp(AliPHOSEmcRecPoint)
44 //____________________________________________________________________________
45 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() : AliPHOSRecPoint()
53 fGeom = AliPHOSGeometry::GetInstance() ;
54 fLocPos.SetX(1000000.) ; //Local position should be evaluated
58 //____________________________________________________________________________
59 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
63 delete[] fEnergyList ;
66 //____________________________________________________________________________
67 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
69 // Adds a digit to the RecPoint
70 // and accumulates the total amplitude and the multiplicity
73 fEnergyList = new Float_t[fMaxDigit];
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 ;
106 EvalPHOSMod(&digit) ;
109 //____________________________________________________________________________
110 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
112 // Tells if (true) or not (false) two digits are neighbors)
114 Bool_t aren = kFALSE ;
116 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
118 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
121 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
123 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
124 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
126 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
132 //____________________________________________________________________________
133 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
135 // Compares two RecPoints according to their position in the PHOS modules
137 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
138 //value (what is senseless) change as vell delta in
139 //AliPHOSTrackSegmentMakerv* and other RecPoints...
142 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
145 Int_t phosmod1 = GetPHOSMod() ;
146 Int_t phosmod2 = clu->GetPHOSMod() ;
149 GetLocalPosition(locpos1) ;
151 clu->GetLocalPosition(locpos2) ;
153 if(phosmod1 == phosmod2 ) {
154 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
159 else if(locpos1.Z()>locpos2.Z())
166 if(phosmod1 < phosmod2 )
175 //______________________________________________________________________________
176 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
178 // Commented by Dmitri Peressounko: there is no possibility to ensure,
179 // that AliPHOSIndexToObject keeps the correct information.
181 // // Execute action corresponding to one event
182 // // This member function is called when a AliPHOSRecPoint is clicked with the locator
184 // // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
185 // // and switched off when the mouse button is released.
188 // // static Int_t pxold, pyold;
190 // AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
192 // static TGraph * digitgraph = 0 ;
194 // if (!gPad->IsEditable()) return;
196 // TH2F * histo = 0 ;
197 // TCanvas * histocanvas ;
201 // case kButton1Down: {
202 // AliPHOSDigit * digit ;
203 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
207 // const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
208 // Float_t * xi = new Float_t[kMulDigit] ;
209 // Float_t * zi = new Float_t[kMulDigit] ;
211 // // create the histogram for the single cluster
212 // // 1. gets histogram boundaries
213 // Float_t ximax = -999. ;
214 // Float_t zimax = -999. ;
215 // Float_t ximin = 999. ;
216 // Float_t zimin = 999. ;
218 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
219 // digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
220 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
221 // phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
222 // if ( xi[iDigit] > ximax )
223 // ximax = xi[iDigit] ;
224 // if ( xi[iDigit] < ximin )
225 // ximin = xi[iDigit] ;
226 // if ( zi[iDigit] > zimax )
227 // zimax = zi[iDigit] ;
228 // if ( zi[iDigit] < zimin )
229 // zimin = zi[iDigit] ;
231 // ximax += phosgeom->GetCrystalSize(0) / 2. ;
232 // zimax += phosgeom->GetCrystalSize(2) / 2. ;
233 // ximin -= phosgeom->GetCrystalSize(0) / 2. ;
234 // zimin -= phosgeom->GetCrystalSize(2) / 2. ;
235 // Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
236 // Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
238 // // 2. gets the histogram title
240 // Text_t title[100] ;
241 // sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
247 // histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
250 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
251 // digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
252 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
253 // phosgeom->RelPosInModule(relid, x, z);
254 // histo->Fill(x, z, fEnergyList[iDigit] ) ;
257 // if (!digitgraph) {
258 // digitgraph = new TGraph(kMulDigit,xi,zi);
259 // digitgraph-> SetMarkerStyle(5) ;
260 // digitgraph-> SetMarkerSize(1.) ;
261 // digitgraph-> SetMarkerColor(1) ;
262 // digitgraph-> Paint("P") ;
266 // histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
267 // histocanvas->Draw() ;
268 // histo->Draw("lego1") ;
278 // delete digitgraph ;
286 //____________________________________________________________________________
287 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
289 // Calculates the dispersion of the shower at the origine of the RecPoint
295 GetLocalPosition(locpos);
296 Float_t x = locpos.X() ;
297 Float_t z = locpos.Z() ;
299 AliPHOSDigit * digit ;
300 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
303 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
304 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
308 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
309 phosgeom->RelPosInModule(relid, xi, zi);
310 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
311 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
318 fDispersion = TMath::Sqrt(d) ;
320 //______________________________________________________________________________
321 void AliPHOSEmcRecPoint::EvalCoreEnergy(TClonesArray * digits)
323 //This function calculates energy in the core,
324 //i.e. within radius rad = 3cm. Beyond this radius
325 //in accoradnce with shower profile energy deposition
326 // should be less than 2%
328 Float_t coreRadius = 3 ;
331 GetLocalPosition(locpos);
332 Float_t x = locpos.X() ;
333 Float_t z = locpos.Z() ;
335 AliPHOSDigit * digit ;
336 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
339 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
340 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
344 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
345 phosgeom->RelPosInModule(relid, xi, zi);
346 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
347 if(distance < coreRadius)
348 fCoreEnergy += fEnergyList[iDigit] ;
353 //____________________________________________________________________________
354 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
356 // Calculates the axis of the shower ellipsoid
365 AliPHOSDigit * digit ;
366 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
369 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
370 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
374 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
375 phosgeom->RelPosInModule(relid, xi, zi);
376 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
393 // //Apply correction due to non-perpendicular incidence
396 // Double_t DistanceToIP= (Double_t ) ((AliPHOSGeometry *) fGeom)->GetIPtoCrystalSurface() ;
398 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
399 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
401 // dxx = dxx/(CosX*CosX) ;
402 // dzz = dzz/(CosZ*CosZ) ;
403 // dxz = dxz/(CosX*CosZ) ;
406 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
408 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
410 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
411 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
412 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
417 //____________________________________________________________________________
418 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
420 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
421 EvalLocalPosition(logWeight, digits) ;
422 EvalElipsAxis(logWeight, digits) ;
423 EvalDispersion(logWeight, digits) ;
424 EvalCoreEnergy(digits);
426 //____________________________________________________________________________
427 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
429 // Calculates the center of gravity in the local PHOS-module coordinates
438 AliPHOSDigit * digit ;
440 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
444 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
445 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
449 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
450 phosgeom->RelPosInModule(relid, xi, zi);
451 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
461 // Correction for the depth of the shower starting point (TDR p 127)
462 Float_t para = 0.925 ;
463 Float_t parb = 6.52 ;
465 Float_t xo,yo,zo ; //Coordinates of the origin
466 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
468 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
470 //Transform to the local ref.frame
472 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
473 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
475 Float_t radius = TMath::Sqrt((xoL-x)*(xoL-x)+
476 (phosgeom->GetIPtoCrystalSurface()-yoL)*(phosgeom->GetIPtoCrystalSurface()-yoL)+
479 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
480 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
482 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
483 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
486 fLocPos.SetX(x - depthx) ;
488 fLocPos.SetZ(z - depthz) ;
493 //____________________________________________________________________________
494 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
496 // Finds the maximum energy in the cluster
498 Float_t menergy = 0. ;
502 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
504 if(fEnergyList[iDigit] > menergy)
505 menergy = fEnergyList[iDigit] ;
510 //____________________________________________________________________________
511 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
513 // Calculates the multiplicity of digits with energy larger than H*energy
517 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
519 if(fEnergyList[iDigit] > H * fAmp)
525 //____________________________________________________________________________
526 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy,
527 Float_t locMaxCut,TClonesArray * digits) const
529 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
530 // energy difference between two local maxima
532 AliPHOSDigit * digit ;
533 AliPHOSDigit * digitN ;
539 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
540 maxAt[iDigit] = (Int_t) digits->At(fDigitsList[iDigit]) ;
543 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
544 if(maxAt[iDigit] != -1) {
545 digit = (AliPHOSDigit *) maxAt[iDigit] ;
547 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
548 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
550 if ( AreNeighbours(digit, digitN) ) {
551 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
552 maxAt[iDigitN] = -1 ;
553 // but may be digit too is not local max ?
554 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
559 // but may be digitN too is not local max ?
560 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
561 maxAt[iDigitN] = -1 ;
563 } // if Areneighbours
569 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
570 if(maxAt[iDigit] != -1){
571 maxAt[iDigitN] = maxAt[iDigit] ;
572 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
581 //____________________________________________________________________________
582 void AliPHOSEmcRecPoint::Print(Option_t * option)
584 // Print the list of digits belonging to the cluster
586 cout << "AliPHOSEmcRecPoint: " << endl ;
589 cout << " digits # = " ;
590 for(iDigit=0; iDigit<fMulDigit; iDigit++)
591 cout << fDigitsList[iDigit] << " " ;
594 cout << " Energies = " ;
595 for(iDigit=0; iDigit<fMulDigit; iDigit++)
596 cout << fEnergyList[iDigit] << " ";
599 cout << " Primaries " ;
600 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
601 cout << fTracksList[iDigit] << " " << endl ;
603 cout << " Multiplicity = " << fMulDigit << endl ;
604 cout << " Cluster Energy = " << fAmp << endl ;
605 cout << " Number of primaries " << fMulTrack << endl ;
606 cout << " Stored at position " << GetIndexInList() << endl ;