Belle II Software development
quadrilateral_barrel_t Struct Referenceabstract

quadrilateral struct for barrel More...

Inheritance diagram for quadrilateral_barrel_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 tesselated solid
 
virtual G4VSolid * get_tesselatedsolid (const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
 get tesselated 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   H
 
      double   a
 
      double   b
 
      double   h
 
      double   alpha
 
      double   beta
 
      double   betap
 
      double   gamma
 
      double   Volume
 
      double   Weight
 
   } 
 
   double   t [12]
 
}; 
 
int nshape
 shapes
 

Detailed Description

quadrilateral struct for barrel

Definition at line 287 of file shapes.cc.

Constructor & Destructor Documentation

◆ quadrilateral_barrel_t()

Definition at line 294 of file shapes.cc.

294{}

◆ ~quadrilateral_barrel_t()

virtual ~quadrilateral_barrel_t ( )
inlinevirtual

Definition at line 295 of file shapes.cc.

295{}

Member Function Documentation

◆ get_bellecrystal()

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

get Belle crystal

Definition at line 257 of file shapes.cc.

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

◆ get_extrudedsolid()

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

get extruded solid

Definition at line 146 of file shapes.cc.

147 {
148 map<int, G4ThreeVector> v = make_verticies(wrapthick);
149
150 string name(prefix);
151 name += to_string(nshape);
152
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()));
158
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()));
163
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();
168 double s = sqrt(s2);
169 sum += s;
170 if (s > smax) smax = s;
171 if (s < smin) smin = s;
172 }
173 }
174 double ave = sum / 6;
175
176 double scale = ave;
177 G4TwoVector off1(0, 0), off2(scale * p1[0].x() - p2[0].x(), scale * p1[0].y() - p2[0].y());
178
179 return new G4ExtrudedSolid(name, p1, abs(v[1].z()), off1, 1, -off2, scale);
180 }
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 73 of file shapes.cc.

74 {
75 return get_bellecrystal(prefix, wrapthick, shift);
76 }
virtual G4VSolid * get_bellecrystal(const std::string &prefix, double wrapthick, G4Translate3D &shift) const =0
get Belle crystal

◆ get_tesselatedsolid()

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

get tesselated solid

Definition at line 121 of file shapes.cc.

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

◆ get_trapezoid()

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

get trapezoid

Implements shape_t.

Definition at line 183 of file shapes.cc.

184 {
185 map<int, G4ThreeVector> v = make_verticies(wrapthick);
186
187 // make sides @ +-Y parallel
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();
193 // if(abs(h1/h4-1)<0.02) cout<<"Shape = "<<nshape<<" "<<h1<<" "<<h4<<" "<<h1/h4-1<<endl;
194 if (h1 < h4) {
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]);
199 } else {
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]);
204 }
205
206 string name(prefix);
207 name += to_string(nshape);
208
209 G4ThreeVector pt[8];
210 pt[0] = v[4];
211 pt[1] = v[1];
212 pt[2] = v[3];
213 pt[3] = v[2];
214 pt[4] = v[8];
215 pt[5] = v[5];
216 pt[6] = v[7];
217 pt[7] = v[6];
218
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());};
221
222 alignz(0, 1);
223 alignz(0, 2);
224 alignz(0, 3);
225
226 alignz(4, 1 + 4);
227 alignz(4, 2 + 4);
228 alignz(4, 3 + 4);
229
230 aligny(0, 1);
231 aligny(2, 3);
232
233 aligny(4, 5);
234 aligny(6, 7);
235
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();
237 dx /= 8;
238 double dy = pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y();
239 dy /= 4;
240 for (int j = 0; j < 8; j++) {
241 pt[j].setX(pt[j].x() - dx);
242 pt[j].setY(pt[j].y() - dy);
243 }
244
245 // int oprec = cout.precision(17);
246 // cout<<dx<<" "<<dy<<endl;
247 // cout.precision(oprec);
248
249 shift = G4Translate3D(dx, dy, 0);
250 G4VSolid* shape = new G4Trap(name.c_str(), pt);
251 // cout<<name<<" "<<shape->GetCubicVolume()*1e-3<<" "<<Volume<<endl;
252 // G4VSolid *shape = new BelleCrystal(name.c_str(), 4, pt);
253 return shape;
254 }

◆ istrap()

bool istrap ( ) const
inlineoverridevirtual

is trapped

Implements shape_t.

Definition at line 298 of file shapes.cc.

299 {
300 return true;
301 }

◆ make_verticies()

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

create map of vertices

Implements quadrilateral_t.

Definition at line 304 of file shapes.cc.

305 {
306 map<int, G4ThreeVector> v;
307 // ensure sides to be parallel
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;
310 // double tn = tan(alpha*M_PI/180), d = h*tn, D = H*tn;
311 double m = (a + b) * 0.5, M = (A + B) * 0.5;
312
313 const double eps = 0.5e-3; // crystal sides are defined with 0.5 micron precision
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));
318 }
319
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);
328
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]);
339 std::swap(nv, v);
340 }
341
342 // if(nshape==1){ for(int j=1;j<=8;j++) cout<<v[j]<<" "; cout<<endl;}
343
344 return v;
345 }
double atan(double a)
atan for double
Definition: beamHelpers.h:34

Member Data Documentation

◆ A

double A

Definition at line 290 of file shapes.cc.

◆ a

double a

Definition at line 290 of file shapes.cc.

◆ alpha

double alpha

Definition at line 290 of file shapes.cc.

◆ B

double B

Definition at line 290 of file shapes.cc.

◆ b

double b

Definition at line 290 of file shapes.cc.

◆ beta

double beta

Definition at line 290 of file shapes.cc.

◆ betap

double betap

Definition at line 290 of file shapes.cc.

◆ gamma

double gamma

Definition at line 290 of file shapes.cc.

◆ H

double H

Definition at line 290 of file shapes.cc.

◆ h

double h

Definition at line 290 of file shapes.cc.

◆ nshape

int nshape
inherited

shapes

Definition at line 30 of file shapes.h.

◆ t

double t[12]

Definition at line 292 of file shapes.cc.

◆ Volume

double Volume

Definition at line 290 of file shapes.cc.

◆ Weight

double Weight

Definition at line 290 of file shapes.cc.


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