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()
64 delete[] fEnergyList ;
67 //____________________________________________________________________________
68 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
70 // Adds a digit to the RecPoint
71 // and accumulates the total amplitude and the multiplicity
74 fEnergyList = new Float_t[fMaxDigit];
76 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
78 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
79 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
82 for ( index = 0 ; index < fMulDigit ; index++ ){
83 tempo[index] = fDigitsList[index] ;
84 tempoE[index] = fEnergyList[index] ;
87 delete [] fDigitsList ;
88 fDigitsList = new ( Int_t[fMaxDigit] ) ;
90 delete [] fEnergyList ;
91 fEnergyList = new ( Float_t[fMaxDigit] ) ;
93 for ( index = 0 ; index < fMulDigit ; index++ ){
94 fDigitsList[index] = tempo[index] ;
95 fEnergyList[index] = tempoE[index] ;
102 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
103 fEnergyList[fMulDigit] = Energy ;
107 EvalPHOSMod(&digit) ;
110 //____________________________________________________________________________
111 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
113 // Tells if (true) or not (false) two digits are neighbors
115 Bool_t aren = kFALSE ;
117 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
119 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
122 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
124 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
125 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
127 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
133 //____________________________________________________________________________
134 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
136 // Compares two RecPoints according to their position in the PHOS modules
138 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
139 //value (what is senseless) change as vell delta in
140 //AliPHOSTrackSegmentMakerv* and other RecPoints...
143 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
146 Int_t phosmod1 = GetPHOSMod() ;
147 Int_t phosmod2 = clu->GetPHOSMod() ;
150 GetLocalPosition(locpos1) ;
152 clu->GetLocalPosition(locpos2) ;
154 if(phosmod1 == phosmod2 ) {
155 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
160 else if(locpos1.Z()>locpos2.Z())
167 if(phosmod1 < phosmod2 )
176 //______________________________________________________________________________
177 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py)
179 // Commented by Dmitri Peressounko: there is no possibility to ensure,
180 // that AliPHOSIndexToObject keeps the correct information.
182 // // Execute action corresponding to one event
183 // // This member function is called when a AliPHOSRecPoint is clicked with the locator
185 // // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
186 // // and switched off when the mouse button is released.
189 // // static Int_t pxold, pyold;
191 // AliPHOSIndexToObject * please = AliPHOSIndexToObject::GetInstance() ;
193 // static TGraph * digitgraph = 0 ;
195 // if (!gPad->IsEditable()) return;
197 // TH2F * histo = 0 ;
198 // TCanvas * histocanvas ;
202 // case kButton1Down: {
203 // AliPHOSDigit * digit ;
204 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
208 // const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
209 // Float_t * xi = new Float_t[kMulDigit] ;
210 // Float_t * zi = new Float_t[kMulDigit] ;
212 // // create the histogram for the single cluster
213 // // 1. gets histogram boundaries
214 // Float_t ximax = -999. ;
215 // Float_t zimax = -999. ;
216 // Float_t ximin = 999. ;
217 // Float_t zimin = 999. ;
219 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
220 // digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
221 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
222 // phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
223 // if ( xi[iDigit] > ximax )
224 // ximax = xi[iDigit] ;
225 // if ( xi[iDigit] < ximin )
226 // ximin = xi[iDigit] ;
227 // if ( zi[iDigit] > zimax )
228 // zimax = zi[iDigit] ;
229 // if ( zi[iDigit] < zimin )
230 // zimin = zi[iDigit] ;
232 // ximax += phosgeom->GetCrystalSize(0) / 2. ;
233 // zimax += phosgeom->GetCrystalSize(2) / 2. ;
234 // ximin -= phosgeom->GetCrystalSize(0) / 2. ;
235 // zimin -= phosgeom->GetCrystalSize(2) / 2. ;
236 // Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
237 // Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
239 // // 2. gets the histogram title
241 // Text_t title[100] ;
242 // sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
248 // histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
251 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
252 // digit = (AliPHOSDigit *) ( please->GimeDigit(fDigitsList[iDigit]) ) ;
253 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
254 // phosgeom->RelPosInModule(relid, x, z);
255 // histo->Fill(x, z, fEnergyList[iDigit] ) ;
258 // if (!digitgraph) {
259 // digitgraph = new TGraph(kMulDigit,xi,zi);
260 // digitgraph-> SetMarkerStyle(5) ;
261 // digitgraph-> SetMarkerSize(1.) ;
262 // digitgraph-> SetMarkerColor(1) ;
263 // digitgraph-> Paint("P") ;
267 // histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
268 // histocanvas->Draw() ;
269 // histo->Draw("lego1") ;
279 // delete digitgraph ;
287 //____________________________________________________________________________
288 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
290 // Calculates the dispersion of the shower at the origine of the RecPoint
296 GetLocalPosition(locpos);
297 Float_t x = locpos.X() ;
298 Float_t z = locpos.Z() ;
300 AliPHOSDigit * digit ;
301 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
304 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
305 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
309 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
310 phosgeom->RelPosInModule(relid, xi, zi);
311 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
312 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
319 fDispersion = TMath::Sqrt(d) ;
321 //______________________________________________________________________________
322 void AliPHOSEmcRecPoint::EvalCoreEnergy(TClonesArray * digits)
324 // This function calculates energy in the core,
325 // i.e. within a radius rad = 3cm around the center. Beyond this radius
326 // in accordance with shower profile the energy deposition
327 // should be less than 2%
329 Float_t coreRadius = 3 ;
332 GetLocalPosition(locpos);
333 Float_t x = locpos.X() ;
334 Float_t z = locpos.Z() ;
336 AliPHOSDigit * digit ;
337 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
340 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
341 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
345 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
346 phosgeom->RelPosInModule(relid, xi, zi);
347 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
348 if(distance < coreRadius)
349 fCoreEnergy += fEnergyList[iDigit] ;
354 //____________________________________________________________________________
355 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
357 // Calculates the axis of the shower ellipsoid
366 AliPHOSDigit * digit ;
367 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
370 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
371 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
375 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
376 phosgeom->RelPosInModule(relid, xi, zi);
377 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
394 // //Apply correction due to non-perpendicular incidence
397 // Double_t DistanceToIP= (Double_t ) ((AliPHOSGeometry *) fGeom)->GetIPtoCrystalSurface() ;
399 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
400 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
402 // dxx = dxx/(CosX*CosX) ;
403 // dzz = dzz/(CosZ*CosZ) ;
404 // dxz = dxz/(CosX*CosZ) ;
407 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
409 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
411 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
412 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
413 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
418 //____________________________________________________________________________
419 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
421 // calculates the various parameters characterizing the RecPoint
422 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
423 EvalLocalPosition(logWeight, digits) ;
424 EvalElipsAxis(logWeight, digits) ;
425 EvalDispersion(logWeight, digits) ;
426 EvalCoreEnergy(digits);
428 //____________________________________________________________________________
429 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
431 // Calculates the center of gravity in the local PHOS-module coordinates
439 AliPHOSDigit * digit ;
441 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
445 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
446 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
450 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
451 phosgeom->RelPosInModule(relid, xi, zi);
452 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
462 // Correction for the depth of the shower starting point (TDR p 127)
463 Float_t para = 0.925 ;
464 Float_t parb = 6.52 ;
466 Float_t xo,yo,zo ; //Coordinates of the origin
467 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
469 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
471 //Transform to the local ref.frame
473 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
474 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
476 Float_t radius = TMath::Sqrt((xoL-x)*(xoL-x)+
477 (phosgeom->GetIPtoCrystalSurface()-yoL)*(phosgeom->GetIPtoCrystalSurface()-yoL)+
480 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
481 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
483 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
484 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
487 fLocPos.SetX(x - depthx) ;
489 fLocPos.SetZ(z - depthz) ;
494 //____________________________________________________________________________
495 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
497 // Finds the maximum energy in the cluster
499 Float_t menergy = 0. ;
503 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
505 if(fEnergyList[iDigit] > menergy)
506 menergy = fEnergyList[iDigit] ;
511 //____________________________________________________________________________
512 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
514 // Calculates the multiplicity of digits with energy larger than H*energy
518 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
520 if(fEnergyList[iDigit] > H * fAmp)
526 //____________________________________________________________________________
527 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy,
528 Float_t locMaxCut,TClonesArray * digits) const
530 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
531 // energy difference between two local maxima
533 AliPHOSDigit * digit ;
534 AliPHOSDigit * digitN ;
540 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
541 maxAt[iDigit] = (Int_t) digits->At(fDigitsList[iDigit]) ;
544 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
545 if(maxAt[iDigit] != -1) {
546 digit = (AliPHOSDigit *) maxAt[iDigit] ;
548 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
549 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
551 if ( AreNeighbours(digit, digitN) ) {
552 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
553 maxAt[iDigitN] = -1 ;
554 // but may be digit too is not local max ?
555 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
560 // but may be digitN too is not local max ?
561 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
562 maxAt[iDigitN] = -1 ;
564 } // if Areneighbours
570 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
571 if(maxAt[iDigit] != -1){
572 maxAt[iDigitN] = maxAt[iDigit] ;
573 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
582 //____________________________________________________________________________
583 void AliPHOSEmcRecPoint::Print(Option_t * option)
585 // Print the list of digits belonging to the cluster
587 cout << "AliPHOSEmcRecPoint: " << endl ;
590 cout << " digits # = " ;
591 for(iDigit=0; iDigit<fMulDigit; iDigit++)
592 cout << fDigitsList[iDigit] << " " ;
595 cout << " Energies = " ;
596 for(iDigit=0; iDigit<fMulDigit; iDigit++)
597 cout << fEnergyList[iDigit] << " ";
600 cout << " Primaries " ;
601 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
602 cout << fTracksList[iDigit] << " " << endl ;
604 cout << " Multiplicity = " << fMulDigit << endl ;
605 cout << " Cluster Energy = " << fAmp << endl ;
606 cout << " Number of primaries " << fMulTrack << endl ;
607 cout << " Stored at position " << GetIndexInList() << endl ;