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 EMCAL-EMC
20 // An TowerRecPoint is a cluster of digits
22 //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
25 // --- ROOT system ---
30 // --- Standard library ---
32 // --- AliRoot header files ---
34 #include "AliGenerator.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALTowerRecPoint.h"
38 #include "AliEMCALGetter.h"
40 ClassImp(AliEMCALTowerRecPoint)
42 //____________________________________________________________________________
43 AliEMCALTowerRecPoint::AliEMCALTowerRecPoint() : AliEMCALRecPoint()
52 fLocPos.SetX(0.) ; //Local position should be evaluated
55 //____________________________________________________________________________
56 AliEMCALTowerRecPoint::AliEMCALTowerRecPoint(const char * opt) : AliEMCALRecPoint(opt)
65 fLocPos.SetX(1000000.) ; //Local position should be evaluated
68 //____________________________________________________________________________
69 AliEMCALTowerRecPoint::~AliEMCALTowerRecPoint()
74 delete[] fEnergyList ;
77 //____________________________________________________________________________
78 void AliEMCALTowerRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy)
80 // Adds a digit to the RecPoint
81 // and accumulates the total amplitude and the multiplicity
84 fEnergyList = new Float_t[fMaxDigit];
86 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
88 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
89 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
92 for ( index = 0 ; index < fMulDigit ; index++ ){
93 tempo[index] = fDigitsList[index] ;
94 tempoE[index] = fEnergyList[index] ;
97 delete [] fDigitsList ;
98 fDigitsList = new ( Int_t[fMaxDigit] ) ;
100 delete [] fEnergyList ;
101 fEnergyList = new ( Float_t[fMaxDigit] ) ;
103 for ( index = 0 ; index < fMulDigit ; index++ ){
104 fDigitsList[index] = tempo[index] ;
105 fEnergyList[index] = tempoE[index] ;
112 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
113 fEnergyList[fMulDigit] = Energy ;
117 // EvalEMCALMod(&digit) ;
120 //____________________________________________________________________________
121 Bool_t AliEMCALTowerRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
123 // Tells if (true) or not (false) two digits are neighbors
125 Bool_t aren = kFALSE ;
127 AliEMCALGeometry * phosgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
130 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
133 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
135 Int_t rowdiff = TMath::Abs( relid1[2] - relid2[2] ) ;
136 Int_t coldiff = TMath::Abs( relid1[3] - relid2[3] ) ;
138 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
144 //____________________________________________________________________________
145 Int_t AliEMCALTowerRecPoint::Compare(const TObject * obj) const
147 // Compares two RecPoints according to their position in the EMCAL modules
149 Float_t delta = 1 ; //Width of "Sorting row". If you change this
150 //value (what is senseless) change as vell delta in
151 //AliEMCALTrackSegmentMakerv* and other RecPoints...
154 AliEMCALTowerRecPoint * clu = (AliEMCALTowerRecPoint *)obj ;
157 Int_t phosmod1 = GetEMCALArm() ;
158 Int_t phosmod2 = clu->GetEMCALArm() ;
161 GetLocalPosition(locpos1) ;
163 clu->GetLocalPosition(locpos2) ;
165 if(phosmod1 == phosmod2 ) {
166 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
171 else if(locpos1.Z()>locpos2.Z())
178 if(phosmod1 < phosmod2 )
186 //______________________________________________________________________________
187 void AliEMCALTowerRecPoint::ExecuteEvent(Int_t event, Int_t px, Int_t py) const
190 // Execute action corresponding to one event
191 // This member function is called when a AliEMCALRecPoint is clicked with the locator
193 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
194 // and switched off when the mouse button is released.
197 // AliEMCALGeometry * phosgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
199 // static TGraph * digitgraph = 0 ;
201 // if (!gPad->IsEditable()) return;
203 // TH2F * histo = 0 ;
204 // TCanvas * histocanvas ;
206 // const TClonesArray * digits = gime->Digits() ;
210 // case kButton1Down: {
211 // AliEMCALDigit * digit ;
215 // const Int_t kMulDigit = AliEMCALTowerRecPoint::GetDigitsMultiplicity() ;
216 // Float_t * xi = new Float_t[kMulDigit] ;
217 // Float_t * zi = new Float_t[kMulDigit] ;
219 // // create the histogram for the single cluster
220 // // 1. gets histogram boundaries
221 // Float_t ximax = -999. ;
222 // Float_t zimax = -999. ;
223 // Float_t ximin = 999. ;
224 // Float_t zimin = 999. ;
226 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
227 // digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
228 // emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
229 // emcalgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
230 // if ( xi[iDigit] > ximax )
231 // ximax = xi[iDigit] ;
232 // if ( xi[iDigit] < ximin )
233 // ximin = xi[iDigit] ;
234 // if ( zi[iDigit] > zimax )
235 // zimax = zi[iDigit] ;
236 // if ( zi[iDigit] < zimin )
237 // zimin = zi[iDigit] ;
239 // ximax += emcalgeom->GetCrystalSize(0) / 2. ;
240 // zimax += emcalgeom->GetCrystalSize(2) / 2. ;
241 // ximin -= emcalgeom->GetCrystalSize(0) / 2. ;
242 // zimin -= emcalgeom->GetCrystalSize(2) / 2. ;
243 // Int_t xdim = (int)( (ximax - ximin ) / emcalgeom->GetCrystalSize(0) + 0.5 ) ;
244 // Int_t zdim = (int)( (zimax - zimin ) / emcalgeom->GetCrystalSize(2) + 0.5 ) ;
246 // // 2. gets the histogram title
248 // Text_t title[100] ;
249 // sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
255 // histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
258 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
259 // digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
260 // emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
261 // emcalgeom->RelPosInModule(relid, x, z);
262 // histo->Fill(x, z, fEnergyList[iDigit] ) ;
265 // if (!digitgraph) {
266 // digitgraph = new TGraph(kMulDigit,xi,zi);
267 // digitgraph-> SetMarkerStyle(5) ;
268 // digitgraph-> SetMarkerSize(1.) ;
269 // digitgraph-> SetMarkerColor(1) ;
270 // digitgraph-> Paint("P") ;
274 // histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
275 // histocanvas->Draw() ;
276 // histo->Draw("lego1") ;
286 // delete digitgraph ;
294 //____________________________________________________________________________
295 void AliEMCALTowerRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
297 // Calculates the dispersion of the shower at the origine of the RecPoint
302 AliEMCALDigit * digit ;
304 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
307 // Calculates the center of gravity in the local EMCAL-module coordinates
311 if (!fTheta || !fPhi )
312 EvalGlobalPosition(logWeight, digits) ;
314 const Float_t kDeg2Rad = TMath::DegToRad() ;
316 Float_t cyl_radius = 0 ;
319 cyl_radius = emcalgeom->GetIP2PRESection() ;
321 cyl_radius = emcalgeom->GetIP2ECASection() ;
323 cyl_radius = emcalgeom->GetIP2HCASection() ;
325 Fatal("EvalDispersion", "Unexpected tower section!") ;
327 Float_t x = fLocPos.X() ;
328 Float_t y = fLocPos.Y() ;
329 Float_t z = fLocPos.Z() ;
332 Info("EvalDispersion", "x,y,z = %f,%f,%f", x, y, z) ;
334 // Calculates the dispersion in coordinates
336 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
337 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
338 Float_t thetai = 0. ;
340 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
341 Float_t xi = cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
342 Float_t yi = cyl_radius * TMath::Sin(phii * kDeg2Rad ) ;
343 Float_t zi = cyl_radius / TMath::Tan(thetai * kDeg2Rad ) ;
346 Info("EvalDispersion", "id = %d, xi,yi,zi = %f,%f,%f", digit->GetId(), xi, yi, 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 AliEMCALTowerRecPoint::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 = 10. ;
371 AliEMCALDigit * digit ;
374 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
377 if (!fTheta || !fPhi ) {
378 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
379 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
383 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
384 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
385 fTheta = fTheta + thetai * w ;
399 const Float_t kDeg2Rad = TMath::DegToRad() ;
401 Float_t cyl_radius = emcalgeom->GetIP2ECASection();
402 Float_t x = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
403 Float_t y = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
404 Float_t z = cyl_radius * TMath::Tan(fTheta * kDeg2Rad ) ;
406 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
407 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
408 Float_t thetai = 0. ;
410 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
412 Float_t xi = cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
413 Float_t yi = cyl_radius * TMath::Sin(phii * kDeg2Rad ) ;
414 Float_t zi = cyl_radius * TMath::Tan(thetai * kDeg2Rad ) ;
416 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(yi-y)*(yi-y)+(zi-z)*(zi-z)) ;
417 if(distance < coreRadius)
418 fCoreEnergy += fEnergyList[iDigit] ;
423 //____________________________________________________________________________
424 void AliEMCALTowerRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
426 // Calculates the axis of the shower ellipsoid
435 AliEMCALDigit * digit ;
437 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
440 const Float_t kDeg2Rad = TMath::DegToRad() ;
442 Float_t cyl_radius = 0 ;
445 cyl_radius = emcalgeom->GetIP2PRESection() ;
447 cyl_radius = emcalgeom->GetIP2ECASection() ;
449 cyl_radius = emcalgeom->GetIP2HCASection() ;
451 Fatal("EvalDispersion", "Unexpected tower section!") ;
453 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
454 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
455 Float_t thetai = 0. ;
457 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
458 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
459 Float_t xi = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
460 Float_t zi = cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ;
479 // //Apply correction due to non-perpendicular incidence
482 // AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
483 // Double_t DistanceToIP= (Double_t ) emcalgeom->GetIPDistance() ;
485 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
486 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
488 // dxx = dxx/(CosX*CosX) ;
489 // dzz = dzz/(CosZ*CosZ) ;
490 // dxz = dxz/(CosX*CosZ) ;
493 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
495 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
497 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
498 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
499 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
508 //____________________________________________________________________________
509 void AliEMCALTowerRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
511 // Evaluates all shower parameters
513 AliEMCALRecPoint::EvalAll(logWeight,digits) ;
514 EvalGlobalPosition(logWeight, digits) ;
515 EvalElipsAxis(logWeight, digits) ;
516 EvalDispersion(logWeight, digits) ;
517 EvalCoreEnergy(logWeight, digits);
521 //____________________________________________________________________________
522 void AliEMCALTowerRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits)
524 // Calculates the center of gravity in the local EMCAL-module coordinates
529 AliEMCALDigit * digit ;
530 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
533 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
534 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
538 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
539 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
540 fTheta = fTheta + thetai * w ;
554 const Float_t kDeg2Rad = TMath::DegToRad() ;
556 Float_t cyl_radius = 0 ;
559 cyl_radius = emcalgeom->GetIP2PRESection() ;
561 cyl_radius = emcalgeom->GetIP2ECASection() ;
563 cyl_radius = emcalgeom->GetIP2HCASection() ;
565 Fatal("EvalGlobalPosition", "Unexpected tower section!") ;
567 Float_t x = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
568 Float_t y = cyl_radius * TMath::Sin(fPhi * kDeg2Rad ) ;
569 Float_t z = cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ;
576 Info("EvalGlobalPosition", "x,y,z = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
582 //____________________________________________________________________________
583 Float_t AliEMCALTowerRecPoint::GetMaximalEnergy(void) const
585 // Finds the maximum energy in the cluster
587 Float_t menergy = 0. ;
591 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
593 if(fEnergyList[iDigit] > menergy)
594 menergy = fEnergyList[iDigit] ;
599 //____________________________________________________________________________
600 Int_t AliEMCALTowerRecPoint::GetMultiplicityAtLevel(const Float_t H) const
602 // Calculates the multiplicity of digits with energy larger than H*energy
606 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
608 if(fEnergyList[iDigit] > H * fAmp)
614 //____________________________________________________________________________
615 Int_t AliEMCALTowerRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
616 Float_t locMaxCut,TClonesArray * digits) const
618 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
619 // energy difference between two local maxima
621 AliEMCALDigit * digit ;
622 AliEMCALDigit * digitN ;
628 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
629 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
632 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
634 digit = maxAt[iDigit] ;
636 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
637 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
639 if ( AreNeighbours(digit, digitN) ) {
640 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
642 // but may be digit too is not local max ?
643 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
648 // but may be digitN too is not local max ?
649 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
652 } // if Areneighbours
658 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
660 maxAt[iDigitN] = maxAt[iDigit] ;
661 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
667 //____________________________________________________________________________
668 void AliEMCALTowerRecPoint::EvalTime(TClonesArray * digits){
672 for(Int_t idig=0; idig < fMulDigit; idig++){
673 if(fEnergyList[idig] > maxE){
674 maxE = fEnergyList[idig] ;
678 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
681 //____________________________________________________________________________
682 void AliEMCALTowerRecPoint::Print(Option_t * option)
684 // Print the list of digits belonging to the cluster
686 TString message("\n") ;
689 message += "digits # = " ;
690 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
691 message += fDigitsList[iDigit] ;
695 message += "\nEnergies = " ;
696 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
697 message += fEnergyList[iDigit] ;
701 message += "\nPrimaries " ;
702 for(iDigit = 0;iDigit < fMulTrack; iDigit++) {
703 message += fTracksList[iDigit] ;
706 message += "\n Multiplicity = " ;
707 message += fMulDigit ;
708 message += "\n Cluster Energy = " ;
710 message += "\n Number of primaries " ;
711 message += fMulTrack ;
712 message += "\n Stored at position " ;
713 message += GetIndexInList() ;
715 Info("Print", message.Data() ) ;
718 //____________________________________________________________________________
719 const TVector3 AliEMCALTowerRecPoint::XYZInAlice(Float_t r, Float_t theta, Float_t phi) const
721 // spherical coordinates of recpoint in Alice reference frame
724 Info("XYZInAlice", "this= %d , r = %f, theta = %f, phi = %f", this, r, theta, phi) ;
726 if (theta == 9999. || phi == 9999. || r == 9999.) {
728 GetGlobalPosition(globalpos);
729 phi = globalpos.X() * TMath::DegToRad() ;
731 theta = globalpos.Z() * TMath::DegToRad() ;
734 theta *= TMath::DegToRad() ;
735 phi *= TMath::DegToRad() ;
738 Float_t y = r * TMath::Cos(phi) ;
739 Float_t x = r * TMath::Sin(phi) * TMath::Sin(theta) ;
740 Float_t z = r * TMath::Sin(phi) * TMath::Cos(theta) ;
742 TVector3 vec(z, x, y) ;