Belle II Software development
quadrilateral_endcap_t Struct Referenceabstract

quadrilateral struct for end cap More...

Inheritance diagram for quadrilateral_endcap_t:
quadrilateral_t shape_t

Public Member Functions

bool istrap () const override
 is trapped?
 
map< int, G4ThreeVector > make_verticies (double wrapthick) const override
 create map of vertices
 
G4VSolid * get_tesselatedsolid (const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
 get tessellated solid
 
virtual G4VSolid * get_tesselatedsolid (const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
 get tessellated solid
 
G4VSolid * get_extrudedsolid (const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
 get extruded solid
 
virtual G4VSolid * get_extrudedsolid (const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
 get extruded solid
 
G4VSolid * get_trapezoid (const string &prefix, double wrapthick, G4Translate3D &shift) const override
 get trapezoid
 
G4VSolid * get_bellecrystal (const string &prefix, double wrapthick, G4Translate3D &shift UNUSED) const override
 get Belle crystal
 
virtual G4VSolid * get_bellecrystal (const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
 get Belle crystal
 
G4VSolid * get_solid (const std::string &prefix, double wrapthick, G4Translate3D &shift) const
 get solid
 

Public Attributes

union { 
 
   struct { 
 
      double   A 
 
      double   B 
 
      double   C 
 
      double   D 
 
      double   a 
 
      double   b 
 
      double   c 
 
      double   d 
 
      double   H_aA 
 
      double   H_dD 
 
      double   dg13 
 
      double   dg24 
 
      double   dg57 
 
      double   dg68 
 
      double   a1 
 
      double   a2 
 
      double   a3 
 
      double   a4 
 
      double   Volume 
 
      double   Weight 
 
   }  
 
   double   t [20] = {} 
 
};  
 
int nshape
 shapes
 

Detailed Description

quadrilateral struct for end cap

Definition at line 353 of file shapes.cc.

Constructor & Destructor Documentation

◆ quadrilateral_endcap_t()

Definition at line 360 of file shapes.cc.

360{}

◆ ~quadrilateral_endcap_t()

virtual ~quadrilateral_endcap_t ( )
inlineoverridevirtual

Definition at line 361 of file shapes.cc.

361{}

Member Function Documentation

◆ get_bellecrystal()

G4VSolid * get_bellecrystal ( const string & prefix,
double wrapthick,
G4Translate3D &shift UNUSED ) const
inlineoverrideinherited

get Belle crystal

Definition at line 261 of file shapes.cc.

262 {
263 map<int, G4ThreeVector> v = make_verticies(wrapthick);
264
265 string name(prefix);
266 name += to_string(nshape);
267
268 G4ThreeVector pt[8];
269 pt[0] = v[4];
270 pt[1] = v[1];
271 pt[2] = v[3];
272 pt[3] = v[2];
273 pt[4] = v[8];
274 pt[5] = v[5];
275 pt[6] = v[7];
276 pt[7] = v[6];
277
278 for (int i = 0; i < 8; i++) pt[i] = v[i + 1];
279 G4VSolid* shape = new BelleCrystal(name.c_str(), 4, pt);
280 // cout<<name<<" "<<shape->GetCubicVolume()*1e-3<<" "<<Volume<<endl;
281 // for(int i=0;i<100000;i++){
282 // G4ThreeVector a = shape->GetPointOnSurface();
283 // cout<<a.x()<<" "<<a.y()<<" "<<a.z()<<endl;
284 // }
285 // exit(0);
286 return shape;
287 }

◆ get_extrudedsolid()

G4VSolid * get_extrudedsolid ( const string & prefix,
double wrapthick,
G4Translate3D &shift UNUSED ) const
inlineoverrideinherited

get extruded solid

Definition at line 150 of file shapes.cc.

151 {
152 map<int, G4ThreeVector> v = make_verticies(wrapthick);
153
154 string name(prefix);
155 name += to_string(nshape);
156
157 std::vector<G4TwoVector> p1, p2;
158 p1.push_back(G4TwoVector(v[1].x(), v[1].y()));
159 p1.push_back(G4TwoVector(v[2].x(), v[2].y()));
160 p1.push_back(G4TwoVector(v[3].x(), v[3].y()));
161 p1.push_back(G4TwoVector(v[4].x(), v[4].y()));
162
163 p2.push_back(G4TwoVector(v[1 + 4].x(), v[1 + 4].y()));
164 p2.push_back(G4TwoVector(v[2 + 4].x(), v[2 + 4].y()));
165 p2.push_back(G4TwoVector(v[3 + 4].x(), v[3 + 4].y()));
166 p2.push_back(G4TwoVector(v[4 + 4].x(), v[4 + 4].y()));
167
168 double sum = 0, smin = 1e9, smax = -1e9;
169 for (int i = 0; i < 4; i++) {
170 for (int j = i + 1; j < 4; j++) {
171 double s2 = (p2[j] - p2[i]).mag2() / (p1[j] - p1[i]).mag2();
172 double s = sqrt(s2);
173 sum += s;
174 if (s > smax) smax = s;
175 if (s < smin) smin = s;
176 }
177 }
178 double ave = sum / 6;
179
180 double scale = ave;
181 G4TwoVector off1(0, 0), off2(scale * p1[0].x() - p2[0].x(), scale * p1[0].y() - p2[0].y());
182
183 return new G4ExtrudedSolid(name, p1, abs(v[1].z()), off1, 1, -off2, scale);
184 }
double sqrt(double a)
sqrt for double
Definition beamHelpers.h:28

◆ get_solid()

G4VSolid * get_solid ( const std::string & prefix,
double wrapthick,
G4Translate3D & shift ) const
inherited

get solid

Definition at line 77 of file shapes.cc.

78 {
79 return get_bellecrystal(prefix, wrapthick, shift);
80 }

◆ get_tesselatedsolid()

G4VSolid * get_tesselatedsolid ( const string & prefix,
double wrapthick,
G4Translate3D &shift UNUSED ) const
inlineoverrideinherited

get tessellated solid

Definition at line 125 of file shapes.cc.

126 {
127 map<int, G4ThreeVector> v = make_verticies(wrapthick);
128
129 string name(prefix);
130 name += to_string(nshape);
131 G4TessellatedSolid* s = new G4TessellatedSolid(name.c_str());
132
133 // Now add the facets to the solid
134 // top plane
135 s->AddFacet(new G4QuadrangularFacet(v[1], v[4], v[3], v[2], ABSOLUTE));
136 // bottom plane
137 s->AddFacet(new G4QuadrangularFacet(v[5], v[6], v[7], v[8], ABSOLUTE));
138 // lateral sides
139 s->AddFacet(new G4QuadrangularFacet(v[1], v[2], v[6], v[5], ABSOLUTE));
140 s->AddFacet(new G4QuadrangularFacet(v[2], v[3], v[7], v[6], ABSOLUTE));
141 s->AddFacet(new G4QuadrangularFacet(v[3], v[4], v[8], v[7], ABSOLUTE));
142 s->AddFacet(new G4QuadrangularFacet(v[4], v[1], v[5], v[8], ABSOLUTE));
143
144 // Finally declare the solid is complete
145 s->SetSolidClosed(true);
146 return s;
147 }

◆ get_trapezoid()

G4VSolid * get_trapezoid ( const string & prefix,
double wrapthick,
G4Translate3D & shift ) const
inlineoverridevirtualinherited

get trapezoid

Implements shape_t.

Definition at line 187 of file shapes.cc.

188 {
189 map<int, G4ThreeVector> v = make_verticies(wrapthick);
190
191 // make sides @ +-Y parallel
192 G4ThreeVector b = v[4] - v[1];
193 G4ThreeVector d12 = v[2] - v[1], d43 = v[3] - v[4];
194 double b2 = b.mag2();
195 double h1 = b.cross(d12).mag2();
196 double h4 = b.cross(d43).mag2();
197 // if(abs(h1/h4-1)<0.02) cout<<"Shape = "<<nshape<<" "<<h1<<" "<<h4<<" "<<h1/h4-1<<endl;
198 if (h1 < h4) {
199 G4ThreeVector d24 = v[4] - v[2];
200 double d43b = d43 * b, s = (b2 * (d24 * d43) - (d24 * b) * d43b) / (d43b * d43b - b2 * d43.mag2());
201 v[3] = v[4] + s * d43;
202 v[7] = v[8] + s * (v[7] - v[8]);
203 } else {
204 G4ThreeVector d31 = v[1] - v[3];
205 double d12b = d12 * b, s = (b2 * (d31 * d12) - (d31 * b) * d12b) / (d12b * d12b - b2 * d12.mag2());
206 v[2] = v[1] + s * d12;
207 v[6] = v[5] + s * (v[6] - v[5]);
208 }
209
210 string name(prefix);
211 name += to_string(nshape);
212
213 G4ThreeVector pt[8];
214 pt[0] = v[4];
215 pt[1] = v[1];
216 pt[2] = v[3];
217 pt[3] = v[2];
218 pt[4] = v[8];
219 pt[5] = v[5];
220 pt[6] = v[7];
221 pt[7] = v[6];
222
223 auto alignz = [&](int i, int j) {pt[j].setZ(pt[i].z());};
224 auto aligny = [&](int i, int j) {pt[j].setY(pt[i].y());};
225
226 alignz(0, 1);
227 alignz(0, 2);
228 alignz(0, 3);
229
230 alignz(4, 1 + 4);
231 alignz(4, 2 + 4);
232 alignz(4, 3 + 4);
233
234 aligny(0, 1);
235 aligny(2, 3);
236
237 aligny(4, 5);
238 aligny(6, 7);
239
240 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();
241 dx /= 8;
242 double dy = pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y();
243 dy /= 4;
244 for (int j = 0; j < 8; j++) {
245 pt[j].setX(pt[j].x() - dx);
246 pt[j].setY(pt[j].y() - dy);
247 }
248
249 // int oprec = cout.precision(17);
250 // cout<<dx<<" "<<dy<<endl;
251 // cout.precision(oprec);
252
253 shift = G4Translate3D(dx, dy, 0);
254 G4VSolid* shape = new G4Trap(name.c_str(), pt);
255 // cout<<name<<" "<<shape->GetCubicVolume()*1e-3<<" "<<Volume<<endl;
256 // G4VSolid *shape = new BelleCrystal(name.c_str(), 4, pt);
257 return shape;
258 }

◆ istrap()

bool istrap ( ) const
inlineoverridevirtual

is trapped?

Implements shape_t.

Definition at line 364 of file shapes.cc.

365 {
366 double h1 = sind(a1) * D, h4 = sind(a4) * C;
367 return abs(h1 - h4) < 0.01 * h1;
368 }

◆ make_verticies()

map< int, G4ThreeVector > make_verticies ( double wrapthick) const
inlineoverridevirtual

create map of vertices

Implements quadrilateral_t.

Definition at line 371 of file shapes.cc.

372 {
373 double minh = std::min(sind(a1) * D, sind(a4) * C);
374 double h2 = minh / 2;
375 double db = (tand(a1 - 90) - tand(a4 - 90)) * h2 / 2;
376
377 map<int, G4ThreeVector> v;
378 v[5] = G4ThreeVector(-A / 2 + db, -h2, -150);
379 v[6] = v[5] + moveto(D, a1);
380 v[8] = G4ThreeVector(A / 2 + db, -h2, -150);
381 v[7] = v[8] + moveto(C, 180 - a4);
382
383 // adjust position of v[2],v[3],v[7],v[6] to have all 4 points in a plane, other combination already in a plane by the construction
384 G4ThreeVector vB = v[7] - v[6], va(a, 0, 0), vd = moveto(d, a1), vc = moveto(c, 180 - a4);
385 double delta = vB.cross(va + vc - vd).z() / vB.cross(vc + vd).z(); // delta should be very small ~10^-6 or less
386
387 vd *= 1 + delta;
388 vc *= 1 - delta;
389
390 v[1] = v[5] + G4ThreeVector((H_aA * cosd(a1) + H_dD) / sind(a1), H_aA, 300);
391 v[2] = v[1] + vd;
392 v[4] = v[1] + va;
393 v[3] = v[4] + vc;
394
395 for (int j = 1; j <= 8; j++) v[j] = G4ThreeVector(v[j].x(), -v[j].y(), -v[j].z());
396
397 // G4ThreeVector c0 = centerofgravity(v, 1, 4);
398 // G4ThreeVector c1 = centerofgravity(v, 5, 4);
399 // G4ThreeVector cz = 0.5*(c0+c1);
400 // cout<<c0<<" "<<c1<<" "<<cz<<endl;
401
402 if (wrapthick != 0) {
403 map<int, G4ThreeVector> nv;
404 nv[1] = newvertex(wrapthick, v[1], v[5], v[2], v[4]);
405 nv[2] = newvertex(wrapthick, v[2], v[6], v[3], v[1]);
406 nv[3] = newvertex(wrapthick, v[3], v[7], v[4], v[2]);
407 nv[4] = newvertex(wrapthick, v[4], v[8], v[1], v[3]);
408 nv[5] = newvertex(wrapthick, v[5], v[1], v[8], v[6]);
409 nv[6] = newvertex(wrapthick, v[6], v[2], v[5], v[7]);
410 nv[7] = newvertex(wrapthick, v[7], v[3], v[6], v[8]);
411 nv[8] = newvertex(wrapthick, v[8], v[4], v[7], v[5]);
412 std::swap(nv, v);
413 }
414 // if(nshape==2){ for(int j=1;j<=8;j++) cout<<v[j]<<" "; cout<<endl;}
415 return v;
416 }

Member Data Documentation

◆ A

double A

Definition at line 356 of file shapes.cc.

◆ a

double a

Definition at line 356 of file shapes.cc.

◆ a1

double a1

Definition at line 356 of file shapes.cc.

◆ a2

double a2

Definition at line 356 of file shapes.cc.

◆ a3

double a3

Definition at line 356 of file shapes.cc.

◆ a4

double a4

Definition at line 356 of file shapes.cc.

◆ B

double B

Definition at line 356 of file shapes.cc.

◆ b

double b

Definition at line 356 of file shapes.cc.

◆ C

double C

Definition at line 356 of file shapes.cc.

◆ c

double c

Definition at line 356 of file shapes.cc.

◆ D

double D

Definition at line 356 of file shapes.cc.

◆ d

double d

Definition at line 356 of file shapes.cc.

◆ dg13

double dg13

Definition at line 356 of file shapes.cc.

◆ dg24

double dg24

Definition at line 356 of file shapes.cc.

◆ dg57

double dg57

Definition at line 356 of file shapes.cc.

◆ dg68

double dg68

Definition at line 356 of file shapes.cc.

◆ H_aA

double H_aA

Definition at line 356 of file shapes.cc.

◆ H_dD

double H_dD

Definition at line 356 of file shapes.cc.

◆ nshape

int nshape
inherited

shapes

Definition at line 30 of file shapes.h.

◆ t

double t[20] = {}

Definition at line 358 of file shapes.cc.

358{};

◆ Volume

double Volume

Definition at line 356 of file shapes.cc.

◆ Weight

double Weight

Definition at line 356 of file shapes.cc.


The documentation for this struct was generated from the following file: