5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4VisAttributes.hh>
10 #include <boost/algorithm/hex.hpp>
11 #include <boost/algorithm/string.hpp>
12 #include <boost/uuid/detail/md5.hpp>
30 double theta = 2.0 * std::atan(std::exp(-eta));
31 length = radius / std::tan(theta);
38 return GetLengthForRapidityCoverage(radius, _eta_coverage);
49 double theta = 2 * atan(exp(-eta));
56 double eta = -log(tan(theta / 2.));
67 radius = sqrt(x * x + y * y);
69 theta = atan2(radius, z);
70 eta = -log(tan(theta / 2.));
71 return make_pair(eta, phi);
79 theta = atan2(radius, fabs(z));
80 eta = -log(tan(theta / 2.));
92 cout <<
"G4VisAttributes pointer is NULL" << endl;
95 if (material ==
"AL_BABAR_MAG")
99 else if (material ==
"BlackHole")
103 else if (material ==
"C4F10")
107 else if (material ==
"CF4")
111 else if (material ==
"G4_AIR")
115 else if (material ==
"G4_Al")
119 else if (material ==
"G4_Au")
123 else if (material ==
"G4_CARBON_DIOXIDE")
127 else if (material ==
"G4_CELLULOSE_CELLOPHANE")
131 else if (material ==
"G4_Cu")
135 else if (material ==
"G4_Fe")
139 else if (material ==
"G4_KAPTON")
143 else if (material ==
"G4_MYLAR")
147 else if (material ==
"G4_METHANE")
151 else if (material ==
"G4_Si")
155 else if (material ==
"G4_TEFLON")
159 else if (material ==
"G4_W")
163 else if (material ==
"Quartz")
167 else if (material ==
"Scintillator" || material ==
"G4_POLYSTYRENE")
171 else if (material ==
"W_Epoxy")
175 else if (material ==
"G10")
209 double bottom = fx * px + fy * py;
212 double top = gx * px + gy * py;
221 if (h > 0. && h < 1.)
223 double rx = cx + fx *
h;
224 double ry = cy + fy *
h;
226 if ((rx > ax && rx > bx) || (rx < ax && rx < bx) || (ry < ay && ry < by) || (ry > ay && ry > by))
229 return make_pair(
false, make_pair(NAN, NAN));
234 return make_pair(
true, make_pair(rx, ry));
238 return make_pair(
false, make_pair(NAN, NAN));
260 if (cx > dx || cy > dy)
262 cout <<
PHWHERE <<
"ERROR: Bad rectangle definition!" << endl;
263 return make_pair(
false, NAN);
273 pair<bool, pair<double, double>> intersect1 = lines_intersect(ax, ay, bx, by, cx, cy, fx, fy);
275 if (intersect1.first)
277 vx.push_back(intersect1.second.first);
278 vy.push_back(intersect1.second.second);
280 pair<bool, pair<double, double>> intersect2 = lines_intersect(ax, ay, bx, by, fx, fy, dx, dy);
282 if (intersect2.first)
284 vx.push_back(intersect2.second.first);
285 vy.push_back(intersect2.second.second);
287 pair<bool, pair<double, double>> intersect3 = lines_intersect(ax, ay, bx, by, ex, ey, dx, dy);
289 if (intersect3.first)
291 vx.push_back(intersect3.second.first);
292 vy.push_back(intersect3.second.second);
294 pair<bool, pair<double, double>> intersect4 = lines_intersect(ax, ay, bx, by, cx, cy, ex, ey);
296 if (intersect4.first)
298 vx.push_back(intersect4.second.first);
299 vy.push_back(intersect4.second.second);
308 rr = sqrt((vx[0] - vx[1]) * (vx[0] - vx[1]) + (vy[0] - vy[1]) * (vy[0] - vy[1]));
314 if (ax > cx && ay > cy && ax < dx && ay < dy)
317 rr = sqrt((vx[0] - ax) * (vx[0] - ax) + (vy[0] - ay) * (vy[0] - ay));
319 if (bx > cx && by > cy && bx < dx && by < dy)
322 rr = sqrt((vx[0] - bx) * (vx[0] - bx) + (vy[0] - by) * (vy[0] - by));
326 if (intersect1.first || intersect2.first || intersect3.first || intersect4.first)
328 return make_pair(
true, rr);
330 return make_pair(
false, NAN);
345 return -sA(r, -x, y);
350 return -sA(r, x, -y);
363 if (x * x + y * y > r * r)
365 a = r * r * asin(x / r) + x * sqrt(r * r - x * x) + r * r * asin(y / r) + y * sqrt(r * r - y * y) - r * r *
M_PI_2;
397 return sA(r, x2, y1) - sA(r, x1, y1) - sA(r, x2, y2) + sA(r, x1, y2);
403 myfile.open(filename);
404 if (!myfile.is_open())
406 cout <<
"Error opening " << filename << endl;
410 boost::uuids::detail::md5
hash;
411 boost::uuids::detail::md5::digest_type digest;
413 while (myfile.get(c))
415 hash.process_bytes(&c, 1);
418 hash.get_digest(digest);
419 const auto charDigest =
reinterpret_cast<const char*
>(&digest);
421 boost::algorithm::hex(charDigest, charDigest +
sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result));
422 boost::algorithm::to_lower(result);