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 ---
28 // --- Standard library ---
30 // --- AliRoot header files ---
32 #include "AliGenerator.h"
33 #include "AliEMCALGeometry.h"
34 #include "AliEMCALTowerRecPoint.h"
35 #include "AliEMCALGetter.h"
37 ClassImp(AliEMCALTowerRecPoint)
39 //____________________________________________________________________________
40 AliEMCALTowerRecPoint::AliEMCALTowerRecPoint() : AliEMCALRecPoint()
49 fLocPos.SetX(0.) ; //Local position should be evaluated
52 //____________________________________________________________________________
53 AliEMCALTowerRecPoint::AliEMCALTowerRecPoint(const char * opt) : AliEMCALRecPoint(opt)
62 fLocPos.SetX(1000000.) ; //Local position should be evaluated
65 //____________________________________________________________________________
66 AliEMCALTowerRecPoint::~AliEMCALTowerRecPoint()
71 delete[] fEnergyList ;
74 //____________________________________________________________________________
75 void AliEMCALTowerRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy)
77 // Adds a digit to the RecPoint
78 // and accumulates the total amplitude and the multiplicity
81 fEnergyList = new Float_t[fMaxDigit];
83 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
85 Int_t * tempo = new ( Int_t[fMaxDigit] ) ;
86 Float_t * tempoE = new ( Float_t[fMaxDigit] ) ;
89 for ( index = 0 ; index < fMulDigit ; index++ ){
90 tempo[index] = fDigitsList[index] ;
91 tempoE[index] = fEnergyList[index] ;
94 delete [] fDigitsList ;
95 fDigitsList = new ( Int_t[fMaxDigit] ) ;
97 delete [] fEnergyList ;
98 fEnergyList = new ( Float_t[fMaxDigit] ) ;
100 for ( index = 0 ; index < fMulDigit ; index++ ){
101 fDigitsList[index] = tempo[index] ;
102 fEnergyList[index] = tempoE[index] ;
109 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
110 fEnergyList[fMulDigit] = Energy ;
114 // EvalEMCALMod(&digit) ;
117 //____________________________________________________________________________
118 Bool_t AliEMCALTowerRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
120 // Tells if (true) or not (false) two digits are neighbors
122 Bool_t aren = kFALSE ;
124 AliEMCALGeometry * phosgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
127 phosgeom->AbsToRelNumbering(digit1->GetId(), relid1) ;
130 phosgeom->AbsToRelNumbering(digit2->GetId(), relid2) ;
132 Int_t rowdiff = TMath::Abs( relid1[1] - relid2[1] ) ;
133 Int_t coldiff = TMath::Abs( relid1[2] - relid2[2] ) ;
135 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
141 //____________________________________________________________________________
142 Int_t AliEMCALTowerRecPoint::Compare(const TObject * obj) const
144 // Compares two RecPoints according to their position in the EMCAL modules
146 Float_t delta = 1 ; //Width of "Sorting row". If you change this
147 //value (what is senseless) change as vell delta in
148 //AliEMCALTrackSegmentMakerv* and other RecPoints...
151 AliEMCALTowerRecPoint * clu = (AliEMCALTowerRecPoint *)obj ;
154 Int_t phosmod1 = GetEMCALArm() ;
155 Int_t phosmod2 = clu->GetEMCALArm() ;
158 GetLocalPosition(locpos1) ;
160 clu->GetLocalPosition(locpos2) ;
162 if(phosmod1 == phosmod2 ) {
163 Int_t rowdif = (Int_t)TMath::Ceil(locpos1.X()/delta)-(Int_t)TMath::Ceil(locpos2.X()/delta) ;
168 else if(locpos1.Z()>locpos2.Z())
175 if(phosmod1 < phosmod2 )
183 //______________________________________________________________________________
184 void AliEMCALTowerRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t) const
187 // Execute action corresponding to one event
188 // This member function is called when a AliEMCALRecPoint is clicked with the locator
190 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
191 // and switched off when the mouse button is released.
194 // AliEMCALGeometry * phosgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
196 // static TGraph * digitgraph = 0 ;
198 // if (!gPad->IsEditable()) return;
200 // TH2F * histo = 0 ;
201 // TCanvas * histocanvas ;
203 // const TClonesArray * digits = gime->Digits() ;
207 // case kButton1Down: {
208 // AliEMCALDigit * digit ;
212 // const Int_t kMulDigit = AliEMCALTowerRecPoint::GetDigitsMultiplicity() ;
213 // Float_t * xi = new Float_t[kMulDigit] ;
214 // Float_t * zi = new Float_t[kMulDigit] ;
216 // // create the histogram for the single cluster
217 // // 1. gets histogram boundaries
218 // Float_t ximax = -999. ;
219 // Float_t zimax = -999. ;
220 // Float_t ximin = 999. ;
221 // Float_t zimin = 999. ;
223 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
224 // digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
225 // emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
226 // emcalgeom->RelPosInModule(relid, xi[iDigit], zi[iDigit]);
227 // if ( xi[iDigit] > ximax )
228 // ximax = xi[iDigit] ;
229 // if ( xi[iDigit] < ximin )
230 // ximin = xi[iDigit] ;
231 // if ( zi[iDigit] > zimax )
232 // zimax = zi[iDigit] ;
233 // if ( zi[iDigit] < zimin )
234 // zimin = zi[iDigit] ;
236 // ximax += emcalgeom->GetCrystalSize(0) / 2. ;
237 // zimax += emcalgeom->GetCrystalSize(2) / 2. ;
238 // ximin -= emcalgeom->GetCrystalSize(0) / 2. ;
239 // zimin -= emcalgeom->GetCrystalSize(2) / 2. ;
240 // Int_t xdim = (int)( (ximax - ximin ) / emcalgeom->GetCrystalSize(0) + 0.5 ) ;
241 // Int_t zdim = (int)( (zimax - zimin ) / emcalgeom->GetCrystalSize(2) + 0.5 ) ;
243 // // 2. gets the histogram title
245 // Text_t title[100] ;
246 // sprintf(title,"Energy=%1.2f GeV ; Digits ; %d ", GetEnergy(), GetDigitsMultiplicity()) ;
252 // histo = new TH2F("cluster3D", title, xdim, ximin, ximax, zdim, zimin, zimax) ;
255 // for(iDigit=0; iDigit<kMulDigit; iDigit++) {
256 // digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
257 // emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
258 // emcalgeom->RelPosInModule(relid, x, z);
259 // histo->Fill(x, z, fEnergyList[iDigit] ) ;
262 // if (!digitgraph) {
263 // digitgraph = new TGraph(kMulDigit,xi,zi);
264 // digitgraph-> SetMarkerStyle(5) ;
265 // digitgraph-> SetMarkerSize(1.) ;
266 // digitgraph-> SetMarkerColor(1) ;
267 // digitgraph-> Paint("P") ;
271 // histocanvas = new TCanvas("cluster", "a single cluster", 600, 500) ;
272 // histocanvas->Draw() ;
273 // histo->Draw("lego1") ;
283 // delete digitgraph ;
291 //____________________________________________________________________________
292 void AliEMCALTowerRecPoint::EvalDispersion(Float_t logWeight,TClonesArray * digits)
294 // Calculates the dispersion of the shower at the origine of the RecPoint
299 AliEMCALDigit * digit ;
301 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
304 // Calculates the center of gravity in the local EMCAL-module coordinates
308 if (!fTheta || !fPhi )
309 EvalGlobalPosition(logWeight, digits) ;
311 const Float_t kDeg2Rad = TMath::DegToRad() ;
313 Float_t cyl_radius = 0 ;
316 cyl_radius = emcalgeom->GetIP2ECASection() ;
318 Fatal("EvalDispersion", "Unexpected tower section!") ;
320 Float_t x = fLocPos.X() ;
321 Float_t y = fLocPos.Y() ;
322 Float_t z = fLocPos.Z() ;
325 printf("EvalDispersion: x,y,z = %f,%f,%f", x, y, z) ;
327 // Calculates the dispersion in coordinates
329 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
330 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
331 Float_t thetai = 0. ;
333 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
334 Float_t xi = cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
335 Float_t yi = cyl_radius * TMath::Sin(phii * kDeg2Rad ) ;
336 Float_t zi = cyl_radius / TMath::Tan(thetai * kDeg2Rad ) ;
339 printf("EvalDispersion: id = %d, xi,yi,zi = %f,%f,%f", digit->GetId(), xi, yi, zi) ;
341 Float_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
342 d += w * ( (xi-x)*(xi-x) + (zi-z)*(zi-z) ) ;
351 fDispersion = TMath::Sqrt(d) ;
354 //______________________________________________________________________________
355 void AliEMCALTowerRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
357 // This function calculates energy in the core,
358 // i.e. within a radius rad = 3cm around the center. Beyond this radius
359 // in accordance with shower profile the energy deposition
360 // should be less than 2%
362 Float_t coreRadius = 10. ;
364 AliEMCALDigit * digit ;
367 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
370 if (!fTheta || !fPhi ) {
371 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
372 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
376 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
377 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
378 fTheta = fTheta + thetai * w ;
392 const Float_t kDeg2Rad = TMath::DegToRad() ;
394 Float_t cyl_radius = emcalgeom->GetIP2ECASection();
395 Float_t x = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
396 Float_t y = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
397 Float_t z = cyl_radius * TMath::Tan(fTheta * kDeg2Rad ) ;
399 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
400 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
401 Float_t thetai = 0. ;
403 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
405 Float_t xi = cyl_radius * TMath::Cos(phii * kDeg2Rad ) ;
406 Float_t yi = cyl_radius * TMath::Sin(phii * kDeg2Rad ) ;
407 Float_t zi = cyl_radius * TMath::Tan(thetai * kDeg2Rad ) ;
409 Float_t distance = TMath::Sqrt((xi-x)*(xi-x)+(yi-y)*(yi-y)+(zi-z)*(zi-z)) ;
410 if(distance < coreRadius)
411 fCoreEnergy += fEnergyList[iDigit] ;
416 //____________________________________________________________________________
417 void AliEMCALTowerRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
419 // Calculates the axis of the shower ellipsoid
428 AliEMCALDigit * digit ;
430 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
433 const Float_t kDeg2Rad = TMath::DegToRad() ;
435 Float_t cyl_radius = 0 ;
438 cyl_radius = emcalgeom->GetIP2ECASection() ;
440 Fatal("EvalDispersion", "Unexpected tower section!") ;
442 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
443 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
444 Float_t thetai = 0. ;
446 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
447 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
448 Float_t xi = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
449 Float_t zi = cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ;
468 // //Apply correction due to non-perpendicular incidence
471 // AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
472 // Double_t DistanceToIP= (Double_t ) emcalgeom->GetIPDistance() ;
474 // CosX = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+x*x) ;
475 // CosZ = DistanceToIP/TMath::Sqrt(DistanceToIP*DistanceToIP+z*z) ;
477 // dxx = dxx/(CosX*CosX) ;
478 // dzz = dzz/(CosZ*CosZ) ;
479 // dxz = dxz/(CosX*CosZ) ;
482 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
484 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
486 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
487 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
488 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
497 //____________________________________________________________________________
498 void AliEMCALTowerRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits )
500 // Evaluates all shower parameters
502 AliEMCALRecPoint::EvalAll(logWeight,digits) ;
503 EvalGlobalPosition(logWeight, digits) ;
504 EvalElipsAxis(logWeight, digits) ;
505 EvalDispersion(logWeight, digits) ;
506 EvalCoreEnergy(logWeight, digits);
510 //____________________________________________________________________________
511 void AliEMCALTowerRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits)
513 // Calculates the center of gravity in the local EMCAL-module coordinates
518 AliEMCALDigit * digit ;
519 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry();
522 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
523 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
527 emcalgeom->PosInAlice(digit->GetId(), thetai, phii);
528 Float_t w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ) ) ;
529 fTheta = fTheta + thetai * w ;
543 const Float_t kDeg2Rad = TMath::DegToRad() ;
545 Float_t cyl_radius = 0 ;
548 cyl_radius = emcalgeom->GetIP2ECASection() ;
550 Fatal("EvalGlobalPosition", "Unexpected tower section!") ;
552 Float_t x = cyl_radius * TMath::Cos(fPhi * kDeg2Rad ) ;
553 Float_t y = cyl_radius * TMath::Sin(fPhi * kDeg2Rad ) ;
554 Float_t z = cyl_radius / TMath::Tan(fTheta * kDeg2Rad ) ;
561 printf("EvalGlobalPosition: x,y,z = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
565 //____________________________________________________________________________
566 Float_t AliEMCALTowerRecPoint::GetMaximalEnergy(void) const
568 // Finds the maximum energy in the cluster
570 Float_t menergy = 0. ;
574 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
576 if(fEnergyList[iDigit] > menergy)
577 menergy = fEnergyList[iDigit] ;
582 //____________________________________________________________________________
583 Int_t AliEMCALTowerRecPoint::GetMultiplicityAtLevel(Float_t H) const
585 // Calculates the multiplicity of digits with energy larger than H*energy
589 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
591 if(fEnergyList[iDigit] > H * fAmp)
597 //____________________________________________________________________________
598 Int_t AliEMCALTowerRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
599 Float_t locMaxCut,TClonesArray * digits) const
601 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
602 // energy difference between two local maxima
604 AliEMCALDigit * digit ;
605 AliEMCALDigit * digitN ;
610 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
611 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
613 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
615 digit = maxAt[iDigit] ;
617 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
618 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
620 if ( AreNeighbours(digit, digitN) ) {
621 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
623 // but may be digit too is not local max ?
624 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
629 // but may be digitN too is not local max ?
630 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
633 } // if Areneighbours
639 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
641 maxAt[iDigitN] = maxAt[iDigit] ;
642 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
648 //____________________________________________________________________________
649 void AliEMCALTowerRecPoint::EvalTime(TClonesArray * digits){
653 for(Int_t idig=0; idig < fMulDigit; idig++){
654 if(fEnergyList[idig] > maxE){
655 maxE = fEnergyList[idig] ;
659 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
662 //____________________________________________________________________________
663 void AliEMCALTowerRecPoint::Print(Option_t *)
665 // Print the list of digits belonging to the cluster
670 printf("digits # = ");
671 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
672 printf("%i ", fDigitsList[iDigit]);
675 printf("\nEnergies = ");
676 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
677 printf("%f ", fEnergyList[iDigit]);
680 printf("\nPrimaries ");
681 for(iDigit = 0;iDigit < fMulTrack; iDigit++) {
682 printf("%i ", fTracksList[iDigit]);
684 printf("\n Multiplicity = %i", fMulDigit);
685 printf("\n Cluster Energy = %f", fAmp);
686 printf("\n Number of primaries %i", fMulTrack);
687 printf("\n Stored at position: %i", GetIndexInList());
690 //____________________________________________________________________________
691 const TVector3 AliEMCALTowerRecPoint::XYZInAlice(Float_t r, Float_t theta, Float_t phi) const
693 // spherical coordinates of recpoint in Alice reference frame
696 printf("XYZInAlice: r = %f, theta = %f, phi = %f", r, theta, phi) ;
698 if (theta == 9999. || phi == 9999. || r == 9999.) {
700 GetGlobalPosition(globalpos);
701 phi = globalpos.X() * TMath::DegToRad() ;
703 theta = globalpos.Z() * TMath::DegToRad() ;
706 theta *= TMath::DegToRad() ;
707 phi *= TMath::DegToRad() ;
710 Float_t y = r * TMath::Cos(phi) ;
711 Float_t x = r * TMath::Sin(phi) * TMath::Sin(theta) ;
712 Float_t z = r * TMath::Sin(phi) * TMath::Cos(theta) ;
714 TVector3 vec(z, x, y) ;