Belle II Software development
quadrilateral_t Struct Referenceabstract

quadrilateral shape struct More...

Inheritance diagram for quadrilateral_t:
shape_t quadrilateral_barrel_t quadrilateral_endcap_t

Public Member Functions

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

Public Attributes

int nshape
 shapes
 

Detailed Description

quadrilateral shape struct

Definition at line 118 of file shapes.cc.

Constructor & Destructor Documentation

◆ quadrilateral_t()

quadrilateral_t ( )
inline

Definition at line 119 of file shapes.cc.

119{}

◆ ~quadrilateral_t()

virtual ~quadrilateral_t ( )
inlineoverridevirtual

Definition at line 120 of file shapes.cc.

120{}

Member Function Documentation

◆ get_bellecrystal()

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

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
inlineoverride

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
inlineoverride

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
inlineoverridevirtual

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()

virtual bool istrap ( ) const
pure virtualinherited

is trapped

Implemented in pent_t, quadrilateral_barrel_t, and quadrilateral_endcap_t.

◆ make_verticies()

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

create map of vertices

Implemented in quadrilateral_barrel_t, and quadrilateral_endcap_t.

Member Data Documentation

◆ nshape

int nshape
inherited

shapes

Definition at line 30 of file shapes.h.


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