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()
55 fLocPos.SetX(1000000.) ; //Local position should be evaluated
59 //____________________________________________________________________________
60 AliPHOSEmcRecPoint::AliPHOSEmcRecPoint(const char * opt) : AliPHOSRecPoint(opt)
69 fLocPos.SetX(1000000.) ; //Local position should be evaluated
73 //____________________________________________________________________________
74 AliPHOSEmcRecPoint::~AliPHOSEmcRecPoint()
79 delete[] fEnergyList ;
82 //____________________________________________________________________________
83 void AliPHOSEmcRecPoint::AddDigit(AliPHOSDigit & digit, Float_t Energy)
85 // Adds a digit to the RecPoint
86 // and accumulates the total amplitude and the multiplicity
89 fEnergyList = new Float_t[fMaxDigit];
91 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
93 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
94 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
97 for ( index = 0 ; index < fMulDigit ; index++ ){
98 tempo[index] = fDigitsList[index] ;
99 tempoE[index] = fEnergyList[index] ;
102 delete [] fDigitsList ;
103 fDigitsList = new ( Int_t[fMaxDigit] ) ;
105 delete [] fEnergyList ;
106 fEnergyList = new ( Float_t[fMaxDigit] ) ;
108 for ( index = 0 ; index < fMulDigit ; index++ ){
109 fDigitsList[index] = tempo[index] ;
110 fEnergyList[index] = tempoE[index] ;
117 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
118 fEnergyList[fMulDigit] = Energy ;
122 EvalPHOSMod(&digit) ;
125 //____________________________________________________________________________
126 Bool_t AliPHOSEmcRecPoint::AreNeighbours(AliPHOSDigit * digit1, AliPHOSDigit * digit2 ) const
128 // Tells if (true) or not (false) two digits are neighbors
130 Bool_t aren = kFALSE ;
132 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
133 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
136 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
139 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
141 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
142 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
144 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
150 //____________________________________________________________________________
151 Int_t AliPHOSEmcRecPoint::Compare(const TObject * obj) const
153 // Compares two RecPoints according to their position in the PHOS modules
155 Float_t delta = 1 ; //Width of "Sorting row". If you changibg this
156 //value (what is senseless) change as vell delta in
157 //AliPHOSTrackSegmentMakerv* and other RecPoints...
160 AliPHOSEmcRecPoint * clu = (AliPHOSEmcRecPoint *)obj ;
163 Int_t phosmod1 = GetPHOSMod() ;
164 Int_t phosmod2 = clu->GetPHOSMod() ;
167 GetLocalPosition(locpos1) ;
169 clu->GetLocalPosition(locpos2) ;
171 if(phosmod1 == phosmod2 ) {
172 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
177 else if(locpos1.Z()>locpos2.Z())
184 if(phosmod1 < phosmod2 )
192 //______________________________________________________________________________
193 void AliPHOSEmcRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
196 // Execute action corresponding to one event
197 // This member function is called when a AliPHOSRecPoint is clicked with the locator
199 // If Left button is clicked on AliPHOSRecPoint, the digits are switched on
200 // and switched off when the mouse button is released.
203 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
205 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
207 static TGraph * digitgraph = 0 ;
209 if (!gPad->IsEditable()) return;
212 TCanvas * histocanvas ;
214 const TClonesArray * digits = gime->Digits() ;
219 AliPHOSDigit * digit ;
223 const Int_t kMulDigit = AliPHOSEmcRecPoint::GetDigitsMultiplicity() ;
224 Float_t * xi = new Float_t[kMulDigit] ;
225 Float_t * zi = new Float_t[kMulDigit] ;
227 // create the histogram for the single cluster
228 // 1. gets histogram boundaries
229 Float_t ximax = -999. ;
230 Float_t zimax = -999. ;
231 Float_t ximin = 999. ;
232 Float_t zimin = 999. ;
234 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
235 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
236 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
237 phosgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
238 if ( xi[iDigit] > ximax )
240 if ( xi[iDigit] < ximin )
242 if ( zi[iDigit] > zimax )
244 if ( zi[iDigit] < zimin )
247 ximax += phosgeom->GetCrystalSize(0) / 2. ;
248 zimax += phosgeom->GetCrystalSize(2) / 2. ;
249 ximin -= phosgeom->GetCrystalSize(0) / 2. ;
250 zimin -= phosgeom->GetCrystalSize(2) / 2. ;
251 Int_t xdim = (int)( (ximax - ximin ) / phosgeom->GetCrystalSize(0) + 0.5 ) ;
252 Int_t zdim = (int)( (zimax - zimin ) / phosgeom->GetCrystalSize(2) + 0.5 ) ;
254 // 2. gets the histogram title
257 sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
263 histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
266 for(iDigit=0; iDigit<kMulDigit; iDigit++) {
267 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
268 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
269 phosgeom->RelPosInModule(relid, x, z);
270 histo->Fill(x, z, fEnergyList[iDigit] ) ;
274 digitgraph = new TGraph(kMulDigit,xi,zi);
275 digitgraph-> SetMarkerStyle(5) ;
276 digitgraph-> SetMarkerSize(1.) ;
277 digitgraph-> SetMarkerColor(1) ;
278 digitgraph-> Paint("P") ;
282 histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
283 histocanvas->Draw() ;
284 histo->Draw("lego1") ;
302 //____________________________________________________________________________
303 void AliPHOSEmcRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
305 // Calculates the dispersion of the shower at the origine of the RecPoint
313 AliPHOSDigit * digit ;
315 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
316 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
319 // Calculates the center of gravity in the local PHOS-module coordinates
323 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
324 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
328 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
329 phosgeom->RelPosInModule(relid, xi, zi);
330 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
339 // Calculates the dispersion in coordinates
341 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
342 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
346 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
347 phosgeom->RelPosInModule(relid, xi, zi);
348 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
349 d += w*((xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
358 fDispersion = TMath::Sqrt(d) ;
361 //______________________________________________________________________________
362 void AliPHOSEmcRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
364 // This function calculates energy in the core,
365 // i.e. within a radius rad = 3cm around the center. Beyond this radius
366 // in accordance with shower profile the energy deposition
367 // should be less than 2%
369 Float_t coreRadius = 3 ;
374 AliPHOSDigit * digit ;
376 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
377 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
381 // Calculates the center of gravity in the local PHOS-module coordinates
383 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
384 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
388 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
389 phosgeom->RelPosInModule(relid, xi, zi);
390 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
399 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
400 digit = (AliPHOSDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
404 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
405 phosgeom->RelPosInModule(relid, xi, zi);
406 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(zi-z)*(zi-z)) ;
407 if(distance < coreRadius)
408 fCoreEnergy += fEnergyList[iDigit] ;
413 //____________________________________________________________________________
414 void AliPHOSEmcRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
416 // Calculates the axis of the shower ellipsoid
425 AliPHOSDigit * digit ;
427 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
428 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
433 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
434 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
438 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
439 phosgeom->RelPosInModule(relid, xi, zi);
440 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
457 // //Apply correction due to non-perpendicular incidence
460 // AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
461 // AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
462 // Double_t DistanceToIP= (Double_t ) phosgeom->GetIPtoCrystalSurface() ;
464 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
465 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
467 // dxx = dxx/(CosX*CosX) ;
468 // dzz = dzz/(CosZ*CosZ) ;
469 // dxz = dxz/(CosX*CosZ) ;
472 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
474 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
476 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
477 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
478 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
483 //____________________________________________________________________________
484 void AliPHOSEmcRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
486 // Evaluates all shower parameters
488 AliPHOSRecPoint::EvalAll(logWeight,digits) ;
489 EvalLocalPosition(logWeight, digits) ;
490 EvalElipsAxis(logWeight, digits) ;
491 EvalDispersion(logWeight, digits) ;
492 EvalCoreEnergy(logWeight, digits);
495 //____________________________________________________________________________
496 void AliPHOSEmcRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
498 // Calculates the center of gravity in the local PHOS-module coordinates
506 AliPHOSDigit * digit ;
508 AliPHOSGetter * gime = AliPHOSGetter::GetInstance() ;
509 AliPHOSGeometry * phosgeom = (AliPHOSGeometry*)gime->PHOSGeometry();
513 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
514 digit = (AliPHOSDigit *) digits->At(fDigitsList[iDigit]) ;
518 phosgeom->AbsToRelNumbering(digit->GetId(), relid) ;
519 phosgeom->RelPosInModule(relid, xi, zi);
520 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
530 // Correction for the depth of the shower starting point (TDR p 127)
531 Float_t para = 0.925 ;
532 Float_t parb = 6.52 ;
534 Float_t xo,yo,zo ; //Coordinates of the origin
535 gAlice->Generator()->GetOrigin(xo,yo,zo) ;
537 Float_t phi = phosgeom->GetPHOSAngle(relid[0]) ;
539 //Transform to the local ref.frame
541 xoL = xo*TMath::Cos(phi)-yo*TMath::Sin(phi) ;
542 yoL = xo*TMath::Sin(phi)+yo*TMath::Cos(phi) ;
544 Float_t radius = TMath::Sqrt((xoL-x)*(xoL-x)+
545 (phosgeom->GetIPtoCrystalSurface()-yoL)*(phosgeom->GetIPtoCrystalSurface()-yoL)+
548 Float_t incidencephi = TMath::ATan((x-xoL ) / radius) ;
549 Float_t incidencetheta = TMath::ATan((z-zo) / radius) ;
551 Float_t depthx = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencephi) ;
552 Float_t depthz = ( para * TMath::Log(fAmp) + parb ) * TMath::Sin(incidencetheta) ;
555 fLocPos.SetX(x - depthx) ;
557 fLocPos.SetZ(z - depthz) ;
562 //____________________________________________________________________________
563 Float_t AliPHOSEmcRecPoint::GetMaximalEnergy(void) const
565 // Finds the maximum energy in the cluster
567 Float_t menergy = 0. ;
571 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
573 if(fEnergyList[iDigit] > menergy)
574 menergy = fEnergyList[iDigit] ;
579 //____________________________________________________________________________
580 Int_t AliPHOSEmcRecPoint::GetMultiplicityAtLevel(const Float_t H) const
582 // Calculates the multiplicity of digits with energy larger than H*energy
586 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
588 if(fEnergyList[iDigit] > H * fAmp)
594 //____________________________________________________________________________
595 Int_t AliPHOSEmcRecPoint::GetNumberOfLocalMax( AliPHOSDigit ** maxAt, Float_t * maxAtEnergy,
596 Float_t locMaxCut,TClonesArray * digits) const
598 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
599 // energy difference between two local maxima
601 AliPHOSDigit * digit ;
602 AliPHOSDigit * digitN ;
608 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
609 maxAt[iDigit] = (AliPHOSDigit*) digits->At(fDigitsList[iDigit]) ;
612 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
614 digit = maxAt[iDigit] ;
616 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
617 digitN = (AliPHOSDigit *) digits->At(fDigitsList[iDigitN]) ;
619 if ( AreNeighbours(digit, digitN) ) {
620 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
622 // but may be digit too is not local max ?
623 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
628 // but may be digitN too is not local max ?
629 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
632 } // if Areneighbours
638 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
640 maxAt[iDigitN] = maxAt[iDigit] ;
641 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
647 //____________________________________________________________________________
648 void AliPHOSEmcRecPoint::EvalTime(TClonesArray * digits){
652 for(Int_t idig=0; idig < fMulDigit; idig++){
653 if(fEnergyList[idig] > maxE){
654 maxE = fEnergyList[idig] ;
658 fTime = ((AliPHOSDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
661 //____________________________________________________________________________
662 void AliPHOSEmcRecPoint::Print(Option_t * option)
664 // Print the list of digits belonging to the cluster
666 cout << "AliPHOSEmcRecPoint: " << endl ;
669 cout << " digits # = " ;
670 for(iDigit=0; iDigit<fMulDigit; iDigit++)
671 cout << fDigitsList[iDigit] << " " ;
674 cout << " Energies = " ;
675 for(iDigit=0; iDigit<fMulDigit; iDigit++)
676 cout << fEnergyList[iDigit] << " ";
679 cout << " Primaries " ;
680 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
681 cout << fTracksList[iDigit] << " " << endl ;
683 cout << " Multiplicity = " << fMulDigit << endl ;
684 cout << " Cluster Energy = " << fAmp << endl ;
685 cout << " Number of primaries " << fMulTrack << endl ;
686 cout << " Stored at position " << GetIndexInList() << endl ;