3 //_________________________________________________________________________
4 // Class for easier handling of track-cluster electron PID.
6 // Author: Tomas Aronsson (Yale)
7 ///////////////////////////////////////////////////////////////////////////
10 #include <TLorentzVector.h>
11 #include <TObjArray.h>
12 #include <AliEMCALGeometry.h>
15 #include <AliESDCaloCells.h>
16 #include <AliESDCaloCluster.h>
17 #include <AliESDtrack.h>
18 #include <AliESDtrack.h>
19 #include "AliEMCALClusterParams.h"
21 ClassImp(AliEMCALClusterParams)
23 //____________________________________________________________________________
24 AliEMCALClusterParams::AliEMCALClusterParams(AliESDtrack *trackin,
25 AliESDCaloCluster *clusin,
26 AliEMCALGeometry *geometryin,
27 AliESDCaloCells *cellsin) :
37 //____________________________________________________________________________
38 Double_t AliEMCALClusterParams::GetPe() const
40 Double_t pe=fTrack->Pt()/fCluster->E();
44 //____________________________________________________________________________
45 Int_t AliEMCALClusterParams::IsElectron() const
47 Double_t ep=fCluster->E()/fTrack->Pt();
48 // if (fCluster->GetNCells() < 2 ) return 0;
49 // if (fCluster->GetNCells() > 35 ) return 0;
50 // if (fCluster->E() < 0 ) return 0;
51 // if (fCluster->GetDispersion() > 1.08 ) return 0;
52 // if (fCluster->GetM20() > 0.42 ) return 0;
53 // if (fCluster->GetM02() > 0.4 ) return 0;
54 // if (fCluster->GetM20() < 0 ) return 0;
55 // if (fCluster->GetM02() < 0.06 ) return 0;
58 dEdx=fTrack->GetTPCsignal();
59 //if(dEdx0>75.&&dEdx0<95&&fRunnumber>141794&&fRunnumber<146861) istpce0=1;
60 //if(dEdx0>56.&&dEdx0<73&&fRunnumber>151564&&fRunnumber<155385) istpce0=1;
61 //if(dEdx0 > 70.&&fRunnumber<141795) istpce0=1;
62 if(dEdx>70.0&&dEdx<95.0) istpce=1;
64 if (ep>0.8&&ep<1.2&&istpce) return 1;
68 //____________________________________________________________________________
69 void AliEMCALClusterParams::LoopThroughCells() const
71 Int_t nclusfCells=fCluster->GetNCells();
73 celllist=fCluster->GetCellsAbsId();
74 for (Int_t i=0;i<nclusfCells;i++) {
82 printf("Cell %d id: %d. ",i,celllist[i]);
84 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
85 printf("iphi,eta: %d %d, ",iIphi,iIeta);
86 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
87 printf("smod %d tower %d ieta %d iphi %d \n",iSupMod,iTower,iphi,ieta);
91 //____________________________________________________________________________
92 void AliEMCALClusterParams::PrintClusterParameters() const
94 printf("N fCells: %d Energy: %f Dispersion %f M02: %f M20: %f p/E: %f \n",
95 fCluster->GetNCells(),fCluster->E(),fCluster->GetDispersion(),
96 fCluster->GetM02(),fCluster->GetM20(),fTrack->Pt()/fCluster->E());
99 //===================================== UNWEIGHTED PARAMETERS==================================
101 //____________________________________________________________________________
102 void AliEMCALClusterParams::GetCentroid(Double_t &xback, Double_t &yback, Double_t &rback) const
104 Int_t nclusfCells=fCluster->GetNCells();
106 celllist=fCluster->GetCellsAbsId();
108 //Calculates mean x,y and r of the fCluster
109 Double_t etai=0, phii=0;
115 for (Int_t i=0;i<nclusfCells;i++) {
123 //printf("Cell %d id: %d. ",i,celllist[i]);
124 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
125 // printf("iphi,eta: %d %d, ",iIphi,iIeta);
126 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
127 //printf("smod %d tower %d ieta %d iphi %d \n",iSupMod,iTower,iphi,ieta);
129 etai=(Double_t)ieta+1.;
130 phii=(Double_t)iphi+1.;
131 xsum+=etai*fCells->GetCellAmplitude(celllist[i]);
132 ysum+=phii*fCells->GetCellAmplitude(celllist[i]);
133 esum+=fCells->GetCellAmplitude(celllist[i]);
134 rsum+=sqrt(etai*etai+phii*phii)*fCells->GetCellAmplitude(celllist[i]);
141 //____________________________________________________________________________
142 Double_t AliEMCALClusterParams::GetR(Double_t x, Double_t y) const
144 // Takes fCluster, and cell position (x,y) and returns distance of cell from centroid
150 GetCentroid(xmean,ymean,rmean);
151 return sqrt(pow((x-xmean),2)+pow((y-ymean),2));
154 //_____________________________________________________________________________
155 Double_t AliEMCALClusterParams::GetRfactor() const
157 Int_t nclusfCells=fCluster->GetNCells();
159 celllist=fCluster->GetCellsAbsId();
161 //Calculates mean x,y and r of the fCluster
162 Double_t etai=0, phii=0;
166 for (Int_t i=0;i<nclusfCells;i++) {
174 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
175 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
177 etai=(Double_t)ieta+1.;
178 phii=(Double_t)iphi+1.;
179 esum+=fCells->GetCellAmplitude(celllist[i]);
180 rsum+=GetR(etai,phii)*fCells->GetCellAmplitude(celllist[i]);//GetR!
187 //____________________________________________________________________________
188 Double_t AliEMCALClusterParams::ElectronFraction(Double_t r, Double_t tce) const
190 // In determination of the 'K-factor', we measure the 'dispersion' of the [energy fraction of the cell
191 // as a function of cell distance from the centroid] from the the distribution for electrons
192 // the functional form for electrons is saved here.
193 // tce is TOTAL FCLUSTER ENERGY, r is distance of cell to centroid.
195 Double_t parm[20][11] = {{0.968421,-0.952347,0.196982,-495.028,495.028,0.512768,3.21555,-134.368,950.132,0.258585,-0.0819375},
196 {0.964309,-0.955084,0.212321,-401.273,401.273,0.600581,-2.44701,-43.9126,1009.65,0.19388,-0.0527486},
197 {0.949579,-0.938399,0.169353,-398.208,398.208,0.801709,-16.1048,399.842,-2319.64,0.16054,-0.044954},
198 {0.937618,-0.926665,0.173489,-291.715,291.715,0.723635,-5.65824,222.248,-1525.94,0.125206,-0.0108058},
199 {0.922977,-0.91741,0.174686,-269.155,269.155,0.777305,-0.656328,86.8073,-733.079,0.123508,-0.0159208},
200 {0.88858,-0.86354,0.102552,-280.217,280.217,0.746299,7.06471,-93.7562,323.688,0.128045,-0.0306688},
201 {0.859556,-0.83609,0.108273,-275.632,275.632,0.752012,4.78987,-66.0216,262.093,0.102209,-0.0201003},
202 {0.789254,-0.749649,0.0960812,-331.001,331.001,0.703363,6.70229,-129.452,725.871,0.0861534,-0.0127965},
203 {0.813629,-0.784791,0.0847636,-287.469,287.469,0.7138,7.15787,-142.766,820.634,0.0625165,-0.00910334},
204 {0.828972,-0.805683,0.0812484,-522.356,522.356,0.813623,1.77465,-34.6065,147.756,0.0467835,-0.00425002},
205 {0.900904,-0.890754,0.048338,-1180.84,1180.84,0.870175,0.0385033,-6.99334,19.6102,0.0232503,-0.00446416},
206 {0.881545,-0.870425,0.0382378,-750,750,0.857701,0.181933,-7.72458,12.6329,0.0198669,-0.00436687},
207 {0.893767,-0.878626,0.0465724,-750,750,0.867552,0.0868854,-9.17702,27.6996,0.013101,-0.00261109},
208 {0.88893,-0.882229,0.0896708,-1166.94,828.101,0.864913,-0.245158,-1.5693,-10.5061,0.00658265,-0.000176185},
209 {0.875546,-0.867819,0.0433809,-750,750,0.853546,0.103699,-4.53405,0.67608,0.00667051,-0.00110355},
210 {0.879879,-0.874221,0.0510928,-750,750,0.846377,0.246414,-4.28576,-22.6443,0.00537529,-0.000852894},
211 {0.889361,-0.884282,0.0475369,-750,750,0.845565,0.419865,-7.83763,-2.71567,0.00348465,-0.000407448},
212 {0.893711,-0.890189,0.0649599,-847.351,847.351,0.844507,0.379177,-8.07506,7.69156,0.0005,-2.89084e-13},
213 {0.893706,-0.891587,0.0409521,-750,750,0.841632,0.269466,-4.04288,-14.8299,0.00211674,-0.000173327},
214 {0.942361,-0.941082,0.0703767,-750,750,0.83202,0.829046,-11.3403,29.0905,0.00025,5.67537e-05}};
216 Double_t par[11]={0};
217 if (tce>0&&tce<0.6) {
218 for (Int_t l=0;l<11;l++)
220 } else if (tce>0.6&&tce<0.8) {
221 for (Int_t l=0;l<11;l++)
223 } else if (tce>0.8&&tce<1.12) {
224 for (Int_t l=0;l<11;l++)
226 } else if (tce>1.12&&tce<1.37) {
227 for (Int_t l=0;l<11;l++)
229 } else if (tce>1.37&&tce<1.75) {
230 for (Int_t l=0;l<11;l++)
232 } else if (tce>1.75&&tce<2.5) {
233 for (Int_t l=0;l<11;l++)
235 } else if (tce>2.5&&tce<3.5) {
236 for (Int_t l=0;l<11;l++)
238 } else if (tce>3.5&&tce<4.5) {
239 for (Int_t l=0;l<11;l++)
241 } else if (tce>4.5&&tce<5.5) {
242 for (Int_t l=0;l<11;l++)
244 } else if (tce>5.5&&tce<8) {
245 for (Int_t l=0;l<11;l++)
247 } else if (tce<8&&tce>12) {
248 for (Int_t l=0;l<11;l++)
250 } else if (tce>12&&tce<20) {
251 for (Int_t l=0;l<11;l++)
253 } else if (tce>20&&tce<40) {
254 for (Int_t l=0;l<11;l++)
256 } else if (tce>40&&tce<63) {
257 for (Int_t l=0;l<11;l++)
259 } else if (tce>63&&tce<88) {
260 for (Int_t l=0;l<11;l++)
262 } else if (tce>88&&tce<113) {
263 for (Int_t l=0;l<11;l++)
265 } else if (tce>113&&tce<138) {
266 for (Int_t l=0;l<11;l++)
268 } else if (tce>138&&tce<163) {
269 for (Int_t l=0;l<11;l++)
271 } else if (tce>163&&tce<188) {
272 for (Int_t l=0;l<11;l++)
274 } else if (tce>188) {
275 for (Int_t l=0;l<11;l++)
281 fr =par[5]+par[6]*r+par[7]*r*r+par[8]*r*r*r;
282 } else if (r>0.1&&r<0.92) {
283 fr = par[0]+par[1]*r+par[2]*exp(par[3]-par[4]*r);
284 } else if (r>0.92&&r<6) {
285 fr = par[9] + par[10]*r;
288 cout<<"Crappy f(r_i) value, more than 6!"<<endl;
291 return fr; //returns fraction of energy at r,E: f(r,E), correct?
294 //____________________________________________________________________________
295 Double_t AliEMCALClusterParams::GetKfactor() const
297 // Determines the k-factor, uses the funtion ElectronFraction(r,totalenergyoffCluster)
299 Double_t totalFClusterEnergy = fCluster->E();
300 //Calculates mean x,y and r of the fCluster
301 Double_t etai=0, phii=0;
305 Int_t nclusfCells=fCluster->GetNCells();
307 celllist=fCluster->GetCellsAbsId();
309 for (Int_t i=0;i<nclusfCells;i++) {
317 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
318 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
320 etai=(Double_t)ieta+1.;
321 phii=(Double_t)iphi+1.;
323 kfactor+=GetR(etai,phii)*pow(fCells->GetCellAmplitude(celllist[i])/(totalFClusterEnergy) -
324 ElectronFraction(GetR(etai,phii),totalFClusterEnergy),2);
330 //____________________________________________________________________________
331 Double_t AliEMCALClusterParams::GetDispersionX() const
339 GetCentroid(xmean,ymean,rmean);
341 Int_t nclusfCells=fCluster->GetNCells();
343 celllist=fCluster->GetCellsAbsId();
345 for (Int_t i=0;i<nclusfCells;i++) {
353 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
354 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
356 Double_t etai=(Double_t)ieta+1.;
358 dsum+=(pow(etai-xmean,2))*fCells->GetCellAmplitude(celllist[i]);
359 esum+=fCells->GetCellAmplitude(celllist[i]);
362 return sqrt(dsum/esum);
365 //____________________________________________________________________________
366 Double_t AliEMCALClusterParams::GetDispersionY() const
374 GetCentroid(xmean,ymean,rmean);
376 Int_t nclusfCells=fCluster->GetNCells();
378 celllist=fCluster->GetCellsAbsId();
380 for (Int_t i=0;i<nclusfCells;i++) {
388 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
389 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
391 Double_t phii=(Double_t)iphi+1.;
393 dsum+=(pow(phii-ymean,2))*fCells->GetCellAmplitude(celllist[i]);
394 esum+=fCells->GetCellAmplitude(celllist[i]);
397 return sqrt(dsum/esum);
400 //____________________________________________________________________________
401 Double_t AliEMCALClusterParams::GetDispersionMax() const
403 Double_t dispX = GetDispersionX();
404 Double_t dispY = GetDispersionY();
413 //____________________________________________________________________________
414 void AliEMCALClusterParams::GetEllipseParameters(Double_t ¶m1, Double_t ¶m2) const
423 Int_t nclusfCells=fCluster->GetNCells();
425 celllist=fCluster->GetCellsAbsId();
427 for (Int_t i=0;i<nclusfCells;i++) {
435 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
436 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
438 Double_t phii=(Double_t)iphi+1.;
439 Double_t etai=(Double_t)ieta+1.;
440 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
442 sumxx += amp*pow(etai,2);
443 sumyy += amp*pow(phii,2);
446 sumxy += amp*etai*phii;
453 sumxx=sumxx-sumx*sumx;
454 sumyy = sumyy-sumy*sumy;
455 sumxy = sumxy/esum - sumx*sumy;
457 param1 = 0.5*(sumxx+sumyy) + sqrt(0.25*pow((sumxx-sumyy),2) + sumxy*sumxy);
458 param2 = 0.5*(sumxx+sumyy) - sqrt(0.25*pow((sumxx-sumyy),2) + sumxy*sumxy);
461 //____________________________________________________________________________
462 Double_t AliEMCALClusterParams::GetDispersion() const
470 GetCentroid(xmean,ymean,rmean);
472 Int_t nclusfCells=fCluster->GetNCells();
474 celllist=fCluster->GetCellsAbsId();
477 for (Int_t i=0;i<nclusfCells;i++) {
484 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
486 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
487 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
489 Double_t phii=(Double_t)iphi+1.;
490 Double_t etai=(Double_t)ieta+1.;
492 dsum+=(pow(phii-ymean,2)+pow(etai-xmean,2))*amp;
496 return sqrt(dsum/esum);
499 //============================LOG WEIGHTED PARAMETERS========================================================
501 //____________________________________________________________________________
502 void AliEMCALClusterParams::GetWeightedCentroid(Double_t &xback, Double_t &yback, Double_t &rback) const
504 Float_t logWeight = 4.5;
505 Double_t totalFClusterEnergy=fCluster->E();
507 //Calculates mean x,y and r of the fCluster
508 Double_t etai=0, phii=0;
514 Int_t nclusfCells=fCluster->GetNCells();
516 celllist=fCluster->GetCellsAbsId();
518 for (Int_t i=0;i<nclusfCells;i++) {
525 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
527 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
528 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
530 etai=(Double_t)ieta+1.;
531 phii=(Double_t)iphi+1.;
532 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
536 rsum+=sqrt(etai*etai+phii*phii)*w;
544 //____________________________________________________________________________
545 Double_t AliEMCALClusterParams::GetWeightedR(Double_t x, Double_t y) const
547 //takes fCluster, and cell position (x,y) and returns distance of cell from
553 GetWeightedCentroid(xmean,ymean,rmean);
554 return sqrt(pow((x-xmean),2)+pow((y-ymean),2));
557 //_____________________________________________________________________________
558 Double_t AliEMCALClusterParams::GetWeightedRfactor() const
562 Double_t etai=0, phii=0;
564 Float_t logWeight = 4.5;
566 Double_t totalFClusterEnergy=fCluster->E();
567 Int_t nclusfCells=fCluster->GetNCells();
569 celllist=fCluster->GetCellsAbsId();
571 for (Int_t i=0;i<nclusfCells;i++) {
578 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
580 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
581 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
583 etai=(Double_t)ieta+1.;
584 phii=(Double_t)iphi+1.;
585 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
587 rsum+=GetWeightedR(etai,phii)*w;
594 //____________________________________________________________________________
595 Double_t AliEMCALClusterParams::ElectronfractionWeighted(Double_t r, Double_t tce) const
597 // In determination of the 'K-factor', we measure the 'dispersion' of the [energy fraction of the cell
598 // as a function of cell distance from the centroid] from the the distribution for electrons
599 // the functional form for electrons is saved here.
601 Double_t parm[20][10] = {{9.65749,-25.2283,146.575,-207.63,-3.53453,86.296,-176.854,110.51,8.21828,0.097827},
602 {9.69895,-19.8042,112.42,-156.762,16.8874,-27.4961,28.4271,-9.31945,8.18897,-0.213499},
603 {9.58816,-15.0126,92.8682,-137.142,19.3093,-42.9118,59.9102,-29.9932,8.10929,-0.118502},
604 {9.66433,-17.3556,105.064,-154.824,19.3254,-43.845,63.0948,-32.7479,7.3532,0.437176},
605 {9.63564,-12.3028,76.0095,-113.329,16.337,-29.9111,42.2855,-22.8323,7.56083,0.14301},
606 {9.57174,-8.92634,58.7273,-91.3475,9.81528,2.85217,-10.6939,4.76399,7.93151,-0.320945},
607 {9.49951,-3.10053,18.9051,-26.8457,11.5665,-6.0263,3.44864,-2.37582,7.36371,-0.057224},
608 {9.43673,-2.63179,13.7039,-19.2528,9.83544,0.91246,-6.30083,2.46559,7.36203,-0.146645},
609 {9.5378,-2.35688,12.6874,-19.3792,7.64049,12.0476,-24.2138,11.5242,7.2368,-0.337072},
610 {9.52255,-0.989157,7.61241,-14.1598,6.28615,18.4146,-33.4616,15.6595,6.66628,-0.0979268},
611 {9.92079,-1.74431,9.58206,-16.8904,20.9936,-35.2392,29.6651,-9.03178,5.74954,-0.082485},
612 {9.88709,-1.11991,6.64989,-13.221,15.0524,-15.8677,9.13398,-1.97541,5.5779,-0.146283},
613 {9.91925,-1.71077,9.34349,-16.919,15.913,-16.3563,8.1726,-1.38982,5.04338,-0.120024},
614 {9.90981,-2.53254,13.2516,-21.0921,15.1033,-14.4442,6.87168,-1.18726,4.25787,0.0881321},
615 {9.7964,-0.0431799,2.45754,-9.00884,15.2986,-15.7366,8.37136,-1.66767,3.83555,0.0409475},
616 {9.82242,-0.718889,5.19571,-11.6806,15.4565,-16.0309,8.56511,-1.70815,3.46559,0.0840781},
617 {9.88062,-1.21927,7.07515,-13.7956,14.2168,-13.5604,6.90633,-1.3678,3.06548,0.162603},
618 {9.98456,-2.58626,12.6175,-20.0417,12.9291,-10.2085,4.02983,-0.606252,3.34551,0.040163},
619 {9.89892,-1.45526,8.17534,-14.9205,12.5899,-9.74255,4.08869,-0.718114,2.51632,0.245529},
620 {11.2705,-5.29437,0.810794,-0.00331736,10.2653,-0.725442,-3.84838,1.23406,3.85982,-0.188577}};
622 Double_t par[10]={0};
623 if (tce>0&&tce<0.6) {
624 for (Int_t l=0;l<10;l++)
626 } else if (tce>0.6&&tce<0.8) {
627 for (Int_t l=0;l<10;l++)
629 } else if (tce>0.8&&tce<1.12) {
630 for (Int_t l=0;l<10;l++)
632 } else if (tce>1.12&&tce<1.37) {
633 for (Int_t l=0;l<10;l++)
635 } else if (tce>1.37&&tce<1.75) {
636 for (Int_t l=0;l<10;l++)
638 } else if (tce>1.75&&tce<2.5) {
639 for (Int_t l=0;l<10;l++)
641 } else if (tce>2.5&&tce<3.5) {
642 for (Int_t l=0;l<10;l++)
644 } else if (tce>3.5&&tce<4.5) {
645 for (Int_t l=0;l<10;l++)
647 } else if (tce>4.5&&tce<5.5) {
648 for (Int_t l=0;l<10;l++)
650 } else if (tce>5.5&&tce<8) {
651 for (Int_t l=0;l<10;l++)
653 } else if (tce<8&&tce>12) {
654 for (Int_t l=0;l<10;l++)
656 } else if (tce>12&&tce<20) {
657 for (Int_t l=0;l<10;l++)
659 } else if (tce>20&&tce<40) {
660 for (Int_t l=0;l<10;l++)
662 } else if (tce>40&&tce<63) {
663 for (Int_t l=0;l<10;l++)
665 } else if (tce>63&&tce<88) {
666 for (Int_t l=0;l<10;l++)
668 } else if (tce>88&&tce<113) {
669 for (Int_t l=0;l<10;l++)
671 } else if (tce>113&&tce<138) {
672 for (Int_t l=0;l<10;l++)
674 } else if (tce>138&&tce<163) {
675 for (Int_t l=0;l<10;l++)
677 } else if (tce>163&&tce<188) {
678 for (Int_t l=0;l<10;l++)
680 } else if (tce>188) {
681 for (Int_t l=0;l<10;l++)
687 fr = par[4]+par[5]*r+par[6]*r*r+par[7]*r*r*r;
688 } else if (r>0.5&&r<1.0) {
689 fr = par[0]+par[1]*r+par[2]*r*r+par[3]*r*r*r;
690 } else if (r>1.0&&r<6) {
691 fr = par[8] + par[9]*r;
694 cout<<"Crappy f(r_i) value, more than 6!"<<endl;
697 //cout<<"Weighter fr is: "<<fr<<" and tce,r: "<<tce<<" "<<r<<endl;
701 //____________________________________________________________________________
702 Double_t AliEMCALClusterParams::GetWeightedKfactor() const
704 Double_t logWeight = 4.5;
705 //determines the k-factor
708 Double_t totalFClusterEnergy=fCluster->E();
709 Int_t nclusfCells=fCluster->GetNCells();
711 celllist=fCluster->GetCellsAbsId();
713 for (Int_t i=0;i<nclusfCells;i++) {
720 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
722 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
723 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
725 Double_t etai=(Double_t)ieta+1.;
726 Double_t phii=(Double_t)iphi+1.;
728 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
729 kfactor+=GetWeightedR(etai,phii)*pow(w - ElectronfractionWeighted(GetWeightedR(etai,phii),totalFClusterEnergy),2);
735 //____________________________________________________________________________
736 Double_t AliEMCALClusterParams::GetWeightedDispersionX() const
738 Float_t logWeight = 4.5;
739 // Calculates the dispersion of the shower at the origin of the RecPoint
740 // in cell units - Nov 16,2006
742 Double_t d = 0., wtot = 0., w = 0.;
745 // Calculates the dispersion in cell units
746 Double_t etai=0, etaMean=0.0;
748 // Calculate mean values
749 Double_t totalFClusterEnergy=fCluster->E();
750 Int_t nclusfCells=fCluster->GetNCells();
752 celllist=fCluster->GetCellsAbsId();
754 Int_t ncell=0;//cell counter
756 for (Int_t i=0;i<nclusfCells;i++) {
763 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
765 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
766 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
770 etai=(Double_t)ieta+1.;
771 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
779 etaMean = etaMean/wtot;
781 // Calculate dispersion
782 // Loop over fCells in the newly created fCluster
783 Int_t ncell1=0;//cell counter
786 for (Int_t i=0;i<nclusfCells;i++) {
793 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
795 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
796 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
799 etai=(Double_t)ieta+1.;
800 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
804 d += w*((etai-etaMean)*(etai-etaMean)); //Add squares
808 if ( wtot > 0 && nstat>1) d /= wtot;
811 return TMath::Sqrt(d);
814 //____________________________________________________________________________
815 Double_t AliEMCALClusterParams::GetWeightedDispersionY() const
817 Float_t logWeight = 4.5;
818 // Calculates the dispersion of the shower at the origin of the RecPoint
819 // in cell units - Nov 16,2006
821 Double_t d = 0., wtot = 0., w = 0.;
824 // Calculates the dispersion in cell units
825 Double_t phii=0, phiMean=0.0;
827 // Calculate mean values
828 Double_t totalFClusterEnergy=fCluster->E();
829 Int_t nclusfCells=fCluster->GetNCells();
831 celllist=fCluster->GetCellsAbsId();
833 Int_t ncell=0;//cell counter
835 for (Int_t i=0;i<nclusfCells;i++) {
842 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
844 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
845 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
849 phii=(Double_t)iphi+1.;
850 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
858 phiMean = phiMean/wtot;
860 // Calculate dispersion
861 // Loop over fCells in the newly created fCluster
862 Int_t ncell1=0;//cell counter
864 for (Int_t i=0;i<nclusfCells;i++) {
871 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
873 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
874 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
878 phii=(Double_t)iphi+1.;
879 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
883 d += w*((phii-phiMean)*(phii-phiMean)); //Add squares
887 if ( wtot > 0 && nstat>1) d /= wtot;
890 return TMath::Sqrt(d);
893 //____________________________________________________________________________
894 Double_t AliEMCALClusterParams::GetWeightedDispersionMax() const
896 Double_t dispX = GetWeightedDispersionX();
897 Double_t dispY = GetWeightedDispersionY();
906 //____________________________________________________________________________
907 void AliEMCALClusterParams::GetWeightedEllipseParameters(Double_t ¶m1, Double_t ¶m2) const
909 Float_t logWeight=4.5;
918 Double_t etai =0, phii=0, w=0;
920 Int_t ncell=0;//cell counter
922 Double_t totalFClusterEnergy=fCluster->E();
923 Int_t nclusfCells=fCluster->GetNCells();
925 celllist=fCluster->GetCellsAbsId();
927 for (Int_t i=0;i<nclusfCells;i++) {
934 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
938 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
939 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
945 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ) ); //Energy of tower/total clus E, in GeV
946 dxx += w * etai * etai;
948 dzz += w * phii * phii;
950 dxz += w * etai * phii;
963 param1 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
964 param2 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
971 //____________________________________________________________________________
972 Double_t AliEMCALClusterParams::GetWeightedDispersion(Double_t &dispersionback) const
974 Float_t logWeight = 4.5;
975 // Calculates the dispersion of the shower at the origin of the RecPoint
976 // in cell units - Nov 16,2006
978 Double_t d = 0., wtot = 0., w = 0.;
982 // Calculates the dispersion in cell units
983 Double_t etai, phii, etaMean=0.0, phiMean=0.0;
985 // Calculate mean values
986 Int_t ncell=0;//cell counter
988 Double_t totalFClusterEnergy=fCluster->E();
989 Int_t nclusfCells=fCluster->GetNCells();
991 celllist=fCluster->GetCellsAbsId();
993 for (Int_t i=0;i<nclusfCells;i++) {
1000 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1004 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1005 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1007 etai=(Double_t)ieta+1.;
1008 phii=(Double_t)iphi+1.;
1009 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
1019 phiMean = phiMean/wtot;
1020 etaMean = etaMean/wtot;
1023 // Calculate dispersion
1024 Int_t ncell1=0;//cell counter
1027 for (Int_t i=0;i<nclusfCells;i++) {
1034 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1038 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1039 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1041 etai=(Double_t)ieta+1.;
1042 phii=(Double_t)iphi+1.;
1043 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
1047 d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean)); //Add squares
1054 if ( wtot > 0 && nstat>1) d /= wtot;
1057 //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",d);
1059 return TMath::Sqrt(d);
1063 //____________________________________________________________________________
1064 void AliEMCALClusterParams::RecalculateClusterShowerShapeParameters(Double_t &m02, Double_t &m20, Double_t &dispersion) const
1066 // Calculates new center of gravity in the local EMCAL-module coordinates
1067 // and tranfers into global ALICE coordinates
1068 // Calculates Dispersion and main axis
1074 Double_t eCell = 0.;
1082 Double_t etai = -1.;
1083 Double_t phii = -1.;
1090 Double_t xmean = 0.;
1091 Double_t zmean = 0.;
1093 Double_t totalFClusterEnergy=fCluster->E();
1094 Int_t nclusfCells=fCluster->GetNCells();
1096 celllist=fCluster->GetCellsAbsId();
1099 for (Int_t i=0;i<nclusfCells;i++) {
1100 //Get from the absid the supermodule, tower and eta/phi numbers
1102 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1103 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1105 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1108 if (totalFClusterEnergy > 0 && eCell > 0) {
1109 w = TMath::Max( 0., fW0 + TMath::Log( eCell / totalFClusterEnergy ));
1110 etai=(Double_t)ieta;
1111 phii=(Double_t)iphi;
1116 dxx += w * etai * etai;
1118 dzz += w * phii * phii;
1120 dxz += w * etai * phii;
1124 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, fCluster->E()));
1127 //Normalize to the weight
1133 AliError(Form("Wrong weight %f\n", wtot));
1135 //Calculate dispersion
1136 for (Int_t i=0;i<nclusfCells;i++) {
1137 //Get from the absid the supermodule, tower and eta/phi numbers
1138 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1139 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1141 eCell = fCells->GetCellAmplitude(celllist[i]);
1143 if (totalFClusterEnergy > 0 && eCell > 0) {
1144 w = TMath::Max( 0., fW0 + TMath::Log( eCell / totalFClusterEnergy ));
1145 etai=(Double_t)ieta;
1146 phii=(Double_t)iphi;
1147 if (w > 0.0) d += w*((etai-xmean)*(etai-xmean)+(phii-zmean)*(phii-zmean));
1150 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, fCluster->E()));
1153 //Normalize to the weigth and set shower shape parameters
1154 if (wtot > 0 && nstat > 1) {
1159 dxx -= xmean * xmean;
1160 dzz -= zmean * zmean;
1161 dxz -= xmean * zmean;
1162 m02=(0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1163 m20=(0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1172 dispersion=TMath::Sqrt(d);