AliRoot Core  3dc7879 (3dc7879)
AliEMCALRecPoint.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 // --- ROOT system ---
17 #include "TPad.h"
18 #include "TGraph.h"
19 #include "TPaveText.h"
20 #include "TClonesArray.h"
21 #include "TMath.h"
22 #include "TGeoMatrix.h"
23 #include "TGeoManager.h"
24 #include "TGeoPhysicalNode.h"
25 #include "TRandom.h"
26 
27 // --- Standard library ---
28 #include <Riostream.h>
29 
30 // --- AliRoot header files ---
31 class AliGenerator;
32 class AliEMCAL;
33 #include "AliLog.h"
34 #include "AliGeomManager.h"
35 #include "AliEMCALGeometry.h"
36 #include "AliEMCALHit.h"
37 #include "AliEMCALDigit.h"
38 #include "AliEMCALRecPoint.h"
39 #include "AliCaloCalibPedestal.h"
40 #include "AliEMCALGeoParams.h"
41 
43 ClassImp(AliEMCALRecPoint) ;
45 
48 //____________________________________________________________________________
50  : AliCluster(), fGeomPtr(0),
51  fAmp(0), fIndexInList(-1), //to be set when the point is already stored
52  fGlobPos(0,0,0),fLocPos(0,0,0),
53  fMaxDigit(100), fMulDigit(0), fMaxTrack(200),
54  fMulTrack(0), fDigitsList(0), fTracksList(0),
55  fClusterType(-1), fCoreEnergy(0), fDispersion(0),
56  fEnergyList(0), fAbsIdList(0),
57  fTime(0.), fNExMax(0), fCoreRadius(10), //HG check this
58  fDETracksList(0), fMulParent(0), fMaxParent(0),
59  fParentsList(0), fDEParentsList(0), fSuperModuleNumber(0),
60  fDigitIndMax(-1), fDistToBadTower(-1), fSharedCluster(kFALSE)
61 {
63 
64  fLambda[0] = 0;
65  fLambda[1] = 0;
66 }
67 
70 //____________________________________________________________________________
72  : AliCluster(), fGeomPtr(0),
73  fAmp(0), fIndexInList(-1), //to be set when the point is already stored
74  fGlobPos(0,0,0), fLocPos(0,0,0),
75  fMaxDigit(100), fMulDigit(0), fMaxTrack(1000), fMulTrack(0),
76  fDigitsList(new Int_t[fMaxDigit]), fTracksList(new Int_t[fMaxTrack]),
78  fEnergyList(new Float_t[fMaxDigit]),
79  fAbsIdList(new Int_t[fMaxDigit]), fTime(-1.), fNExMax(0), fCoreRadius(10),
80  fDETracksList(new Float_t[fMaxTrack]), fMulParent(0), fMaxParent(1000),
81  fParentsList(new Int_t[fMaxParent]), fDEParentsList(new Float_t[fMaxParent]),
83 {
84  for (Int_t i = 0; i < fMaxTrack; i++)
85  fDETracksList[i] = 0;
86 
87  for (Int_t i = 0; i < fMaxParent; i++)
88  {
89  fParentsList [i] = -1;
90  fDEParentsList[i] = 0;
91  }
92 
94 
95  fLambda[0] = 0;
96  fLambda[1] = 0;
97 }
98 
101 //____________________________________________________________________________
103  : AliCluster(rp), fGeomPtr(rp.fGeomPtr),
108  fDigitsList(new Int_t[rp.fMaxDigit]), fTracksList(new Int_t[rp.fMaxTrack]),
111  fEnergyList(new Float_t[rp.fMaxDigit]),
112  fAbsIdList(new Int_t[rp.fMaxDigit]), fTime(rp.fTime), fNExMax(rp.fNExMax),fCoreRadius(rp.fCoreRadius),
113  fDETracksList(new Float_t[rp.fMaxTrack]), fMulParent(rp.fMulParent),
114  fMaxParent(rp.fMaxParent), fParentsList(new Int_t[rp.fMaxParent]),
115  fDEParentsList(new Float_t[rp.fMaxParent]),
118 {
119  fLambda[0] = rp.fLambda[0];
120  fLambda[1] = rp.fLambda[1];
121 
122  for(Int_t i = 0; i < rp.fMulDigit; i++)
123  {
124  fEnergyList[i] = rp.fEnergyList[i];
125  fAbsIdList [i] = rp.fAbsIdList [i];
126  }
127 
128  for(Int_t i = 0; i < rp.fMulTrack; i++)
129  fDETracksList[i] = rp.fDETracksList[i];
130 
131  for(Int_t i = 0; i < rp.fMulParent; i++)
132  {
133  fParentsList [i] = rp.fParentsList [i];
134  fDEParentsList[i] = rp.fDEParentsList[i];
135  }
136 }
137 
140 //____________________________________________________________________________
142 {
143  if ( fEnergyList )
144  delete[] fEnergyList ;
145  if ( fAbsIdList )
146  delete[] fAbsIdList ;
147  if ( fDETracksList)
148  delete[] fDETracksList;
149  if ( fParentsList)
150  delete[] fParentsList;
151  if ( fDEParentsList)
152  delete[] fDEParentsList;
153 
154  delete [] fDigitsList ;
155  delete [] fTracksList ;
156 }
157 
160 //____________________________________________________________________________
162 {
163  if(&rp == this) return *this;
164 
165  fGeomPtr = rp.fGeomPtr;
166  fAmp = rp.fAmp;
168  fGlobPos = rp.fGlobPos;
169  fLocPos = rp.fLocPos;
170  fMaxDigit = rp.fMaxDigit;
171  fMulDigit = rp.fMulDigit;
172  fMaxTrack = rp.fMaxTrack;
173  fMulTrack = rp.fMulTrack;
174 
175  if(fDigitsList) delete [] fDigitsList;
176  fDigitsList = new Int_t[rp.fMaxDigit];
177  if(fTracksList) delete [] fTracksList;
178  fTracksList = new Int_t[rp.fMaxTrack];
179  for(Int_t i = 0; i<fMaxDigit; i++) fDigitsList[i] = rp.fDigitsList[i];
180  for(Int_t i = 0; i<fMaxTrack; i++) fTracksList[i] = rp.fTracksList[i];
181 
183  fCoreEnergy = rp.fCoreEnergy;
185 
186 
187  if(fEnergyList) delete [] fEnergyList;
188  fEnergyList = new Float_t[rp.fMaxDigit];
189  if(fAbsIdList) delete [] fAbsIdList;
190  fAbsIdList = new Int_t[rp.fMaxDigit];
191  for(Int_t i = 0; i<fMaxDigit; i++) {
192  fEnergyList[i] = rp.fEnergyList[i];
193  fAbsIdList[i] = rp.fAbsIdList[i];
194  }
195 
196  fTime = rp.fTime;
197  fNExMax = rp.fNExMax;
199 
200  if(fDETracksList) delete [] fDETracksList;
201  fDETracksList = new Float_t[rp.fMaxTrack];
202  for(Int_t i = 0; i < fMaxTrack; i++) fDETracksList[i] = rp.fDETracksList[i];
203 
204  fMulParent = rp.fMulParent;
205  fMaxParent = rp.fMaxParent;
206 
207  if(fParentsList) delete [] fParentsList;
208  fParentsList = new Int_t[rp.fMaxParent];
209  if(fDEParentsList) delete [] fDEParentsList;
210  fDEParentsList = new Float_t[rp.fMaxParent];
211  for(Int_t i = 0; i < fMaxParent; i++) {
212  fParentsList[i] = rp.fParentsList[i];
213  fDEParentsList[i] = rp.fDEParentsList[i];
214  }
215 
218 
219  fLambda[0] = rp.fLambda[0];
220  fLambda[1] = rp.fLambda[1];
221 
224 
225  return *this;
226 
227 }
228 
232 //____________________________________________________________________________
233 void AliEMCALRecPoint::AddDigit(AliEMCALDigit & digit, const Float_t energy, const Bool_t shared)
234 {
235  if(fEnergyList == 0)
236  fEnergyList = new Float_t[fMaxDigit];
237 
238  if(fAbsIdList == 0)
239  fAbsIdList = new Int_t [fMaxDigit];
240 
241  if ( fMulDigit >= fMaxDigit )
242  {
243  // increase the size of the lists
244  fMaxDigit*=2 ;
245 
246  Int_t * tempo = new Int_t [fMaxDigit];
247  Float_t * tempoE = new Float_t[fMaxDigit];
248  Int_t * tempoId = new Int_t [fMaxDigit];
249 
250  Int_t index ;
251  for ( index = 0 ; index < fMulDigit ; index++ )
252  {
253  tempo [index] = fDigitsList[index] ;
254  tempoE [index] = fEnergyList[index] ;
255  tempoId[index] = fAbsIdList [index] ;
256  }
257 
258  delete [] fDigitsList ;
259  delete [] fEnergyList ;
260  delete [] fAbsIdList ;
261 
262  fDigitsList = tempo;
263  fEnergyList = tempoE;
264  fAbsIdList = tempoId;
265  } // if
266 
267  fDigitsList[fMulDigit] = digit.GetIndexInList() ;
268  fEnergyList[fMulDigit] = energy ;
269  fAbsIdList [fMulDigit] = digit.GetId();
270 
271  fMulDigit++ ;
272  fAmp += energy ;
273 
274  if(shared) fSharedCluster = kTRUE;
275 }
276 
287 //____________________________________________________________________________
289 {
290  Bool_t areNeighbours = kFALSE ;
291  Int_t nSupMod = 0, nModule = 0, nIphi = 0, nIeta = 0;
292  Int_t nSupMod1 = 0, nModule1 = 0, nIphi1 = 0, nIeta1 = 0;
293  Int_t relid1[2] , relid2[2] ; // ieta, iphi
294  Int_t rowdiff = 0, coldiff = 0;
295 
296  areNeighbours = kFALSE ;
297 
298  fGeomPtr->GetCellIndex(digit1->GetId(), nSupMod,nModule,nIphi,nIeta);
299  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, relid1[0],relid1[1]);
300 
301  fGeomPtr->GetCellIndex(digit2->GetId(), nSupMod1,nModule1,nIphi1,nIeta1);
302  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod1,nModule1,nIphi1,nIeta1, relid2[0],relid2[1]);
303 
304  // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2-1
305  // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0
306  if ( fSharedCluster && nSupMod1 != nSupMod )
307  {
308  if(nSupMod1%2) relid2[1]+=AliEMCALGeoParams::fgkEMCALCols;
309  else relid1[1]+=AliEMCALGeoParams::fgkEMCALCols;
310  }
311 
312  rowdiff = TMath::Abs( relid1[0] - relid2[0] ) ;
313  coldiff = TMath::Abs( relid1[1] - relid2[1] ) ;
314 
315  // With this condition, cells touching one corner are considered neighbours
316  // which was considered as the behavior expected initially, but changed later.
317  //if (( coldiff <= 1 ) && ( rowdiff <= 1 ) && (coldiff + rowdiff > 0))
318 
319  if ((coldiff + rowdiff == 1 ))
320  areNeighbours = kTRUE ;
321 
322  return areNeighbours;
323 }
324 
327 //____________________________________________________________________________
328 Int_t AliEMCALRecPoint::Compare(const TObject * obj) const
329 {
330  Float_t delta = 1 ; //Width of "Sorting row".
331 
332  Int_t rv = 2 ;
333 
334  AliEMCALRecPoint * clu = (AliEMCALRecPoint *)obj ;
335 
336  TVector3 locpos1;
337  GetLocalPosition(locpos1);
338 
339  TVector3 locpos2;
340  clu->GetLocalPosition(locpos2);
341 
342  Int_t rowdif = (Int_t)(TMath::Ceil(locpos1.X()/delta)-TMath::Ceil(locpos2.X()/delta)) ;
343 
344  if (rowdif> 0)
345  rv = 1 ;
346  else if(rowdif < 0)
347  rv = -1 ;
348  else if(locpos1.Y()>locpos2.Y())
349  rv = -1 ;
350  else
351  rv = 1 ;
352 
353  return rv ;
354 }
355 
358 //___________________________________________________________________________
359 void AliEMCALRecPoint::Draw(Option_t *option)
360 {
361  AppendPad(option);
362 }
363 
366 //____________________________________________________________________________
367 void AliEMCALRecPoint::EvalAll(Float_t logWeight, TClonesArray * digits,
368  const Bool_t justClusters)
369 {
370  // First calculate the index of digit with maximum amplitude and get
371  // the supermodule number where it sits.
374 
375  // Evaluate global and local position
376  EvalGlobalPosition(logWeight, digits) ;
377  EvalLocalPosition(logWeight, digits) ;
378 
379  // Evaluate shower parameters
380  EvalElipsAxis(logWeight, digits) ;
381  EvalDispersion(logWeight, digits) ;
382 
383  // EvalCoreEnergy(logWeight, digits);
384  EvalTime(digits) ;
385  EvalPrimaries(digits) ;
386  EvalParents(digits);
387 
388  // Called last because it sets the global position of the cluster?
389  // Do not call it when recalculating clusters out of standard reconstruction
390  if(!justClusters)
392 }
393 
397 //____________________________________________________________________________
398 void AliEMCALRecPoint::EvalDispersion(Float_t logWeight, TClonesArray * digits)
399 {
400  Double_t d = 0., wtot = 0., w = 0.;
401  Int_t iDigit=0, nstat=0;
402  AliEMCALDigit * digit=0;
403 
404  // Calculates the dispersion in cell units
405  Double_t etai, phii, etaMean=0.0, phiMean=0.0;
406  int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
407  int iphi=0, ieta=0;
408 
409  // Calculate mean values
410  for(iDigit=0; iDigit < fMulDigit; iDigit++)
411  {
412  digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
413 
414  if (fAmp>0 && fEnergyList[iDigit]>0)
415  {
416  fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
417  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
418 
419  // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
420  // C Side impair SM, nSupMod%2=1; A side pair SM nSupMod%2=0
421  if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
422 
423  etai=(Double_t)ieta;
424  phii=(Double_t)iphi;
425  w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
426 
427  if(w>0.0)
428  {
429  phiMean += phii*w;
430  etaMean += etai*w;
431  wtot += w;
432  }
433  }
434  }
435 
436  if (wtot>0)
437  {
438  phiMean /= wtot ;
439  etaMean /= wtot ;
440  }
441  else AliError(Form("Wrong weight %f\n", wtot));
442 
443  // Calculate dispersion
444  for(iDigit=0; iDigit < fMulDigit; iDigit++)
445  {
446  digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
447 
448  if (fAmp>0 && fEnergyList[iDigit]>0)
449  {
450  fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
451  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
452 
453  // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
454  // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
455  if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
456 
457  etai=(Double_t)ieta;
458  phii=(Double_t)iphi;
459  w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
460 
461  if(w>0.0)
462  {
463  nstat++;
464  d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean));
465  }
466  }
467  }
468 
469  if ( wtot > 0 && nstat>1) d /= wtot ;
470  else d = 0. ;
471 
472  fDispersion = TMath::Sqrt(d) ;
473  //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",fDispersion);
474 }
475 
479 //____________________________________________________________________________
481 {
483 
484  if(!caloped->GetDeadTowerCount()) return;
485 
486  // Get channels map of the supermodule where the cluster is.
487  TH2D* hMap = caloped->GetDeadMap(fSuperModuleNumber);
488 
489  Int_t dRrow, dReta;
490  Float_t minDist = 10000.;
491  Float_t dist = 0.;
492  Int_t nSupMod, nModule;
493  Int_t nIphi, nIeta;
494  Int_t iphi, ieta;
495 
497 
498  fGeomPtr->GetCellIndex(fAbsIdList[fDigitIndMax], nSupMod,nModule,nIphi,nIeta);
499  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
500 
501  // Loop on tower status map
502  for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++)
503  {
504  for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++)
505  {
506  // Check if tower is bad.
507  if(hMap->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue;
508  //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow);
509 
510  dRrow=TMath::Abs(irow-iphi);
511  dReta=TMath::Abs(icol-ieta);
512 
513  dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta);
514  if(dist < minDist) minDist = dist;
515  }
516  }
517 
518  // In case the cluster is shared by 2 SuperModules, need to check the map of the second Super Module
519  if (fSharedCluster)
520  {
521  TH2D* hMap2 = 0;
522  Int_t nSupMod2 = -1;
523 
524  // The only possible combinations are (0,1), (2,3) ... (10,11)
525  if(fSuperModuleNumber%2) nSupMod2 = fSuperModuleNumber-1;
526  else nSupMod2 = fSuperModuleNumber+1;
527  hMap2 = caloped->GetDeadMap(nSupMod2);
528 
529  //Loop on tower status map of second super module
530  for(Int_t irow = 0; irow < AliEMCALGeoParams::fgkEMCALRows; irow++)
531  {
532  for(Int_t icol = 0; icol < AliEMCALGeoParams::fgkEMCALCols; icol++)
533  {
534  //Check if tower is bad.
535  if(hMap2->GetBinContent(icol,irow)==AliCaloCalibPedestal::kAlive) continue;
536 
537  //printf("AliEMCALRecPoint::EvalDistanceToBadChannels() - Bad channel in SM %d, col %d, row %d\n",iSM,icol, irow);
538  dRrow=TMath::Abs(irow-iphi);
539 
540  if(fSuperModuleNumber%2)
541  {
542  dReta=TMath::Abs(icol-(AliEMCALGeoParams::fgkEMCALCols+ieta));
543  }
544  else
545  {
546  dReta=TMath::Abs(AliEMCALGeoParams::fgkEMCALCols+icol-ieta);
547  }
548 
549  dist=TMath::Sqrt(dRrow*dRrow+dReta*dReta);
550  if(dist < minDist) minDist = dist;
551  } // col loop
552  } // row loop
553  }// shared cluster in 2 SuperModules
554 
555  fDistToBadTower = minDist;
556  //printf("AliEMCALRecPoint::EvalDistanceToBadChannel() - Distance to Bad is %f cm, shared cluster? %d \n",fDistToBadTower,fSharedCluster);
557 }
558 
561 //____________________________________________________________________________
562 void AliEMCALRecPoint::EvalLocalPosition(Float_t logWeight, TClonesArray * digits)
563 {
564  // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
565 
566  AliEMCALDigit * digit=0;
567  Int_t i=0, nstat=0;
568 
569  Double_t dist = TmaxInCm(Double_t(fAmp));
570  //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
571 
572  Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
573 
574  //printf(" dist : %f e : %f \n", dist, fAmp);
575  for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++)
576  {
577  digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
578 
579  if(!digit)
580  {
581  AliError("No Digit!!");
582  continue;
583  }
584 
585  fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
586 
587  //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
588  if(fSharedCluster && fSuperModuleNumber != fGeomPtr->GetSuperModuleNumber(digit->GetId())) xyzi[1]*=-1;
589 
590  //printf("EvalLocalPosition Cell: Id %i, SM %i : dist %f Local x,y,z %f %f %f \n",
591  // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()), dist, xyzi[0], xyzi[1], xyzi[2]);
592 
593  if(logWeight > 0.0)
594  w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
595  else
596  w = fEnergyList[iDigit]; // just energy
597 
598  if(w>0.0)
599  {
600  wtot += w ;
601  nstat++;
602 
603  for(i=0; i<3; i++ )
604  {
605  clXYZ[i] += (w*xyzi[i]);
606  clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
607  }
608  } // w > 0
609  } // dig loop
610 
611  // cout << " wtot " << wtot << endl;
612 
613  if ( wtot > 0 )
614  {
615  // xRMS = TMath::Sqrt(x2m - xMean*xMean);
616  for(i=0; i<3; i++ )
617  {
618  clXYZ[i] /= wtot;
619 
620  if(nstat>1)
621  {
622  clRmsXYZ[i] /= (wtot*wtot);
623  clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
624 
625  if(clRmsXYZ[i] > 0.0) clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
626  else clRmsXYZ[i] = 0;
627  }
628  else
629  clRmsXYZ[i] = 0;
630  }
631  }
632  else
633  {
634  for(i=0; i<3; i++ )
635  {
636  clXYZ[i] = clRmsXYZ[i] = -1.;
637  }
638  }
639 
640  // // Cluster of one single digit, smear the position to avoid discrete position
641  // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm.
642  // // Rndm generates a number in ]0,1]
643  // if (fMulDigit==1) {
644  // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm());
645  // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm());
646  // }
647 
648  // Set position in local vector
649  fLocPos.SetX(clXYZ[0]);
650  fLocPos.SetY(clXYZ[1]);
651  fLocPos.SetZ(clXYZ[2]);
652 
653  if (gDebug==2)
654  printf("EvalLocalPosition Cluster: Local (x,y,z) = (%f,%f,%f) \n", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
655 
656 }
657 
660 //____________________________________________________________________________
661 void AliEMCALRecPoint::EvalGlobalPosition(Float_t logWeight, TClonesArray * digits)
662 {
663  // Info("Print", " logWeight %f : cluster energy %f ", logWeight, fAmp); // for testing
664 
665  AliEMCALDigit * digit=0;
666  Int_t i=0, nstat=0;
667 
668  Double_t dist = TmaxInCm(Double_t(fAmp));
669  //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
670 
671  Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, lxyzi[3], xyzi[3], wtot=0., w=0.;
672 
673  //printf(" dist : %f e : %f \n", dist, fAmp);
674  for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++)
675  {
676  digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
677 
678  if(!digit)
679  {
680  AliError("No Digit!!");
681  continue;
682  }
683 
684  // Get the local coordinates of the cell
685  fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, lxyzi[0], lxyzi[1], lxyzi[2]);
686 
687  // Now get the global coordinate
688  fGeomPtr->GetGlobal(lxyzi,xyzi, fGeomPtr->GetSuperModuleNumber(digit->GetId()));
689 
690  //TVector3 pos(xyzi[0], xyzi[1], xyzi[2]);
691  //printf("EvalGlobalPosition Cell: Id %i, SM %i : dist %f Local (x,y,z) = (%f %f %f), eta %f, phi%f \n",
692  // digit->GetId(), fGeomPtr->GetSuperModuleNumber(digit->GetId()),dist, xyzi[0], xyzi[1], xyzi[2],pos.Eta(),pos.Phi()*TMath::RadToDeg());
693 
694  if(logWeight > 0.0)
695  w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
696  else
697  w = fEnergyList[iDigit]; // just energy
698 
699  if(w>0.0)
700  {
701  wtot += w ;
702  nstat++;
703 
704  for(i=0; i<3; i++ )
705  {
706  clXYZ[i] += (w*xyzi[i]);
707  clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
708  }
709  }
710  }
711 
712  // cout << " wtot " << wtot << endl;
713 
714  if ( wtot > 0 )
715  {
716  // xRMS = TMath::Sqrt(x2m - xMean*xMean);
717  for(i=0; i<3; i++ )
718  {
719  clXYZ[i] /= wtot;
720 
721  if(nstat>1)
722  {
723  clRmsXYZ[i] /= (wtot*wtot);
724  clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
725 
726  if(clRmsXYZ[i] > 0.0) clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
727  else clRmsXYZ[i] = 0;
728  }
729  else clRmsXYZ[i] = 0;
730  }
731  }
732  else
733  {
734  for(i=0; i<3; i++ )
735  {
736  clXYZ[i] = clRmsXYZ[i] = -1.;
737  }
738  }
739 
740  // // Cluster of one single digit, smear the position to avoid discrete position
741  // // smear x and z with +- 3 cm to uniform (avoid discrete effects). Tower size is approx 6 cm.
742  // // Rndm generates a number in ]0,1]
743  // if (fMulDigit==1) {
744  // clXYZ[0] += fGeomPtr->GetPhiTileSize()*(0.5 - gRandom->Rndm());
745  // clXYZ[2] += fGeomPtr->GetEtaTileSize()*(0.5 - gRandom->Rndm());
746  // }
747 
748  // Set position in global vector
749  fGlobPos.SetX(clXYZ[0]);
750  fGlobPos.SetY(clXYZ[1]);
751  fGlobPos.SetZ(clXYZ[2]);
752 
753  if (gDebug==2)
754  printf("EvalGlobalPosition Cluster: (x ,y ,z) = (%f,%f,%f), eta %f,phi %f\n",
755  fGlobPos.X(), fGlobPos.Y(), fGlobPos.Z(),fGlobPos.Eta(),fGlobPos.Phi()*TMath::RadToDeg()) ;
756 }
757 
760 //____________________________________________________________________________
761 void AliEMCALRecPoint::EvalLocalPositionFit(Double_t deff, Double_t logWeight,
762  Double_t phiSlope, TClonesArray * digits)
763 {
764  Double_t ycorr=0;
765  AliEMCALDigit *digit=0;
766  Int_t i=0, nstat=0;
767  Double_t clXYZ[3]={0.,0.,0.}, clRmsXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
768 
769  Double_t dist = TmaxInCm(Double_t(fAmp));
770  //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
771 
772  for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++)
773  {
774  digit = dynamic_cast<AliEMCALDigit *>(digits->At(fDigitsList[iDigit])) ;
775 
776  if(digit)
777  {
778  dist = deff;
779  //fGeomPtr->RelPosCellInSModule(digit->GetId(), idMax, dist, xyzi[0], xyzi[1], xyzi[2]);
780  fGeomPtr->RelPosCellInSModule(digit->GetId(), dist, xyzi[0], xyzi[1], xyzi[2]);
781 
782  if(logWeight > 0.0)
783  w = TMath::Max( 0., logWeight + TMath::Log( fEnergyList[iDigit] / fAmp ));
784  else
785  w = fEnergyList[iDigit]; // just energy
786 
787  if(w>0.0)
788  {
789  wtot += w ;
790  nstat++;
791 
792  for(i=0; i<3; i++ )
793  {
794  clXYZ[i] += (w*xyzi[i]);
795  clRmsXYZ[i] += (w*xyzi[i]*xyzi[i]);
796  }
797  }
798  }
799  else AliError("Digit null");
800  }//loop
801 
802  // cout << " wtot " << wtot << endl;
803 
804  if ( wtot > 0 )
805  {
806  // xRMS = TMath::Sqrt(x2m - xMean*xMean);
807  for(i=0; i<3; i++ )
808  {
809  clXYZ[i] /= wtot;
810 
811  if(nstat>1)
812  {
813  clRmsXYZ[i] /= (wtot*wtot);
814  clRmsXYZ[i] = clRmsXYZ[i] - clXYZ[i]*clXYZ[i];
815 
816  if(clRmsXYZ[i] > 0.0) clRmsXYZ[i] = TMath::Sqrt(clRmsXYZ[i]);
817  else clRmsXYZ[i] = 0;
818  } else clRmsXYZ[i] = 0;
819  }
820  }
821  else
822  {
823  for(i=0; i<3; i++ )
824  {
825  clXYZ[i] = clRmsXYZ[i] = -1.;
826  }
827  }
828 
829  // clRmsXYZ[i] ??
830 
831  if(phiSlope != 0.0 && logWeight > 0.0 && wtot)
832  {
833  // Correction in phi direction (y - coords here); Aug 16;
834  // May be put to global level or seperate method
835  ycorr = clXYZ[1] * (1. + phiSlope);
836 
837  //printf(" y %f : ycorr %f : slope %f \n", clXYZ[1], ycorr, phiSlope);
838  clXYZ[1] = ycorr;
839  }
840 
841  fLocPos.SetX(clXYZ[0]);
842  fLocPos.SetY(clXYZ[1]);
843  fLocPos.SetZ(clXYZ[2]);
844 
845  // if (gDebug==2)
846  // printf("EvalLocalPosition: eta,phi,r = %f,%f,%f", fLocPos.X(), fLocPos.Y(), fLocPos.Z()) ;
847 }
848 
852 //_____________________________________________________________________________
853 Bool_t AliEMCALRecPoint::EvalLocalPosition2(TClonesArray * digits, TArrayD &ed)
854 {
855  //printf(" <I> AliEMCALRecPoint::EvalLocalPosition2() \n");
857 }
858 
861 //_____________________________________________________________________________
862 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
863 {
864  Double_t deff=0, w0=0, esum=0;
865  Int_t iDigit=0;
866  // AliEMCALDigit *digit;
867 
868  if(ed.GetSize() && (digits->GetEntries()!=ed.GetSize())) return kFALSE;
869 
870  // Calculate sum energy of digits
871  esum = 0.0;
872  for(iDigit=0; iDigit<ed.GetSize(); iDigit++) esum += ed[iDigit];
873 
874  GetDeffW0(esum, deff, w0);
875 
876  return EvalLocalPositionFromDigits(esum, deff, w0, digits, ed, locPos);
877 }
878 
881 //_____________________________________________________________________________
882 Bool_t AliEMCALRecPoint::EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff,
883  const Double_t w0, TClonesArray *digits,
884  TArrayD &ed, TVector3 &locPos)
885 {
886  AliEMCALDigit *digit=0;
887 
888  Int_t i=0, nstat=0;
889  Double_t clXYZ[3]={0.,0.,0.}, xyzi[3], wtot=0., w=0.;
890  //Int_t idMax = GetAbsIdMaxDigit();// idMax is not used at all in RelPosCellInSModule, why use it?
891 
892  // Get pointer to EMCAL geometry
893  // (can't use fGeomPtr in static method)
895 
896  for(Int_t iDigit=0; iDigit<digits->GetEntries(); iDigit++)
897  {
898  digit = dynamic_cast<AliEMCALDigit *>(digits->At(iDigit));
899 
900  if(digit)
901  {
902  //geo->RelPosCellInSModule(digit->GetId(), idMax, deff, xyzi[0], xyzi[1], xyzi[2]);
903  geo->RelPosCellInSModule(digit->GetId(), deff, xyzi[0], xyzi[1], xyzi[2]);
904 
905  if(w0 > 0.0) w = TMath::Max( 0., w0 + TMath::Log(ed[iDigit] / esum));
906  else w = ed[iDigit]; // just energy
907 
908  if(w>0.0)
909  {
910  wtot += w ;
911  nstat++;
912  for(i=0; i<3; i++ )
913  {
914  clXYZ[i] += (w*xyzi[i]);
915  }
916  }
917  } else AliError("Digit null");
918  }//loop
919 
920  // cout << " wtot " << wtot << endl;
921 
922  if (wtot > 0)
923  {
924  for(i=0; i<3; i++ )
925  {
926  clXYZ[i] /= wtot;
927  }
928 
929  locPos.SetX(clXYZ[0]);
930  locPos.SetY(clXYZ[1]);
931  locPos.SetZ(clXYZ[2]);
932 
933  return kTRUE;
934  }
935  else
936  {
937  return kFALSE;
938  }
939 }
940 
946 //_____________________________________________________________________________
947 void AliEMCALRecPoint::GetDeffW0(const Double_t esum , Double_t &deff, Double_t &w0)
948 {
949  Double_t e=0.0;
950  const Double_t kdp0=9.25147, kdp1=1.16700; // Hard coded now
951  const Double_t kwp0=4.83713, kwp1=-2.77970e-01, kwp2 = 4.41116;
952 
953  // No extrapolation here
954  e = esum<0.5?0.5:esum;
955  e = e>100.?100.:e;
956 
957  deff = kdp0 + kdp1*TMath::Log(e);
958  w0 = kwp0 / (1. + TMath::Exp(kwp1*(e+kwp2)));
959  //printf("<I> AliEMCALRecPoint::GetDeffW0 esum %5.2f : deff %5.2f : w0 %5.2f \n", esum, deff, w0);
960 }
961 
969 //______________________________________________________________________________
970 void AliEMCALRecPoint::EvalCoreEnergy(Float_t logWeight, TClonesArray * digits)
971 {
972  AliEMCALDigit * digit = 0 ;
973 
974  Int_t iDigit=0;
975 
976  if (!fLocPos.Mag())
977  EvalLocalPosition(logWeight, digits);
978 
979 
980  Double_t phiPoint = fLocPos.Phi(), etaPoint = fLocPos.Eta();
981  Double_t eta, phi, distance;
982  for(iDigit=0; iDigit < fMulDigit; iDigit++)
983  {
984  digit = (AliEMCALDigit *) ( digits->At(fDigitsList[iDigit]) ) ;
985 
986  eta = phi = 0.0;
987  fGeomPtr->EtaPhiFromIndex(digit->GetId(),eta, phi) ;
988  phi = phi * TMath::DegToRad();
989 
990  distance = TMath::Sqrt((eta-etaPoint)*(eta-etaPoint)+(phi-phiPoint)*(phi-phiPoint));
991 
992  if(distance < fCoreRadius)
993  fCoreEnergy += fEnergyList[iDigit] ;
994  }
995 
996 }
997 
1001 //____________________________________________________________________________
1002 void AliEMCALRecPoint::EvalElipsAxis(Float_t logWeight,TClonesArray * digits)
1003 {
1004  TString gn(fGeomPtr->GetName());
1005 
1006  Double_t wtot = 0.;
1007  Double_t x = 0.;
1008  Double_t z = 0.;
1009  Double_t dxx = 0.;
1010  Double_t dzz = 0.;
1011  Double_t dxz = 0.;
1012 
1013  AliEMCALDigit * digit = 0;
1014 
1015  Double_t etai =0, phii=0, w=0;
1016  int nSupMod=0, nModule=0, nIphi=0, nIeta=0;
1017  int iphi=0, ieta=0;
1018  for(Int_t iDigit=0; iDigit<fMulDigit; iDigit++)
1019  {
1020  digit = (AliEMCALDigit *) digits->At(fDigitsList[iDigit]) ;
1021  etai = phii = 0.;
1022  // Nov 15,2006 - use cell numbers as coordinates
1023  // Copied for shish-kebab geometry, ieta,iphi is cast as double as eta,phi
1024  // We can use the eta,phi(or coordinates) of cell
1025  nSupMod = nModule = nIphi = nIeta = iphi = ieta = 0;
1026 
1027  fGeomPtr->GetCellIndex(digit->GetId(), nSupMod,nModule,nIphi,nIeta);
1028  fGeomPtr->GetCellPhiEtaIndexInSModule(nSupMod,nModule,nIphi,nIeta, iphi,ieta);
1029 
1030  // In case of a shared cluster, index of SM in C side, columns start at 48 and ends at 48*2
1031  // C Side impair SM, nSupMod%2=1; A side pair SM, nSupMod%2=0
1032  if(fSharedCluster && nSupMod%2) ieta+=AliEMCALGeoParams::fgkEMCALCols;
1033 
1034  etai=(Double_t)ieta;
1035  phii=(Double_t)iphi;
1036 
1037  w = TMath::Max(0.,logWeight+TMath::Log(fEnergyList[iDigit]/fAmp ) ) ;
1038  // fAmp summed amplitude of digits, i.e. energy of recpoint
1039  // Gives smaller value of lambda than log weight
1040  // w = fEnergyList[iDigit] / fAmp; // Nov 16, 2006 - try just energy
1041 
1042  dxx += w * etai * etai ;
1043  x += w * etai ;
1044  dzz += w * phii * phii ;
1045  z += w * phii ;
1046 
1047  dxz += w * etai * phii ;
1048 
1049  wtot += w ;
1050  }
1051 
1052  if ( wtot > 0 )
1053  {
1054  dxx /= wtot ;
1055  x /= wtot ;
1056  dxx -= x * x ;
1057  dzz /= wtot ;
1058  z /= wtot ;
1059  dzz -= z * z ;
1060  dxz /= wtot ;
1061  dxz -= x * z ;
1062 
1063  fLambda[0] = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
1064 
1065  if(fLambda[0] > 0)
1066  fLambda[0] = TMath::Sqrt(fLambda[0]) ;
1067  else
1068  fLambda[0] = 0;
1069 
1070  fLambda[1] = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
1071 
1072  if(fLambda[1] > 0) //To avoid exception if numerical errors lead to negative lambda.
1073  fLambda[1] = TMath::Sqrt(fLambda[1]) ;
1074  else
1075  fLambda[1]= 0. ;
1076  }
1077  else
1078  {
1079  fLambda[0]= 0. ;
1080  fLambda[1]= 0. ;
1081  }
1082 
1083  //printf("AliEMCALRecPoint::EvalElipsAxis() lambdas = %f,%f \n", fLambda[0],fLambda[1]) ;
1084 }
1085 
1090 //______________________________________________________________________________
1091 void AliEMCALRecPoint::EvalPrimaries(TClonesArray * digits)
1092 {
1093  AliEMCALDigit * digit =0;
1094 
1095  Int_t * primArray = new Int_t[fMaxTrack] ;
1096  memset(primArray,-1,sizeof(Int_t)*fMaxTrack);
1097 
1098  Float_t * dEPrimArray = new Float_t[fMaxTrack] ;
1099  memset(dEPrimArray,-1,sizeof(Int_t)*fMaxTrack);
1100 
1101  // All digits in rec point
1102  Int_t index ;
1103  for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ )
1104  {
1105  digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
1106 
1107  if(!digit)
1108  {
1109  AliError("No Digit!!");
1110  continue;
1111  }
1112 
1113  Int_t nprimaries = digit->GetNprimary() ;
1114  if ( nprimaries == 0 ) continue ;
1115 
1116  // All primaries in digit
1117  Int_t jndex ;
1118  for ( jndex = 0 ; jndex < nprimaries ; jndex++ )
1119  {
1120  if ( fMulTrack > fMaxTrack )
1121  {
1122  fMulTrack = fMaxTrack ;
1123  Error("EvalPrimaries", "increase fMaxTrack ") ;
1124  break ;
1125  }
1126 
1127  Int_t newPrimary = digit->GetPrimary (jndex+1);
1128  Float_t dEPrimary = digit->GetDEPrimary(jndex+1);
1129 
1130  // Check if not already stored
1131  Int_t kndex ;
1132  Bool_t already = kFALSE ;
1133  for ( kndex = 0 ; kndex < fMulTrack ; kndex++ )
1134  {
1135  if ( newPrimary == primArray[kndex] )
1136  {
1137  already = kTRUE ;
1138  dEPrimArray[kndex] += dEPrimary;
1139  break ;
1140  }
1141  } // end of check
1142 
1143  // Store it
1144  if ( !already && (fMulTrack < fMaxTrack))
1145  {
1146  primArray [fMulTrack] = newPrimary ;
1147  dEPrimArray[fMulTrack] = dEPrimary ;
1148  fMulTrack++ ;
1149  } // store it
1150  } // all primaries in digit
1151  } // all digits
1152 
1153  Int_t *sortIdx = new Int_t[fMulTrack];
1154  TMath::Sort(fMulTrack,dEPrimArray,sortIdx);
1155 
1156  for(index = 0; index < fMulTrack; index++)
1157  {
1158  fTracksList [index] = primArray [sortIdx[index]] ;
1159  fDETracksList[index] = dEPrimArray[sortIdx[index]] ;
1160  }
1161 
1162  delete [] sortIdx;
1163  delete [] primArray ;
1164  delete [] dEPrimArray ;
1165 }
1166 
1171 //______________________________________________________________________________
1172 void AliEMCALRecPoint::EvalParents(TClonesArray * digits)
1173 {
1174  AliEMCALDigit * digit=0 ;
1175 
1176  Int_t * parentArray = new Int_t[fMaxTrack] ;
1177  memset(parentArray,-1,sizeof(Int_t)*fMaxTrack);
1178 
1179  Float_t * dEParentArray = new Float_t[fMaxTrack] ;
1180  memset(dEParentArray,-1,sizeof(Int_t)*fMaxTrack);
1181 
1182  // Loop on all digits in rec point (cluster)
1183  Int_t index ;
1184  for ( index = 0 ; index < GetDigitsMultiplicity() ; index++ )
1185  {
1186  if (fDigitsList[index] >= digits->GetEntries() || fDigitsList[index] < 0)
1187  AliError(Form("Trying to get invalid digit %d (idx in WriteRecPoint %d)",fDigitsList[index],index));
1188 
1189  digit = dynamic_cast<AliEMCALDigit *>(digits->At( fDigitsList[index] )) ;
1190 
1191  if(!digit)
1192  {
1193  AliError("No Digit!!");
1194  continue;
1195  }
1196 
1197  Int_t nparents = digit->GetNiparent() ;
1198  if ( nparents == 0 ) continue ;
1199 
1200  // Loop on all parents in digit
1201  Int_t jndex ;
1202  for ( jndex = 0 ; jndex < nparents ; jndex++ )
1203  {
1204  if ( fMulParent > fMaxParent )
1205  {
1206  fMulTrack = - 1 ;
1207  Error("EvalParents", "increase fMaxParent") ;
1208  break ;
1209  }
1210 
1211  Int_t newParent = digit->GetIparent (jndex+1) ;
1212  Float_t newdEParent = digit->GetDEParent(jndex+1) ;
1213 
1214  // Check if parent was not already stored
1215  // if stored, add its energy deposition.
1216  Int_t kndex ;
1217  Bool_t already = kFALSE ;
1218  for ( kndex = 0 ; kndex < fMulParent ; kndex++ )
1219  {
1220  if ( newParent == parentArray[kndex] )
1221  {
1222  dEParentArray[kndex] += newdEParent;
1223  already = kTRUE ;
1224  break ;
1225  }
1226  } // end of check
1227 
1228  // Store the parent
1229  if ( !already && (fMulParent < fMaxParent) )
1230  {
1231  parentArray [fMulParent] = newParent ;
1232  dEParentArray[fMulParent] = newdEParent ;
1233  fMulParent++ ;
1234  } // store it
1235  } // all parents in digit
1236  } // all digits
1237 
1238  // Order the parents from highest to lowest energy deposit
1239  if ( fMulParent > 0 )
1240  {
1241  Int_t *sortIdx = new Int_t[fMulParent];
1242  TMath::Sort(fMulParent,dEParentArray,sortIdx);
1243 
1244  for(index = 0; index < fMulParent; index++)
1245  {
1246  fParentsList [index] = parentArray [sortIdx[index]] ;
1247  fDEParentsList[index] = dEParentArray[sortIdx[index]] ;
1248  }
1249  delete [] sortIdx;
1250  }
1251 
1252  delete [] parentArray;
1253  delete [] dEParentArray;
1254 }
1255 
1258 //____________________________________________________________________________
1259 void AliEMCALRecPoint::GetLocalPosition(TVector3 & lpos) const
1260 {
1261  lpos = fLocPos;
1262 }
1263 
1267 //____________________________________________________________________________
1268 void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos) const
1269 {
1270  // cout<<" geom "<<geom<<endl;
1271  // fGeomPtr->GetGlobal(fLocPos, gpos, fSuperModuleNumber);
1272  gpos = fGlobPos;
1273 }
1274 
1275 //____________________________________________________________________________
1276 //void AliEMCALRecPoint::GetGlobalPosition(TVector3 & gpos, TMatrixF & gmat) const
1277 //{
1278 // // returns the position of the cluster in the global reference system of ALICE
1279 // // These are now the Cartesian X, Y and Z
1280 // // cout<<" geom "<<geom<<endl;
1281 //
1282 // //To be implemented
1283 // fGeomPtr->GetGlobalEMCAL(this, gpos, gmat);
1284 //
1285 //}
1286 
1291 //_____________________________________________________________________________
1293 {
1295 
1296  const TGeoHMatrix* tr2loc = GetTracking2LocalMatrix();
1297  if(!tr2loc) AliFatal(Form("No Tracking2LocalMatrix found."));
1298 
1299  Double_t lxyz[3] = {fLocPos.X(),fLocPos.Y(),fLocPos.Z()};
1300  Double_t txyz[3] = {0,0,0};
1301 
1302  tr2loc->MasterToLocal(lxyz,txyz);
1303  SetX(txyz[0]); SetY(txyz[1]); SetZ(txyz[2]);
1304 
1306  {
1307  TVector3 gpos; //TMatrixF gmat;
1308  //GetGlobalPosition(gpos,gmat); //Not doing anythin special, replace by next line.
1310 
1311  Float_t gxyz[3];
1312  GetGlobalXYZ(gxyz);
1313  AliInfo(Form("lCS-->(%.3f,%.3f,%.3f), tCS-->(%.3f,%.3f,%.3f), gCS-->(%.3f,%.3f,%.3f), "
1314  " gCScalc->(%.3f,%.3f,%.3f), supermodule %d",
1315  fLocPos.X(),fLocPos.Y(),fLocPos.Z(),
1316  GetX(),GetY(),GetZ(),
1317  gpos.X(),gpos.Y(),gpos.Z(),
1318  gxyz[0],gxyz[1],gxyz[2],GetSuperModuleNumber()));
1319  }
1320 }
1321 
1324 //____________________________________________________________________________
1326 {
1327  Float_t menergy = 0. ;
1328 
1329  Int_t iDigit;
1330  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1331  {
1332  if(fEnergyList[iDigit] > menergy)
1333  menergy = fEnergyList[iDigit] ;
1334  }
1335 
1336  return menergy ;
1337 }
1338 
1341 //____________________________________________________________________________
1343 {
1344  Float_t menergy = 0. ;
1345  Int_t mid = 0 ;
1346  Int_t iDigit;
1347 
1348  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1349  {
1350  if(fEnergyList[iDigit] > menergy)
1351  {
1352  menergy = fEnergyList[iDigit] ;
1353  mid = iDigit ;
1354  }
1355  } // loop on cluster digits
1356 
1357  return mid ;
1358 }
1359 
1362 //____________________________________________________________________________
1364 {
1365  Int_t multipl = 0 ;
1366  Int_t iDigit ;
1367  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1368  {
1369  if(fEnergyList[iDigit] > H * fAmp)
1370  multipl++ ;
1371  }
1372 
1373  return multipl ;
1374 }
1375 
1385 //____________________________________________________________________________
1387  Float_t locMaxCut,
1388  TClonesArray * digits) const
1389 {
1390  AliEMCALDigit ** maxAt = new AliEMCALDigit*[nMult] ;
1391  Float_t * maxAtEnergy = new Float_t [nMult] ;
1392 
1393  Int_t nMax = GetNumberOfLocalMax(maxAt, maxAtEnergy, locMaxCut, digits);
1394 
1395  delete[] maxAt ;
1396  delete[] maxAtEnergy ;
1397 
1398  return nMax;
1399 }
1400 
1411 //____________________________________________________________________________
1412 Int_t AliEMCALRecPoint::GetNumberOfLocalMax(AliEMCALDigit ** maxAt, Float_t * maxAtEnergy,
1413  Float_t locMaxCut,TClonesArray * digits) const
1414 {
1415  AliEMCALDigit * digit = 0;
1416  AliEMCALDigit * digitN = 0;
1417 
1418  Int_t iDigitN = 0 ;
1419  Int_t iDigit = 0 ;
1420 
1421  for(iDigit = 0; iDigit < fMulDigit; iDigit++)
1422  {
1423  maxAt[iDigit] = (AliEMCALDigit*) digits->At(fDigitsList[iDigit]) ;
1424  }
1425 
1426  for(iDigit = 0 ; iDigit < fMulDigit; iDigit++)
1427  {
1428  if(maxAt[iDigit])
1429  {
1430  digit = maxAt[iDigit] ;
1431 
1432  for(iDigitN = 0; iDigitN < fMulDigit; iDigitN++)
1433  {
1434  if(iDigitN == iDigit) continue;//the same digit
1435 
1436  digitN = (AliEMCALDigit *) digits->At(fDigitsList[iDigitN]) ;
1437 
1438  if ( AreNeighbours(digit, digitN) )
1439  {
1440  if (fEnergyList[iDigit] > fEnergyList[iDigitN] )
1441  {
1442  maxAt[iDigitN] = 0 ;
1443 
1444  // but may be digit too is not local max ?
1445  if(fEnergyList[iDigit] < fEnergyList[iDigitN] + locMaxCut)
1446  maxAt[iDigit] = 0 ;
1447  }
1448  else
1449  {
1450  maxAt[iDigit] = 0 ;
1451 
1452  // but may be digitN too is not local max ?
1453  if(fEnergyList[iDigit] > fEnergyList[iDigitN] - locMaxCut)
1454  maxAt[iDigitN] = 0 ;
1455  }
1456  } // if Are neighbours
1457  } // while digitN
1458  } // slot not empty
1459  } // while digit
1460 
1461  iDigitN = 0 ;
1462  for(iDigit = 0; iDigit < fMulDigit; iDigit++)
1463  {
1464  if(maxAt[iDigit] )
1465  {
1466  maxAt[iDigitN] = maxAt[iDigit] ;
1467  maxAtEnergy[iDigitN] = fEnergyList[iDigit] ;
1468  iDigitN++ ;
1469  }
1470  }
1471 
1472  return iDigitN ;
1473 }
1474 
1477 //____________________________________________________________________________
1479 {
1480  if (fMulTrack)
1481  return fTracksList[0];
1482 
1483  return -12345;
1484 }
1485 
1488 //____________________________________________________________________________
1489 void AliEMCALRecPoint::EvalTime(TClonesArray * digits)
1490 {
1491  Float_t maxE = 0;
1492  Int_t maxAt = 0;
1493  for(Int_t idig=0; idig < fMulDigit; idig++)
1494  {
1495  if(fEnergyList[idig] > maxE)
1496  {
1497  maxE = fEnergyList[idig] ;
1498  maxAt = idig;
1499  }
1500  }
1501 
1502  fTime = ((AliEMCALDigit*) digits->At(fDigitsList[maxAt]))->GetTime() ;
1503 }
1504 
1507 //______________________________________________________________________________
1508 void AliEMCALRecPoint::Paint(Option_t *)
1509 {
1510  TVector3 pos(0.,0.,0.) ;
1511  GetLocalPosition(pos) ;
1512  Coord_t x = pos.X() ;
1513  Coord_t y = pos.Z() ;
1514  Color_t markercolor = 1 ;
1515  Size_t markersize = 1.;
1516  Style_t markerstyle = 5 ;
1517 
1518  if (!gPad->IsBatch())
1519  {
1520  gVirtualX->SetMarkerColor(markercolor) ;
1521  gVirtualX->SetMarkerSize (markersize) ;
1522  gVirtualX->SetMarkerStyle(markerstyle) ;
1523  }
1524 
1525  gPad->SetAttMarkerPS(markercolor,markerstyle,markersize) ;
1526  gPad->PaintPolyMarker(1,&x,&y,"") ;
1527 }
1528 
1532 //_____________________________________________________________________
1533 Double_t AliEMCALRecPoint::TmaxInCm(const Double_t e , const Int_t key)
1534 {
1535  const Double_t ca = 4.82; // shower max parameter - first guess; ca=TMath::Log(1000./8.07)
1536  Double_t tmax = 0.; // position of electromagnetic shower max in cm
1537 
1538  Double_t x0 = 1.31; // radiation lenght (cm)
1539 
1540  // If old geometry in use
1541  if(!((fGeomPtr->GetEMCGeometry()->GetGeoName()).Contains("V1"))) x0 = 1.28;
1542 
1543  if(e>0.1)
1544  {
1545  tmax = TMath::Log(e) + ca;
1546  if (key==0) tmax += 0.5;
1547  else tmax -= 0.5;
1548  tmax *= x0; // convert to cm
1549  }
1550 
1551  return tmax;
1552 }
1553 
1556 //______________________________________________________________________________
1557 Float_t AliEMCALRecPoint::EtaToTheta(Float_t arg) const
1558 {
1559  return (2.*TMath::ATan(TMath::Exp(-arg)));
1560 }
1561 
1564 //______________________________________________________________________________
1565 Float_t AliEMCALRecPoint::ThetaToEta(Float_t arg) const
1566 {
1567  return (-1 * TMath::Log(TMath::Tan(0.5 * arg)));
1568 }
1569 
1572 //____________________________________________________________________________
1573 void AliEMCALRecPoint::Print(Option_t *opt) const
1574 {
1575  if(strlen(opt)==0) return;
1576 
1577  TString message ;
1578  message = "AliEMCALRecPoint:\n" ;
1579  message += " digits # = " ;
1580  AliInfo(message.Data()) ;
1581 
1582  Int_t iDigit;
1583  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1584  printf(" %d ", fDigitsList[iDigit] ) ;
1585  printf("\n");
1586 
1587  AliInfo(" Energies = ") ;
1588  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1589  printf(" %f ", fEnergyList[iDigit] ) ;
1590  printf("\n");
1591 
1592  AliInfo("\n Abs Ids = ") ;
1593  for(iDigit=0; iDigit<fMulDigit; iDigit++)
1594  printf(" %i ", fAbsIdList[iDigit] ) ;
1595  printf("\n");
1596 
1597  AliInfo(" Primaries ") ;
1598  for(iDigit = 0;iDigit < fMulTrack; iDigit++)
1599  printf(" %d ", fTracksList[iDigit]) ;
1600 
1601  printf("\n Local x %6.2f y %7.2f z %7.1f \n", fLocPos[0], fLocPos[1], fLocPos[2]);
1602 
1603  message = " ClusterType = %d" ;
1604  message += " Multiplicity = %d" ;
1605  message += " Cluster Energy = %f" ;
1606  message += " Core energy = %f" ;
1607  message += " Core radius = %f" ;
1608  message += " Number of primaries %d" ;
1609  message += " Stored at position %d" ;
1610 
1612 }
1613 
1616 //___________________________________________________________
1618 {
1619  Double_t e=0.0;
1620 
1621  for(int ic=0; ic<GetMultiplicity(); ic++) e += double(fEnergyList[ic]);
1622 
1623  return e;
1624 }
Bool_t EvalLocalPosition2(TClonesArray *digits, TArrayD &ed)
void EvalDistanceToBadChannels(AliCaloCalibPedestal *caloped)
virtual void EvalElipsAxis(Float_t logWeight, TClonesArray *digits)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
virtual Int_t GetNumberOfLocalMax(Int_t nDigitMult, Float_t locMaxCut, TClonesArray *digits) const
Int_t fMaxTrack
! Max initial size of tracks array (not saved)
Int_t GetIndexInList() const
Float_t fAmp
Summed amplitude of digits.
Float_t GetDEParent(Int_t index) const
Float_t * fDETracksList
List of tracks to which the point was assigned.
AliEMCALRecPoint & operator=(const AliEMCALRecPoint &rp)
Assignment operator.
Int_t fMaxParent
Maximum number of parents allowed.
Short_t fNExMax
Number of (Ex-)maxima before unfolding.
virtual Bool_t GetGlobalXYZ(Float_t xyz[3]) const
Definition: AliCluster.cxx:163
Int_t * fDigitsList
List of digit&#39;s indexes from which the point was reconstructed.
static const int fgkEMCALRows
Number of rows per module for EMCAL.
virtual Int_t GetSuperModuleNumber(void) const
void EtaPhiFromIndex(Int_t absId, Double_t &eta, Double_t &phi) const
Int_t fMulTrack
Total multiplicity of tracks.
virtual void EvalDispersion(Float_t logWeight, TClonesArray *digits)
Float_t GetMaximalEnergy(void) const
Finds the maximum energy in the cluster.
virtual Int_t GetDigitsMultiplicity(void) const
TVector3 fGlobPos
Global position.
virtual void Paint(Option_t *option="")
Paint this ALiRecPoint as a TMarker with its current attributes.
Float_t fDistToBadTower
Distance to nearest bad tower.
Float_t GetX() const
Definition: AliCluster.h:44
Float_t fCoreRadius
The radius in which the core energy is evaluated.
void SetZ(Float_t z)
Definition: AliCluster.h:69
void EvalCoreEnergy(Float_t logWeight, TClonesArray *digits)
Double_t TmaxInCm(const Double_t e=0.0, const Int_t key=0)
void EvalLocal2TrackingCSTransform()
EMCal digits object.
Definition: AliEMCALDigit.h:30
Float_t fLambda[2]
Shower ellipse axes.
Int_t GetMaximalEnergyIndex(void) const
Finds the maximum energy in the cluster.
Int_t GetIparent(Int_t index) const
Int_t fSuperModuleNumber
number identifying supermodule containing recpoint, reference is cell with maximum energy...
virtual Bool_t AreNeighbours(AliEMCALDigit *digit1, AliEMCALDigit *digit2) const
void GetCellPhiEtaIndexInSModule(Int_t nSupMod, Int_t nModule, Int_t nIphi, Int_t nIeta, Int_t &iphi, Int_t &ieta) const
Int_t GetMultiplicity(void) const
virtual const TGeoHMatrix * GetTracking2LocalMatrix() const
Definition: AliCluster.cxx:333
virtual void Draw(Option_t *option="")
Draw this AliEMCALRecPoint with its current attributes.
virtual void GetLocalPosition(TVector3 &lpos) const
Bool_t fSharedCluster
States if cluster is shared by 2 SuperModules in same phi rack (0,1), (2,3) ... (10,11).
Float_t fTime
Time of the digit with maximal energy deposition.
Bool_t RelPosCellInSModule(Int_t absId, Double_t &xr, Double_t &yr, Double_t &zr) const
static Int_t GetGlobalDebugLevel()
Definition: AliLog.cxx:476
Int_t GetPrimaryIndex() const
Float_t GetZ() const
Definition: AliCluster.h:46
Float_t ThetaToEta(Float_t arg) const
Converts Eta (Radians) to Theta (Radians)
virtual void EvalPrimaries(TClonesArray *digits)
#define AliInfo(message)
Definition: AliLog.h:484
Bool_t GetCellIndex(Int_t absId, Int_t &nSupMod, Int_t &nModule, Int_t &nIphi, Int_t &nIeta) const
Int_t GetNprimary() const
Definition: AliEMCALDigit.h:57
virtual void AddDigit(AliEMCALDigit &digit, const Float_t energy, const Bool_t shared)
Float_t GetDEPrimary(Int_t index) const
AliEMCALRecPoint()
Default constructor.
EMCal rec_points object.
Int_t GetMultiplicityAtLevel(Float_t level) const
Calculates the multiplicity of digits with energy larger than H*energy.
Float_t * fDEParentsList
List of the parents energy deposit of the digits.
Int_t * fAbsIdList
List with absId of digits.
Int_t fMaxDigit
! Max initial size of digits array (not saved)
void SetX(Float_t x)
Definition: AliCluster.h:67
void SetY(Float_t y)
Definition: AliCluster.h:68
Int_t GetIndexInList() const
Definition: AliDigitNew.h:24
Int_t GetAbsIdMaxDigit() const
virtual void EvalParents(TClonesArray *digits)
void SetVolumeId(UShort_t id)
Definition: AliCluster.h:73
void GetGlobal(const Double_t *loc, Double_t *glob, int ind) const
Base Class for EMCAL description.
Definition: AliEMCAL.h:35
pedestal/bad map monitoring and calibration tools
#define AliFatal(message)
Definition: AliLog.h:640
Float_t EtaToTheta(Float_t arg) const
Converts Theta (Radians) to Eta (Radians)
Float_t * fEnergyList
List with energy of digits.
Int_t fClusterType
Type of cluster stored: v1.
TVector3 fLocPos
Local position in the sub-detector coordinate.
Int_t GetSuperModuleNumber(Int_t absId) const
Float_t fCoreEnergy
Energy in a shower core.
static const int fgkEMCALCols
Number of columns per module for EMCAL.
virtual Int_t Compare(const TObject *obj) const
Compares two RecPoints according to their position in the EMCAL modules.
Int_t * fTracksList
List of tracks to which the point was assigned.
virtual void GetGlobalPosition(TVector3 &gpos) const
Int_t GetPrimary(Int_t index) const
virtual void Print(Option_t *option="") const
Print the list of digits belonging to the cluster.
void EvalTime(TClonesArray *digits)
Time is set to the time of the digit with the maximum energy.
AliEMCALEMCGeometry * GetEMCGeometry() const
Float_t fDispersion
Shower dispersion.
AliEMCALGeometry * fGeomPtr
! Pointer to geometry for utilities
Int_t GetId() const
Definition: AliDigitNew.h:23
virtual void EvalAll(Float_t logWeight, TClonesArray *digits, const Bool_t justClusters)
Evaluates cluster parameters: position, shower shape, primaries ...
Float_t GetY() const
Definition: AliCluster.h:45
static UShort_t LayerToVolUID(ELayerID layerId, Int_t modId)
void EvalLocalPositionFit(Double_t deff, Double_t w0, Double_t phiSlope, TClonesArray *digits)
Evaluates local position of clusters in SM.
Int_t fDigitIndMax
Index of digit with max energy in array fAbsIdList.
Float_t GetTime(void) const
#define AliError(message)
Definition: AliLog.h:591
Int_t fIndexInList
The index of this RecPoint in the list stored in TreeR (to be set by analysis)
static AliEMCALGeometry * GetInstance()
Int_t GetNiparent() const
Definition: AliEMCALDigit.h:60
Double_t GetPointEnergy() const
virtual void EvalLocalPosition(Float_t logWeight, TClonesArray *digits)
Calculates the center of gravity in the local EMCAL-module coordinates.
virtual ~AliEMCALRecPoint()
Destructor.
Int_t fMulDigit
Total multiplicity of digits.
Bool_t EvalLocalPositionFromDigits(const Double_t esum, const Double_t deff, const Double_t w0, TClonesArray *digits, TArrayD &ed, TVector3 &locPos)
Evaluate position of digits in supermodule.
EMCal geometry, singleton.
virtual void EvalGlobalPosition(Float_t logWeight, TClonesArray *digits)
Calculates the center of gravity in the global ALICE coordinates.
static void GetDeffW0(const Double_t esum, Double_t &deff, Double_t &w0)
Int_t * fParentsList
List of the parents index of the digits.
Int_t fMulParent
Multiplicity of the parents.
TString GetGeoName() const
static double fAmp
amplitude