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) const
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 // Evaluates all shower parameters
423 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
424 EvalLocalPosition(logWeight, digits) ;
425 EvalElipsAxis(logWeight, digits) ;
426 EvalDispersion(logWeight, digits) ;
427 EvalCoreEnergy(digits);
429 //____________________________________________________________________________
430 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
432 // Calculates the center of gravity in the local PHOS-module coordinates
440 AliPHOSDigit * digit ;
442 AliPHOSGeometry * phosgeom = (AliPHOSGeometry *) fGeom ;
446 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
447 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
451 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
452 phosgeom->RelPosInModule(relid, xi, zi);
453 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
463 // Correction for the depth of the shower starting point (TDR p 127)
464 Float_t para = 0.925 ;
465 Float_t parb = 6.52 ;
467 Float_t xo,yo,zo ; //Coordinates of the origin
468 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
470 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
472 //Transform to the local ref.frame
474 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
475 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
477 Float_t radius = TMath::Sqrt((xoL-x)*(xoL-x)+
478 (phosgeom->GetIPtoCrystalSurface()-yoL)*(phosgeom->GetIPtoCrystalSurface()-yoL)+
481 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
482 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
484 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
485 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
488 fLocPos.SetX(x - depthx) ;
490 fLocPos.SetZ(z - depthz) ;
495 //____________________________________________________________________________
496 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
498 // Finds the maximum energy in the cluster
500 Float_t menergy = 0. ;
504 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
506 if(fEnergyList[iDigit] > menergy)
507 menergy = fEnergyList[iDigit] ;
512 //____________________________________________________________________________
513 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
515 // Calculates the multiplicity of digits with energy larger than H*energy
519 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
521 if(fEnergyList[iDigit] > H * fAmp)
527 //____________________________________________________________________________
528 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy,
529 Float_t locMaxCut,TClonesArray * digits) const
531 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
532 // energy difference between two local maxima
534 AliPHOSDigit * digit ;
535 AliPHOSDigit * digitN ;
541 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
542 maxAt[iDigit] = (Int_t) digits->At(fDigitsList[iDigit]) ;
545 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
546 if(maxAt[iDigit] != -1) {
547 digit = (AliPHOSDigit *) maxAt[iDigit] ;
549 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
550 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
552 if ( AreNeighbours(digit, digitN) ) {
553 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
554 maxAt[iDigitN] = -1 ;
555 // but may be digit too is not local max ?
556 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
561 // but may be digitN too is not local max ?
562 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
563 maxAt[iDigitN] = -1 ;
565 } // if Areneighbours
571 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
572 if(maxAt[iDigit] != -1){
573 maxAt[iDigitN] = maxAt[iDigit] ;
574 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
583 //____________________________________________________________________________
584 void AliPHOSEmcRecPoint::Print(Option_t * option)
586 // Print the list of digits belonging to the cluster
588 cout << "AliPHOSEmcRecPoint: " << endl ;
591 cout << " digits # = " ;
592 for(iDigit=0; iDigit<fMulDigit; iDigit++)
593 cout << fDigitsList[iDigit] << " " ;
596 cout << " Energies = " ;
597 for(iDigit=0; iDigit<fMulDigit; iDigit++)
598 cout << fEnergyList[iDigit] << " ";
601 cout << " Primaries " ;
602 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
603 cout << fTracksList[iDigit] << " " << endl ;
605 cout << " Multiplicity = " << fMulDigit << endl ;
606 cout << " Cluster Energy = " << fAmp << endl ;
607 cout << " Number of primaries " << fMulTrack << endl ;
608 cout << " Stored at position " << GetIndexInList() << endl ;