8#include "ecl/geometry/shapes.h"
9#include "G4TessellatedSolid.hh"
10#include "G4TriangularFacet.hh"
11#include "G4QuadrangularFacet.hh"
12#include <G4ExtrudedSolid.hh>
14#include "ecl/geometry/BelleCrystal.h"
18#include "CLHEP/Matrix/Vector.h"
19#include "CLHEP/Matrix/Matrix.h"
20#include <G4TwoVector.hh>
21#include <G4Vector3D.hh>
22#include <framework/utilities/FileSystem.h>
23#include <framework/logging/Logger.h>
33 double cosd(
double x) {
return cos(x * (M_PI / 180));}
34 double sind(
double x) {
return sin(x * (M_PI / 180));}
35 double tand(
double x) {
return tan(x * (M_PI / 180));}
37 double volume(
const G4ThreeVector& v0,
const G4ThreeVector& v1,
const G4ThreeVector& v2,
const G4ThreeVector& v3)
39 G4ThreeVector x =
v1 - v0, y =
v2 - v0, z =
v3 - v0;
40 return x.cross(y) * z;
43 G4ThreeVector newvertex(
double d,
const G4ThreeVector& v0,
const G4ThreeVector& v1,
const G4ThreeVector& v2,
44 const G4ThreeVector& v3)
46 G4ThreeVector x =
v1 - v0, y =
v2 - v0, z =
v3 - v0;
47 G4ThreeVector nxy = x.cross(y).unit();
48 G4ThreeVector nyz = y.cross(z).unit();
49 G4ThreeVector nzx = z.cross(x).unit();
51 CLHEP::HepMatrix A(3, 3);
52 A[0][0] = nxy.x(), A[0][1] = nxy.y(), A[0][2] = nxy.z();
53 A[1][0] = nyz.x(), A[1][1] = nyz.y(), A[1][2] = nyz.z();
54 A[2][0] = nzx.x(), A[2][1] = nzx.y(), A[2][2] = nzx.z();
56 CLHEP::HepVector B(3);
62 CLHEP::HepVector r = A.inverse() * B;
64 return G4ThreeVector(r[0], r[1], r[2]);
67 G4ThreeVector moveto(
double r,
double phi)
69 return G4ThreeVector(r * cosd(phi), r * sind(phi), 0);
78 G4ThreeVector centerofgravity(
const map<int, G4ThreeVector>& v,
int i0,
int n)
80 double cx = 0, cy = 0, A = 0;
81 for (
int j = 0; j < n; j++) {
82 int j0 = j + i0, j1 = ((j + 1) % n) + i0;
83 const G4ThreeVector& v0 = v.find(j0)->second, &v1 = v.find(j1)->second;
84 double t = v0.x() * v1.y() - v0.y() * v1.x();
87 cx += (v0.x() + v1.x()) * t;
88 cy += (v0.y() + v1.y()) * t;
92 return G4ThreeVector(cx, cy, v.find(i0)->second.z());
95 Point_t centerofgravity(Point_t* b,
const Point_t* e)
97 double cx = 0, cy = 0, A = 0;
99 for (
int j = 0; j < n; j++) {
100 int j0 = j, j1 = ((j + 1) % n);
101 const Point_t& v0 = b[j0], &v1 = b[j1];
102 double t = v0.x * v1.y - v0.y * v1.x;
104 cx += (v0.x + v1.x) * t;
105 cy += (v0.y + v1.y) * t;
109 Point_t t = {cx, cy};
121 G4VSolid*
get_tesselatedsolid(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
126 name += to_string(
nshape);
127 G4TessellatedSolid* s =
new G4TessellatedSolid(name.c_str());
131 s->AddFacet(
new G4QuadrangularFacet(v[1], v[4], v[3], v[2], ABSOLUTE));
133 s->AddFacet(
new G4QuadrangularFacet(v[5], v[6], v[7], v[8], ABSOLUTE));
135 s->AddFacet(
new G4QuadrangularFacet(v[1], v[2], v[6], v[5], ABSOLUTE));
136 s->AddFacet(
new G4QuadrangularFacet(v[2], v[3], v[7], v[6], ABSOLUTE));
137 s->AddFacet(
new G4QuadrangularFacet(v[3], v[4], v[8], v[7], ABSOLUTE));
138 s->AddFacet(
new G4QuadrangularFacet(v[4], v[1], v[5], v[8], ABSOLUTE));
141 s->SetSolidClosed(
true);
146 G4VSolid*
get_extrudedsolid(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
151 name += to_string(
nshape);
153 std::vector<G4TwoVector> p1, p2;
154 p1.push_back(G4TwoVector(v[1].x(), v[1].y()));
155 p1.push_back(G4TwoVector(v[2].x(), v[2].y()));
156 p1.push_back(G4TwoVector(v[3].x(), v[3].y()));
157 p1.push_back(G4TwoVector(v[4].x(), v[4].y()));
159 p2.push_back(G4TwoVector(v[1 + 4].x(), v[1 + 4].y()));
160 p2.push_back(G4TwoVector(v[2 + 4].x(), v[2 + 4].y()));
161 p2.push_back(G4TwoVector(v[3 + 4].x(), v[3 + 4].y()));
162 p2.push_back(G4TwoVector(v[4 + 4].x(), v[4 + 4].y()));
164 double sum = 0, smin = 1e9, smax = -1e9;
165 for (
int i = 0; i < 4; i++) {
166 for (
int j = i + 1; j < 4; j++) {
167 double s2 = (p2[j] - p2[i]).mag2() / (p1[j] - p1[i]).mag2();
170 if (s > smax) smax = s;
171 if (s < smin) smin = s;
174 double ave = sum / 6;
177 G4TwoVector off1(0, 0), off2(scale * p1[0].x() - p2[0].x(), scale * p1[0].y() - p2[0].y());
179 return new G4ExtrudedSolid(name, p1, abs(v[1].z()), off1, 1, -off2, scale);
183 G4VSolid*
get_trapezoid(
const string& prefix,
double wrapthick, G4Translate3D& shift)
const override
188 G4ThreeVector b = v[4] - v[1];
189 G4ThreeVector d12 = v[2] - v[1], d43 = v[3] - v[4];
190 double b2 = b.mag2();
191 double h1 = b.cross(d12).mag2();
192 double h4 = b.cross(d43).mag2();
195 G4ThreeVector d24 = v[4] - v[2];
196 double d43b = d43 * b, s = (b2 * (d24 * d43) - (d24 * b) * d43b) / (d43b * d43b - b2 * d43.mag2());
197 v[3] = v[4] + s * d43;
198 v[7] = v[8] + s * (v[7] - v[8]);
200 G4ThreeVector d31 = v[1] - v[3];
201 double d12b = d12 * b, s = (b2 * (d31 * d12) - (d31 * b) * d12b) / (d12b * d12b - b2 * d12.mag2());
202 v[2] = v[1] + s * d12;
203 v[6] = v[5] + s * (v[6] - v[5]);
207 name += to_string(
nshape);
219 auto alignz = [&](
int i,
int j) {pt[j].setZ(pt[i].z());};
220 auto aligny = [&](
int i,
int j) {pt[j].setY(pt[i].y());};
236 double dx = pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() + pt[2].x() + pt[3].x() + pt[6].x() + pt[7].x();
238 double dy = pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y();
240 for (
int j = 0; j < 8; j++) {
241 pt[j].setX(pt[j].x() - dx);
242 pt[j].setY(pt[j].y() - dy);
249 shift = G4Translate3D(dx, dy, 0);
250 G4VSolid* shape =
new G4Trap(name.c_str(), pt);
257 G4VSolid*
get_bellecrystal(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
262 name += to_string(
nshape);
274 for (
int i = 0; i < 8; i++) pt[i] = v[i + 1];
275 G4VSolid* shape =
new BelleCrystal(name.c_str(), 4, pt);
290 double A, B, H, a, b, h, alpha, beta, betap, gamma, Volume, Weight;
306 map<int, G4ThreeVector> v;
308 double wh = h * h, wH = H * H, wnorm = wh + wH;
309 double tn = ((b - a) / 2 / h * wh + (B - A) / 2 / H * wH) / wnorm, d = h * tn, D = H * tn;
311 double m = (a + b) * 0.5, M = (A + B) * 0.5;
313 const double eps = 0.5e-3;
314 if (fabs(a - (m - d)) > eps || fabs(b - (m + d)) > eps || fabs(A - (M - D)) > eps || fabs(B - (M + D)) > eps) {
315 double alfa =
atan(tn) * 180 / M_PI;
316 B2WARNING(
"Cannot make parallel sides better than 0.5 mcm: alpha =" << alpha <<
" alpha from sides = " << alfa <<
" da = " << a -
317 (m - d) <<
" db = " << b - (m + d) <<
" dA = " << A - (M - D) <<
" dB = " << B - (M + D));
320 v[1] = G4ThreeVector(-(m - d) / 2, h / 2, -150);
321 v[2] = G4ThreeVector(-(m + d) / 2, -h / 2, -150);
322 v[3] = G4ThreeVector((m + d) / 2, -h / 2, -150);
323 v[4] = G4ThreeVector((m - d) / 2, h / 2, -150);
324 v[5] = G4ThreeVector(-(M - D) / 2, H / 2, 150);
325 v[6] = G4ThreeVector(-(M + D) / 2, -H / 2, 150);
326 v[7] = G4ThreeVector((M + D) / 2, -H / 2, 150);
327 v[8] = G4ThreeVector((M - D) / 2, H / 2, 150);
329 if (wrapthick != 0) {
330 map<int, G4ThreeVector> nv;
331 nv[1] = newvertex(wrapthick, v[1], v[5], v[2], v[4]);
332 nv[2] = newvertex(wrapthick, v[2], v[6], v[3], v[1]);
333 nv[3] = newvertex(wrapthick, v[3], v[7], v[4], v[2]);
334 nv[4] = newvertex(wrapthick, v[4], v[8], v[1], v[3]);
335 nv[5] = newvertex(wrapthick, v[5], v[1], v[8], v[6]);
336 nv[6] = newvertex(wrapthick, v[6], v[2], v[5], v[7]);
337 nv[7] = newvertex(wrapthick, v[7], v[3], v[6], v[8]);
338 nv[8] = newvertex(wrapthick, v[8], v[4], v[7], v[5]);
352 double A, B, C, D, a, b, c, d, H_aA, H_dD, dg13, dg24, dg57, dg68, a1, a2, a3, a4, Volume, Weight;
362 double h1 = sind(a1) * D, h4 = sind(a4) * C;
363 return abs(h1 - h4) < 0.01 * h1;
369 double minh = std::min(sind(a1) * D, sind(a4) * C);
370 double h2 = minh / 2;
371 double db = (tand(a1 - 90) - tand(a4 - 90)) * h2 / 2;
373 map<int, G4ThreeVector> v;
374 v[5] = G4ThreeVector(-A / 2 + db, -h2, -150);
375 v[6] = v[5] + moveto(D, a1);
376 v[8] = G4ThreeVector(A / 2 + db, -h2, -150);
377 v[7] = v[8] + moveto(C, 180 - a4);
380 G4ThreeVector vB = v[7] - v[6], va(a, 0, 0), vd = moveto(d, a1), vc = moveto(c, 180 - a4);
381 double delta = vB.cross(va + vc - vd).z() / vB.cross(vc + vd).z();
386 v[1] = v[5] + G4ThreeVector((H_aA * cosd(a1) + H_dD) / sind(a1), H_aA, 300);
391 for (
int j = 1; j <= 8; j++) v[j] = G4ThreeVector(v[j].x(), -v[j].y(), -v[j].z());
398 if (wrapthick != 0) {
399 map<int, G4ThreeVector> nv;
400 nv[1] = newvertex(wrapthick, v[1], v[5], v[2], v[4]);
401 nv[2] = newvertex(wrapthick, v[2], v[6], v[3], v[1]);
402 nv[3] = newvertex(wrapthick, v[3], v[7], v[4], v[2]);
403 nv[4] = newvertex(wrapthick, v[4], v[8], v[1], v[3]);
404 nv[5] = newvertex(wrapthick, v[5], v[1], v[8], v[6]);
405 nv[6] = newvertex(wrapthick, v[6], v[2], v[5], v[7]);
406 nv[7] = newvertex(wrapthick, v[7], v[3], v[6], v[8]);
407 nv[8] = newvertex(wrapthick, v[8], v[4], v[7], v[5]);
419 double A, C, D, a, c, d, B, b, H_aA, H_dD, dg13, dg24, dg57, dg68, a1, a4, a2, a3, a9, Volume, Weight;
432 H_dD -= 0.00005551197484235;
433 B += 0.0011245236213532729;
434 b += -0.00044853029662963;
440 bool istrap()
const override {
return false;}
447 double h2 = cosd(a1 - 90) * D / 2;
448 map<int, G4ThreeVector> v;
449 v[5] = G4ThreeVector(-A / 2, -h2, -150);
450 v[6] = v[5] + moveto(D, a1);
451 v[10] = v[6] + moveto(B, a1 + a2 - 180);
452 v[8] = G4ThreeVector(A / 2, -h2, -150);
453 v[7] = v[8] + moveto(D, 180 - a1);
455 v[1] = v[5] + G4ThreeVector((H_aA * cosd(a1) + H_dD) / sind(a1), H_aA, 300);
456 v[2] = v[1] + moveto(d, a1);
457 v[9] = v[2] + moveto(b, a1 + a2 - 180);
458 v[4] = v[1] + moveto(a, 0);
459 v[3] = v[4] + moveto(d, 180 - a1);
461 for (
int j = 1; j <= 10; j++) v[j] = G4ThreeVector(v[j].x(), -v[j].y(), -v[j].z());
462 if (wrapthick != 0) {
463 map<int, G4ThreeVector> nv;
464 nv[ 1] = newvertex(wrapthick, v[1], v[5], v[2], v[4]);
465 nv[ 2] = newvertex(wrapthick, v[2], v[6], v[9], v[1]);
466 nv[ 9] = newvertex(wrapthick, v[9], v[10], v[3], v[2]);
467 nv[ 3] = newvertex(wrapthick, v[3], v[7], v[4], v[9]);
468 nv[ 4] = newvertex(wrapthick, v[4], v[8], v[1], v[3]);
469 nv[ 5] = newvertex(wrapthick, v[5], v[1], v[8], v[6]);
470 nv[ 6] = newvertex(wrapthick, v[6], v[2], v[5], v[10]);
471 nv[10] = newvertex(wrapthick, v[10], v[9], v[6], v[7]);
472 nv[ 7] = newvertex(wrapthick, v[7], v[3], v[10], v[8]);
473 nv[ 8] = newvertex(wrapthick, v[8], v[4], v[7], v[5]);
480 G4VSolid*
get_tesselatedsolid(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
482 if (
nshape != 36)
return nullptr;
487 name += to_string(
nshape);
488 G4TessellatedSolid* s =
new G4TessellatedSolid(name.c_str());
492 s->AddFacet(
new G4QuadrangularFacet(v[1], v[4], v[3], v[2], ABSOLUTE));
493 s->AddFacet(
new G4TriangularFacet(v[2], v[3], v[9], ABSOLUTE));
496 s->AddFacet(
new G4QuadrangularFacet(v[5], v[6], v[7], v[8], ABSOLUTE));
497 s->AddFacet(
new G4TriangularFacet(v[6], v[10], v[7], ABSOLUTE));
500 s->AddFacet(
new G4QuadrangularFacet(v[1], v[2], v[6], v[5], ABSOLUTE));
501 s->AddFacet(
new G4QuadrangularFacet(v[2], v[9], v[10], v[6], ABSOLUTE));
502 s->AddFacet(
new G4QuadrangularFacet(v[9], v[3], v[7], v[10], ABSOLUTE));
503 s->AddFacet(
new G4QuadrangularFacet(v[3], v[4], v[8], v[7], ABSOLUTE));
504 s->AddFacet(
new G4QuadrangularFacet(v[4], v[1], v[5], v[8], ABSOLUTE));
507 s->SetSolidClosed(
true);
512 G4VSolid*
get_extrudedsolid(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
517 name += to_string(
nshape);
519 std::vector<G4TwoVector> p1, p2;
520 p1.push_back(G4TwoVector(v[1].x(), v[1].y()));
521 p1.push_back(G4TwoVector(v[2].x(), v[2].y()));
522 p1.push_back(G4TwoVector(v[9].x(), v[9].y()));
523 p1.push_back(G4TwoVector(v[3].x(), v[3].y()));
524 p1.push_back(G4TwoVector(v[4].x(), v[4].y()));
526 p2.push_back(G4TwoVector(v[1 + 4].x(), v[1 + 4].y()));
527 p2.push_back(G4TwoVector(v[2 + 4].x(), v[2 + 4].y()));
528 p2.push_back(G4TwoVector(v[ 10].x(), v[ 10].y()));
529 p2.push_back(G4TwoVector(v[3 + 4].x(), v[3 + 4].y()));
530 p2.push_back(G4TwoVector(v[4 + 4].x(), v[4 + 4].y()));
532 double sum = 0, smin = 1e9, smax = -1e9;
534 for (
int i = 0; i < 5; i++) {
535 for (
int j = i + 1; j < 5; j++) {
536 double s2 = (p2[j] - p2[i]).mag2() / (p1[j] - p1[i]).mag2();
539 if (s > smax) smax = s;
540 if (s < smin) smin = s;
544 double ave = sum / count;
547 G4TwoVector off1(0, 0), off2(scale * p1[0].x() - p2[0].x(), scale * p1[0].y() - p2[0].y());
549 return new G4ExtrudedSolid(name, p1, abs(v[1].z()), off1, 1, -off2, scale);
553 G4VSolid*
get_trapezoid(
const string& prefix,
double wrapthick, G4Translate3D& shift)
const override
555 if (
nshape != 36)
return nullptr;
560 name += to_string(
nshape);
572 auto alignz = [&](
int i,
int j) {pt[j].setZ(pt[i].z());};
573 auto aligny = [&](
int i,
int j) {pt[j].setY(pt[i].y());};
590 double dx = pt[0].x() + pt[1].x() + pt[4].x() + pt[5].x() + pt[2].x() + pt[3].x() + pt[6].x() + pt[7].x();
592 double dy = pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y();
594 for (
int j = 0; j < 8; j++) {
595 pt[j].setX(pt[j].x() - dx);
596 pt[j].setY(pt[j].y() - dy);
598 shift = G4Translate3D(dx, dy, 0);
602 G4VSolid* shape =
new G4Trap(name.c_str(), pt);
608 G4VSolid*
get_bellecrystal(
const string& prefix,
double wrapthick, G4Translate3D& shift UNUSED)
const override
613 name += to_string(
nshape);
615 G4ThreeVector pt[10];
627 G4VSolid* shape =
new BelleCrystal(name.c_str(), 5, pt);
646 vector<shape_t*> load_shapes(
const string& fname)
648 vector<shape_t*> shapes;
651 ifstream IN(fnamef.c_str());
653 while (getline(IN, tmp)) {
654 size_t ic = tmp.find(
"#");
655 if (ic != string::npos) tmp.erase(ic);
656 istringstream iss(tmp);
658 copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(t));
661 if (t.size() == 21) {
665 istringstream in(t[0]);
668 for (
size_t i = 1; i < t.size(); i++) {
669 in.str(t[i]); in.seekg(0, ios_base::beg);
672 }
else if (t.size() == 13) {
673 shape =
new quadrilateral_barrel_t();
674 quadrilateral_barrel_t& trap =
static_cast<quadrilateral_barrel_t&
>(*shape);
676 istringstream in(t[0]);
679 for (
size_t i = 1; i < t.size(); i++) {
680 in.str(t[i]); in.seekg(0, ios_base::beg);
683 }
else if (t.size() == 22) {
684 shape =
new pent_t();
685 pent_t& pent =
static_cast<pent_t&
>(*shape);
687 istringstream in(t[0]);
690 for (
size_t i = 1; i < t.size(); i++) {
691 in.str(t[i]); in.seekg(0, ios_base::beg);
696 shapes.push_back(shape);
710 vector<cplacement_t> load_placements(
const string& fname)
712 vector<cplacement_t> plcmnt;
715 ifstream IN(fnamef.c_str());
717 while (getline(IN, tmp)) {
718 size_t ic = tmp.find(
"#");
719 if (ic != string::npos) tmp.erase(ic);
720 istringstream iss(tmp);
722 copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(t));
725 istringstream in(t[0]);
727 in.str(t[1]); in.seekg(0, ios_base::beg);
729 in.str(t[2]); in.seekg(0, ios_base::beg);
731 in.str(t[3]); in.seekg(0, ios_base::beg);
733 in.str(t[4]); in.seekg(0, ios_base::beg);
735 in.str(t[5]); in.seekg(0, ios_base::beg);
737 in.str(t[6]); in.seekg(0, ios_base::beg);
746 G4Transform3D get_transform(
const cplacement_t& t)
748 G4Transform3D r = G4Rotate3D(t.Rphi1, G4Vector3D(sin(t.Rtheta) * cos(t.Rphi2), sin(t.Rtheta) * sin(t.Rphi2), cos(t.Rtheta)));
749 G4Transform3D p = G4Translate3D(t.Pr * sin(t.Ptheta) * cos(t.Pphi), t.Pr * sin(t.Ptheta) * sin(t.Pphi), t.Pr * cos(t.Ptheta));
756 auto fillbuffer = [&buffer](
const string & fname) {
758 ifstream IN(path.c_str());
759 buffer.clear(); buffer.str(
"");
760 buffer << IN.rdbuf();
764 fillbuffer(
"/ecl/data/crystal_shape_forward.dat"); a.setShapeForward(buffer.str());
765 fillbuffer(
"/ecl/data/crystal_shape_barrel.dat"); a.setShapeBarrel(buffer.str());
766 fillbuffer(
"/ecl/data/crystal_shape_backward.dat"); a.setShapeBackward(buffer.str());
767 fillbuffer(
"/ecl/data/crystal_placement_forward.dat"); a.setPlacementForward(buffer.str());
768 fillbuffer(
"/ecl/data/crystal_placement_barrel.dat"); a.setPlacementBarrel(buffer.str());
769 fillbuffer(
"/ecl/data/crystal_placement_backward.dat"); a.setPlacementBackward(buffer.str());
775 vector<shape_t*> load_shapes(stringstream& IN)
777 vector<shape_t*> shapes;
779 while (getline(IN, tmp)) {
780 size_t ic = tmp.find(
"#");
781 if (ic != string::npos) tmp.erase(ic);
782 istringstream iss(tmp);
784 copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(t));
786 shape_t* shape =
nullptr;
787 if (t.size() == 21) {
788 shape =
new quadrilateral_endcap_t();
789 quadrilateral_endcap_t& trap =
static_cast<quadrilateral_endcap_t&
>(*shape);
791 istringstream in(t[0]);
794 for (
size_t i = 1; i < t.size(); i++) {
795 in.str(t[i]); in.seekg(0, ios_base::beg);
798 }
else if (t.size() == 13) {
799 shape =
new quadrilateral_barrel_t();
800 quadrilateral_barrel_t& trap =
static_cast<quadrilateral_barrel_t&
>(*shape);
802 istringstream in(t[0]);
805 for (
size_t i = 1; i < t.size(); i++) {
806 in.str(t[i]); in.seekg(0, ios_base::beg);
809 }
else if (t.size() == 22) {
810 shape =
new pent_t();
811 pent_t& pent =
static_cast<pent_t&
>(*shape);
813 istringstream in(t[0]);
816 for (
size_t i = 1; i < t.size(); i++) {
817 in.str(t[i]); in.seekg(0, ios_base::beg);
822 shapes.push_back(shape);
829 vector<cplacement_t> load_placements(stringstream& IN)
831 vector<cplacement_t> plcmnt;
833 while (getline(IN, tmp)) {
834 size_t ic = tmp.find(
"#");
835 if (ic != string::npos) tmp.erase(ic);
836 istringstream iss(tmp);
838 copy(istream_iterator<string>(iss), istream_iterator<string>(), back_inserter(t));
841 istringstream in(t[0]);
843 in.str(t[1]); in.seekg(0, ios_base::beg);
845 in.str(t[2]); in.seekg(0, ios_base::beg);
847 in.str(t[3]); in.seekg(0, ios_base::beg);
849 in.str(t[4]); in.seekg(0, ios_base::beg);
851 in.str(t[5]); in.seekg(0, ios_base::beg);
853 in.str(t[6]); in.seekg(0, ios_base::beg);
884 if (part == ECLParts::forward)
886 else if (part == ECLParts::barrel)
888 else if (part == ECLParts::backward)
890 return load_placements(IN);
896 if (part == ECLParts::forward)
898 else if (part == ECLParts::barrel)
900 else if (part == ECLParts::backward)
902 return load_shapes(IN);
908 vector<cplacement_t> bp = load_placements(&crystals, ECLParts::forward);
909 for (vector<cplacement_t>::const_iterator it = bp.begin(); it != bp.end(); ++it) {
910 const cplacement_t& t = *it;
911 cout << t.nshape <<
" " << t.Rphi1 <<
" " << t.Rtheta <<
" " << t.Rphi2 <<
" " << t.Pr <<
" " << t.Ptheta <<
" " << t.Pphi << endl;
Crystal shapes and positions.
const std::string & getPlacementBarrel() const
Return crystal placement in barrel.
const std::string & getShapeBackward() const
Return crystal shape in backward endcap.
const std::string & getShapeForward() const
Return crystal shape in forward endcap.
const std::string & getShapeBarrel() const
Return crystal shape in barrel.
const std::string & getPlacementBackward() const
Return crystal placement in backward endcap.
const std::string & getPlacementForward() const
Return crystal placement in forward endcap.
a Belle crystal in Geant4
static std::string findFile(const std::string &path, bool silent=false)
Search for given file or directory in local or central release directory, and return absolute path if...
double atan(double a)
atan for double
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.
const std::vector< double > v3
MATLAB generated random vector.
const std::vector< double > v2
MATLAB generated random vector.
const std::vector< double > v1
MATLAB generated random vector.
G4VSolid * get_tesselatedsolid(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get tessellated solid
bool istrap() const override
is trapped?
G4VSolid * get_extrudedsolid(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get extruded solid
G4VSolid * get_bellecrystal(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get Belle crystal
void adjust()
adjust sizes to have flat sides
map< int, G4ThreeVector > make_verticies(double wrapthick) const
create map of vertices
G4VSolid * get_trapezoid(const string &prefix, double wrapthick, G4Translate3D &shift) const override
get trapezoid
bool _adjusted
are sizes adjusted?
quadrilateral struct for barrel
bool istrap() const override
is trapped
map< int, G4ThreeVector > make_verticies(double wrapthick) const override
create map of vertices
quadrilateral struct for end cap
bool istrap() const override
is trapped?
map< int, G4ThreeVector > make_verticies(double wrapthick) const override
create map of vertices
quadrilateral shape struct
G4VSolid * get_tesselatedsolid(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get tessellated solid
virtual map< int, G4ThreeVector > make_verticies(double wrapthick) const =0
create map of vertices
G4VSolid * get_extrudedsolid(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get extruded solid
G4VSolid * get_bellecrystal(const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
get Belle crystal
G4VSolid * get_trapezoid(const string &prefix, double wrapthick, G4Translate3D &shift) const override
get trapezoid
G4VSolid * get_solid(const std::string &prefix, double wrapthick, G4Translate3D &shift) const
get solid
virtual G4VSolid * get_bellecrystal(const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
get Belle crystal