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()
64 // fLocPos.SetX(1.e+6) ; //Local position should be evaluated
65 fCoreRadius = 10; //HG Check this
67 AliRunLoader *rl = AliRunLoader::GetRunLoader();
68 fGeomPtr = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
69 //fGeomPtr = AliEMCALGeometry::GetInstance();
70 fGeomPtr->GetTransformationForSM(); // Global <-> Local
73 //____________________________________________________________________________
74 AliEMCALRecPoint::AliEMCALRecPoint(const char * opt) : AliRecPoint(opt)
87 fParentsList = new Int_t[fMaxParent];
89 //fLocPos.SetX(1.e+6) ; //Local position should be evaluated
90 fCoreRadius = 10; //HG Check this
91 //fGeomPtr = AliEMCALGeometry::GetInstance();
92 AliRunLoader *rl = AliRunLoader::GetRunLoader();
93 fGeomPtr = dynamic_cast<AliEMCAL*>(rl->GetAliRun()->GetDetector("EMCAL"))->GetGeometry();
94 fGeomPtr->GetTransformationForSM(); // Global <-> Local
96 //____________________________________________________________________________
97 AliEMCALRecPoint::AliEMCALRecPoint(const AliEMCALRecPoint & rp) : AliRecPoint(rp)
100 fGeomPtr = rp.fGeomPtr;
101 fClusterType = rp.fClusterType;
102 fCoreEnergy = rp.fCoreEnergy;
103 fLambda[0] = rp.fLambda[0];
104 fLambda[1] = rp.fLambda[1];
105 fDispersion = rp.fDispersion;
106 fEnergyList = new Float_t[rp.fMulDigit];
107 fTimeList = new Float_t[rp.fMulDigit];
108 fAbsIdList = new Int_t[rp.fMulDigit];
109 for(Int_t i = 0; i < rp.fMulDigit; i++) {
110 fEnergyList[i] = rp.fEnergyList[i];
111 fTimeList[i] = rp.fTimeList[i];
112 fAbsIdList[i] = rp.fAbsIdList[i];
115 fCoreRadius = rp.fCoreRadius;
116 fMulParent = rp.fMulParent;
117 fMaxParent = rp.fMaxParent;
118 fParentsList = new Int_t[rp.fMulParent];
119 for(Int_t i = 0; i < rp.fMulParent; i++) fParentsList[i] = rp.fParentsList[i];
120 fSuperModuleNumber = rp.fSuperModuleNumber;
123 //____________________________________________________________________________
124 AliEMCALRecPoint::~AliEMCALRecPoint()
128 delete[] fEnergyList ;
132 delete[] fAbsIdList ;
134 delete[] fParentsList;
137 //____________________________________________________________________________
138 void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy)
140 // Adds a digit to the RecPoint
141 // and accumulates the total amplitude and the multiplicity
144 fEnergyList = new Float_t[fMaxDigit];
146 fTimeList = new Float_t[fMaxDigit];
147 if(fAbsIdList == 0) {
148 fAbsIdList = new Int_t[fMaxDigit];
149 fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(digit.GetId());
152 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
154 Int_t * tempo = new Int_t[fMaxDigit];
155 Float_t * tempoE = new Float_t[fMaxDigit];
156 Float_t * tempoT = new Float_t[fMaxDigit];
157 Int_t * tempoId = new Int_t[fMaxDigit];
160 for ( index = 0 ; index < fMulDigit ; index++ ){
161 tempo[index] = fDigitsList[index] ;
162 tempoE[index] = fEnergyList[index] ;
163 tempoT[index] = fTimeList[index] ;
164 tempoId[index] = fAbsIdList[index] ;
167 delete [] fDigitsList ;
168 fDigitsList = new Int_t[fMaxDigit];
170 delete [] fEnergyList ;
171 fEnergyList = new Float_t[fMaxDigit];
173 delete [] fTimeList ;
174 fTimeList = new Float_t[fMaxDigit];
176 delete [] fAbsIdList ;
177 fAbsIdList = new Int_t[fMaxDigit];
179 for ( index = 0 ; index < fMulDigit ; index++ ){
180 fDigitsList[index] = tempo[index] ;
181 fEnergyList[index] = tempoE[index] ;
182 fTimeList[index] = tempoT[index] ;
183 fAbsIdList[index] = tempoId[index] ;
192 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
193 fEnergyList[fMulDigit] = Energy ;
194 fTimeList[fMulDigit] = digit.GetTime() ;
195 fAbsIdList[fMulDigit] = digit.GetId();
200 //____________________________________________________________________________
201 Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
203 // Tells if (true) or not (false) two digits are neighbours
204 // A neighbour is defined as being two digits which share a corner
206 static Bool_t areNeighbours = kFALSE ;
207 static Int_t nSupMod=0, nTower=0, nIphi=0, nIeta=0;
208 static int nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0;
209 static Int_t relid1[2] , relid2[2] ; // ieta, iphi
210 static Int_t rowdiff=0, coldiff=0;
212 areNeighbours = kFALSE ;
214 fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nTower,nIphi,nIeta);
215 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, relid1[0],relid1[1]);
217 fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
218 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, relid2[0],relid2[1]);
220 rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ;
221 coldiff = TMath::Abs( relid1[1] - relid2[1] ) ;
223 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
224 areNeighbours = kTRUE ;
226 return areNeighbours;
229 //____________________________________________________________________________
230 Int_t AliEMCALRecPoint::Compare(const TObject * obj) const
232 // Compares two RecPoints according to their position in the EMCAL modules
234 Float_t delta = 1 ; //Width of "Sorting row". If you change this
235 //value (what is senseless) change as well delta in
236 //AliEMCALTrackSegmentMakerv* and other RecPoints...
239 AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ;
242 GetLocalPosition(locpos1);
244 clu->GetLocalPosition(locpos2);
246 Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ;
251 else if(locpos1.Y()>locpos2.Y())
259 //____________________________________________________________________________
260 Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
262 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
263 // Compute the closest distance of approach from point px,py to this marker.
264 // The distance is computed in pixels units.
265 // HG Still need to update -> Not sure what this should achieve
267 TVector3 pos(0.,0.,0.) ;
268 GetLocalPosition(pos) ;
269 Float_t x = pos.X() ;
270 Float_t y = pos.Y() ;
271 const Int_t kMaxDiff = 10;
272 Int_t pxm = gPad->XtoAbsPixel(x);
273 Int_t pym = gPad->YtoAbsPixel(y);
274 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
276 if (dist > kMaxDiff) return 9999;
280 //___________________________________________________________________________
281 void AliEMCALRecPoint::Draw(Option_t *option)
283 // Draw this AliEMCALRecPoint with its current attributes
288 //______________________________________________________________________________
289 void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t)
291 // Execute action corresponding to one event
292 // This member function is called when a AliEMCALRecPoint is clicked with the locator
294 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
295 // and switched off when the mouse button is released.
297 // static Int_t pxold, pyold;
299 /* static TGraph * digitgraph = 0 ;
300 static TPaveText* clustertext = 0 ;
302 if (!gPad->IsEditable()) return;
308 AliEMCALDigit * digit ;
309 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ;
314 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
315 Float_t * xi = new Float_t [kMulDigit] ;
316 Float_t * zi = new Float_t [kMulDigit] ;
318 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
319 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
320 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
321 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
322 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
326 digitgraph = new TGraph(fMulDigit,xi,zi);
327 digitgraph-> SetMarkerStyle(5) ;
328 digitgraph-> SetMarkerSize(1.) ;
329 digitgraph-> SetMarkerColor(1) ;
330 digitgraph-> Draw("P") ;
334 TVector3 pos(0.,0.,0.) ;
335 GetLocalPosition(pos) ;
336 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
339 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
340 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
341 clustertext ->AddText(line1) ;
342 clustertext ->AddText(line2) ;
343 clustertext ->Draw("");
367 //____________________________________________________________________________
368 void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
370 // Evaluates all shower parameters
372 EvalLocalPosition(logWeight, digits) ;
373 // printf("eval position done\n");
374 EvalElipsAxis(logWeight, digits) ;
375 // printf("eval axis done\n");
376 EvalDispersion(logWeight, digits) ;
377 // printf("eval dispersion done\n");
378 //EvalCoreEnergy(logWeight, digits);
379 // printf("eval energy done\n");
381 // printf("eval time done\n");
383 EvalPrimaries(digits) ;
384 // printf("eval pri done\n");
386 // printf("eval parent done\n");
389 //____________________________________________________________________________
390 void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits)
392 // Calculates the dispersion of the shower at the origin of the RecPoint
394 Double_t d = 0., wtot = 0., w = 0., xyzi[3], diff=0.;
395 Int_t iDigit=0, nstat=0, i=0;
396 AliEMCALDigit * digit ;
398 // Calculates the centre of gravity in the local EMCAL-module coordinates
400 EvalLocalPosition(logWeight, digits) ;
402 // Calculates the dispersion in coordinates
403 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
404 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
406 fGeomPtr->RelPosCellInSModule(digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
407 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
412 for(i=0; i<3; i++ ) {
413 diff = xyzi[i] - double(fLocPos[i]);
419 if ( wtot > 0 && nstat>1) d /= wtot ;
422 fDispersion = TMath::Sqrt(d) ;
425 //____________________________________________________________________________
426 void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
428 // Calculates the center of gravity in the local EMCAL-module coordinates
429 // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
431 AliEMCALDigit * digit;
433 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
435 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
436 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
438 fGeomPtr->RelPosCellInSModule(digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
439 // printf(" Id %i : Local x,y,z %f %f %f \n", digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
441 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
442 else w = fEnergyList[iDigit]; // just energy
447 for(i=0; i<3; i++ ) {
448 clXYZ[i] += (w*xyzi[i]);
449 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
453 // cout << " wtot " << wtot << endl;
455 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
456 for(i=0; i<3; i++ ) {
459 clRmsXYZ[i] /= (wtot*wtot);
460 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
461 if(clRmsXYZ[i] > 0.0) {
462 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
463 } else clRmsXYZ[i] = 0;
464 } else clRmsXYZ[i] = 0;
467 for(i=0; i<3; i++ ) {
468 clXYZ[i] = clRmsXYZ[i] = -1.;
472 fLocPos.SetX(clXYZ[0]);
473 fLocPos.SetY(clXYZ[1]);
474 fLocPos.SetZ(clXYZ[2]);
477 // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
478 fLocPosM = 0 ; // covariance matrix
481 //void AliEMCALRecPoint::EvalLocalPositionSimple()
482 //{ // Weight is proportional of cell energy
485 //______________________________________________________________________________
486 void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
488 // This function calculates energy in the core,
489 // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius
490 // in accordance with shower profile the energy deposition
491 // should be less than 2%
493 AliEMCALDigit * digit ;
494 const Float_t kDeg2Rad = TMath::DegToRad() ;
498 if (!fLocPos.Mag()) {
499 EvalLocalPosition(logWeight, digits);
502 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
503 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
507 //fGeomPtr->PosInAlice(digit->GetId(), ieta, iphi);
508 fGeomPtr->EtaPhiFromIndex(digit->GetId(),ieta, iphi) ;
509 iphi = iphi * kDeg2Rad;
511 Float_t distance = TMath::Sqrt((ieta-fLocPos.X())*(ieta-fLocPos.X())+(iphi-fLocPos.Y())*(iphi-fLocPos.Y())) ;
512 if(distance < fCoreRadius)
513 fCoreEnergy += fEnergyList[iDigit] ;
517 //____________________________________________________________________________
518 void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
520 // Calculates the axis of the shower ellipsoid in eta and phi
529 const Float_t kDeg2Rad = TMath::DegToRad();
530 AliEMCALDigit * digit ;
532 TString gn(fGeomPtr->GetName());
536 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
537 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
540 if(gn.Contains("SHISH")) { // have to be change - Feb 28, 2006
541 //copied for shish-kebab geometry, ieta,iphi is cast as float as eta,phi conversion
542 // for this geometry does not exist
543 int nSupMod=0, nTower=0, nIphi=0, nIeta=0;
545 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nTower,nIphi,nIeta);
546 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi,ieta);
550 fGeomPtr->EtaPhiFromIndex(digit->GetId(), etai, phii);
551 phii = phii * kDeg2Rad;
554 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
556 dxx += w * etai * etai ;
558 dzz += w * phii * phii ;
561 dxz += w * etai * phii ;
576 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
578 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
582 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
584 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
585 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
593 // printf("Evalaxis: lambdas = %f,%f", fLambda[0],fLambda[1]) ;
597 //______________________________________________________________________________
598 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
600 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
602 AliEMCALDigit * digit ;
603 Int_t * tempo = new Int_t[fMaxTrack] ;
606 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
607 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
608 Int_t nprimaries = digit->GetNprimary() ;
609 if ( nprimaries == 0 ) continue ;
610 Int_t * newprimaryarray = new Int_t[nprimaries] ;
612 for ( ii = 0 ; ii < nprimaries ; ii++)
613 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
616 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
617 if ( fMulTrack > fMaxTrack ) {
618 fMulTrack = fMaxTrack ;
619 Error("GetNprimaries", "increase fMaxTrack ") ;
622 Int_t newprimary = newprimaryarray[jndex] ;
624 Bool_t already = kFALSE ;
625 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
626 if ( newprimary == tempo[kndex] ){
631 if ( !already && (fMulTrack < fMaxTrack)) { // store it
632 tempo[fMulTrack] = newprimary ;
635 } // all primaries in digit
636 delete [] newprimaryarray ;
640 fTracksList = new Int_t[fMulTrack] ;
641 for(index = 0; index < fMulTrack; index++)
642 fTracksList[index] = tempo[index] ;
648 //______________________________________________________________________________
649 void AliEMCALRecPoint::EvalParents(TClonesArray * digits)
651 // Constructs the list of parent particles (tracks) which have contributed to this RecPoint
653 AliEMCALDigit * digit ;
654 Int_t * tempo = new Int_t[fMaxParent] ;
657 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
658 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
659 Int_t nparents = digit->GetNiparent() ;
660 if ( nparents == 0 ) continue ;
661 Int_t * newparentarray = new Int_t[nparents] ;
663 for ( ii = 0 ; ii < nparents ; ii++)
664 newparentarray[ii] = digit->GetIparent(ii+1) ;
667 for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit
668 if ( fMulParent > fMaxParent ) {
670 Error("GetNiparent", "increase fMaxParent") ;
673 Int_t newparent = newparentarray[jndex] ;
675 Bool_t already = kFALSE ;
676 for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored
677 if ( newparent == tempo[kndex] ){
682 if ( !already && (fMulTrack < fMaxTrack)) { // store it
683 tempo[fMulParent] = newparent ;
686 } // all parents in digit
687 delete [] newparentarray ;
691 fParentsList = new Int_t[fMulParent] ;
692 for(index = 0; index < fMulParent; index++)
693 fParentsList[index] = tempo[index] ;
700 //____________________________________________________________________________
701 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
703 // returns the position of the cluster in the local reference system of ALICE
705 lpos.SetX(fLocPos.X()) ;
706 lpos.SetY(fLocPos.Y()) ;
707 lpos.SetZ(fLocPos.Z()) ;
710 //____________________________________________________________________________
711 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
713 // returns the position of the cluster in the global reference system of ALICE
714 // These are now the Cartesian X, Y and Z
715 // cout<<" geom "<<geom<<endl;
716 fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber);
719 //____________________________________________________________________________
720 Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const
722 // Finds the maximum energy in the cluster
724 Float_t menergy = 0. ;
728 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
730 if(fEnergyList[iDigit] > menergy)
731 menergy = fEnergyList[iDigit] ;
736 //____________________________________________________________________________
737 Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const
739 // Calculates the multiplicity of digits with energy larger than H*energy
743 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
745 if(fEnergyList[iDigit] > H * fAmp)
751 //____________________________________________________________________________
752 Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
753 Float_t locMaxCut,TClonesArray * digits) const
755 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
756 // energy difference between two local maxima
758 AliEMCALDigit * digit ;
759 AliEMCALDigit * digitN ;
764 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
765 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
767 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
769 digit = maxAt[iDigit] ;
771 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
772 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
774 if ( AreNeighbours(digit, digitN) ) {
775 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
777 // but may be digit too is not local max ?
778 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
783 // but may be digitN too is not local max ?
784 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
787 } // if Areneighbours
793 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
795 maxAt[iDigitN] = maxAt[iDigit] ;
796 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
803 //____________________________________________________________________________
804 Int_t AliEMCALRecPoint::GetPrimaryIndex() const
806 // Get the primary track index in TreeK which deposits the most energy
807 // in Digits which forms RecPoint. Kinematics, Hits and Digits must be
808 // loaded before the call of the method.
810 AliRunLoader *rl = AliRunLoader::GetRunLoader();
812 AliError(Form(" No Runloader ")) ;
814 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
815 (rl->GetDetectorLoader("EMCAL"));
817 // Get the list of digits forming this RecPoint
818 Int_t nDigits = fMulDigit ;
819 Int_t *digitList = fDigitsList ;
821 // Find the digit with maximum amplitude
822 AliEMCALDigit *digit = 0;
823 TClonesArray *digits = emcalLoader->Digits();
825 Int_t bestDigitIndex = -1;
826 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
827 digit = static_cast<AliEMCALDigit *>(digits->At(digitList[iDigit]));
828 if (digit->GetAmp() > maxAmp) {
829 maxAmp = digit->GetAmp();
830 bestDigitIndex = iDigit;
834 digit = static_cast<AliEMCALDigit *>(digits->At(digitList[bestDigitIndex]));
836 // Get the list of hits producing this digit,
837 // find which hit has deposited more energy
838 // and find the primary track.
840 AliEMCALHit *hit = 0;
841 TClonesArray *hits = emcalLoader->Hits();
843 Double_t maxedep = 0;
845 Int_t nHits = hits ->GetEntries();
846 Int_t id = digit->GetId();
847 for (Int_t iHit=0; iHit<nHits; iHit++) {
848 hit = static_cast<AliEMCALHit*> (hits->At(iHit)) ;
849 if(hit->GetId() == id){
850 Double_t edep = hit->GetEnergy();
851 Int_t track = hit->GetIparent();//Primary();
858 if (maxtrack != -1) return maxtrack;
859 return -12345; // no track found :(
862 //____________________________________________________________________________
863 void AliEMCALRecPoint::EvalTime(TClonesArray * digits){
864 // time is set to the time of the digit with the maximum energy
868 for(Int_t idig=0; idig < fMulDigit; idig++){
869 if(fEnergyList[idig] > maxE){
870 maxE = fEnergyList[idig] ;
874 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
878 //______________________________________________________________________________
879 void AliEMCALRecPoint::Paint(Option_t *)
881 // Paint this ALiRecPoint as a TMarker with its current attributes
883 TVector3 pos(0.,0.,0.) ;
884 GetLocalPosition(pos) ;
885 Coord_t x = pos.X() ;
886 Coord_t y = pos.Z() ;
887 Color_t markercolor = 1 ;
888 Size_t markersize = 1. ;
889 Style_t markerstyle = 5 ;
891 if (!gPad->IsBatch()) {
892 gVirtualX->SetMarkerColor(markercolor) ;
893 gVirtualX->SetMarkerSize (markersize) ;
894 gVirtualX->SetMarkerStyle(markerstyle) ;
896 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
897 gPad->PaintPolyMarker(1,&x,&y,"") ;
900 //______________________________________________________________________________
901 Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const
903 //Converts Theta (Radians) to Eta(Radians)
904 return (2.*TMath::ATan(TMath::Exp(-arg)));
907 //______________________________________________________________________________
908 Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const
910 //Converts Eta (Radians) to Theta(Radians)
911 return (-1 * TMath::Log(TMath::Tan(0.5 * arg)));
914 //____________________________________________________________________________
915 void AliEMCALRecPoint::Print(Option_t *) const
917 // Print the list of digits belonging to the cluster
920 message = "AliEMCALRecPoint:\n" ;
921 message += " digits # = " ;
922 Info("Print", message.Data()) ;
925 for(iDigit=0; iDigit<fMulDigit; iDigit++)
926 printf(" %d ", fDigitsList[iDigit] ) ;
929 Info("Print", " Energies = ") ;
930 for(iDigit=0; iDigit<fMulDigit; iDigit++)
931 printf(" %f ", fEnergyList[iDigit] ) ;
934 Info("Print", "\n Abs Ids = ") ;
935 for(iDigit=0; iDigit<fMulDigit; iDigit++)
936 printf(" %i ", fAbsIdList[iDigit] ) ;
939 Info("Print", " Primaries ") ;
940 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
941 printf(" %d ", fTracksList[iDigit]) ;
943 printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]);
945 message = " ClusterType = %d" ;
946 message += " Multiplicity = %d" ;
947 message += " Cluster Energy = %f" ;
948 message += " Core energy = %f" ;
949 message += " Core radius = %f" ;
950 message += " Number of primaries %d" ;
951 message += " Stored at position %d" ;
952 Info("Print", message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList() ) ;