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 **************************************************************************/
16 //_________________________________________________________________________
17 // Reconstructed Points for the EMCAL
18 // A RecPoint is a cluster of digits
19 //*-- Author: Yves Schutz (SUBATECH)
20 //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
21 //*-- Author: Heather Gray (LBL) merged AliEMCALRecPoint and AliEMCALTowerRecPoint 02/04
23 // --- ROOT system ---
28 #include <TClonesArray.h>
31 // --- Standard library ---
33 // --- AliRoot header files ---
34 //#include "AliGenerator.h"
36 #include "AliRunLoader.h"
39 #include "AliEMCALLoader.h"
40 #include "AliEMCALGeometry.h"
41 #include "AliEMCALHit.h"
42 #include "AliEMCALDigit.h"
43 #include "AliEMCALRecPoint.h"
45 ClassImp(AliEMCALRecPoint)
47 //____________________________________________________________________________
48 AliEMCALRecPoint::AliEMCALRecPoint()
58 fCoreRadius(10), //HG check this
64 fSuperModuleNumber(0),
68 AliRunLoader *rl = AliRunLoader::GetRunLoader();
69 if (rl && rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
70 fGeomPtr = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
72 fGeomPtr = AliEMCALGeometry::GetInstance();
73 //fGeomPtr = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
74 // fGeomPtr->GetTransformationForSM(); // Global <-> Local
77 //____________________________________________________________________________
78 AliEMCALRecPoint::AliEMCALRecPoint(const char * opt)
88 fCoreRadius(10), //HG check this
94 fSuperModuleNumber(0),
98 // Increase fMaxTrack for EMCAL.
99 delete [] fTracksList;
101 fTracksList = new Int_t[fMaxTrack];
102 fDETracksList = new Float_t[fMaxTrack];
104 fParentsList = new Int_t[fMaxParent];
105 fDEParentsList = new Float_t[fMaxParent];
106 for (Int_t i = 0; i < fMaxTrack; i++)
107 fDETracksList[i] = 0;
108 for (Int_t i = 0; i < fMaxParent; i++) {
109 fParentsList[i] = -1;
110 fDEParentsList[i] = 0;
113 AliRunLoader *rl = AliRunLoader::GetRunLoader();
114 if (rl && rl->GetAliRun() && rl->GetAliRun()->GetDetector("EMCAL"))
115 fGeomPtr = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
117 fGeomPtr = AliEMCALGeometry::GetInstance();
118 // fGeomPtr = AliEMCALGeometry::GetInstance(AliEMCALGeometry::GetDefaulGeometryName());
119 // fGeomPtr->GetTransformationForSM(); // Global <-> Local
122 //____________________________________________________________________________
123 AliEMCALRecPoint::AliEMCALRecPoint(const AliEMCALRecPoint & rp)
125 fGeomPtr(rp.fGeomPtr),
126 fClusterType(rp.fClusterType),
127 fCoreEnergy(rp.fCoreEnergy),
128 fDispersion(rp.fDispersion),
133 fCoreRadius(rp.fCoreRadius),
135 fMulParent(rp.fMulParent),
136 fMaxParent(rp.fMaxParent),
139 fSuperModuleNumber(rp.fSuperModuleNumber),
140 fDigitIndMax(rp.fDigitIndMax)
143 fLambda[0] = rp.fLambda[0];
144 fLambda[1] = rp.fLambda[1];
146 fEnergyList = new Float_t[rp.fMaxDigit];
147 fTimeList = new Float_t[rp.fMaxDigit];
148 fAbsIdList = new Int_t[rp.fMaxDigit];
149 for(Int_t i = 0; i < rp.fMulDigit; i++) {
150 fEnergyList[i] = rp.fEnergyList[i];
151 fTimeList[i] = rp.fTimeList[i];
152 fAbsIdList[i] = rp.fAbsIdList[i];
154 fDETracksList = new Float_t[rp.fMaxTrack];
155 for(Int_t i = 0; i < rp.fMulTrack; i++) fDETracksList[i] = rp.fDETracksList[i];
156 fParentsList = new Int_t[rp.fMaxParent];
157 for(Int_t i = 0; i < rp.fMulParent; i++) fParentsList[i] = rp.fParentsList[i];
158 fDEParentsList = new Float_t[rp.fMaxParent];
159 for(Int_t i = 0; i < rp.fMulParent; i++) fDEParentsList[i] = rp.fDEParentsList[i];
162 //____________________________________________________________________________
163 AliEMCALRecPoint::~AliEMCALRecPoint()
167 delete[] fEnergyList ;
171 delete[] fAbsIdList ;
173 delete[] fDETracksList;
175 delete[] fParentsList;
177 delete[] fDEParentsList;
180 //____________________________________________________________________________
181 void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy)
183 // Adds a digit to the RecPoint
184 // and accumulates the total amplitude and the multiplicity
187 fEnergyList = new Float_t[fMaxDigit];
189 fTimeList = new Float_t[fMaxDigit];
190 if(fAbsIdList == 0) {
191 fAbsIdList = new Int_t[fMaxDigit];
192 fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(digit.GetId());
195 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
197 Int_t * tempo = new Int_t[fMaxDigit];
198 Float_t * tempoE = new Float_t[fMaxDigit];
199 Float_t * tempoT = new Float_t[fMaxDigit];
200 Int_t * tempoId = new Int_t[fMaxDigit];
203 for ( index = 0 ; index < fMulDigit ; index++ ){
204 tempo[index] = fDigitsList[index] ;
205 tempoE[index] = fEnergyList[index] ;
206 tempoT[index] = fTimeList[index] ;
207 tempoId[index] = fAbsIdList[index] ;
210 delete [] fDigitsList ;
211 delete [] fEnergyList ;
212 delete [] fTimeList ;
213 delete [] fAbsIdList ;
216 fEnergyList = tempoE;
218 fAbsIdList = tempoId;
221 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
222 fEnergyList[fMulDigit] = Energy ;
223 fTimeList[fMulDigit] = digit.GetTimeR() ;
224 fAbsIdList[fMulDigit] = digit.GetId();
229 //____________________________________________________________________________
230 Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
232 // Tells if (true) or not (false) two digits are neighbours
233 // A neighbour is defined as being two digits which share a corner
235 static Bool_t areNeighbours = kFALSE ;
236 static Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0;
237 static int nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0;
238 static Int_t relid1[2] , relid2[2] ; // ieta, iphi
239 static Int_t rowdiff=0, coldiff=0;
241 areNeighbours = kFALSE ;
243 fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nModule,nIphi,nIeta);
244 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, relid1[0],relid1[1]);
246 fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nModule1,nIphi1,nIeta1);
247 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, relid2[0],relid2[1]);
249 rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ;
250 coldiff = TMath::Abs( relid1[1] - relid2[1] ) ;
252 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
253 areNeighbours = kTRUE ;
255 return areNeighbours;
258 //____________________________________________________________________________
259 Int_t AliEMCALRecPoint::Compare(const TObject * obj) const
261 // Compares two RecPoints according to their position in the EMCAL modules
263 Float_t delta = 1 ; //Width of "Sorting row". If you change this
264 //value (what is senseless) change as well delta in
265 //AliEMCALTrackSegmentMakerv* and other RecPoints...
268 AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ;
271 GetLocalPosition(locpos1);
273 clu->GetLocalPosition(locpos2);
275 Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ;
280 else if(locpos1.Y()>locpos2.Y())
288 //____________________________________________________________________________
289 Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
291 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
292 // Compute the closest distance of approach from point px,py to this marker.
293 // The distance is computed in pixels units.
294 // HG Still need to update -> Not sure what this should achieve
296 TVector3 pos(0.,0.,0.) ;
297 GetLocalPosition(pos) ;
298 Float_t x = pos.X() ;
299 Float_t y = pos.Y() ;
300 const Int_t kMaxDiff = 10;
301 Int_t pxm = gPad->XtoAbsPixel(x);
302 Int_t pym = gPad->YtoAbsPixel(y);
303 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
305 if (dist > kMaxDiff) return 9999;
309 //___________________________________________________________________________
310 void AliEMCALRecPoint::Draw(Option_t *option)
312 // Draw this AliEMCALRecPoint with its current attributes
317 //______________________________________________________________________________
318 void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t)
320 // Execute action corresponding to one event
321 // This member function is called when a AliEMCALRecPoint is clicked with the locator
323 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
324 // and switched off when the mouse button is released.
326 // static Int_t pxold, pyold;
328 /* static TGraph * digitgraph = 0 ;
329 static TPaveText* clustertext = 0 ;
331 if (!gPad->IsEditable()) return;
337 AliEMCALDigit * digit ;
338 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ;
343 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
344 Float_t * xi = new Float_t [kMulDigit] ;
345 Float_t * zi = new Float_t [kMulDigit] ;
347 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
348 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
349 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
350 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
351 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
355 digitgraph = new TGraph(fMulDigit,xi,zi);
356 digitgraph-> SetMarkerStyle(5) ;
357 digitgraph-> SetMarkerSize(1.) ;
358 digitgraph-> SetMarkerColor(1) ;
359 digitgraph-> Draw("P") ;
363 TVector3 pos(0.,0.,0.) ;
364 GetLocalPosition(pos) ;
365 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
368 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
369 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
370 clustertext ->AddText(line1) ;
371 clustertext ->AddText(line2) ;
372 clustertext ->Draw("");
396 //____________________________________________________________________________
397 void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
399 // Evaluates all shower parameters
400 EvalLocalPosition(logWeight, digits) ;
401 EvalElipsAxis(logWeight, digits) ;
402 EvalDispersion(logWeight, digits) ;
403 //EvalCoreEnergy(logWeight, digits);
405 EvalPrimaries(digits) ;
409 //____________________________________________________________________________
410 void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits)
412 // Calculates the dispersion of the shower at the origin of the RecPoint
413 // in cell units - Nov 16,2006
415 Double_t d = 0., wtot = 0., w = 0.;
416 Int_t iDigit=0, nstat=0;
417 AliEMCALDigit * digit ;
419 // Calculates the dispersion in cell units
420 Double_t etai, phii, etaMean=0.0, phiMean=0.0;
421 int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
423 // Calculate mean values
424 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
425 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
427 if (fAmp>0 && fEnergyList[iDigit]>0) {
428 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
429 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
432 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
444 } else AliError(Form("Wrong weight %f\n", wtot));
446 // Calculate dispersion
447 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
448 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
450 if (fAmp>0 && fEnergyList[iDigit]>0) {
451 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
452 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
455 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
459 d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean));
464 if ( wtot > 0 && nstat>1) d /= wtot ;
467 fDispersion = TMath::Sqrt(d) ;
470 //____________________________________________________________________________
471 void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
473 // Calculates the center of gravity in the local EMCAL-module coordinates
474 // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
476 static Double_t dist;
478 AliEMCALDigit * digit;
479 Int_t i=0, nstat=0, idMax=-1;
480 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
482 //printf(" dist : %f e : %f \n", dist, fAmp);
483 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
484 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
486 idMax = digit->GetId(); // is it correct
487 dist = TmaxInCm(Double_t(fAmp));
489 fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
490 //printf(" Id %i : dist %f Local x,y,z %f %f %f \n", digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
492 //fGeomPtr->RelPosCellInSModule(digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
493 //printf(" Id %i : dist %f Local x,y,z %f %f %f \n", digit->GetId(), 0.0, xyzi[0], xyzi[1], xyzi[2]);
494 // if(fAmp>102.) assert(0);
496 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
497 else w = fEnergyList[iDigit]; // just energy
502 for(i=0; i<3; i++ ) {
503 clXYZ[i] += (w*xyzi[i]);
504 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
508 // cout << " wtot " << wtot << endl;
510 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
511 for(i=0; i<3; i++ ) {
514 clRmsXYZ[i] /= (wtot*wtot);
515 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
516 if(clRmsXYZ[i] > 0.0) {
517 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
518 } else clRmsXYZ[i] = 0;
519 } else clRmsXYZ[i] = 0;
522 for(i=0; i<3; i++ ) {
523 clXYZ[i] = clRmsXYZ[i] = -1.;
527 fLocPos.SetX(clXYZ[0]);
528 fLocPos.SetY(clXYZ[1]);
529 fLocPos.SetZ(clXYZ[2]);
532 // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
533 fLocPosM = 0 ; // covariance matrix
536 //void AliEMCALRecPoint::EvalLocalPositionSimple()
537 //{ // Weight is proportional of cell energy
539 //____________________________________________________________________________
540 void AliEMCALRecPoint::EvalLocalPositionFit(Double_t deff, Double_t logWeight,
541 Double_t phiSlope, TClonesArray * digits)
543 // Aug 14-16, 2007 - for fit
544 // Aug 31 - should be static ??
545 static Double_t dist, ycorr;
546 static AliEMCALDigit *digit;
548 Int_t i=0, nstat=0, idMax=-1;
549 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
551 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
552 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
554 idMax = digit->GetId(); // is it correct
555 dist = TmaxInCm(Double_t(fAmp));
559 fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
561 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
562 else w = fEnergyList[iDigit]; // just energy
567 for(i=0; i<3; i++ ) {
568 clXYZ[i] += (w*xyzi[i]);
569 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
573 // cout << " wtot " << wtot << endl;
575 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
576 for(i=0; i<3; i++ ) {
579 clRmsXYZ[i] /= (wtot*wtot);
580 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
581 if(clRmsXYZ[i] > 0.0) {
582 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
583 } else clRmsXYZ[i] = 0;
584 } else clRmsXYZ[i] = 0;
587 for(i=0; i<3; i++ ) {
588 clXYZ[i] = clRmsXYZ[i] = -1.;
592 if(phiSlope != 0.0 && logWeight > 0.0 && wtot) {
593 // Correction in phi direction (y - coords here); Aug 16;
594 // May be put to global level or seperate method
595 ycorr = clXYZ[1] * (1. + phiSlope);
596 //printf(" y %f : ycorr %f : slope %f \n", clXYZ[1], ycorr, phiSlope);
599 fLocPos.SetX(clXYZ[0]);
600 fLocPos.SetY(clXYZ[1]);
601 fLocPos.SetZ(clXYZ[2]);
604 // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
605 fLocPosM = 0 ; // covariance matrix
608 Bool_t AliEMCALRecPoint::EvalLocalPosition2(TClonesArray * digits, TArrayD &ed)
610 // Evaluated local position of rec.point using digits
611 // and parametrisation of w0 and deff
612 //printf(" <I> AliEMCALRecPoint::EvalLocalPosition2() \n");
613 return AliEMCALRecPoint::EvalLocalPositionFromDigits(digits, ed, fLocPos);
616 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
618 // Used when digits should be recalibrated
619 static Double_t deff, w0, esum;
621 static AliEMCALDigit *digit;
623 if(ed.GetSize() && (digits->GetEntries()!=ed.GetSize())) return kFALSE;
625 // Calculate sum energy of digits
627 for(iDigit=0; iDigit<ed.GetSize(); iDigit++) esum += ed[iDigit];
629 GetDeffW0(esum, deff, w0);
631 return EvalLocalPositionFromDigits(esum, deff, w0, digits, ed, locPos);
634 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff, const Double_t w0,
635 TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
637 static AliEMCALDigit *digit;
639 Int_t i=0, nstat=0, idMax=-1;
640 Double_t clXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
642 AliEMCALGeometry* geo = AliEMCALGeometry::GetInstance(); // Get pointer to EMCAL geometry
644 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
645 digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit));
647 geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]);
649 if(w0 > 0.0) w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum));
650 else w = ed[iDigit]; // just energy
655 for(i=0; i<3; i++ ) {
656 clXYZ[i] += (w*xyzi[i]);
660 // cout << " wtot " << wtot << endl;
662 for(i=0; i<3; i++ ) {
665 locPos.SetX(clXYZ[0]);
666 locPos.SetY(clXYZ[1]);
667 locPos.SetZ(clXYZ[2]);
675 void AliEMCALRecPoint::GetDeffW0(const Double_t esum , Double_t &deff, Double_t &w0)
679 // Applied for simulation data with threshold 3 adc
680 // Calculate efective distance (deff) and weigh parameter (w0)
681 // for coordinate calculation; 0.5 GeV < esum <100 GeV.
682 // Look to: http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/CALIB/GEOMCORR/deffandW0VaEgamma_2.gif
684 static Double_t e=0.0;
685 const Double_t dp0=9.25147, dp1=1.16700; // Hard coded now
686 const Double_t wp0=4.83713, wp1=-2.77970e-01, wp2 = 4.41116;
688 // No extrapolation here
689 e = esum<0.5?0.5:esum;
692 deff = dp0 + dp1*TMath::Log(e);
693 w0 = wp0 / (1. + TMath::Exp(wp1*(e+wp2)));
694 //printf("<I> AliEMCALRecPoint::GetDeffW0 esum %5.2f : deff %5.2f : w0 %5.2f \n", esum, deff, w0);
697 //______________________________________________________________________________
698 void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
700 // This function calculates energy in the core,
701 // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius
702 // in accordance with shower profile the energy deposition
703 // should be less than 2%
704 // Unfinished - Nov 15,2006
705 // Distance is calculate in (phi,eta) units
707 AliEMCALDigit * digit ;
711 if (!fLocPos.Mag()) {
712 EvalLocalPosition(logWeight, digits);
715 Double_t phiPoint = fLocPos.Phi(), etaPoint = fLocPos.Eta();
716 Double_t eta, phi, distance;
717 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
718 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
721 fGeomPtr->EtaPhiFromIndex(digit->GetId(),eta, phi) ;
722 phi = phi * TMath::DegToRad();
724 distance = TMath::Sqrt((eta-etaPoint)*(eta-etaPoint)+(phi-phiPoint)*(phi-phiPoint));
725 if(distance < fCoreRadius)
726 fCoreEnergy += fEnergyList[iDigit] ;
730 //____________________________________________________________________________
731 void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
733 // Calculates the axis of the shower ellipsoid in eta and phi
736 static TString gn(fGeomPtr->GetName());
745 AliEMCALDigit * digit = 0;
747 Double_t etai , phii, w;
748 int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
750 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
751 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
753 if(gn.Contains("SHISH")) {
754 // Nov 15,2006 - use cell numbers as coordinates
755 // Copied for shish-kebab geometry, ieta,iphi is cast as double as eta,phi
756 // We can use the eta,phi(or coordinates) of cell
757 nSupMod = nModule = nIphi = nIeta = iphi = ieta = 0;
759 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
760 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
764 fGeomPtr->EtaPhiFromIndex(digit->GetId(), etai, phii);
765 phii = phii * TMath::DegToRad();
768 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
769 // fAmp summed amplitude of digits, i.e. energy of recpoint
770 // Gives smaller value of lambda than log weight
771 // w = fEnergyList[iDigit] / fAmp; // Nov 16, 2006 - try just energy
773 dxx += w * etai * etai ;
775 dzz += w * phii * phii ;
778 dxz += w * etai * phii ;
793 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
795 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
799 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
801 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
802 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
810 // printf("Evalaxis: lambdas = %f,%f", fLambda[0],fLambda[1]) ;
814 //______________________________________________________________________________
815 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
817 // Constructs the list of primary particles (tracks) which
818 // have contributed to this RecPoint and calculate deposited energy
821 AliEMCALDigit * digit ;
822 Int_t * primArray = new Int_t[fMaxTrack] ;
823 Float_t * dEPrimArray = new Float_t[fMaxTrack] ;
826 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
827 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
828 Int_t nprimaries = digit->GetNprimary() ;
829 if ( nprimaries == 0 ) continue ;
831 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
832 if ( fMulTrack > fMaxTrack ) {
833 fMulTrack = fMaxTrack ;
834 Error("EvalPrimaries", "increase fMaxTrack ") ;
837 Int_t newPrimary = digit->GetPrimary(jndex+1);
838 Float_t dEPrimary = digit->GetDEPrimary(jndex+1);
840 Bool_t already = kFALSE ;
841 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
842 if ( newPrimary == primArray[kndex] ){
844 dEPrimArray[kndex] += dEPrimary;
848 if ( !already && (fMulTrack < fMaxTrack)) { // store it
849 primArray[fMulTrack] = newPrimary ;
850 dEPrimArray[fMulTrack] = dEPrimary ;
853 } // all primaries in digit
856 Int_t *sortIdx = new Int_t[fMulTrack];
857 TMath::Sort(fMulTrack,dEPrimArray,sortIdx);
858 for(index = 0; index < fMulTrack; index++) {
859 fTracksList[index] = primArray[sortIdx[index]] ;
860 fDETracksList[index] = dEPrimArray[sortIdx[index]] ;
863 delete [] primArray ;
864 delete [] dEPrimArray ;
868 //______________________________________________________________________________
869 void AliEMCALRecPoint::EvalParents(TClonesArray * digits)
871 // Constructs the list of parent particles (tracks) which have contributed to this RecPoint
873 AliEMCALDigit * digit ;
874 Int_t * parentArray = new Int_t[fMaxTrack] ;
875 Float_t * dEParentArray = new Float_t[fMaxTrack] ;
878 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
879 if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0)
880 AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index));
881 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
882 Int_t nparents = digit->GetNiparent() ;
883 if ( nparents == 0 ) continue ;
886 for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit
887 if ( fMulParent > fMaxParent ) {
889 Error("EvalParents", "increase fMaxParent") ;
892 Int_t newParent = digit->GetIparent(jndex+1) ;
893 Float_t newdEParent = digit->GetDEParent(jndex+1) ;
895 Bool_t already = kFALSE ;
896 for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored
897 if ( newParent == parentArray[kndex] ){
898 dEParentArray[kndex] += newdEParent;
903 if ( !already && (fMulParent < fMaxParent)) { // store it
904 parentArray[fMulParent] = newParent ;
905 dEParentArray[fMulParent] = newdEParent ;
908 } // all parents in digit
912 Int_t *sortIdx = new Int_t[fMulParent];
913 TMath::Sort(fMulParent,dEParentArray,sortIdx);
914 for(index = 0; index < fMulParent; index++) {
915 fParentsList[index] = parentArray[sortIdx[index]] ;
916 fDEParentsList[index] = dEParentArray[sortIdx[index]] ;
921 delete [] parentArray;
922 delete [] dEParentArray;
925 //____________________________________________________________________________
926 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
928 // returns the position of the cluster in the local reference system of ALICE
930 lpos.SetX(fLocPos.X()) ;
931 lpos.SetY(fLocPos.Y()) ;
932 lpos.SetZ(fLocPos.Z()) ;
935 //____________________________________________________________________________
936 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
938 // returns the position of the cluster in the global reference system of ALICE
939 // These are now the Cartesian X, Y and Z
940 // cout<<" geom "<<geom<<endl;
941 fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber);
944 //____________________________________________________________________________
945 Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const
947 // Finds the maximum energy in the cluster
949 Float_t menergy = 0. ;
953 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
955 if(fEnergyList[iDigit] > menergy)
956 menergy = fEnergyList[iDigit] ;
961 //____________________________________________________________________________
962 Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const
964 // Calculates the multiplicity of digits with energy larger than H*energy
968 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
970 if(fEnergyList[iDigit] > H * fAmp)
976 //____________________________________________________________________________
977 Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
978 Float_t locMaxCut,TClonesArray * digits) const
980 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
981 // energy difference between two local maxima
983 AliEMCALDigit * digit ;
984 AliEMCALDigit * digitN ;
989 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
990 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
992 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
994 digit = maxAt[iDigit] ;
996 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
997 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
999 if ( AreNeighbours(digit, digitN) ) {
1000 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
1001 maxAt[iDigitN] = 0 ;
1002 // but may be digit too is not local max ?
1003 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
1008 // but may be digitN too is not local max ?
1009 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
1010 maxAt[iDigitN] = 0 ;
1012 } // if Areneighbours
1018 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
1020 maxAt[iDigitN] = maxAt[iDigit] ;
1021 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
1028 //____________________________________________________________________________
1029 Int_t AliEMCALRecPoint::GetPrimaryIndex() const
1031 // Get the primary track index in TreeK which deposits the most energy
1032 // in Digits which forms RecPoint.
1035 return fTracksList[0];
1039 //____________________________________________________________________________
1040 void AliEMCALRecPoint::EvalTime(TClonesArray * digits){
1041 // time is set to the time of the digit with the maximum energy
1045 for(Int_t idig=0; idig < fMulDigit; idig++){
1046 if(fEnergyList[idig] > maxE){
1047 maxE = fEnergyList[idig] ;
1051 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
1055 //______________________________________________________________________________
1056 void AliEMCALRecPoint::Paint(Option_t *)
1058 // Paint this ALiRecPoint as a TMarker with its current attributes
1060 TVector3 pos(0.,0.,0.) ;
1061 GetLocalPosition(pos) ;
1062 Coord_t x = pos.X() ;
1063 Coord_t y = pos.Z() ;
1064 Color_t markercolor = 1 ;
1065 Size_t markersize = 1. ;
1066 Style_t markerstyle = 5 ;
1068 if (!gPad->IsBatch()) {
1069 gVirtualX->SetMarkerColor(markercolor) ;
1070 gVirtualX->SetMarkerSize (markersize) ;
1071 gVirtualX->SetMarkerStyle(markerstyle) ;
1073 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
1074 gPad->PaintPolyMarker(1,&x,&y,"") ;
1077 Double_t AliEMCALRecPoint::TmaxInCm(const Double_t e , const Int_t key)
1079 // e energ in in GeV)
1080 // key = 0(gamma, default)
1082 static Double_t ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07)
1083 static Double_t X0 = 1.23; // radiation lenght (cm)
1084 static Double_t tmax = 0.; // position of electromagnetic shower max in cm
1088 tmax = TMath::Log(e) + ca;
1089 if (key==0) tmax += 0.5;
1091 tmax *= X0; // convert to cm
1096 //______________________________________________________________________________
1097 Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const
1099 //Converts Theta (Radians) to Eta(Radians)
1100 return (2.*TMath::ATan(TMath::Exp(-arg)));
1103 //______________________________________________________________________________
1104 Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const
1106 //Converts Eta (Radians) to Theta(Radians)
1107 return (-1 * TMath::Log(TMath::Tan(0.5 * arg)));
1110 //____________________________________________________________________________
1111 void AliEMCALRecPoint::Print(Option_t *opt) const
1113 // Print the list of digits belonging to the cluster
1114 if(strlen(opt)==0) return;
1116 message = "AliEMCALRecPoint:\n" ;
1117 message += " digits # = " ;
1118 Info("Print", message.Data()) ;
1121 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1122 printf(" %d ", fDigitsList[iDigit] ) ;
1125 Info("Print", " Energies = ") ;
1126 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1127 printf(" %f ", fEnergyList[iDigit] ) ;
1130 Info("Print", "\n Abs Ids = ") ;
1131 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1132 printf(" %i ", fAbsIdList[iDigit] ) ;
1135 Info("Print", " Primaries ") ;
1136 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1137 printf(" %d ", fTracksList[iDigit]) ;
1139 printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]);
1141 message = " ClusterType = %d" ;
1142 message += " Multiplicity = %d" ;
1143 message += " Cluster Energy = %f" ;
1144 message += " Core energy = %f" ;
1145 message += " Core radius = %f" ;
1146 message += " Number of primaries %d" ;
1147 message += " Stored at position %d" ;
1148 Info("Print", message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList() ) ;
1151 Double_t AliEMCALRecPoint::GetPointEnergy() const
1155 for(int ic=0; ic<GetMultiplicity(); ic++) e += double(fEnergyList[ic]);