ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
BEmcRecFEMC.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file BEmcRecFEMC.cc
1 #include "BEmcRecFEMC.h"
2 #include "BEmcCluster.h"
3 #include "BEmcProfile.h"
4 
5 #include <cmath>
6 #include <iostream>
7 
8 using namespace std;
9 
11 // : _emcprof(nullptr)
12 {
13  Name("BEmcRecFEMC");
14  SetPlanarGeometry();
15 }
16 
18 {
19  // one can delete null pointers
20  // delete _emcprof;
21 }
22 
23 void BEmcRecFEMC::LoadProfile(const string& fname)
24 {
25  _emcprof = new BEmcProfile(fname);
26 }
27 
28 void BEmcRecFEMC::GetImpactThetaPhi(float xg, float yg, float zg, float& theta, float& phi)
29 {
30  theta = atan(sqrt(xg*xg + yg*yg)/fabs(zg-fVz));
31  phi = atan2(yg,xg);
32 }
33 
34 /*
35 float BEmcRecFEMC::GetProb(vector<EmcModule> HitList, float ecl, float xg, float yg, float zg, float& chi2, int& ndf)
36 {
37  chi2 = 0;
38  ndf = 0;
39  float prob = -1;
40 
41  float theta = atan(sqrt(xg * xg + yg * yg) / fabs(zg - fVz));
42  float phi = atan2(yg, xg);
43  if (_emcprof != nullptr) prob = _emcprof->GetProb(&HitList, fNx, ecl, theta, phi);
44 
45  return prob;
46 }
47 */
48 
49 void BEmcRecFEMC::CorrectShowerDepth(float E, float xA, float yA, float zA, float& xC, float& yC, float& zC)
50 {
51  // For ala PHENIX PbSc modules
52  /*
53  const float DZ = 18; // in cm, tower half length
54  const float D = 13.3; // in cm, shower depth at 1 GeV relative to tower face; obtained from GEANT
55  const float X0 = 2.2; // in cm; obtained from GEANT (should be ~ rad length)
56  */
57  // For E684-based modules
58  const float DZ = 8; // in cm, tower half length
59  const float D = 4.6; // in cm, shower depth at 1 GeV relative to tower face; obtained from GEANT
60  const float X0 = 0.8; // in cm; obtained from GEANT (should be ~ rad length)
61 
62  float logE = log(0.1);
63  if (E > 0.1) logE = log(E);
64  float zV = zA - fVz;
65  float cosT = fabs(zV) / sqrt(xA * xA + yA * yA + zV * zV);
66 
67  zC = (zA - DZ) + (D + X0 * logE) * cosT;
68  // zC = zA; // !!!!!
69 
70  xC = xA;
71  yC = yA;
72 }
73 
74 void BEmcRecFEMC::CorrectEnergy(float Energy, float /*x*/, float /*y*/,
75  float& Ecorr)
76 {
77  Ecorr = Energy;
78 }
79 
80 float BEmcRecFEMC::GetImpactAngle(float /*e*/, float /*x*/, float /*y*/)
81 // Get impact angle, (x,y) - position in Sector frame (cm)
82 {
83  /*
84  float xVert, yVert, zVert;
85  float vx, vy, vz;
86 
87  GlobalToSector( fVx, fVy, fVz, &xVert, &yVert, &zVert );
88  vz = -zVert;
89  vy = y - yVert;
90  vx = x - xVert;
91  // From this point X coord in sector frame is Z coord in Global Coord System !!!
92  *sinT = sqrt((vx*vx+vy*vy)/(vx*vx+vy*vy+vz*vz));
93  */
94  return 0;
95 }
96 
97 void BEmcRecFEMC::CorrectECore(float Ecore, float x, float y, float& Ecorr)
98 {
99  // Corrects the EM Shower Core Energy for attenuation in fibers,
100  // long energy leakage and angle dependance
101  //
102  // (x,y) - shower CG in tower units (not projected anywhere!)
103 
104  // Ecorr = Ecore;
105  float ec, ec2, corr;
106  const float par1 = 0.938;
107  const float par2 = 0.50;
108  const float par3 = 0.067;
109 
110  Ecorr = Ecore;
111  if (Ecore < 0.01) return;
112 
113  float xA, yA, zA;
114  Tower2Global(Ecore / 0.91, x, y, xA, yA, zA); // 0.91 - average correction
115  float tanT = sqrt(xA * xA + yA * yA) / fabs(zA - fVz);
116  corr = par1 * (1 - tanT * tanT * tanT * (par2 + par3 * log(Ecore)));
117  ec = Ecore / corr;
118 
119  // CorrectEnergy( ec, x, y, &ec2);
120  ec2 = ec; // !!!!! CorrectEnergy must be implemented
121  Ecorr = ec2;
122 }
123 
124 void BEmcRecFEMC::CorrectPosition(float Energy, float x, float y,
125  float& xc, float& yc)
126 {
127  // Corrects the Shower Center of Gravity for the systematic shift due to
128  // limited tower size
129  //
130  // Everything here is in tower units.
131  // (x,y) - CG position, (xc,yc) - corrected position
132 
133  float xZero, yZero, bx, by;
134  float t, x0, y0;
135  int ix0, iy0;
136 
137  xc = x;
138  yc = y;
139  // return;
140 
141  if (Energy < 0.01) return;
142 
143  float xA, yA, zA;
144  Tower2Global(Energy, x, y, xA, yA, zA);
145  zA -= fVz;
146  // float sinTx = xA / sqrt(xA * xA + zA * zA);
147  // float sinTy = yA / sqrt(yA * yA + zA * zA);
148  float sinTy = xA / sqrt(xA * xA + zA * zA); // x is second index in here
149  float sinTx = yA / sqrt(yA * yA + zA * zA);
150  float sin2Tx = sinTx * sinTx;
151  float sin2Ty = sinTy * sinTy;
152 
153  if (sinTx > 0)
154  xZero = -0.417 * sinTx - 1.500 * sin2Tx;
155  else
156  xZero = -0.417 * sinTx + 1.500 * sin2Tx;
157 
158  if (sinTy > 0)
159  yZero = -0.417 * sinTy - 1.500 * sin2Ty;
160  else
161  yZero = -0.417 * sinTy + 1.500 * sin2Ty;
162 
163  t = 0.98 + 0.98 * sqrt(Energy);
164  t *= 0.7; // Temp correction
165  bx = 0.17 - 0.009 * log(Energy) + t * sin2Tx;
166  by = 0.17 - 0.009 * log(Energy) + t * sin2Ty;
167 
168  // xZero *= 0.5;
169  // yZero *= 0.5;
170 
171  x0 = x + xZero;
172  ix0 = EmcCluster::lowint(x0 + 0.5);
173 
174  if (EmcCluster::ABS(x0 - ix0) <= 0.5)
175  {
176  x0 = (ix0 - xZero) + bx * asinh(2. * (x0 - ix0) * sinh(0.5 / bx));
177  xc = x0;
178  }
179  else
180  {
181  xc = x;
182  cout << "????? Something wrong in BEmcRecFEMC::CorrectPosition: x = "
183  << x << ", dx = " << x0 - ix0 << endl;
184  }
185 
186  y0 = y + yZero;
187  iy0 = EmcCluster::lowint(y0 + 0.5);
188 
189  if (EmcCluster::ABS(y0 - iy0) <= 0.5)
190  {
191  y0 = (iy0 - yZero) + by * asinh(2. * (y0 - iy0) * sinh(0.5 / by));
192  yc = y0;
193  }
194  else
195  {
196  yc = y;
197  cout << "????? Something wrong in BEmcRecFEMC::CorrectPosition: y = "
198  << y << ", dy = " << y0 - iy0 << endl;
199  }
200 }