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"
24 ClassImp(AliEMCALClusterParams)
26 //____________________________________________________________________________
27 AliEMCALClusterParams::AliEMCALClusterParams(AliESDtrack *trackin,
28 AliESDCaloCluster *clusin,
29 AliEMCALGeometry *geometryin,
30 AliESDCaloCells *cellsin) :
40 //____________________________________________________________________________
41 Double_t AliEMCALClusterParams::GetPe() const
43 Double_t pe=fTrack->Pt()/fCluster->E();
47 //____________________________________________________________________________
48 Int_t AliEMCALClusterParams::IsElectron() const
50 Double_t ep=fCluster->E()/fTrack->Pt();
51 // if (fCluster->GetNCells() < 2 ) return 0;
52 // if (fCluster->GetNCells() > 35 ) return 0;
53 // if (fCluster->E() < 0 ) return 0;
54 // if (fCluster->GetDispersion() > 1.08 ) return 0;
55 // if (fCluster->GetM20() > 0.42 ) return 0;
56 // if (fCluster->GetM02() > 0.4 ) return 0;
57 // if (fCluster->GetM20() < 0 ) return 0;
58 // if (fCluster->GetM02() < 0.06 ) return 0;
61 dEdx=fTrack->GetTPCsignal();
62 //if(dEdx0>75.&&dEdx0<95&&fRunnumber>141794&&fRunnumber<146861) istpce0=1;
63 //if(dEdx0>56.&&dEdx0<73&&fRunnumber>151564&&fRunnumber<155385) istpce0=1;
64 //if(dEdx0 > 70.&&fRunnumber<141795) istpce0=1;
65 if(dEdx>70.0&&dEdx<95.0) istpce=1;
67 if (ep>0.8&&ep<1.2&&istpce) return 1;
71 //____________________________________________________________________________
72 void AliEMCALClusterParams::LoopThroughCells() const
74 Int_t nclusfCells=fCluster->GetNCells();
76 celllist=fCluster->GetCellsAbsId();
77 for (Int_t i=0;i<nclusfCells;i++) {
85 printf("Cell %d id: %d. ",i,celllist[i]);
87 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
88 printf("iphi,eta: %d %d, ",iIphi,iIeta);
89 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
90 printf("smod %d tower %d ieta %d iphi %d \n",iSupMod,iTower,iphi,ieta);
94 //____________________________________________________________________________
95 void AliEMCALClusterParams::PrintClusterParameters() const
97 printf("N fCells: %d Energy: %f Dispersion %f M02: %f M20: %f p/E: %f \n",
98 fCluster->GetNCells(),fCluster->E(),fCluster->GetDispersion(),
99 fCluster->GetM02(),fCluster->GetM20(),fTrack->Pt()/fCluster->E());
102 //===================================== UNWEIGHTED PARAMETERS==================================
104 //____________________________________________________________________________
105 void AliEMCALClusterParams::GetCentroid(Double_t &xback, Double_t &yback, Double_t &rback) const
107 Int_t nclusfCells=fCluster->GetNCells();
109 celllist=fCluster->GetCellsAbsId();
111 //Calculates mean x,y and r of the fCluster
112 Double_t etai=0, phii=0;
118 for (Int_t i=0;i<nclusfCells;i++) {
126 //printf("Cell %d id: %d. ",i,celllist[i]);
127 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
128 // printf("iphi,eta: %d %d, ",iIphi,iIeta);
129 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
130 //printf("smod %d tower %d ieta %d iphi %d \n",iSupMod,iTower,iphi,ieta);
132 etai=(Double_t)ieta+1.;
133 phii=(Double_t)iphi+1.;
134 xsum+=etai*fCells->GetCellAmplitude(celllist[i]);
135 ysum+=phii*fCells->GetCellAmplitude(celllist[i]);
136 esum+=fCells->GetCellAmplitude(celllist[i]);
137 rsum+=sqrt(etai*etai+phii*phii)*fCells->GetCellAmplitude(celllist[i]);
144 //____________________________________________________________________________
145 Double_t AliEMCALClusterParams::GetR(Double_t x, Double_t y) const
147 // Takes fCluster, and cell position (x,y) and returns distance of cell from centroid
153 GetCentroid(xmean,ymean,rmean);
154 return sqrt(pow((x-xmean),2)+pow((y-ymean),2));
157 //_____________________________________________________________________________
158 Double_t AliEMCALClusterParams::GetRfactor() const
160 Int_t nclusfCells=fCluster->GetNCells();
162 celllist=fCluster->GetCellsAbsId();
164 //Calculates mean x,y and r of the fCluster
165 Double_t etai=0, phii=0;
169 for (Int_t i=0;i<nclusfCells;i++) {
177 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
178 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
180 etai=(Double_t)ieta+1.;
181 phii=(Double_t)iphi+1.;
182 esum+=fCells->GetCellAmplitude(celllist[i]);
183 rsum+=GetR(etai,phii)*fCells->GetCellAmplitude(celllist[i]);//GetR!
190 //____________________________________________________________________________
191 Double_t AliEMCALClusterParams::ElectronFraction(Double_t r, Double_t tce) const
193 // In determination of the 'K-factor', we measure the 'dispersion' of the [energy fraction of the cell
194 // as a function of cell distance from the centroid] from the the distribution for electrons
195 // the functional form for electrons is saved here.
196 // tce is TOTAL FCLUSTER ENERGY, r is distance of cell to centroid.
198 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},
199 {0.964309,-0.955084,0.212321,-401.273,401.273,0.600581,-2.44701,-43.9126,1009.65,0.19388,-0.0527486},
200 {0.949579,-0.938399,0.169353,-398.208,398.208,0.801709,-16.1048,399.842,-2319.64,0.16054,-0.044954},
201 {0.937618,-0.926665,0.173489,-291.715,291.715,0.723635,-5.65824,222.248,-1525.94,0.125206,-0.0108058},
202 {0.922977,-0.91741,0.174686,-269.155,269.155,0.777305,-0.656328,86.8073,-733.079,0.123508,-0.0159208},
203 {0.88858,-0.86354,0.102552,-280.217,280.217,0.746299,7.06471,-93.7562,323.688,0.128045,-0.0306688},
204 {0.859556,-0.83609,0.108273,-275.632,275.632,0.752012,4.78987,-66.0216,262.093,0.102209,-0.0201003},
205 {0.789254,-0.749649,0.0960812,-331.001,331.001,0.703363,6.70229,-129.452,725.871,0.0861534,-0.0127965},
206 {0.813629,-0.784791,0.0847636,-287.469,287.469,0.7138,7.15787,-142.766,820.634,0.0625165,-0.00910334},
207 {0.828972,-0.805683,0.0812484,-522.356,522.356,0.813623,1.77465,-34.6065,147.756,0.0467835,-0.00425002},
208 {0.900904,-0.890754,0.048338,-1180.84,1180.84,0.870175,0.0385033,-6.99334,19.6102,0.0232503,-0.00446416},
209 {0.881545,-0.870425,0.0382378,-750,750,0.857701,0.181933,-7.72458,12.6329,0.0198669,-0.00436687},
210 {0.893767,-0.878626,0.0465724,-750,750,0.867552,0.0868854,-9.17702,27.6996,0.013101,-0.00261109},
211 {0.88893,-0.882229,0.0896708,-1166.94,828.101,0.864913,-0.245158,-1.5693,-10.5061,0.00658265,-0.000176185},
212 {0.875546,-0.867819,0.0433809,-750,750,0.853546,0.103699,-4.53405,0.67608,0.00667051,-0.00110355},
213 {0.879879,-0.874221,0.0510928,-750,750,0.846377,0.246414,-4.28576,-22.6443,0.00537529,-0.000852894},
214 {0.889361,-0.884282,0.0475369,-750,750,0.845565,0.419865,-7.83763,-2.71567,0.00348465,-0.000407448},
215 {0.893711,-0.890189,0.0649599,-847.351,847.351,0.844507,0.379177,-8.07506,7.69156,0.0005,-2.89084e-13},
216 {0.893706,-0.891587,0.0409521,-750,750,0.841632,0.269466,-4.04288,-14.8299,0.00211674,-0.000173327},
217 {0.942361,-0.941082,0.0703767,-750,750,0.83202,0.829046,-11.3403,29.0905,0.00025,5.67537e-05}};
219 Double_t par[11]={0};
220 if (tce>0&&tce<0.6) {
221 for (Int_t l=0;l<11;l++)
223 } else if (tce>0.6&&tce<0.8) {
224 for (Int_t l=0;l<11;l++)
226 } else if (tce>0.8&&tce<1.12) {
227 for (Int_t l=0;l<11;l++)
229 } else if (tce>1.12&&tce<1.37) {
230 for (Int_t l=0;l<11;l++)
232 } else if (tce>1.37&&tce<1.75) {
233 for (Int_t l=0;l<11;l++)
235 } else if (tce>1.75&&tce<2.5) {
236 for (Int_t l=0;l<11;l++)
238 } else if (tce>2.5&&tce<3.5) {
239 for (Int_t l=0;l<11;l++)
241 } else if (tce>3.5&&tce<4.5) {
242 for (Int_t l=0;l<11;l++)
244 } else if (tce>4.5&&tce<5.5) {
245 for (Int_t l=0;l<11;l++)
247 } else if (tce>5.5&&tce<8) {
248 for (Int_t l=0;l<11;l++)
250 } else if (tce<8&&tce>12) {
251 for (Int_t l=0;l<11;l++)
253 } else if (tce>12&&tce<20) {
254 for (Int_t l=0;l<11;l++)
256 } else if (tce>20&&tce<40) {
257 for (Int_t l=0;l<11;l++)
259 } else if (tce>40&&tce<63) {
260 for (Int_t l=0;l<11;l++)
262 } else if (tce>63&&tce<88) {
263 for (Int_t l=0;l<11;l++)
265 } else if (tce>88&&tce<113) {
266 for (Int_t l=0;l<11;l++)
268 } else if (tce>113&&tce<138) {
269 for (Int_t l=0;l<11;l++)
271 } else if (tce>138&&tce<163) {
272 for (Int_t l=0;l<11;l++)
274 } else if (tce>163&&tce<188) {
275 for (Int_t l=0;l<11;l++)
277 } else if (tce>188) {
278 for (Int_t l=0;l<11;l++)
284 fr =par[5]+par[6]*r+par[7]*r*r+par[8]*r*r*r;
285 } else if (r>0.1&&r<0.92) {
286 fr = par[0]+par[1]*r+par[2]*exp(par[3]-par[4]*r);
287 } else if (r>0.92&&r<6) {
288 fr = par[9] + par[10]*r;
291 cout<<"Crappy f(r_i) value, more than 6!"<<endl;
294 return fr; //returns fraction of energy at r,E: f(r,E), correct?
297 //____________________________________________________________________________
298 Double_t AliEMCALClusterParams::GetKfactor() const
300 // Determines the k-factor, uses the funtion ElectronFraction(r,totalenergyoffCluster)
302 Double_t totalFClusterEnergy = fCluster->E();
303 //Calculates mean x,y and r of the fCluster
304 Double_t etai=0, phii=0;
308 Int_t nclusfCells=fCluster->GetNCells();
310 celllist=fCluster->GetCellsAbsId();
312 for (Int_t i=0;i<nclusfCells;i++) {
320 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
321 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
323 etai=(Double_t)ieta+1.;
324 phii=(Double_t)iphi+1.;
326 kfactor+=GetR(etai,phii)*pow(fCells->GetCellAmplitude(celllist[i])/(totalFClusterEnergy) -
327 ElectronFraction(GetR(etai,phii),totalFClusterEnergy),2);
333 //____________________________________________________________________________
334 Double_t AliEMCALClusterParams::GetDispersionX() const
342 GetCentroid(xmean,ymean,rmean);
344 Int_t nclusfCells=fCluster->GetNCells();
346 celllist=fCluster->GetCellsAbsId();
348 for (Int_t i=0;i<nclusfCells;i++) {
356 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
357 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
359 Double_t etai=(Double_t)ieta+1.;
361 dsum+=(pow(etai-xmean,2))*fCells->GetCellAmplitude(celllist[i]);
362 esum+=fCells->GetCellAmplitude(celllist[i]);
365 return sqrt(dsum/esum);
368 //____________________________________________________________________________
369 Double_t AliEMCALClusterParams::GetDispersionY() const
377 GetCentroid(xmean,ymean,rmean);
379 Int_t nclusfCells=fCluster->GetNCells();
381 celllist=fCluster->GetCellsAbsId();
383 for (Int_t i=0;i<nclusfCells;i++) {
391 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
392 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
394 Double_t phii=(Double_t)iphi+1.;
396 dsum+=(pow(phii-ymean,2))*fCells->GetCellAmplitude(celllist[i]);
397 esum+=fCells->GetCellAmplitude(celllist[i]);
400 return sqrt(dsum/esum);
403 //____________________________________________________________________________
404 Double_t AliEMCALClusterParams::GetDispersionMax() const
406 Double_t dispX = GetDispersionX();
407 Double_t dispY = GetDispersionY();
416 //____________________________________________________________________________
417 void AliEMCALClusterParams::GetEllipseParameters(Double_t ¶m1, Double_t ¶m2) const
426 Int_t nclusfCells=fCluster->GetNCells();
428 celllist=fCluster->GetCellsAbsId();
430 for (Int_t i=0;i<nclusfCells;i++) {
438 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
439 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
441 Double_t phii=(Double_t)iphi+1.;
442 Double_t etai=(Double_t)ieta+1.;
443 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
445 sumxx += amp*pow(etai,2);
446 sumyy += amp*pow(phii,2);
449 sumxy += amp*etai*phii;
456 sumxx=sumxx-sumx*sumx;
457 sumyy = sumyy-sumy*sumy;
458 sumxy = sumxy/esum - sumx*sumy;
460 param1 = 0.5*(sumxx+sumyy) + sqrt(0.25*pow((sumxx-sumyy),2) + sumxy*sumxy);
461 param2 = 0.5*(sumxx+sumyy) - sqrt(0.25*pow((sumxx-sumyy),2) + sumxy*sumxy);
464 //____________________________________________________________________________
465 Double_t AliEMCALClusterParams::GetDispersion() const
473 GetCentroid(xmean,ymean,rmean);
475 Int_t nclusfCells=fCluster->GetNCells();
477 celllist=fCluster->GetCellsAbsId();
480 for (Int_t i=0;i<nclusfCells;i++) {
487 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
489 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
490 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
492 Double_t phii=(Double_t)iphi+1.;
493 Double_t etai=(Double_t)ieta+1.;
495 dsum+=(pow(phii-ymean,2)+pow(etai-xmean,2))*amp;
499 return sqrt(dsum/esum);
502 //============================LOG WEIGHTED PARAMETERS========================================================
504 //____________________________________________________________________________
505 void AliEMCALClusterParams::GetWeightedCentroid(Double_t &xback, Double_t &yback, Double_t &rback) const
507 Float_t logWeight = 4.5;
508 Double_t totalFClusterEnergy=fCluster->E();
510 //Calculates mean x,y and r of the fCluster
511 Double_t etai=0, phii=0;
517 Int_t nclusfCells=fCluster->GetNCells();
519 celllist=fCluster->GetCellsAbsId();
521 for (Int_t i=0;i<nclusfCells;i++) {
528 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
530 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
531 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
533 etai=(Double_t)ieta+1.;
534 phii=(Double_t)iphi+1.;
535 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
539 rsum+=sqrt(etai*etai+phii*phii)*w;
547 //____________________________________________________________________________
548 Double_t AliEMCALClusterParams::GetWeightedR(Double_t x, Double_t y) const
550 //takes fCluster, and cell position (x,y) and returns distance of cell from
556 GetWeightedCentroid(xmean,ymean,rmean);
557 return sqrt(pow((x-xmean),2)+pow((y-ymean),2));
560 //_____________________________________________________________________________
561 Double_t AliEMCALClusterParams::GetWeightedRfactor() const
565 Double_t etai=0, phii=0;
567 Float_t logWeight = 4.5;
569 Double_t totalFClusterEnergy=fCluster->E();
570 Int_t nclusfCells=fCluster->GetNCells();
572 celllist=fCluster->GetCellsAbsId();
574 for (Int_t i=0;i<nclusfCells;i++) {
581 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
583 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
584 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
586 etai=(Double_t)ieta+1.;
587 phii=(Double_t)iphi+1.;
588 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
590 rsum+=GetWeightedR(etai,phii)*w;
597 //____________________________________________________________________________
598 Double_t AliEMCALClusterParams::ElectronfractionWeighted(Double_t r, Double_t tce) const
600 // In determination of the 'K-factor', we measure the 'dispersion' of the [energy fraction of the cell
601 // as a function of cell distance from the centroid] from the the distribution for electrons
602 // the functional form for electrons is saved here.
604 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},
605 {9.69895,-19.8042,112.42,-156.762,16.8874,-27.4961,28.4271,-9.31945,8.18897,-0.213499},
606 {9.58816,-15.0126,92.8682,-137.142,19.3093,-42.9118,59.9102,-29.9932,8.10929,-0.118502},
607 {9.66433,-17.3556,105.064,-154.824,19.3254,-43.845,63.0948,-32.7479,7.3532,0.437176},
608 {9.63564,-12.3028,76.0095,-113.329,16.337,-29.9111,42.2855,-22.8323,7.56083,0.14301},
609 {9.57174,-8.92634,58.7273,-91.3475,9.81528,2.85217,-10.6939,4.76399,7.93151,-0.320945},
610 {9.49951,-3.10053,18.9051,-26.8457,11.5665,-6.0263,3.44864,-2.37582,7.36371,-0.057224},
611 {9.43673,-2.63179,13.7039,-19.2528,9.83544,0.91246,-6.30083,2.46559,7.36203,-0.146645},
612 {9.5378,-2.35688,12.6874,-19.3792,7.64049,12.0476,-24.2138,11.5242,7.2368,-0.337072},
613 {9.52255,-0.989157,7.61241,-14.1598,6.28615,18.4146,-33.4616,15.6595,6.66628,-0.0979268},
614 {9.92079,-1.74431,9.58206,-16.8904,20.9936,-35.2392,29.6651,-9.03178,5.74954,-0.082485},
615 {9.88709,-1.11991,6.64989,-13.221,15.0524,-15.8677,9.13398,-1.97541,5.5779,-0.146283},
616 {9.91925,-1.71077,9.34349,-16.919,15.913,-16.3563,8.1726,-1.38982,5.04338,-0.120024},
617 {9.90981,-2.53254,13.2516,-21.0921,15.1033,-14.4442,6.87168,-1.18726,4.25787,0.0881321},
618 {9.7964,-0.0431799,2.45754,-9.00884,15.2986,-15.7366,8.37136,-1.66767,3.83555,0.0409475},
619 {9.82242,-0.718889,5.19571,-11.6806,15.4565,-16.0309,8.56511,-1.70815,3.46559,0.0840781},
620 {9.88062,-1.21927,7.07515,-13.7956,14.2168,-13.5604,6.90633,-1.3678,3.06548,0.162603},
621 {9.98456,-2.58626,12.6175,-20.0417,12.9291,-10.2085,4.02983,-0.606252,3.34551,0.040163},
622 {9.89892,-1.45526,8.17534,-14.9205,12.5899,-9.74255,4.08869,-0.718114,2.51632,0.245529},
623 {11.2705,-5.29437,0.810794,-0.00331736,10.2653,-0.725442,-3.84838,1.23406,3.85982,-0.188577}};
625 Double_t par[10]={0};
626 if (tce>0&&tce<0.6) {
627 for (Int_t l=0;l<10;l++)
629 } else if (tce>0.6&&tce<0.8) {
630 for (Int_t l=0;l<10;l++)
632 } else if (tce>0.8&&tce<1.12) {
633 for (Int_t l=0;l<10;l++)
635 } else if (tce>1.12&&tce<1.37) {
636 for (Int_t l=0;l<10;l++)
638 } else if (tce>1.37&&tce<1.75) {
639 for (Int_t l=0;l<10;l++)
641 } else if (tce>1.75&&tce<2.5) {
642 for (Int_t l=0;l<10;l++)
644 } else if (tce>2.5&&tce<3.5) {
645 for (Int_t l=0;l<10;l++)
647 } else if (tce>3.5&&tce<4.5) {
648 for (Int_t l=0;l<10;l++)
650 } else if (tce>4.5&&tce<5.5) {
651 for (Int_t l=0;l<10;l++)
653 } else if (tce>5.5&&tce<8) {
654 for (Int_t l=0;l<10;l++)
656 } else if (tce<8&&tce>12) {
657 for (Int_t l=0;l<10;l++)
659 } else if (tce>12&&tce<20) {
660 for (Int_t l=0;l<10;l++)
662 } else if (tce>20&&tce<40) {
663 for (Int_t l=0;l<10;l++)
665 } else if (tce>40&&tce<63) {
666 for (Int_t l=0;l<10;l++)
668 } else if (tce>63&&tce<88) {
669 for (Int_t l=0;l<10;l++)
671 } else if (tce>88&&tce<113) {
672 for (Int_t l=0;l<10;l++)
674 } else if (tce>113&&tce<138) {
675 for (Int_t l=0;l<10;l++)
677 } else if (tce>138&&tce<163) {
678 for (Int_t l=0;l<10;l++)
680 } else if (tce>163&&tce<188) {
681 for (Int_t l=0;l<10;l++)
683 } else if (tce>188) {
684 for (Int_t l=0;l<10;l++)
690 fr = par[4]+par[5]*r+par[6]*r*r+par[7]*r*r*r;
691 } else if (r>0.5&&r<1.0) {
692 fr = par[0]+par[1]*r+par[2]*r*r+par[3]*r*r*r;
693 } else if (r>1.0&&r<6) {
694 fr = par[8] + par[9]*r;
697 cout<<"Crappy f(r_i) value, more than 6!"<<endl;
700 //cout<<"Weighter fr is: "<<fr<<" and tce,r: "<<tce<<" "<<r<<endl;
704 //____________________________________________________________________________
705 Double_t AliEMCALClusterParams::GetWeightedKfactor() const
707 Double_t logWeight = 4.5;
708 //determines the k-factor
711 Double_t totalFClusterEnergy=fCluster->E();
712 Int_t nclusfCells=fCluster->GetNCells();
714 celllist=fCluster->GetCellsAbsId();
716 for (Int_t i=0;i<nclusfCells;i++) {
723 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
725 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
726 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
728 Double_t etai=(Double_t)ieta+1.;
729 Double_t phii=(Double_t)iphi+1.;
731 Double_t w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ));
732 kfactor+=GetWeightedR(etai,phii)*pow(w - ElectronfractionWeighted(GetWeightedR(etai,phii),totalFClusterEnergy),2);
738 //____________________________________________________________________________
739 Double_t AliEMCALClusterParams::GetWeightedDispersionX() const
741 Float_t logWeight = 4.5;
742 // Calculates the dispersion of the shower at the origin of the RecPoint
743 // in cell units - Nov 16,2006
745 Double_t d = 0., wtot = 0., w = 0.;
748 // Calculates the dispersion in cell units
749 Double_t etai=0, etaMean=0.0;
751 // Calculate mean values
752 Double_t totalFClusterEnergy=fCluster->E();
753 Int_t nclusfCells=fCluster->GetNCells();
755 celllist=fCluster->GetCellsAbsId();
757 Int_t ncell=0;//cell counter
759 for (Int_t i=0;i<nclusfCells;i++) {
766 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
768 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
769 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
773 etai=(Double_t)ieta+1.;
774 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
782 etaMean = etaMean/wtot;
784 // Calculate dispersion
785 // Loop over fCells in the newly created fCluster
786 Int_t ncell1=0;//cell counter
789 for (Int_t i=0;i<nclusfCells;i++) {
796 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
798 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
799 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
802 etai=(Double_t)ieta+1.;
803 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
807 d += w*((etai-etaMean)*(etai-etaMean)); //Add squares
811 if ( wtot > 0 && nstat>1) d /= wtot;
814 return TMath::Sqrt(d);
817 //____________________________________________________________________________
818 Double_t AliEMCALClusterParams::GetWeightedDispersionY() const
820 Float_t logWeight = 4.5;
821 // Calculates the dispersion of the shower at the origin of the RecPoint
822 // in cell units - Nov 16,2006
824 Double_t d = 0., wtot = 0., w = 0.;
827 // Calculates the dispersion in cell units
828 Double_t phii=0, phiMean=0.0;
830 // Calculate mean values
831 Double_t totalFClusterEnergy=fCluster->E();
832 Int_t nclusfCells=fCluster->GetNCells();
834 celllist=fCluster->GetCellsAbsId();
836 Int_t ncell=0;//cell counter
838 for (Int_t i=0;i<nclusfCells;i++) {
845 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
847 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
848 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
852 phii=(Double_t)iphi+1.;
853 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
861 phiMean = phiMean/wtot;
863 // Calculate dispersion
864 // Loop over fCells in the newly created fCluster
865 Int_t ncell1=0;//cell counter
867 for (Int_t i=0;i<nclusfCells;i++) {
874 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
876 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
877 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
881 phii=(Double_t)iphi+1.;
882 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
886 d += w*((phii-phiMean)*(phii-phiMean)); //Add squares
890 if ( wtot > 0 && nstat>1) d /= wtot;
893 return TMath::Sqrt(d);
896 //____________________________________________________________________________
897 Double_t AliEMCALClusterParams::GetWeightedDispersionMax() const
899 Double_t dispX = GetWeightedDispersionX();
900 Double_t dispY = GetWeightedDispersionY();
909 //____________________________________________________________________________
910 void AliEMCALClusterParams::GetWeightedEllipseParameters(Double_t ¶m1, Double_t ¶m2) const
912 Float_t logWeight=4.5;
921 Double_t etai =0, phii=0, w=0;
923 Int_t ncell=0;//cell counter
925 Double_t totalFClusterEnergy=fCluster->E();
926 Int_t nclusfCells=fCluster->GetNCells();
928 celllist=fCluster->GetCellsAbsId();
930 for (Int_t i=0;i<nclusfCells;i++) {
937 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
941 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
942 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
948 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy ) ); //Energy of tower/total clus E, in GeV
949 dxx += w * etai * etai;
951 dzz += w * phii * phii;
953 dxz += w * etai * phii;
966 param1 = 0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
967 param2 = 0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ) ;
974 //____________________________________________________________________________
975 Double_t AliEMCALClusterParams::GetWeightedDispersion(Double_t &dispersionback) const
977 Float_t logWeight = 4.5;
978 // Calculates the dispersion of the shower at the origin of the RecPoint
979 // in cell units - Nov 16,2006
981 Double_t d = 0., wtot = 0., w = 0.;
985 // Calculates the dispersion in cell units
986 Double_t etai, phii, etaMean=0.0, phiMean=0.0;
988 // Calculate mean values
989 Int_t ncell=0;//cell counter
991 Double_t totalFClusterEnergy=fCluster->E();
992 Int_t nclusfCells=fCluster->GetNCells();
994 celllist=fCluster->GetCellsAbsId();
996 for (Int_t i=0;i<nclusfCells;i++) {
1003 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1007 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1008 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1010 etai=(Double_t)ieta+1.;
1011 phii=(Double_t)iphi+1.;
1012 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy )); //Calc weight
1022 phiMean = phiMean/wtot;
1023 etaMean = etaMean/wtot;
1026 // Calculate dispersion
1027 Int_t ncell1=0;//cell counter
1030 for (Int_t i=0;i<nclusfCells;i++) {
1037 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1041 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1042 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1044 etai=(Double_t)ieta+1.;
1045 phii=(Double_t)iphi+1.;
1046 w = TMath::Max(0.,logWeight+TMath::Log(amp/totalFClusterEnergy));
1050 d += w*((etai-etaMean)*(etai-etaMean)+(phii-phiMean)*(phii-phiMean)); //Add squares
1057 if ( wtot > 0 && nstat>1) d /= wtot;
1060 //printf("AliEMCALRecPoint::EvalDispersion() : Dispersion %f \n",d);
1062 return TMath::Sqrt(d);
1066 //____________________________________________________________________________
1067 void AliEMCALClusterParams::RecalculateClusterShowerShapeParameters(Double_t &m02, Double_t &m20, Double_t &dispersion) const
1069 // Calculates new center of gravity in the local EMCAL-module coordinates
1070 // and tranfers into global ALICE coordinates
1071 // Calculates Dispersion and main axis
1077 Double_t eCell = 0.;
1085 Double_t etai = -1.;
1086 Double_t phii = -1.;
1093 Double_t xmean = 0.;
1094 Double_t zmean = 0.;
1096 Double_t totalFClusterEnergy=fCluster->E();
1097 Int_t nclusfCells=fCluster->GetNCells();
1099 celllist=fCluster->GetCellsAbsId();
1102 for (Int_t i=0;i<nclusfCells;i++) {
1103 //Get from the absid the supermodule, tower and eta/phi numbers
1105 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1106 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1108 Double_t amp=fCells->GetCellAmplitude(celllist[i]);
1111 if (totalFClusterEnergy > 0 && eCell > 0) {
1112 w = TMath::Max( 0., fW0 + TMath::Log( eCell / totalFClusterEnergy ));
1113 etai=(Double_t)ieta;
1114 phii=(Double_t)iphi;
1119 dxx += w * etai * etai;
1121 dzz += w * phii * phii;
1123 dxz += w * etai * phii;
1127 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, fCluster->E()));
1130 //Normalize to the weight
1136 AliError(Form("Wrong weight %f\n", wtot));
1138 //Calculate dispersion
1139 for (Int_t i=0;i<nclusfCells;i++) {
1140 //Get from the absid the supermodule, tower and eta/phi numbers
1141 fGeom->GetCellIndex(celllist[i],iSupMod,iTower,iIphi,iIeta);
1142 fGeom->GetCellPhiEtaIndexInSModule(iSupMod,iTower,iIphi,iIeta, iphi,ieta);
1144 eCell = fCells->GetCellAmplitude(celllist[i]);
1146 if (totalFClusterEnergy > 0 && eCell > 0) {
1147 w = TMath::Max( 0., fW0 + TMath::Log( eCell / totalFClusterEnergy ));
1148 etai=(Double_t)ieta;
1149 phii=(Double_t)iphi;
1150 if (w > 0.0) d += w*((etai-xmean)*(etai-xmean)+(phii-zmean)*(phii-zmean));
1153 AliError(Form("Wrong energy %f and/or amplitude %f\n", eCell, fCluster->E()));
1156 //Normalize to the weigth and set shower shape parameters
1157 if (wtot > 0 && nstat > 1) {
1162 dxx -= xmean * xmean;
1163 dzz -= zmean * zmean;
1164 dxz -= xmean * zmean;
1165 m02=(0.5 * (dxx + dzz) + TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1166 m20=(0.5 * (dxx + dzz) - TMath::Sqrt( 0.25 * (dxx - dzz) * (dxx - dzz) + dxz * dxz ));
1175 dispersion=TMath::Sqrt(d);