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
21 //*-- Author: Yves Schutz (SUBATECH)
22 //*-- Author: Dmitri Peressounko (RRC KI & SUBATECH)
23 //*-- Author: Heather Gray (LBL) merged AliEMCALRecPoint and AliEMCALTowerRecPoint 02/04
25 // --- ROOT system ---
28 #include "TPaveText.h"
29 #include "TClonesArray.h"
31 #include "TGeoMatrix.h"
32 #include "TGeoManager.h"
33 #include "TGeoPhysicalNode.h"
36 // --- Standard library ---
37 #include <Riostream.h>
39 // --- AliRoot header files ---
40 //#include "AliGenerator.h"
44 #include "AliGeomManager.h"
45 #include "AliEMCALGeometry.h"
46 #include "AliEMCALHit.h"
47 #include "AliEMCALDigit.h"
48 #include "AliEMCALRecPoint.h"
49 #include "AliCaloCalibPedestal.h"
50 #include "AliEMCALGeoParams.h"
52 ClassImp(AliEMCALRecPoint)
54 //____________________________________________________________________________
55 AliEMCALRecPoint::AliEMCALRecPoint()
56 : AliCluster(), fGeomPtr(0),
57 fAmp(0), fIndexInList(-1), //to be set when the point is already stored
58 fGlobPos(0,0,0),fLocPos(0,0,0),
59 fMaxDigit(100), fMulDigit(0), fMaxTrack(200),
60 fMulTrack(0), fDigitsList(0), fTracksList(0),
61 fClusterType(-1), fCoreEnergy(0), fDispersion(0),
62 fEnergyList(0), fTimeList(0), fAbsIdList(0),
63 fTime(0.), fNExMax(0), fCoreRadius(10), //HG check this
64 fDETracksList(0), fMulParent(0), fMaxParent(0),
65 fParentsList(0), fDEParentsList(0), fSuperModuleNumber(0),
66 fDigitIndMax(-1), fDistToBadTower(-1), fSharedCluster(kFALSE)
69 fGeomPtr = AliEMCALGeometry::GetInstance();
76 //____________________________________________________________________________
77 AliEMCALRecPoint::AliEMCALRecPoint(const char *)
78 : AliCluster(), fGeomPtr(0),
79 fAmp(0), fIndexInList(-1), //to be set when the point is already stored
80 fGlobPos(0,0,0), fLocPos(0,0,0),
81 fMaxDigit(100), fMulDigit(0), fMaxTrack(1000), fMulTrack(0),
82 fDigitsList(new Int_t[fMaxDigit]), fTracksList(new Int_t[fMaxTrack]),
83 fClusterType(-1), fCoreEnergy(0), fDispersion(0),
84 fEnergyList(new Float_t[fMaxDigit]), fTimeList(new Float_t[fMaxDigit]),
85 fAbsIdList(new Int_t[fMaxDigit]), fTime(-1.), fNExMax(0), fCoreRadius(10),
86 fDETracksList(new Float_t[fMaxTrack]), fMulParent(0), fMaxParent(1000),
87 fParentsList(new Int_t[fMaxParent]), fDEParentsList(new Float_t[fMaxParent]),
88 fSuperModuleNumber(0), fDigitIndMax(-1), fDistToBadTower(-1),fSharedCluster(kFALSE)
91 for (Int_t i = 0; i < fMaxTrack; i++)
93 for (Int_t i = 0; i < fMaxParent; i++) {
95 fDEParentsList[i] = 0;
98 fGeomPtr = AliEMCALGeometry::GetInstance();
103 //____________________________________________________________________________
104 AliEMCALRecPoint::AliEMCALRecPoint(const AliEMCALRecPoint & rp)
105 : AliCluster(rp), fGeomPtr(rp.fGeomPtr),
106 fAmp(rp.fAmp), fIndexInList(rp.fIndexInList),
107 fGlobPos(rp.fGlobPos),fLocPos(rp.fLocPos),
108 fMaxDigit(rp.fMaxDigit), fMulDigit(rp.fMulDigit),
109 fMaxTrack(rp.fMaxTrack), fMulTrack(rp.fMaxTrack),
110 fDigitsList(new Int_t[rp.fMaxDigit]), fTracksList(new Int_t[rp.fMaxTrack]),
111 fClusterType(rp.fClusterType), fCoreEnergy(rp.fCoreEnergy),
112 fDispersion(rp.fDispersion),
113 fEnergyList(new Float_t[rp.fMaxDigit]), fTimeList(new Float_t[rp.fMaxDigit]),
114 fAbsIdList(new Int_t[rp.fMaxDigit]), fTime(rp.fTime), fNExMax(rp.fNExMax),fCoreRadius(rp.fCoreRadius),
115 fDETracksList(new Float_t[rp.fMaxTrack]), fMulParent(rp.fMulParent),
116 fMaxParent(rp.fMaxParent), fParentsList(new Int_t[rp.fMaxParent]),
117 fDEParentsList(new Float_t[rp.fMaxParent]),
118 fSuperModuleNumber(rp.fSuperModuleNumber), fDigitIndMax(rp.fDigitIndMax),
119 fDistToBadTower(rp.fDistToBadTower), fSharedCluster(rp.fSharedCluster)
122 fLambda[0] = rp.fLambda[0];
123 fLambda[1] = rp.fLambda[1];
125 for(Int_t i = 0; i < rp.fMulDigit; i++) {
126 fEnergyList[i] = rp.fEnergyList[i];
127 fTimeList[i] = rp.fTimeList[i];
128 fAbsIdList[i] = rp.fAbsIdList[i];
131 for(Int_t i = 0; i < rp.fMulTrack; i++) fDETracksList[i] = rp.fDETracksList[i];
133 for(Int_t i = 0; i < rp.fMulParent; i++) {
134 fParentsList[i] = rp.fParentsList[i];
135 fDEParentsList[i] = rp.fDEParentsList[i];
139 //____________________________________________________________________________
140 AliEMCALRecPoint::~AliEMCALRecPoint()
144 delete[] fEnergyList ;
148 delete[] fAbsIdList ;
150 delete[] fDETracksList;
152 delete[] fParentsList;
154 delete[] fDEParentsList;
156 delete [] fDigitsList ;
157 delete [] fTracksList ;
160 //____________________________________________________________________________
161 AliEMCALRecPoint& AliEMCALRecPoint::operator= (const AliEMCALRecPoint &rp)
163 // assignment operator
165 if(&rp == this) return *this;
167 fGeomPtr = rp.fGeomPtr;
169 fIndexInList = rp.fIndexInList;
170 fGlobPos = rp.fGlobPos;
171 fLocPos = rp.fLocPos;
172 fMaxDigit = rp.fMaxDigit;
173 fMulDigit = rp.fMulDigit;
174 fMaxTrack = rp.fMaxTrack;
175 fMulTrack = rp.fMaxTrack;
176 for(Int_t i = 0; i<fMaxDigit; i++) fDigitsList[i] = rp.fDigitsList[i];
177 for(Int_t i = 0; i<fMaxTrack; i++) fTracksList[i] = rp.fTracksList[i];
178 fClusterType = rp.fClusterType;
179 fCoreEnergy = rp.fCoreEnergy;
180 fDispersion = rp.fDispersion;
181 for(Int_t i = 0; i<fMaxDigit; i++) {
182 fEnergyList[i] = rp.fEnergyList[i];
183 fTimeList[i] = rp.fTimeList[i];
184 fAbsIdList[i] = rp.fAbsIdList[i];
187 fNExMax = rp.fNExMax;
188 fCoreRadius = rp.fCoreRadius;
189 for(Int_t i = 0; i < fMaxTrack; i++) fDETracksList[i] = rp.fDETracksList[i];
190 fMulParent = rp.fMulParent;
191 fMaxParent = rp.fMaxParent;
192 for(Int_t i = 0; i < fMaxParent; i++) {
193 fParentsList[i] = rp.fParentsList[i];
194 fDEParentsList[i] = rp.fDEParentsList[i];
196 fSuperModuleNumber = rp.fSuperModuleNumber;
197 fDigitIndMax = rp.fDigitIndMax;
199 fLambda[0] = rp.fLambda[0];
200 fLambda[1] = rp.fLambda[1];
202 fDistToBadTower = rp.fDistToBadTower;
203 fSharedCluster = rp.fSharedCluster;
209 //____________________________________________________________________________
210 void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, Float_t energy, Bool_t shared)
212 // Adds a digit to the RecPoint
213 // and accumulates the total amplitude and the multiplicity
216 fEnergyList = new Float_t[fMaxDigit];
218 fTimeList = new Float_t[fMaxDigit];
219 if(fAbsIdList == 0) {
220 fAbsIdList = new Int_t[fMaxDigit];
223 if ( fMulDigit >= fMaxDigit ) { // increase the size of the lists
225 Int_t * tempo = new Int_t[fMaxDigit];
226 Float_t * tempoE = new Float_t[fMaxDigit];
227 Float_t * tempoT = new Float_t[fMaxDigit];
228 Int_t * tempoId = new Int_t[fMaxDigit];
231 for ( index = 0 ; index < fMulDigit ; index++ ){
232 tempo[index] = fDigitsList[index] ;
233 tempoE[index] = fEnergyList[index] ;
234 tempoT[index] = fTimeList[index] ;
235 tempoId[index] = fAbsIdList[index] ;
238 delete [] fDigitsList ;
239 delete [] fEnergyList ;
240 delete [] fTimeList ;
241 delete [] fAbsIdList ;
244 fEnergyList = tempoE;
246 fAbsIdList = tempoId;
249 fDigitsList[fMulDigit] = digit.GetIndexInList() ;
250 fEnergyList[fMulDigit] = energy ;
251 fTimeList[fMulDigit] = digit.GetTimeR() ;
252 fAbsIdList[fMulDigit] = digit.GetId();
256 if(shared) fSharedCluster = kTRUE;
258 //GCB, May-2010, setting moved to EvalAll method, set the super module number for the largest energy digit position.
259 //JLK 10-Oct-2007 this hasn't been filled before because it was in
260 //the wrong place in previous versions.
261 //Now we evaluate it only if the supermodulenumber for this recpoint
262 //has not yet been set (or is the 0th one)
263 //if(fSuperModuleNumber == 0)
264 //fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(digit.GetId());
267 //____________________________________________________________________________
268 Bool_t AliEMCALRecPoint::AreNeighbours(AliEMCALDigit * digit1, AliEMCALDigit * digit2 ) const
270 // Tells if (true) or not (false) two digits are neighbours
271 // A neighbour is defined as being two digits which share a corner
272 // ONLY USED IN CASE OF UNFOLDING
274 Bool_t areNeighbours = kFALSE ;
275 Int_t nSupMod=0, nModule=0, nIphi=0, nIeta=0;
276 Int_t nSupMod1=0, nModule1=0, nIphi1=0, nIeta1=0;
277 Int_t relid1[2] , relid2[2] ; // ieta, iphi
278 Int_t rowdiff=0, coldiff=0;
280 areNeighbours = kFALSE ;
282 fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nModule,nIphi,nIeta);
283 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, relid1[0],relid1[1]);
285 fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nModule1,nIphi1,nIeta1);
286 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, relid2[0],relid2[1]);
288 // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2-1
289 // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0
291 if(nSupMod1%2) relid1[1]+=AliEMCALGeoParams::fgkEMCALCols;
292 else relid2[1]+=AliEMCALGeoParams::fgkEMCALCols;
295 rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ;
296 coldiff = TMath::Abs( relid1[1] - relid2[1] ) ;
298 if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
299 areNeighbours = kTRUE ;
301 return areNeighbours;
304 //____________________________________________________________________________
305 Int_t AliEMCALRecPoint::Compare(const TObject * obj) const
307 // Compares two RecPoints according to their position in the EMCAL modules
309 Float_t delta = 1 ; //Width of "Sorting row".
313 AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ;
316 GetLocalPosition(locpos1);
318 clu->GetLocalPosition(locpos2);
320 Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ;
325 else if(locpos1.Y()>locpos2.Y())
333 // GCB, May-2010, Method not used, just comment it but remove?
334 //____________________________________________________________________________
335 //Int_t AliEMCALRecPoint::DistancetoPrimitive(Int_t px, Int_t py)
337 // // Compute distance from point px,py to a AliEMCALRecPoint considered as a Tmarker
338 // // Compute the closest distance of approach from point px,py to this marker.
339 // // The distance is computed in pixels units.
340 // // HG Still need to update -> Not sure what this should achieve
342 // TVector3 pos(0.,0.,0.) ;
343 // GetLocalPosition(pos) ;
344 // Float_t x = pos.X() ;
345 // Float_t y = pos.Y() ;
346 // const Int_t kMaxDiff = 10;
347 // Int_t pxm = gPad->XtoAbsPixel(x);
348 // Int_t pym = gPad->YtoAbsPixel(y);
349 // Int_t dist = (px-pxm)*(px-pxm) + (py-pym)*(py-pym);
351 // if (dist > kMaxDiff) return 9999;
355 //___________________________________________________________________________
356 void AliEMCALRecPoint::Draw(Option_t *option)
358 // Draw this AliEMCALRecPoint with its current attributes
363 // GCB, May-2010, Method not used, just comment it but remove?
364 //______________________________________________________________________________
365 //void AliEMCALRecPoint::ExecuteEvent(Int_t /*event*/, Int_t, Int_t)
367 // // Execute action corresponding to one event
368 // // This member function is called when a AliEMCALRecPoint is clicked with the locator
370 // // If Left button is clicked on AliEMCALRecPoint, the digits are switched on
371 // // and switched off when the mouse button is released.
373 // // static Int_t pxold, pyold;
375 // /* static TGraph * digitgraph = 0 ;
376 // static TPaveText* clustertext = 0 ;
378 // if (!gPad->IsEditable()) return;
383 // case kButton1Down:{
384 // AliEMCALDigit * digit ;
389 // const Int_t kMulDigit=AliEMCALRecPoint::GetDigitsMultiplicity() ;
390 // Float_t * xi = new Float_t [kMulDigit] ;
391 // Float_t * zi = new Float_t [kMulDigit] ;
393 // for(iDigit = 0; iDigit < kMulDigit; iDigit++) {
394 // Fatal("AliEMCALRecPoint::ExecuteEvent", " -> Something wrong with the code");
395 // digit = 0 ; //dynamic_cast<AliEMCALDigit *>((fDigitsList)[iDigit]);
396 // fGeomPtr->AbsToRelNumbering(digit->GetId(), relid) ;
397 // fGeomPtr->PosInAlice(relid, xi[iDigit], zi[iDigit]) ;
400 // if (!digitgraph) {
401 // digitgraph = new TGraph(fMulDigit,xi,zi);
402 // digitgraph-> SetMarkerStyle(5) ;
403 // digitgraph-> SetMarkerSize(1.) ;
404 // digitgraph-> SetMarkerColor(1) ;
405 // digitgraph-> Draw("P") ;
407 // if (!clustertext) {
409 // TVector3 pos(0.,0.,0.) ;
410 // GetLocalPosition(pos) ;
411 // clustertext = new TPaveText(pos.X()-10,pos.Z()+10,pos.X()+50,pos.Z()+35,"") ;
412 // Text_t line1[40] ;
413 // Text_t line2[40] ;
414 // sprintf(line1,"Energy=%1.2f GeV",GetEnergy()) ;
415 // sprintf(line2,"%d Digits",GetDigitsMultiplicity()) ;
416 // clustertext ->AddText(line1) ;
417 // clustertext ->AddText(line2) ;
418 // clustertext ->Draw("");
430 // delete digitgraph ;
433 // if (clustertext) {
434 // delete clustertext ;
443 //____________________________________________________________________________
444 void AliEMCALRecPoint::EvalAll(Float_t logWeight,TClonesArray * digits)
446 // Evaluates cluster parameters
448 // First calculate the index of digit with maximum amplitude and get
449 // the supermodule number where it sits.
451 fDigitIndMax = GetMaximalEnergyIndex();
452 fSuperModuleNumber = fGeomPtr->GetSuperModuleNumber(GetAbsIdMaxDigit());
454 //Evaluate global and local position
455 EvalGlobalPosition(logWeight, digits) ;
456 EvalLocalPosition(logWeight, digits) ;
458 //Evaluate shower parameters
459 EvalElipsAxis(logWeight, digits) ;
460 EvalDispersion(logWeight, digits) ;
462 //EvalCoreEnergy(logWeight, digits);
464 EvalPrimaries(digits) ;
467 //Called last because it sets the global position of the cluster?
468 EvalLocal2TrackingCSTransform();
472 //____________________________________________________________________________
473 void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits)
475 // Calculates the dispersion of the shower at the origin of the RecPoint
476 // in cell units - Nov 16,2006
478 Double_t d = 0., wtot = 0., w = 0.;
479 Int_t iDigit=0, nstat=0;
480 AliEMCALDigit * digit=0;
482 // Calculates the dispersion in cell units
483 Double_t etai, phii, etaMean=0.0, phiMean=0.0;
484 int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
486 // Calculate mean values
487 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
488 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
490 if (fAmp>0 && fEnergyList[iDigit]>0) {
491 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
492 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
494 // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
495 // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0
496 if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
500 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
512 } else AliError(Form("Wrong weight %f\n", wtot));
514 // Calculate dispersion
515 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
516 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
518 if (fAmp>0 && fEnergyList[iDigit]>0) {
519 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
520 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
522 // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
523 // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
524 if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
528 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
532 d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean));
537 if ( wtot > 0 && nstat>1) d /= wtot ;
540 fDispersion = TMath::Sqrt(d) ;
541 //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",fDispersion);
544 //____________________________________________________________________________
545 void AliEMCALRecPoint::EvalDistanceToBadChannels(AliCaloCalibPedestal* caloped)
547 //For each EMC rec. point set the distance to the nearest bad channel.
548 //AliInfo(Form("%d bad channel(s) found.\n", caloped->GetDeadTowerCount()));
549 //It is done in cell units and not in global or local position as before (Sept 2010)
551 if(!caloped->GetDeadTowerCount()) return;
553 //Get channels map of the supermodule where the cluster is.
554 TH2D* hMap = caloped->GetDeadMap(fSuperModuleNumber);
557 Float_t minDist = 10000.;
559 Int_t nSupMod, nModule;
562 fDigitIndMax = GetMaximalEnergyIndex();
563 fGeomPtr->GetCellIndex(fAbsIdList[fDigitIndMax], nSupMod,nModule,nIphi,nIeta);
564 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
568 // Float_t minDist = 100000;
572 //Loop on tower status map
573 for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
574 for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
575 //Check if tower is bad.
576 if(hMap->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue;
577 //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow);
579 dRrow=TMath::Abs(irow-iphi);
580 dReta=TMath::Abs(icol-ieta);
581 dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta);
582 if(dist < minDist) minDist = dist;
584 // //Tower is bad, get the absId of the index.
585 // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(fSuperModuleNumber, irow, icol);
587 // //Get the position of this tower.
589 // //Calculate the distance in local coordinates
590 // //fGeomPtr->RelPosCellInSModule(absId,cellpos);
591 // //Calculate distance between this tower and cluster, set if is smaller than previous.
592 // //dR = cellpos-fLocPos;
594 // //Calculate the distance in global coordinates
595 // fGeomPtr->GetGlobal(absId,cellpos);
596 // //Calculate distance between this tower and cluster, set if it is smaller than previous.
597 // dR = cellpos-fGlobPos;
600 // if(dist < minDist) minDist = dist;
605 //In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module
606 if (fSharedCluster) {
610 //The only possible combinations are (0,1), (2,3) ... (10,11)
611 if(fSuperModuleNumber%2) nSupMod2 = fSuperModuleNumber-1;
612 else nSupMod2 = fSuperModuleNumber+1;
613 hMap2 = caloped->GetDeadMap(nSupMod2);
615 //Loop on tower status map of second super module
616 for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++){
617 for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++){
618 //Check if tower is bad.
619 if(hMap2->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue;
620 //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow);
622 dRrow=TMath::Abs(irow-iphi);
624 if(fSuperModuleNumber%2) {
625 dReta=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+ieta));
628 dReta=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-ieta);
631 dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta);
632 if(dist < minDist) minDist = dist;
635 // //Tower is bad, get the absId of the index.
636 // absId = fGeomPtr->GetAbsCellIdFromCellIndexes(nSupMod2, irow, icol);
638 // //Get the position of this tower.
640 // //Calculate the distance in global coordinates
641 // fGeomPtr->GetGlobal(absId,cellpos);
642 // //Calculate distance between this tower and cluster, set if it is smaller than previous.
643 // dR = cellpos-fGlobPos;
646 // if(dist < minDist) minDist = dist;
650 }// shared cluster in 2 SuperModules
652 fDistToBadTower = minDist;
653 //printf("AliEMCALRecPoint::EvalDistanceToBadChannel() - Distance to Bad is %f cm, shared cluster? %d \n",fDistToBadTower,fSharedCluster);
657 //____________________________________________________________________________
658 void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
660 // Calculates the center of gravity in the local EMCAL-module coordinates
661 // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
663 AliEMCALDigit * digit=0;
666 Double_t dist = TmaxInCm(Double_t(fAmp));
667 //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
669 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
671 //printf(" dist : %f e : %f \n", dist, fAmp);
672 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
673 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
676 AliError("No Digit!!");
680 //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
681 fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
683 //Temporal patch, due to mapping problem, need to swap "y" in one of the 2 SM, although no effect in position calculation. GCB 05/2010
684 if(fSharedCluster && fSuperModuleNumber != fGeomPtr->GetSuperModuleNumber(digit->GetId())) xyzi[1]*=-1;
686 //printf("EvalLocalPosition Cell: Id %i, SM %i : dist %f Local x,y,z %f %f %f \n",
687 // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()), dist, xyzi[0], xyzi[1], xyzi[2]);
689 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
690 else w = fEnergyList[iDigit]; // just energy
695 for(i=0; i<3; i++ ) {
696 clXYZ[i] += (w*xyzi[i]);
697 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
701 // cout << " wtot " << wtot << endl;
703 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
704 for(i=0; i<3; i++ ) {
707 clRmsXYZ[i] /= (wtot*wtot);
708 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
709 if(clRmsXYZ[i] > 0.0) {
710 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
711 } else clRmsXYZ[i] = 0;
712 } else clRmsXYZ[i] = 0;
715 for(i=0; i<3; i++ ) {
716 clXYZ[i] = clRmsXYZ[i] = -1.;
721 // // Cluster of one single digit, smear the position to avoid discrete position
722 // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm.
723 // // Rndm generates a number in ]0,1]
724 // if (fMulDigit==1) {
725 // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm());
726 // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm());
729 //Set position in local vector
730 fLocPos.SetX(clXYZ[0]);
731 fLocPos.SetY(clXYZ[1]);
732 fLocPos.SetZ(clXYZ[2]);
735 printf("EvalLocalPosition Cluster: Local (x,y,z) = (%f,%f,%f) \n", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
740 //____________________________________________________________________________
741 void AliEMCALRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits)
743 // Calculates the center of gravity in the global ALICE coordinates
744 // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
746 AliEMCALDigit * digit=0;
749 Double_t dist = TmaxInCm(Double_t(fAmp));
750 //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
752 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, lxyzi[3], xyzi[3], wtot=0., w=0.;
754 //printf(" dist : %f e : %f \n", dist, fAmp);
755 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
756 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
759 AliError("No Digit!!");
763 //Get the local coordinates of the cell
764 //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, lxyzi[0], lxyzi[1], lxyzi[2]);
765 fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, lxyzi[0], lxyzi[1], lxyzi[2]);
767 //Now get the global coordinate
768 fGeomPtr->GetGlobal(lxyzi,xyzi, fGeomPtr->GetSuperModuleNumber(digit->GetId()));
769 //TVector3 pos(xyzi[0], xyzi[1], xyzi[2]);
770 //printf("EvalGlobalPosition Cell: Id %i, SM %i : dist %f Local (x,y,z) = (%f %f %f), eta %f, phi%f \n",
771 // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()),dist, xyzi[0], xyzi[1], xyzi[2],pos.Eta(),pos.Phi()*TMath::RadToDeg());
773 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
774 else w = fEnergyList[iDigit]; // just energy
779 for(i=0; i<3; i++ ) {
780 clXYZ[i] += (w*xyzi[i]);
781 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
785 // cout << " wtot " << wtot << endl;
787 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
788 for(i=0; i<3; i++ ) {
791 clRmsXYZ[i] /= (wtot*wtot);
792 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
793 if(clRmsXYZ[i] > 0.0) {
794 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
795 } else clRmsXYZ[i] = 0;
796 } else clRmsXYZ[i] = 0;
799 for(i=0; i<3; i++ ) {
800 clXYZ[i] = clRmsXYZ[i] = -1.;
805 // // Cluster of one single digit, smear the position to avoid discrete position
806 // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm.
807 // // Rndm generates a number in ]0,1]
808 // if (fMulDigit==1) {
809 // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm());
810 // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm());
813 //Set position in global vector
814 fGlobPos.SetX(clXYZ[0]);
815 fGlobPos.SetY(clXYZ[1]);
816 fGlobPos.SetZ(clXYZ[2]);
819 printf("EvalGlobalPosition Cluster: (x ,y ,z) = (%f,%f,%f), eta %f,phi %f\n",
820 fGlobPos.X(), fGlobPos.Y(), fGlobPos.Z(),fGlobPos.Eta(),fGlobPos.Phi()*TMath::RadToDeg()) ;
823 //____________________________________________________________________________
824 void AliEMCALRecPoint::EvalLocalPositionFit(Double_t deff, Double_t logWeight,
825 Double_t phiSlope, TClonesArray * digits)
827 // Evaluates local position of clusters in SM
830 AliEMCALDigit *digit=0;
832 Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
834 Double_t dist = TmaxInCm(Double_t(fAmp));
835 //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
837 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
838 digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
841 //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
842 fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
844 if(logWeight > 0.0) w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
845 else w = fEnergyList[iDigit]; // just energy
850 for(i=0; i<3; i++ ) {
851 clXYZ[i] += (w*xyzi[i]);
852 clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
855 }else AliError("Digit null");
857 // cout << " wtot " << wtot << endl;
859 // xRMS = TMath::Sqrt(x2m - xMean*xMean);
860 for(i=0; i<3; i++ ) {
863 clRmsXYZ[i] /= (wtot*wtot);
864 clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
865 if(clRmsXYZ[i] > 0.0) {
866 clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
867 } else clRmsXYZ[i] = 0;
868 } else clRmsXYZ[i] = 0;
871 for(i=0; i<3; i++ ) {
872 clXYZ[i] = clRmsXYZ[i] = -1.;
876 if(phiSlope != 0.0 && logWeight > 0.0 && wtot) {
877 // Correction in phi direction (y - coords here); Aug 16;
878 // May be put to global level or seperate method
879 ycorr = clXYZ[1] * (1. + phiSlope);
880 //printf(" y %f : ycorr %f : slope %f \n", clXYZ[1], ycorr, phiSlope);
884 fLocPos.SetX(clXYZ[0]);
885 fLocPos.SetY(clXYZ[1]);
886 fLocPos.SetZ(clXYZ[2]);
889 // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
892 //_____________________________________________________________________________
893 Bool_t AliEMCALRecPoint::EvalLocalPosition2(TClonesArray * digits, TArrayD &ed)
895 // Evaluated local position of rec.point using digits
896 // and parametrisation of w0 and deff
897 //printf(" <I> AliEMCALRecPoint::EvalLocalPosition2() \n");
898 return AliEMCALRecPoint::EvalLocalPositionFromDigits(digits, ed, fLocPos);
901 //_____________________________________________________________________________
902 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
904 // Used when digits should be recalibrated
905 Double_t deff=0, w0=0, esum=0;
907 // AliEMCALDigit *digit;
909 if(ed.GetSize() && (digits->GetEntries()!=ed.GetSize())) return kFALSE;
911 // Calculate sum energy of digits
913 for(iDigit=0; iDigit<ed.GetSize(); iDigit++) esum += ed[iDigit];
915 GetDeffW0(esum, deff, w0);
917 return EvalLocalPositionFromDigits(esum, deff, w0, digits, ed, locPos);
920 //_____________________________________________________________________________
921 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff, const Double_t w0, TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
923 //Evaluate position of digits in supermodule.
924 AliEMCALDigit *digit=0;
927 Double_t clXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
928 //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
930 // Get pointer to EMCAL geometry
931 // (can't use fGeomPtr in static method)
932 AliEMCALGeometry* geo = AliEMCALGeometry::GetInstance();
934 for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++) {
935 digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit));
937 //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]);
938 geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]);
940 if(w0 > 0.0) w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum));
941 else w = ed[iDigit]; // just energy
946 for(i=0; i<3; i++ ) {
947 clXYZ[i] += (w*xyzi[i]);
950 }else AliError("Digit null");
952 // cout << " wtot " << wtot << endl;
954 for(i=0; i<3; i++ ) {
957 locPos.SetX(clXYZ[0]);
958 locPos.SetY(clXYZ[1]);
959 locPos.SetZ(clXYZ[2]);
967 //_____________________________________________________________________________
968 void AliEMCALRecPoint::GetDeffW0(const Double_t esum , Double_t &deff, Double_t &w0)
972 // Applied for simulation data with threshold 3 adc
973 // Calculate efective distance (deff) and weigh parameter (w0)
974 // for coordinate calculation; 0.5 GeV < esum <100 GeV.
975 // Look to: http://rhic.physics.wayne.edu/~pavlinov/ALICE/SHISHKEBAB/RES/CALIB/GEOMCORR/deffandW0VaEgamma_2.gif
978 const Double_t kdp0=9.25147, kdp1=1.16700; // Hard coded now
979 const Double_t kwp0=4.83713, kwp1=-2.77970e-01, kwp2 = 4.41116;
981 // No extrapolation here
982 e = esum<0.5?0.5:esum;
985 deff = kdp0 + kdp1*TMath::Log(e);
986 w0 = kwp0 / (1. + TMath::Exp(kwp1*(e+kwp2)));
987 //printf("<I> AliEMCALRecPoint::GetDeffW0 esum %5.2f : deff %5.2f : w0 %5.2f \n", esum, deff, w0);
990 //______________________________________________________________________________
991 void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
993 // This function calculates energy in the core,
994 // i.e. within a radius rad = fCoreEnergy around the center. Beyond this radius
995 // in accordance with shower profile the energy deposition
996 // should be less than 2%
997 // Unfinished - Nov 15,2006
998 // Distance is calculate in (phi,eta) units
1000 AliEMCALDigit * digit = 0 ;
1004 if (!fLocPos.Mag()) {
1005 EvalLocalPosition(logWeight, digits);
1008 Double_t phiPoint = fLocPos.Phi(), etaPoint = fLocPos.Eta();
1009 Double_t eta, phi, distance;
1010 for(iDigit=0; iDigit < fMulDigit; iDigit++) {
1011 digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
1014 fGeomPtr->EtaPhiFromIndex(digit->GetId(),eta, phi) ;
1015 phi = phi * TMath::DegToRad();
1017 distance = TMath::Sqrt((eta-etaPoint)*(eta-etaPoint)+(phi-phiPoint)*(phi-phiPoint));
1018 if(distance < fCoreRadius)
1019 fCoreEnergy += fEnergyList[iDigit] ;
1023 //____________________________________________________________________________
1024 void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
1026 // Calculates the axis of the shower ellipsoid in eta and phi
1029 TString gn(fGeomPtr->GetName());
1038 AliEMCALDigit * digit = 0;
1040 Double_t etai =0, phii=0, w=0;
1041 int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
1043 for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++) {
1044 digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
1046 // Nov 15,2006 - use cell numbers as coordinates
1047 // Copied for shish-kebab geometry, ieta,iphi is cast as double as eta,phi
1048 // We can use the eta,phi(or coordinates) of cell
1049 nSupMod = nModule = nIphi = nIeta = iphi = ieta = 0;
1051 fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
1052 fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
1054 // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
1055 // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
1056 if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
1058 etai=(Double_t)ieta;
1059 phii=(Double_t)iphi;
1061 w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
1062 // fAmp summed amplitude of digits, i.e. energy of recpoint
1063 // Gives smaller value of lambda than log weight
1064 // w = fEnergyList[iDigit] / fAmp; // Nov 16, 2006 - try just energy
1066 dxx += w * etai * etai ;
1068 dzz += w * phii * phii ;
1071 dxz += w * etai * phii ;
1086 fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
1088 fLambda[0] = TMath::Sqrt(fLambda[0]) ;
1092 fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
1094 if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
1095 fLambda[1] = TMath::Sqrt(fLambda[1]) ;
1103 //printf("AliEMCALRecPoint::EvalElipsAxis() lambdas = %f,%f \n", fLambda[0],fLambda[1]) ;
1107 //______________________________________________________________________________
1108 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
1110 // Constructs the list of primary particles (tracks) which
1111 // have contributed to this RecPoint and calculate deposited energy
1114 AliEMCALDigit * digit =0;
1115 Int_t * primArray = new Int_t[fMaxTrack] ;
1116 memset(primArray,-1,sizeof(Int_t)*fMaxTrack);
1117 Float_t * dEPrimArray = new Float_t[fMaxTrack] ;
1118 memset(dEPrimArray,-1,sizeof(Int_t)*fMaxTrack);
1121 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
1122 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
1124 AliError("No Digit!!");
1128 Int_t nprimaries = digit->GetNprimary() ;
1129 if ( nprimaries == 0 ) continue ;
1131 for ( jndex = 0 ; jndex < nprimaries ; jndex++ ) { // all primaries in digit
1132 if ( fMulTrack > fMaxTrack ) {
1133 fMulTrack = fMaxTrack ;
1134 Error("EvalPrimaries", "increase fMaxTrack ") ;
1137 Int_t newPrimary = digit->GetPrimary(jndex+1);
1138 Float_t dEPrimary = digit->GetDEPrimary(jndex+1);
1140 Bool_t already = kFALSE ;
1141 for ( kndex = 0 ; kndex < fMulTrack ; kndex++ ) { //check if not already stored
1142 if ( newPrimary == primArray[kndex] ){
1144 dEPrimArray[kndex] += dEPrimary;
1148 if ( !already && (fMulTrack < fMaxTrack)) { // store it
1149 primArray[fMulTrack] = newPrimary ;
1150 dEPrimArray[fMulTrack] = dEPrimary ;
1153 } // all primaries in digit
1156 Int_t *sortIdx = new Int_t[fMulTrack];
1157 TMath::Sort(fMulTrack,dEPrimArray,sortIdx);
1158 for(index = 0; index < fMulTrack; index++) {
1159 fTracksList[index] = primArray[sortIdx[index]] ;
1160 fDETracksList[index] = dEPrimArray[sortIdx[index]] ;
1163 delete [] primArray ;
1164 delete [] dEPrimArray ;
1168 //______________________________________________________________________________
1169 void AliEMCALRecPoint::EvalParents(TClonesArray * digits)
1171 // Constructs the list of parent particles (tracks) which have contributed to this RecPoint
1173 AliEMCALDigit * digit=0 ;
1174 Int_t * parentArray = new Int_t[fMaxTrack] ;
1175 memset(parentArray,-1,sizeof(Int_t)*fMaxTrack);
1176 Float_t * dEParentArray = new Float_t[fMaxTrack] ;
1177 memset(dEParentArray,-1,sizeof(Int_t)*fMaxTrack);
1180 for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ ) { // all digits
1181 if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0)
1182 AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index));
1183 digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
1185 AliError("No Digit!!");
1189 Int_t nparents = digit->GetNiparent() ;
1190 if ( nparents == 0 ) continue ;
1193 for ( jndex = 0 ; jndex < nparents ; jndex++ ) { // all primaries in digit
1194 if ( fMulParent > fMaxParent ) {
1196 Error("EvalParents", "increase fMaxParent") ;
1199 Int_t newParent = digit->GetIparent(jndex+1) ;
1200 Float_t newdEParent = digit->GetDEParent(jndex+1) ;
1202 Bool_t already = kFALSE ;
1203 for ( kndex = 0 ; kndex < fMulParent ; kndex++ ) { //check if not already stored
1204 if ( newParent == parentArray[kndex] ){
1205 dEParentArray[kndex] += newdEParent;
1210 if ( !already && (fMulParent < fMaxParent)) { // store it
1211 parentArray[fMulParent] = newParent ;
1212 dEParentArray[fMulParent] = newdEParent ;
1215 } // all parents in digit
1219 Int_t *sortIdx = new Int_t[fMulParent];
1220 TMath::Sort(fMulParent,dEParentArray,sortIdx);
1221 for(index = 0; index < fMulParent; index++) {
1222 fParentsList[index] = parentArray[sortIdx[index]] ;
1223 fDEParentsList[index] = dEParentArray[sortIdx[index]] ;
1228 delete [] parentArray;
1229 delete [] dEParentArray;
1232 //____________________________________________________________________________
1233 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
1235 // returns the position of the cluster in the local reference system
1236 // of the sub-detector
1241 //____________________________________________________________________________
1242 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
1244 // returns the position of the cluster in the global reference system of ALICE
1245 // These are now the Cartesian X, Y and Z
1246 // cout<<" geom "<<geom<<endl;
1247 // fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber);
1252 //____________________________________________________________________________
1253 //void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
1255 // // returns the position of the cluster in the global reference system of ALICE
1256 // // These are now the Cartesian X, Y and Z
1257 // // cout<<" geom "<<geom<<endl;
1259 // //To be implemented
1260 // fGeomPtr->GetGlobalEMCAL(this, gpos, gmat);
1264 //_____________________________________________________________________________
1265 void AliEMCALRecPoint::EvalLocal2TrackingCSTransform()
1267 //Evaluates local to "tracking" c.s. transformation (B.P.).
1268 //All evaluations should be completed before calling for this
1270 //See ALICE PPR Chapter 5 p.18 for "tracking" c.s. definition,
1271 //or just ask Jouri Belikov. :)
1273 SetVolumeId(AliGeomManager::LayerToVolUID(AliGeomManager::kEMCAL,GetSuperModuleNumber()));
1275 const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix();
1276 if(!tr2loc) AliFatal(Form("No Tracking2LocalMatrix found."));
1278 Double_t lxyz[3] = {fLocPos.X(),fLocPos.Y(),fLocPos.Z()};
1279 Double_t txyz[3] = {0,0,0};
1281 tr2loc->MasterToLocal(lxyz,txyz);
1282 SetX(txyz[0]); SetY(txyz[1]); SetZ(txyz[2]);
1284 if(AliLog::GetGlobalDebugLevel()>0) {
1285 TVector3 gpos; //TMatrixF gmat;
1286 //GetGlobalPosition(gpos,gmat); //Not doing anythin special, replace by next line.
1287 fGeomPtr->GetGlobal(fLocPos, gpos, GetSuperModuleNumber());
1291 AliInfo(Form("lCS-->(%.3f,%.3f,%.3f), tCS-->(%.3f,%.3f,%.3f), gCS-->(%.3f,%.3f,%.3f), gCScalc-\
1292 ->(%.3f,%.3f,%.3f), supermodule %d",
1293 fLocPos.X(),fLocPos.Y(),fLocPos.Z(),
1294 GetX(),GetY(),GetZ(),
1295 gpos.X(),gpos.Y(),gpos.Z(),
1296 gxyz[0],gxyz[1],gxyz[2],GetSuperModuleNumber()));
1301 //____________________________________________________________________________
1302 Float_t AliEMCALRecPoint::GetMaximalEnergy(void) const
1304 // Finds the maximum energy in the cluster
1306 Float_t menergy = 0. ;
1309 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
1311 if(fEnergyList[iDigit] > menergy)
1312 menergy = fEnergyList[iDigit] ;
1317 //____________________________________________________________________________
1318 Int_t AliEMCALRecPoint::GetMaximalEnergyIndex(void) const
1320 // Finds the maximum energy in the cluster
1322 Float_t menergy = 0. ;
1326 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
1328 if(fEnergyList[iDigit] > menergy){
1329 menergy = fEnergyList[iDigit] ;
1332 }//loop on cluster digits
1338 //____________________________________________________________________________
1339 Int_t AliEMCALRecPoint::GetMultiplicityAtLevel(Float_t H) const
1341 // Calculates the multiplicity of digits with energy larger than H*energy
1345 for(iDigit=0; iDigit<fMulDigit; iDigit++) {
1347 if(fEnergyList[iDigit] > H * fAmp)
1353 //____________________________________________________________________________
1354 Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
1355 Float_t locMaxCut,TClonesArray * digits) const
1357 // Calculates the number of local maxima in the cluster using fLocalMaxCut as the minimum
1358 // energy difference between two local maxima
1360 AliEMCALDigit * digit = 0;
1361 AliEMCALDigit * digitN = 0;
1366 for(iDigit = 0; iDigit < fMulDigit; iDigit++)
1367 maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
1369 for(iDigit = 0 ; iDigit < fMulDigit; iDigit++) {
1371 digit = maxAt[iDigit] ;
1373 for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++) {
1374 digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
1376 if ( AreNeighbours(digit, digitN) ) {
1377 if (fEnergyList[iDigit] > fEnergyList[iDigitN] ) {
1378 maxAt[iDigitN] = 0 ;
1379 // but may be digit too is not local max ?
1380 if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
1385 // but may be digitN too is not local max ?
1386 if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
1387 maxAt[iDigitN] = 0 ;
1389 } // if Areneighbours
1395 for(iDigit = 0; iDigit < fMulDigit; iDigit++) {
1397 maxAt[iDigitN] = maxAt[iDigit] ;
1398 maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
1405 //____________________________________________________________________________
1406 Int_t AliEMCALRecPoint::GetPrimaryIndex() const
1408 // Get the primary track index in TreeK which deposits the most energy
1409 // in Digits which forms RecPoint.
1412 return fTracksList[0];
1416 //____________________________________________________________________________
1417 void AliEMCALRecPoint::EvalTime(TClonesArray * digits){
1418 // time is set to the time of the digit with the maximum energy
1422 for(Int_t idig=0; idig < fMulDigit; idig++){
1423 if(fEnergyList[idig] > maxE){
1424 maxE = fEnergyList[idig] ;
1428 fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
1432 //______________________________________________________________________________
1433 void AliEMCALRecPoint::Paint(Option_t *)
1435 // Paint this ALiRecPoint as a TMarker with its current attributes
1437 TVector3 pos(0.,0.,0.) ;
1438 GetLocalPosition(pos) ;
1439 Coord_t x = pos.X() ;
1440 Coord_t y = pos.Z() ;
1441 Color_t markercolor = 1 ;
1442 Size_t markersize = 1.;
1443 Style_t markerstyle = 5 ;
1445 if (!gPad->IsBatch()) {
1446 gVirtualX->SetMarkerColor(markercolor) ;
1447 gVirtualX->SetMarkerSize (markersize) ;
1448 gVirtualX->SetMarkerStyle(markerstyle) ;
1450 gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
1451 gPad->PaintPolyMarker(1,&x,&y,"") ;
1454 //_____________________________________________________________________
1455 Double_t AliEMCALRecPoint::TmaxInCm(const Double_t e , const Int_t key)
1458 // key = 0(gamma, default)
1460 const Double_t ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07)
1461 Double_t tmax = 0.; // position of electromagnetic shower max in cm
1463 Double_t x0 = 1.31; // radiation lenght (cm)
1464 //If old geometry in use
1465 if(!((fGeomPtr->GetEMCGeometry()->GetGeoName()).Contains("V1"))) x0 = 1.28;
1468 tmax = TMath::Log(e) + ca;
1469 if (key==0) tmax += 0.5;
1471 tmax *= x0; // convert to cm
1476 //______________________________________________________________________________
1477 Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const
1479 //Converts Theta (Radians) to Eta(Radians)
1480 return (2.*TMath::ATan(TMath::Exp(-arg)));
1483 //______________________________________________________________________________
1484 Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const
1486 //Converts Eta (Radians) to Theta(Radians)
1487 return (-1 * TMath::Log(TMath::Tan(0.5 * arg)));
1490 //____________________________________________________________________________
1491 void AliEMCALRecPoint::Print(Option_t *opt) const
1493 // Print the list of digits belonging to the cluster
1494 if(strlen(opt)==0) return;
1496 message = "AliEMCALRecPoint:\n" ;
1497 message += " digits # = " ;
1498 AliInfo(message.Data()) ;
1501 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1502 printf(" %d ", fDigitsList[iDigit] ) ;
1505 AliInfo(" Energies = ") ;
1506 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1507 printf(" %f ", fEnergyList[iDigit] ) ;
1510 AliInfo("\n Abs Ids = ") ;
1511 for(iDigit=0; iDigit<fMulDigit; iDigit++)
1512 printf(" %i ", fAbsIdList[iDigit] ) ;
1515 AliInfo(" Primaries ") ;
1516 for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1517 printf(" %d ", fTracksList[iDigit]) ;
1519 printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]);
1521 message = " ClusterType = %d" ;
1522 message += " Multiplicity = %d" ;
1523 message += " Cluster Energy = %f" ;
1524 message += " Core energy = %f" ;
1525 message += " Core radius = %f" ;
1526 message += " Number of primaries %d" ;
1527 message += " Stored at position %d" ;
1528 AliInfo(Form(message.Data(), fClusterType, fMulDigit, fAmp, fCoreEnergy, fCoreRadius, fMulTrack, GetIndexInList()) ) ;
1531 //___________________________________________________________
1532 Double_t AliEMCALRecPoint::GetPointEnergy() const
1534 //Returns energy ....
1536 for(int ic=0; ic<GetMultiplicity(); ic++) e += double(fEnergyList[ic]);