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"
41 #include "AliPHOSGetter.h"
43 ClassImp(AliPHOSEmcRecPoint)
45 //____________________________________________________________________________
46 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint() : AliPHOSRecPoint()
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 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
118 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
121 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
124 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
126 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
127 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
129 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
135 //____________________________________________________________________________
136 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
138 // Compares two RecPoints according to their position in the PHOS modules
140 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
141 //value (what is senseless) change as vell delta in
142 //AliPHOSTrackSegmentMakerv* and other RecPoints...
145 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
148 Int_t phosmod1 = GetPHOSMod() ;
149 Int_t phosmod2 = clu->GetPHOSMod() ;
152 GetLocalPosition(locpos1) ;
154 clu->GetLocalPosition(locpos2) ;
156 if(phosmod1 == phosmod2 ) {
157 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
162 else if(locpos1.Z()>locpos2.Z())
169 if(phosmod1 < phosmod2 )
178 //______________________________________________________________________________
179 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
181 // Commented by Dmitri Peressounko: there is no possibility to ensure,
182 // that AliPHOSGetter keeps the correct information.
184 // // Execute action corresponding to one event
185 // // This member function is called when a AliPHOSRecPoint is clicked with the locator
187 // // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
188 // // and switched off when the mouse button is released.
191 // // static Int_t pxold, pyold;
193 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
195 // static TGraph * digitgraph = 0 ;
197 // if (!gPad->IsEditable()) return;
199 // TH2F * histo = 0 ;
200 // TCanvas * histocanvas ;
204 // case kButton1Down: {
205 // AliPHOSDigit * digit ;
206 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
207 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
211 // const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
212 // Float_t * xi = new Float_t[kMulDigit] ;
213 // Float_t * zi = new Float_t[kMulDigit] ;
215 // // create the histogram for the single cluster
216 // // 1. gets histogram boundaries
217 // Float_t ximax = -999. ;
218 // Float_t zimax = -999. ;
219 // Float_t ximin = 999. ;
220 // Float_t zimin = 999. ;
222 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
223 // digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ;
224 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
225 // phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
226 // if ( xi[iDigit] > ximax )
227 // ximax = xi[iDigit] ;
228 // if ( xi[iDigit] < ximin )
229 // ximin = xi[iDigit] ;
230 // if ( zi[iDigit] > zimax )
231 // zimax = zi[iDigit] ;
232 // if ( zi[iDigit] < zimin )
233 // zimin = zi[iDigit] ;
235 // ximax += phosgeom->GetCrystalSize(0) / 2. ;
236 // zimax += phosgeom->GetCrystalSize(2) / 2. ;
237 // ximin -= phosgeom->GetCrystalSize(0) / 2. ;
238 // zimin -= phosgeom->GetCrystalSize(2) / 2. ;
239 // Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
240 // Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
242 // // 2. gets the histogram title
244 // Text_t title[100] ;
245 // sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
251 // histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
254 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
255 // digit = (AliPHOSDigit *) ( gime->Digit(fDigitsList[iDigit]) ) ;
256 // phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
257 // phosgeom->RelPosInModule(relid, x, z);
258 // histo->Fill(x, z, fEnergyList[iDigit] ) ;
261 // if (!digitgraph) {
262 // digitgraph = new TGraph(kMulDigit,xi,zi);
263 // digitgraph-> SetMarkerStyle(5) ;
264 // digitgraph-> SetMarkerSize(1.) ;
265 // digitgraph-> SetMarkerColor(1) ;
266 // digitgraph-> Paint("P") ;
270 // histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
271 // histocanvas->Draw() ;
272 // histo->Draw("lego1") ;
282 // delete digitgraph ;
290 //____________________________________________________________________________
291 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
293 // Calculates the dispersion of the shower at the origine of the RecPoint
301 AliPHOSDigit * digit ;
303 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
304 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
307 // Calculates the center of gravity in the local PHOS-module coordinates
311 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
312 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
316 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
317 phosgeom->RelPosInModule(relid, xi, zi);
318 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
327 // Calculates the dispersion in coordinates
329 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
330 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
334 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
335 phosgeom->RelPosInModule(relid, xi, zi);
336 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
338 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
345 fDispersion = TMath::Sqrt(d) ;
348 //______________________________________________________________________________
349 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
351 // This function calculates energy in the core,
352 // i.e. within a radius rad = 3cm around the center. Beyond this radius
353 // in accordance with shower profile the energy deposition
354 // should be less than 2%
356 Float_t coreRadius = 3 ;
361 AliPHOSDigit * digit ;
363 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
364 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
368 // Calculates the center of gravity in the local PHOS-module coordinates
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 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
386 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
387 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
391 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
392 phosgeom->RelPosInModule(relid, xi, zi);
393 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
394 if(distance < coreRadius)
395 fCoreEnergy += fEnergyList[iDigit] ;
400 //____________________________________________________________________________
401 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
403 // Calculates the axis of the shower ellipsoid
412 AliPHOSDigit * digit ;
414 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
415 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
420 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
421 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
425 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
426 phosgeom->RelPosInModule(relid, xi, zi);
427 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
444 // //Apply correction due to non-perpendicular incidence
447 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
448 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
449 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
451 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
452 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
454 // dxx = dxx/(CosX*CosX) ;
455 // dzz = dzz/(CosZ*CosZ) ;
456 // dxz = dxz/(CosX*CosZ) ;
459 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
461 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
463 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
464 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
465 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
470 //____________________________________________________________________________
471 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
473 // Evaluates all shower parameters
475 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
476 EvalLocalPosition(logWeight, digits) ;
477 EvalElipsAxis(logWeight, digits) ;
478 EvalDispersion(logWeight, digits) ;
479 EvalCoreEnergy(logWeight, digits);
481 //____________________________________________________________________________
482 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
484 // Calculates the center of gravity in the local PHOS-module coordinates
492 AliPHOSDigit * digit ;
494 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
495 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
499 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
500 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
504 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
505 phosgeom->RelPosInModule(relid, xi, zi);
506 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
516 // Correction for the depth of the shower starting point (TDR p 127)
517 Float_t para = 0.925 ;
518 Float_t parb = 6.52 ;
520 Float_t xo,yo,zo ; //Coordinates of the origin
521 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
523 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
525 //Transform to the local ref.frame
527 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
528 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
530 Float_t radius = TMath::Sqrt((xoL-x)*(xoL-x)+
531 (phosgeom->GetIPtoCrystalSurface()-yoL)*(phosgeom->GetIPtoCrystalSurface()-yoL)+
534 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
535 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
537 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
538 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
541 fLocPos.SetX(x - depthx) ;
543 fLocPos.SetZ(z - depthz) ;
548 //____________________________________________________________________________
549 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
551 // Finds the maximum energy in the cluster
553 Float_t menergy = 0. ;
557 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
559 if(fEnergyList[iDigit] > menergy)
560 menergy = fEnergyList[iDigit] ;
565 //____________________________________________________________________________
566 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
568 // Calculates the multiplicity of digits with energy larger than H*energy
572 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
574 if(fEnergyList[iDigit] > H * fAmp)
580 //____________________________________________________________________________
581 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax(Int_t * maxAt, Float_t * maxAtEnergy,
582 Float_t locMaxCut,TClonesArray * digits) const
584 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
585 // energy difference between two local maxima
587 AliPHOSDigit * digit ;
588 AliPHOSDigit * digitN ;
594 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
595 maxAt[iDigit] = (Int_t) digits->At(fDigitsList[iDigit]) ;
598 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
599 if(maxAt[iDigit] != -1) {
600 digit = (AliPHOSDigit *) maxAt[iDigit] ;
602 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
603 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
605 if ( AreNeighbours(digit, digitN) ) {
606 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
607 maxAt[iDigitN] = -1 ;
608 // but may be digit too is not local max ?
609 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
614 // but may be digitN too is not local max ?
615 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
616 maxAt[iDigitN] = -1 ;
618 } // if Areneighbours
624 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
625 if(maxAt[iDigit] != -1){
626 maxAt[iDigitN] = maxAt[iDigit] ;
627 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
636 //____________________________________________________________________________
637 void AliPHOSEmcRecPoint::Print(Option_t * option)
639 // Print the list of digits belonging to the cluster
641 cout << "AliPHOSEmcRecPoint: " << endl ;
644 cout << " digits # = " ;
645 for(iDigit=0; iDigit<fMulDigit; iDigit++)
646 cout << fDigitsList[iDigit] << " " ;
649 cout << " Energies = " ;
650 for(iDigit=0; iDigit<fMulDigit; iDigit++)
651 cout << fEnergyList[iDigit] << " ";
654 cout << " Primaries " ;
655 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
656 cout << fTracksList[iDigit] << " " << endl ;
658 cout << " Multiplicity = " << fMulDigit << endl ;
659 cout << " Cluster Energy = " << fAmp << endl ;
660 cout << " Number of primaries " << fMulTrack << endl ;
661 cout << " Stored at position " << GetIndexInList() << endl ;