3 #include <phparameter/PHParameterInterface.h>
28 template<
class T>
inline constexpr
T square(
const T&
x ) {
return x*
x; }
62 CalculateVertices(
nStripes_R1,
nPads_R1,
R1_e,
spacing_R1_e,
x1a_R1_e,
y1a_R1_e,
x1b_R1_e,
y1b_R1_e,
x2a_R1_e,
y2a_R1_e,
x2b_R1_e,
y2b_R1_e,
x3a_R1_e,
y3a_R1_e,
x3b_R1_e,
y3b_R1_e,
padfrac_R1,
str_width_R1_e,
widthmod_R1_e,
nGoodStripes_R1_e,
keepUntil_R1_e,
nStripesIn_R1_e,
nStripesBefore_R1_e);
63 CalculateVertices(
nStripes_R1,
nPads_R1,
R1,
spacing_R1,
x1a_R1,
y1a_R1,
x1b_R1,
y1b_R1,
x2a_R1,
y2a_R1,
x2b_R1,
y2b_R1,
x3a_R1,
y3a_R1,
x3b_R1,
y3b_R1,
padfrac_R1,
str_width_R1,
widthmod_R1,
nGoodStripes_R1,
keepUntil_R1,
nStripesIn_R1,
nStripesBefore_R1);
64 CalculateVertices(
nStripes_R2,
nPads_R2,
R2,
spacing_R2,
x1a_R2,
y1a_R2,
x1b_R2,
y1b_R2,
x2a_R2,
y2a_R2,
x2b_R2,
y2b_R2,
x3a_R2,
y3a_R2,
x3b_R2,
y3b_R2,
padfrac_R2,
str_width_R2,
widthmod_R2,
nGoodStripes_R2,
keepUntil_R2,
nStripesIn_R2,
nStripesBefore_R2);
65 CalculateVertices(
nStripes_R3,
nPads_R3,
R3,
spacing_R3,
x1a_R3,
y1a_R3,
x1b_R3,
y1b_R3,
x2a_R3,
y2a_R3,
x2b_R3,
y2b_R3,
x3a_R3,
y3a_R3,
x3b_R3,
y3b_R3,
padfrac_R3,
str_width_R3,
widthmod_R3,
nGoodStripes_R3,
keepUntil_R3,
nStripesIn_R3,
nStripesBefore_R3);
85 std::cout <<
"PHG4TpcCentralMembrane::InitRun - electrons_per_stripe: " <<
electrons_per_stripe << std::endl;
86 std::cout <<
"PHG4TpcCentralMembrane::InitRun - electrons_per_gev " <<
electrons_per_gev << std::endl;
110 PHG4Hits.push_back(
source);
117 PHG4Hits.push_back(copy);
121 for (
int i = 0;
i < 18;
i++)
124 for (
int j = 0;
j < 8;
j++)
163 if(
Verbosity()) std::cout <<
"Event " <<
m_eventNum <<
" will not generate CM hits" << std::endl;
169 auto g4hitcontainer = findNode::getClass<PHG4HitContainer>(topNode,
hitnodename.c_str());
180 g4hitcontainer->AddHit(detId, copy);
197 static constexpr
double Ne_dEdx = 1.56;
198 static constexpr
double CF4_dEdx = 7.00;
201 static constexpr
double Tpc_NTot = 0.5 * Ne_NTotal + 0.5 *
CF4_NTotal;
202 static constexpr
double Tpc_dEdx = 0.5 * Ne_dEdx + 0.5 *
CF4_dEdx;
203 static constexpr
double Tpc_ElectronsPerKeV = Tpc_NTot / Tpc_dEdx;
214 int nStripes,
int nPads,
215 const std::array<double, nRadii>&
R,
216 std::array<double, nRadii>& spacing,
217 double x1a[][nRadii],
double y1a[][nRadii],
218 double x1b[][nRadii],
double y1b[][nRadii],
219 double x2a[][nRadii],
double y2a[][nRadii],
220 double x2b[][nRadii],
double y2b[][nRadii],
221 double x3a[][nRadii],
double y3a[][nRadii],
222 double x3b[][nRadii],
double y3b[][nRadii],
224 double str_width[][nRadii],
225 const std::array<double, nRadii>& widthmod,
226 std::array<int, nRadii>& nGoodStripes,
227 const std::array<int, nRadii>& keepUntil,
228 std::array<int, nRadii>& nStripesIn,
229 std::array<int, nRadii>& nStripesBefore)
231 const double phi_module = M_PI / 6.0;
232 const int pr_mult = 3;
233 const int dw_mult = 8;
234 const double diffwidth = 0.6 *
mm;
235 const double adjust = 0.015;
239 double cx[nStripes][
nRadii];
240 double cy[nStripes][
nRadii];
254 spacing[
i] = 2.0 * ((dw_mult * diffwidth / R[
i]) + (pr_mult * phi_module / nPads));
265 theta =
i * spacing[
j] + (spacing[
j] / 2) - adjust;
266 cx[i_out][
j] = R[
j] * cos(theta);
267 cy[i_out][
j] = R[
j] * sin(theta);
271 theta = (
i + 1) * spacing[
j] - adjust;
272 cx[i_out][
j] = R[
j] * cos(theta);
273 cy[i_out][
j] = R[
j] * sin(theta);
277 corner[0].SetXYZ(-padfrac +
arc_r, -(widthmod[
j] * str_width[
i][
j]) / 2, 0);
278 corner[1].SetXYZ(padfrac -
arc_r, -(widthmod[j] * str_width[
i][j]) / 2, 0);
279 corner[2].SetXYZ(-padfrac +
arc_r, (widthmod[j] * str_width[
i][j]) / 2, 0);
280 corner[3].SetXYZ(padfrac -
arc_r, (widthmod[j] * str_width[
i][j]) / 2, 0);
282 TVector3 rotatedcorner[4];
283 for (
int n = 0;
n < 4;
n++)
285 rotatedcorner[
n] = corner[
n];
286 rotatedcorner[
n].RotateZ(theta);
289 x1a[i_out][
j] = rotatedcorner[0].X() + cx[i_out][
j];
290 x1b[i_out][
j] = rotatedcorner[1].X() + cx[i_out][
j];
291 x2a[i_out][
j] = rotatedcorner[2].X() + cx[i_out][
j];
292 x2b[i_out][
j] = rotatedcorner[3].X() + cx[i_out][
j];
294 y1a[i_out][
j] = rotatedcorner[0].Y() + cy[i_out][
j];
295 y1b[i_out][
j] = rotatedcorner[1].Y() + cy[i_out][
j];
296 y2a[i_out][
j] = rotatedcorner[2].Y() + cy[i_out][
j];
297 y2b[i_out][
j] = rotatedcorner[3].Y() + cy[i_out][
j];
335 x3a[i_out][
j] = (x1a[i_out][
j] + x2a[i_out][
j]) / 2.0;
336 y3a[i_out][
j] = (y1a[i_out][
j] + y2a[i_out][
j]) / 2.0;
337 x3b[i_out][
j] = (x1b[i_out][
j] + x2b[i_out][
j]) / 2.0;
338 y3b[i_out][
j] = (y1b[i_out][
j] + y2b[i_out][
j]) / 2.0;
347 nStripesBefore[
j] = 0;
351 nStripesBefore[
j] = nStripesIn[j - 1] + nStripesBefore[j - 1];
355 nGoodStripes[
j] = i_out;
360 const double x1a[][nRadii],
const double x1b[][nRadii],
361 const double x2a[][nRadii],
const double x2b[][nRadii],
362 const double y1a[][nRadii],
const double y1b[][nRadii],
363 const double y2a[][nRadii],
const double y2b[][nRadii],
364 const double x3a[][nRadii],
const double y3a[][nRadii],
365 const double x3b[][nRadii],
const double y3b[][nRadii],
366 double x,
double y,
const std::array<int, nRadii>& nGoodStripes)
const
372 for (
int i = 0;
i < nGoodStripes[
j];
i++)
374 if (((y1a[
i][
j] > y) != (y2a[
i][
j] > y) && (x < (x2a[
i][
j] - x1a[
i][
j]) * (y - y1a[
i][j]) / (y2a[
i][j] - y1a[
i][j]) + x1a[
i][j])))
376 if (((y1b[
i][j] > y) != (y1a[
i][j] > y) && (x < (x1a[
i][j] - x1b[
i][j]) * (y - y1b[
i][j]) / (y1a[
i][j] - y1b[
i][j]) + x1b[
i][j])))
378 if (((y2b[
i][j] > y) != (y1b[
i][j] > y) && (x < (x1b[
i][j] - x2b[
i][j]) * (y - y2b[
i][j]) / (y1b[
i][j] - y2b[
i][j]) + x2b[
i][j])))
380 if (((y2a[
i][j] > y) != (y2b[
i][j] > y) && (x < (x2b[
i][j] - x2a[
i][j]) * (y - y2a[
i][j]) / (y2b[
i][j] - y2a[
i][j]) + x2a[
i][j])))
386 if (((x - x3a[
i][j]) * (x - x3a[
i][j]) + (y - y3a[
i][j]) * (y - y3a[
i][j])) <=
arc_r *
arc_r)
390 else if (((x - x3b[
i][j]) * (x - x3b[
i][j]) + (y - y3b[
i][j]) * (y - y3b[
i][j])) <= arc_r * arc_r)
402 const double phi_petal = M_PI / 9.0;
403 const double end_R1_e = 312.0 *
mm;
404 const double end_R1 = 408.0 *
mm;
405 const double end_R2 = 580.0 *
mm;
407 double r,
phi, phimod, xmod, ymod;
409 r = sqrt(xcheck * xcheck + ycheck * ycheck);
410 phi = atan(ycheck / xcheck);
411 if ((xcheck < 0.0) && (ycheck > 0.0))
415 else if ((xcheck > 0.0) && (ycheck < 0.0))
417 phi = phi + 2.0 * M_PI;
420 phimod = fmod(phi, phi_petal);
421 xmod = r * cos(phimod);
422 ymod = r * sin(phimod);
428 result =
SearchModule(
nStripes_R1,
x1a_R1_e,
x1b_R1_e,
x2a_R1_e,
x2b_R1_e,
y1a_R1_e,
y1b_R1_e,
y2a_R1_e,
y2b_R1_e,
x3a_R1_e,
y3a_R1_e,
x3b_R1_e,
y3b_R1_e, xmod, ymod,
nGoodStripes_R1_e);
430 else if ((r > end_R1_e) && (r <= end_R1))
432 result =
SearchModule(
nStripes_R1,
x1a_R1,
x1b_R1,
x2a_R1,
x2b_R1,
y1a_R1,
y1b_R1,
y2a_R1,
y2b_R1,
x3a_R1,
y3a_R1,
x3b_R1,
y3b_R1, xmod, ymod,
nGoodStripes_R1);
434 else if ((r > end_R1) && (r <= end_R2))
436 result =
SearchModule(
nStripes_R2,
x1a_R2,
x1b_R2,
x2a_R2,
x2b_R2,
y1a_R2,
y1b_R2,
y2a_R2,
y2b_R2,
x3a_R2,
y3a_R2,
x3b_R2,
y3b_R2, xmod, ymod,
nGoodStripes_R2);
438 else if ((r > end_R2) && (r <=
end_CM))
440 result =
SearchModule(
nStripes_R3,
x1a_R3,
x1b_R3,
x2a_R3,
x2b_R3,
y1a_R3,
y1b_R3,
y2a_R3,
y2b_R3,
x3a_R3,
y3a_R3,
x3b_R3,
y3b_R3, xmod, ymod,
nGoodStripes_R3);
448 const double phi_petal = M_PI / 9.0;
450 TVector3 dummyPos0, dummyPos1;
465 else if (moduleID == 1)
470 else if (moduleID == 2)
475 else if (moduleID == 3)
486 dummyPos0.RotateZ(petalID * phi_petal);
487 hit->
set_x(0, dummyPos0.X());
488 hit->
set_y(0, dummyPos0.Y());
510 else if (moduleID == 1)
515 else if (moduleID == 2)
520 else if (moduleID == 3)
531 dummyPos1.RotateZ(petalID * phi_petal);
532 hit->
set_x(1, dummyPos1.X());
533 hit->
set_y(1, dummyPos1.Y());
582 const double phi_petal = M_PI / 9.0;
592 double r = sqrt(xcheck * xcheck + ycheck * ycheck);
593 double phi = atan(ycheck / xcheck);
594 if ((xcheck < 0.0) && (ycheck > 0.0))
598 else if ((xcheck > 0.0) && (ycheck < 0.0))
600 phi = phi + 2.0 * M_PI;
603 double phimod = fmod(phi, phi_petal);
604 double xmod = r * cos(phimod);
605 double ymod = r * sin(phimod);
607 int petalID = phi / phi_petal;
615 std::cout <<
"rID: " << rID << std::endl;
635 double dist = fabs((-m) * xmod + ymod) / sqrt(1 + m * m);
655 double dist = fabs(m * xmod - ymod) / sqrt(1 + m * m);
671 double dist = fabs(m * xmod - ymod) / sqrt(1 + m * m);
687 double dist = fabs(m * xmod - ymod) / sqrt(1 + m * m);