5 #include <Geant4/G4Colour.hh>
6 #include <Geant4/G4VisAttributes.hh>
10 #pragma GCC diagnostic push
11 #pragma GCC diagnostic ignored "-Wdeprecated-declarations"
12 #include <boost/algorithm/string.hpp>
13 #pragma GCC diagnostic pop
15 #include <boost/algorithm/hex.hpp>
16 #include <boost/uuid/detail/md5.hpp>
34 double theta = 2.0 * std::atan(std::exp(-eta));
35 length = radius / std::tan(theta);
42 return GetLengthForRapidityCoverage(radius, _eta_coverage);
53 double theta = 2 * atan(exp(-eta));
60 double eta = -log(tan(theta / 2.));
71 radius = sqrt(x * x + y * y);
73 theta = atan2(radius, z);
74 eta = -log(tan(theta / 2.));
75 return make_pair(eta, phi);
83 theta = atan2(radius, fabs(z));
84 eta = -log(tan(theta / 2.));
96 cout <<
"G4VisAttributes pointer is NULL" << endl;
99 if (material ==
"AL_BABAR_MAG")
101 att->SetColour(G4Colour::Blue());
103 else if (material ==
"BlackHole")
105 att->SetColour(G4Colour::Black());
107 else if (material ==
"C4F10")
109 att->SetColour(0., 0., 0.5, 0.25);
111 else if (material ==
"CF4")
113 att->SetColour(G4Colour::Magenta());
115 else if (material ==
"G4_AIR")
117 att->SetColour(G4Colour::Black());
119 else if (material ==
"G4_Al")
121 att->SetColour(G4Colour::Gray());
123 else if (material ==
"G4_Au")
125 att->SetColour(G4Colour::Yellow());
127 else if (material ==
"G4_CARBON_DIOXIDE")
129 att->SetColour(G4Colour::Green());
131 else if (material ==
"G4_CELLULOSE_CELLOPHANE")
133 att->SetColour(0.25, 0.25, 0.);
135 else if (material ==
"G4_Cu")
137 att->SetColour(1., 0.51, 0.278);
139 else if (material ==
"G4_Fe")
141 att->SetColour(0.29, 0.44, 0.54);
143 else if (material ==
"G4_KAPTON")
145 att->SetColour(G4Colour::Yellow());
147 else if (material ==
"G4_MYLAR")
149 att->SetColour(0.5, 0.5, 0.5, 0.25);
151 else if (material ==
"G4_METHANE")
153 att->SetColour(0., 1., 1., 0.25);
155 else if (material ==
"G4_Si")
157 att->SetColour(G4Colour::Yellow());
159 else if (material ==
"G4_TEFLON")
161 att->SetColour(G4Colour::White());
163 else if (material ==
"G4_W")
165 att->SetColour(0.36, 0.36, 0.36);
167 else if (material ==
"Quartz")
169 att->SetColour(G4Colour::Green());
171 else if (material ==
"Scintillator" || material ==
"G4_POLYSTYRENE")
173 att->SetColour(0., 1., 1.);
175 else if (material ==
"W_Epoxy")
177 att->SetColour(0.5, 0.5, 0.5);
179 else if (material ==
"G10")
181 att->SetColour(1., 1., 0., 0.5);
186 att->SetColour(G4Colour::Cyan());
213 double bottom = fx * px + fy * py;
216 double top = gx * px + gy * py;
225 if (h > 0. && h < 1.)
227 double rx = cx + fx *
h;
228 double ry = cy + fy *
h;
230 if ((rx > ax && rx > bx) || (rx < ax && rx < bx) || (ry < ay && ry < by) || (ry > ay && ry > by))
233 return make_pair(
false, make_pair(NAN, NAN));
238 return make_pair(
true, make_pair(rx, ry));
242 return make_pair(
false, make_pair(NAN, NAN));
264 if (cx > dx || cy > dy)
266 cout <<
PHWHERE <<
"ERROR: Bad rectangle definition!" << endl;
267 return make_pair(
false, NAN);
277 pair<bool, pair<double, double>> intersect1 = lines_intersect(ax, ay, bx, by, cx, cy, fx, fy);
279 if (intersect1.first)
281 vx.push_back(intersect1.second.first);
282 vy.push_back(intersect1.second.second);
284 pair<bool, pair<double, double>> intersect2 = lines_intersect(ax, ay, bx, by, fx, fy, dx, dy);
286 if (intersect2.first)
288 vx.push_back(intersect2.second.first);
289 vy.push_back(intersect2.second.second);
291 pair<bool, pair<double, double>> intersect3 = lines_intersect(ax, ay, bx, by, ex, ey, dx, dy);
293 if (intersect3.first)
295 vx.push_back(intersect3.second.first);
296 vy.push_back(intersect3.second.second);
298 pair<bool, pair<double, double>> intersect4 = lines_intersect(ax, ay, bx, by, cx, cy, ex, ey);
300 if (intersect4.first)
302 vx.push_back(intersect4.second.first);
303 vy.push_back(intersect4.second.second);
312 rr = sqrt((vx[0] - vx[1]) * (vx[0] - vx[1]) + (vy[0] - vy[1]) * (vy[0] - vy[1]));
318 if (ax > cx && ay > cy && ax < dx && ay < dy)
321 rr = sqrt((vx[0] - ax) * (vx[0] - ax) + (vy[0] - ay) * (vy[0] - ay));
323 if (bx > cx && by > cy && bx < dx && by < dy)
326 rr = sqrt((vx[0] - bx) * (vx[0] - bx) + (vy[0] - by) * (vy[0] - by));
330 if (intersect1.first || intersect2.first || intersect3.first || intersect4.first)
332 return make_pair(
true, rr);
334 return make_pair(
false, NAN);
349 return -sA(r, -x, y);
354 return -sA(r, x, -y);
367 if (x * x + y * y > r * r)
369 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;
401 return sA(r, x2, y1) - sA(r, x1, y1) - sA(r, x2, y2) + sA(r, x1, y2);
407 myfile.open(filename);
408 if (!myfile.is_open())
410 cout <<
"Error opening " << filename << endl;
414 boost::uuids::detail::md5
hash;
415 boost::uuids::detail::md5::digest_type digest;
417 while (myfile.get(c))
419 hash.process_bytes(&c, 1);
422 hash.get_digest(digest);
423 const auto charDigest =
reinterpret_cast<const char*
>(&digest);
425 boost::algorithm::hex(charDigest, charDigest +
sizeof(boost::uuids::detail::md5::digest_type), std::back_inserter(result));
426 boost::algorithm::to_lower(result);