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()
101 delete[] fEnergyList ;
105 delete[] fAbsIdList ;
107 delete[] fParentsList;
110 //____________________________________________________________________________
111 void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t Energy)
113 // Adds a digit to the RecPoint
114 // and accumulates the total amplitude and the multiplicity
117 fEnergyList = new Float_t[fMaxDigit];
119 fTimeList = new Float_t[fMaxDigit];
120 if(fAbsIdList == 0) {
121 fAbsIdList = new Int_t[fMaxDigit];
122 fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(digit.GetId());
125 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
127 Int_t * tempo = new Int_t[fMaxDigit];
128 Float_t * tempoE = new Float_t[fMaxDigit];
129 Float_t * tempoT = new Float_t[fMaxDigit];
130 Int_t * tempoId = new Int_t[fMaxDigit];
133 for ( index = 0 ; index < fMulDigit ; index++ ){
134 tempo[index] = fDigitsList[index] ;
135 tempoE[index] = fEnergyList[index] ;
136 tempoT[index] = fTimeList[index] ;
137 tempoId[index] = fAbsIdList[index] ;
140 delete [] fDigitsList ;
141 fDigitsList = new Int_t[fMaxDigit];
143 delete [] fEnergyList ;
144 fEnergyList = new Float_t[fMaxDigit];
146 delete [] fTimeList ;
147 fTimeList = new Float_t[fMaxDigit];
149 delete [] fAbsIdList ;
150 fAbsIdList = new Int_t[fMaxDigit];
152 for ( index = 0 ; index < fMulDigit ; index++ ){
153 fDigitsList[index] = tempo[index] ;
154 fEnergyList[index] = tempoE[index] ;
155 fTimeList[index] = tempoT[index] ;
156 fAbsIdList[index] = tempoId[index] ;
165 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
166 fEnergyList[fMulDigit] = Energy ;
167 fTimeList[fMulDigit] = digit.GetTime() ;
168 fAbsIdList[fMulDigit] = digit.GetId();
173 //____________________________________________________________________________
174 Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
176 // Tells if (true) or not (false) two digits are neighbours
177 // A neighbour is defined as being two digits which share a corner
179 static Bool_t areNeighbours = kFALSE ;
180 static Int_t nSupMod=0, nTower=0, nIphi=0, nIeta=0;
181 static int nSupMod1=0, nTower1=0, nIphi1=0, nIeta1=0;
182 static Int_t relid1[2] , relid2[2] ; // ieta, iphi
183 static Int_t rowdiff=0, coldiff=0;
185 areNeighbours = kFALSE ;
187 fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nTower,nIphi,nIeta);
188 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, relid1[0],relid1[1]);
190 fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nTower1,nIphi1,nIeta1);
191 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nTower1,nIphi1,nIeta1, relid2[0],relid2[1]);
193 rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ;
194 coldiff = TMath::Abs( relid1[1] - relid2[1] ) ;
196 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
197 areNeighbours = kTRUE ;
199 return areNeighbours;
202 //____________________________________________________________________________
203 Int_t AliEMCALRecPoint::Compare(const TObject * obj) const
205 // Compares two RecPoints according to their position in the EMCAL modules
207 Float_t delta = 1 ; //Width of "Sorting row". If you change this
208 //value (what is senseless) change as well delta in
209 //AliEMCALTrackSegmentMakerv* and other RecPoints...
212 AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ;
215 GetLocalPosition(locpos1);
217 clu->GetLocalPosition(locpos2);
219 Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ;
224 else if(locpos1.Y()>locpos2.Y())
232 //____________________________________________________________________________
233 Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
235 // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
236 // Compute the closest distance of approach from point px,py to this marker.
237 // The distance is computed in pixels units.
238 // HG Still need to update -> Not sure what this should achieve
240 TVector3 pos(0.,0.,0.) ;
241 GetLocalPosition(pos) ;
242 Float_t x = pos.X() ;
243 Float_t y = pos.Y() ;
244 const Int_t kMaxDiff = 10;
245 Int_t pxm = gPad->XtoAbsPixel(x);
246 Int_t pym = gPad->YtoAbsPixel(y);
247 Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
249 if (dist > kMaxDiff) return 9999;
253 //___________________________________________________________________________
254 void AliEMCALRecPoint::Draw(Option_t *option)
256 // Draw this AliEMCALRecPoint with its current attributes
261 //______________________________________________________________________________
262 void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t)
264 // Execute action corresponding to one event
265 // This member function is called when a AliEMCALRecPoint is clicked with the locator
267 // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
268 // and switched off when the mouse button is released.
270 // static Int_t pxold, pyold;
272 /* static TGraph * digitgraph = 0 ;
273 static TPaveText* clustertext = 0 ;
275 if (!gPad->IsEditable()) return;
281 AliEMCALDigit * digit ;
282 AliEMCALGeometry * emcalgeom = (AliEMCALGetter::Instance())->EMCALGeometry() ;
287 const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
288 Float_t * xi = new Float_t [kMulDigit] ;
289 Float_t * zi = new Float_t [kMulDigit] ;
291 for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
292 Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
293 digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
294 emcalgeom->AbsToRelNumbering(digit->GetId(), relid) ;
295 emcalgeom->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
299 digitgraph = new TGraph(fMulDigit,xi,zi);
300 digitgraph-> SetMarkerStyle(5) ;
301 digitgraph-> SetMarkerSize(1.) ;
302 digitgraph-> SetMarkerColor(1) ;
303 digitgraph-> Draw("P") ;
307 TVector3 pos(0.,0.,0.) ;
308 GetLocalPosition(pos) ;
309 clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
312 sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
313 sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
314 clustertext ->AddText(line1) ;
315 clustertext ->AddText(line2) ;
316 clustertext ->Draw("");
340 //____________________________________________________________________________
341 void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
343 // Evaluates all shower parameters
345 EvalLocalPosition(logWeight, digits) ;
346 // printf("eval position done\n");
347 EvalElipsAxis(logWeight, digits) ;
348 // printf("eval axis done\n");
349 EvalDispersion(logWeight, digits) ;
350 // printf("eval dispersion done\n");
351 //EvalCoreEnergy(logWeight, digits);
352 // printf("eval energy done\n");
354 // printf("eval time done\n");
356 EvalPrimaries(digits) ;
357 // printf("eval pri done\n");
359 // printf("eval parent done\n");
362 //____________________________________________________________________________
363 void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits)
365 // Calculates the dispersion of the shower at the origin of the RecPoint
367 Double_t d = 0., wtot = 0., w = 0., xyzi[3], diff=0.;
368 Int_t iDigit=0, nstat=0, i=0;
369 AliEMCALDigit * digit ;
371 // Calculates the centre of gravity in the local EMCAL-module coordinates
373 EvalLocalPosition(logWeight, digits) ;
375 // Calculates the dispersion in coordinates
376 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
377 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
379 fGeomPtr->RelPosCellInSModule(digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
380 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
385 for(i=0; i<3; i++ ) {
386 diff = xyzi[i] - double(fLocPos[i]);
392 if ( wtot > 0 && nstat>1) d /= wtot ;
395 fDispersion = TMath::Sqrt(d) ;
398 //____________________________________________________________________________
399 void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
401 // Calculates the center of gravity in the local EMCAL-module coordinates
402 // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
404 AliEMCALDigit * digit;
406 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
408 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
409 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
411 fGeomPtr->RelPosCellInSModule(digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
412 // printf(" Id %i : Local x,y,z %f %f %f \n", digit->GetId(), xyzi[0], xyzi[1], xyzi[2]);
414 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
415 else w = fEnergyList[iDigit]; // just energy
420 for(i=0; i<3; i++ ) {
421 clXYZ[i] += (w*xyzi[i]);
422 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
426 // cout << " wtot " << wtot << endl;
428 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
429 for(i=0; i<3; i++ ) {
432 clRmsXYZ[i] /= (wtot*wtot);
433 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
434 if(clRmsXYZ[i] > 0.0) {
435 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
436 } else clRmsXYZ[i] = 0;
437 } else clRmsXYZ[i] = 0;
440 for(i=0; i<3; i++ ) {
441 clXYZ[i] = clRmsXYZ[i] = -1.;
445 fLocPos.SetX(clXYZ[0]);
446 fLocPos.SetY(clXYZ[1]);
447 fLocPos.SetZ(clXYZ[2]);
450 // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
451 fLocPosM = 0 ; // covariance matrix
454 //void AliEMCALRecPoint::EvalLocalPositionSimple()
455 //{ // Weight is proportional of cell energy
458 //______________________________________________________________________________
459 void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
461 // This function calculates energy in the core,
462 // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius
463 // in accordance with shower profile the energy deposition
464 // should be less than 2%
466 AliEMCALDigit * digit ;
467 const Float_t kDeg2Rad = TMath::DegToRad() ;
471 if (!fLocPos.Mag()) {
472 EvalLocalPosition(logWeight, digits);
475 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
476 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
480 //fGeomPtr->PosInAlice(digit->GetId(), ieta, iphi);
481 fGeomPtr->EtaPhiFromIndex(digit->GetId(),ieta, iphi) ;
482 iphi = iphi * kDeg2Rad;
484 Float_t distance = TMath::Sqrt((ieta-fLocPos.X())*(ieta-fLocPos.X())+(iphi-fLocPos.Y())*(iphi-fLocPos.Y())) ;
485 if(distance < fCoreRadius)
486 fCoreEnergy += fEnergyList[iDigit] ;
490 //____________________________________________________________________________
491 void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
493 // Calculates the axis of the shower ellipsoid in eta and phi
502 const Float_t kDeg2Rad = TMath::DegToRad();
503 AliEMCALDigit * digit ;
505 TString gn(fGeomPtr->GetName());
509 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
510 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
513 if(gn.Contains("SHISH")) { // have to be change - Feb 28, 2006
514 //copied for shish-kebab geometry, ieta,iphi is cast as float as eta,phi conversion
515 // for this geometry does not exist
516 int nSupMod=0, nTower=0, nIphi=0, nIeta=0;
518 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nTower,nIphi,nIeta);
519 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi,ieta);
523 fGeomPtr->EtaPhiFromIndex(digit->GetId(), etai, phii);
524 phii = phii * kDeg2Rad;
527 Double_t w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
529 dxx += w * etai * etai ;
531 dzz += w * phii * phii ;
534 dxz += w * etai * phii ;
549 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
551 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
555 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
557 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
558 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
566 // printf("Evalaxis: lambdas = %f,%f", fLambda[0],fLambda[1]) ;
570 //______________________________________________________________________________
571 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
573 // Constructs the list of primary particles (tracks) which have contributed to this RecPoint
575 AliEMCALDigit * digit ;
576 Int_t * tempo = new Int_t[fMaxTrack] ;
579 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
580 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
581 Int_t nprimaries = digit->GetNprimary() ;
582 if ( nprimaries == 0 ) continue ;
583 Int_t * newprimaryarray = new Int_t[nprimaries] ;
585 for ( ii = 0 ; ii < nprimaries ; ii++)
586 newprimaryarray[ii] = digit->GetPrimary(ii+1) ;
589 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
590 if ( fMulTrack > fMaxTrack ) {
591 fMulTrack = fMaxTrack ;
592 Error("GetNprimaries", "increase fMaxTrack ") ;
595 Int_t newprimary = newprimaryarray[jndex] ;
597 Bool_t already = kFALSE ;
598 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
599 if ( newprimary == tempo[kndex] ){
604 if ( !already && (fMulTrack < fMaxTrack)) { // store it
605 tempo[fMulTrack] = newprimary ;
608 } // all primaries in digit
609 delete [] newprimaryarray ;
613 fTracksList = new Int_t[fMulTrack] ;
614 for(index = 0; index < fMulTrack; index++)
615 fTracksList[index] = tempo[index] ;
621 //______________________________________________________________________________
622 void AliEMCALRecPoint::EvalParents(TClonesArray * digits)
624 // Constructs the list of parent particles (tracks) which have contributed to this RecPoint
626 AliEMCALDigit * digit ;
627 Int_t * tempo = new Int_t[fMaxParent] ;
630 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
631 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
632 Int_t nparents = digit->GetNiparent() ;
633 if ( nparents == 0 ) continue ;
634 Int_t * newparentarray = new Int_t[nparents] ;
636 for ( ii = 0 ; ii < nparents ; ii++)
637 newparentarray[ii] = digit->GetIparent(ii+1) ;
640 for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit
641 if ( fMulParent > fMaxParent ) {
643 Error("GetNiparent", "increase fMaxParent") ;
646 Int_t newparent = newparentarray[jndex] ;
648 Bool_t already = kFALSE ;
649 for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored
650 if ( newparent == tempo[kndex] ){
655 if ( !already && (fMulTrack < fMaxTrack)) { // store it
656 tempo[fMulParent] = newparent ;
659 } // all parents in digit
660 delete [] newparentarray ;
664 fParentsList = new Int_t[fMulParent] ;
665 for(index = 0; index < fMulParent; index++)
666 fParentsList[index] = tempo[index] ;
673 //____________________________________________________________________________
674 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
676 // returns the position of the cluster in the local reference system of ALICE
678 lpos.SetX(fLocPos.X()) ;
679 lpos.SetY(fLocPos.Y()) ;
680 lpos.SetZ(fLocPos.Z()) ;
683 //____________________________________________________________________________
684 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
686 // returns the position of the cluster in the global reference system of ALICE
687 // These are now the Cartesian X, Y and Z
688 // cout<<" geom "<<geom<<endl;
689 fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber);
692 //____________________________________________________________________________
693 Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const
695 // Finds the maximum energy in the cluster
697 Float_t menergy = 0. ;
701 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
703 if(fEnergyList[iDigit] > menergy)
704 menergy = fEnergyList[iDigit] ;
709 //____________________________________________________________________________
710 Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const
712 // Calculates the multiplicity of digits with energy larger than H*energy
716 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
718 if(fEnergyList[iDigit] > H * fAmp)
724 //____________________________________________________________________________
725 Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
726 Float_t locMaxCut,TClonesArray * digits) const
728 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
729 // energy difference between two local maxima
731 AliEMCALDigit * digit ;
732 AliEMCALDigit * digitN ;
737 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
738 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
740 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
742 digit = maxAt[iDigit] ;
744 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
745 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
747 if ( AreNeighbours(digit, digitN) ) {
748 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
750 // but may be digit too is not local max ?
751 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
756 // but may be digitN too is not local max ?
757 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
760 } // if Areneighbours
766 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
768 maxAt[iDigitN] = maxAt[iDigit] ;
769 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
776 //____________________________________________________________________________
777 Int_t AliEMCALRecPoint::GetPrimaryIndex() const
779 // Get the primary track index in TreeK which deposits the most energy
780 // in Digits which forms RecPoint. Kinematics, Hits and Digits must be
781 // loaded before the call of the method.
783 AliRunLoader *rl = AliRunLoader::GetRunLoader();
785 AliError(Form(" No Runloader ")) ;
787 AliEMCALLoader *emcalLoader = dynamic_cast<AliEMCALLoader*>
788 (rl->GetDetectorLoader("EMCAL"));
790 // Get the list of digits forming this RecPoint
791 Int_t nDigits = fMulDigit ;
792 Int_t *digitList = fDigitsList ;
794 // Find the digit with maximum amplitude
795 AliEMCALDigit *digit = 0;
796 TClonesArray *digits = emcalLoader->Digits();
798 Int_t bestDigitIndex = -1;
799 for (Int_t iDigit=0; iDigit<nDigits; iDigit++) {
800 digit = static_cast<AliEMCALDigit *>(digits->At(digitList[iDigit]));
801 if (digit->GetAmp() > maxAmp) {
802 maxAmp = digit->GetAmp();
803 bestDigitIndex = iDigit;
807 digit = static_cast<AliEMCALDigit *>(digits->At(digitList[bestDigitIndex]));
809 // Get the list of hits producing this digit,
810 // find which hit has deposited more energy
811 // and find the primary track.
813 AliEMCALHit *hit = 0;
814 TClonesArray *hits = emcalLoader->Hits();
816 Double_t maxedep = 0;
818 Int_t nHits = hits ->GetEntries();
819 Int_t id = digit->GetId();
820 for (Int_t iHit=0; iHit<nHits; iHit++) {
821 hit = static_cast<AliEMCALHit*> (hits->At(iHit)) ;
822 if(hit->GetId() == id){
823 Double_t edep = hit->GetEnergy();
824 Int_t track = hit->GetIparent();//Primary();
831 if (maxtrack != -1) return maxtrack;
832 return -12345; // no track found :(
835 //____________________________________________________________________________
836 void AliEMCALRecPoint::EvalTime(TClonesArray * digits){
837 // time is set to the time of the digit with the maximum energy
841 for(Int_t idig=0; idig < fMulDigit; idig++){
842 if(fEnergyList[idig] > maxE){
843 maxE = fEnergyList[idig] ;
847 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
851 //______________________________________________________________________________
852 void AliEMCALRecPoint::Paint(Option_t *)
854 // Paint this ALiRecPoint as a TMarker with its current attributes
856 TVector3 pos(0.,0.,0.) ;
857 GetLocalPosition(pos) ;
858 Coord_t x = pos.X() ;
859 Coord_t y = pos.Z() ;
860 Color_t markercolor = 1 ;
861 Size_t markersize = 1. ;
862 Style_t markerstyle = 5 ;
864 if (!gPad->IsBatch()) {
865 gVirtualX->SetMarkerColor(markercolor) ;
866 gVirtualX->SetMarkerSize (markersize) ;
867 gVirtualX->SetMarkerStyle(markerstyle) ;
869 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
870 gPad->PaintPolyMarker(1,&x,&y,"") ;
873 //______________________________________________________________________________
874 Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const
876 //Converts Theta (Radians) to Eta(Radians)
877 return (2.*TMath::ATan(TMath::Exp(-arg)));
880 //______________________________________________________________________________
881 Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const
883 //Converts Eta (Radians) to Theta(Radians)
884 return (-1 * TMath::Log(TMath::Tan(0.5 * arg)));
887 //____________________________________________________________________________
888 void AliEMCALRecPoint::Print(Option_t *) const
890 // Print the list of digits belonging to the cluster
893 message = "AliEMCALRecPoint:\n" ;
894 message += " digits # = " ;
895 Info("Print", message.Data()) ;
898 for(iDigit=0; iDigit<fMulDigit; iDigit++)
899 printf(" %d ", fDigitsList[iDigit] ) ;
902 Info("Print", " Energies = ") ;
903 for(iDigit=0; iDigit<fMulDigit; iDigit++)
904 printf(" %f ", fEnergyList[iDigit] ) ;
907 Info("Print", "\n Abs Ids = ") ;
908 for(iDigit=0; iDigit<fMulDigit; iDigit++)
909 printf(" %i ", fAbsIdList[iDigit] ) ;
912 Info("Print", " Primaries ") ;
913 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
914 printf(" %d ", fTracksList[iDigit]) ;
916 printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]);
918 message = " ClusterType = %d" ;
919 message += " Multiplicity = %d" ;
920 message += " Cluster Energy = %f" ;
921 message += " Core energy = %f" ;
922 message += " Core radius = %f" ;
923 message += " Number of primaries %d" ;
924 message += " Stored at position %d" ;
925 Info("Print", message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList() ) ;