Belle II Software development
pent_t Struct Referenceabstract

pentagon shape More...

Inheritance diagram for pent_t:
shape_t

Public Member Functions

void adjust ()
 adjust sizes to have flat sides
 
bool istrap () const override
 is trapped?
 
map< int, G4ThreeVector > make_verticies (double wrapthick) const
 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
 

Public Attributes

union { 
 
   struct { 
 
      double   A 
 
      double   C 
 
      double   D 
 
      double   a 
 
      double   c 
 
      double   d 
 
      double   B 
 
      double   b 
 
      double   H_aA 
 
      double   H_dD 
 
      double   dg13 
 
      double   dg24 
 
      double   dg57 
 
      double   dg68 
 
      double   a1 
 
      double   a4 
 
      double   a2 
 
      double   a3 
 
      double   a9 
 
      double   Volume 
 
      double   Weight 
 
   }  
 
   double   t [21] = {} 
 
};  
 
bool _adjusted
 are sizes adjusted?
 
int nshape
 shapes
 

Detailed Description

pentagon shape

Definition at line 420 of file shapes.cc.

Constructor & Destructor Documentation

◆ pent_t()

pent_t ( )
inline

Definition at line 428 of file shapes.cc.

428: _adjusted(false) {}

◆ ~pent_t()

virtual ~pent_t ( )
inlineoverridevirtual

Definition at line 429 of file shapes.cc.

429{}

Member Function Documentation

◆ adjust()

void adjust ( )
inline

adjust sizes to have flat sides

Definition at line 432 of file shapes.cc.

433 {
434 if (!_adjusted) {
435 // adjust sizes to have flat sides
436 H_dD -= 0.00005551197484235;
437 B += 0.0011245236213532729;
438 b += -0.00044853029662963;
439 _adjusted = true;
440 }
441 }

◆ get_bellecrystal()

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

get Belle crystal

Definition at line 612 of file shapes.cc.

613 {
614 map<int, G4ThreeVector> v = make_verticies(wrapthick);
615
616 string name(prefix);
617 name += to_string(nshape);
618
619 G4ThreeVector pt[10];
620 pt[0] = v[1];
621 pt[1] = v[2];
622 pt[2] = v[9];
623 pt[3] = v[3];
624 pt[4] = v[4];
625 pt[5] = v[5];
626 pt[6] = v[6];
627 pt[7] = v[10];
628 pt[8] = v[7];
629 pt[9] = v[8];
630
631 G4VSolid* shape = new BelleCrystal(name.c_str(), 5, pt);
632 // cout<<name<<" "<<shape->GetCubicVolume()*1e-3<<" "<<Volume<<endl;
633 // for(int i=0;i<100000;i++){
634 // G4ThreeVector a = shape->GetPointOnSurface();
635 // cout<<a.x()<<" "<<a.y()<<" "<<a.z()<<endl;
636 // }
637 // exit(0);
638 // if(prefix.find("crystal")!=string::npos){
639 // pentspeed(shape);
640 // exit(0);
641 // }
642 // if(prefix.find("wrap")!=string::npos){
643 // pentspeed2(shape);
644 // exit(0);
645 // }
646 return shape;
647 }

◆ get_extrudedsolid()

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

get extruded solid

Definition at line 516 of file shapes.cc.

517 {
518 map<int, G4ThreeVector> v = make_verticies(wrapthick);
519
520 string name(prefix);
521 name += to_string(nshape);
522
523 std::vector<G4TwoVector> p1, p2;
524 p1.push_back(G4TwoVector(v[1].x(), v[1].y()));
525 p1.push_back(G4TwoVector(v[2].x(), v[2].y()));
526 p1.push_back(G4TwoVector(v[9].x(), v[9].y()));
527 p1.push_back(G4TwoVector(v[3].x(), v[3].y()));
528 p1.push_back(G4TwoVector(v[4].x(), v[4].y()));
529
530 p2.push_back(G4TwoVector(v[1 + 4].x(), v[1 + 4].y()));
531 p2.push_back(G4TwoVector(v[2 + 4].x(), v[2 + 4].y()));
532 p2.push_back(G4TwoVector(v[ 10].x(), v[ 10].y()));
533 p2.push_back(G4TwoVector(v[3 + 4].x(), v[3 + 4].y()));
534 p2.push_back(G4TwoVector(v[4 + 4].x(), v[4 + 4].y()));
535
536 double sum = 0, smin = 1e9, smax = -1e9;
537 int count = 0;
538 for (int i = 0; i < 5; i++) {
539 for (int j = i + 1; j < 5; j++) {
540 double s2 = (p2[j] - p2[i]).mag2() / (p1[j] - p1[i]).mag2();
541 double s = sqrt(s2);
542 sum += s;
543 if (s > smax) smax = s;
544 if (s < smin) smin = s;
545 count++;
546 }
547 }
548 double ave = sum / count;
549
550 double scale = ave;
551 G4TwoVector off1(0, 0), off2(scale * p1[0].x() - p2[0].x(), scale * p1[0].y() - p2[0].y());
552
553 return new G4ExtrudedSolid(name, p1, abs(v[1].z()), off1, 1, -off2, scale);
554 }
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 484 of file shapes.cc.

485 {
486 if (nshape != 36) return nullptr; // only one crystal has pentagon shape
487
488 map<int, G4ThreeVector> v = make_verticies(wrapthick);
489
490 string name(prefix);
491 name += to_string(nshape);
492 G4TessellatedSolid* s = new G4TessellatedSolid(name.c_str());
493
494 // Now add the facets to the solid
495 // top plane
496 s->AddFacet(new G4QuadrangularFacet(v[1], v[4], v[3], v[2], ABSOLUTE));
497 s->AddFacet(new G4TriangularFacet(v[2], v[3], v[9], ABSOLUTE));
498
499 //bottom plane
500 s->AddFacet(new G4QuadrangularFacet(v[5], v[6], v[7], v[8], ABSOLUTE));
501 s->AddFacet(new G4TriangularFacet(v[6], v[10], v[7], ABSOLUTE));
502
503 //sides
504 s->AddFacet(new G4QuadrangularFacet(v[1], v[2], v[6], v[5], ABSOLUTE));
505 s->AddFacet(new G4QuadrangularFacet(v[2], v[9], v[10], v[6], ABSOLUTE));
506 s->AddFacet(new G4QuadrangularFacet(v[9], v[3], v[7], v[10], ABSOLUTE));
507 s->AddFacet(new G4QuadrangularFacet(v[3], v[4], v[8], v[7], ABSOLUTE));
508 s->AddFacet(new G4QuadrangularFacet(v[4], v[1], v[5], v[8], ABSOLUTE));
509
510 // Finally declare the solid is complete
511 s->SetSolidClosed(true);
512 return s;
513 }

◆ get_trapezoid()

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

get trapezoid

Implements shape_t.

Definition at line 557 of file shapes.cc.

558 {
559 if (nshape != 36) return nullptr; // only one crystal has pentagon shape
560
561 map<int, G4ThreeVector> v = make_verticies(wrapthick);
562
563 string name(prefix);
564 name += to_string(nshape);
565
566 G4ThreeVector pt[8];
567 pt[0] = v[4];
568 pt[1] = v[1];
569 pt[2] = v[3];
570 pt[3] = v[2];
571 pt[4] = v[8];
572 pt[5] = v[5];
573 pt[6] = v[7];
574 pt[7] = v[6];
575
576 auto alignz = [&](int i, int j) {pt[j].setZ(pt[i].z());};
577 auto aligny = [&](int i, int j) {pt[j].setY(pt[i].y());};
578
579 alignz(0, 1);
580 alignz(0, 2);
581 alignz(0, 3);
582
583 alignz(4, 1 + 4);
584 alignz(4, 2 + 4);
585 alignz(4, 3 + 4);
586
587 aligny(0, 1);
588 aligny(2, 3);
589
590 aligny(4, 5);
591 aligny(6, 7);
592
593
594 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();
595 dx /= 8;
596 double dy = pt[0].y() + pt[2].y() + pt[4].y() + pt[6].y();
597 dy /= 4;
598 for (int j = 0; j < 8; j++) {
599 pt[j].setX(pt[j].x() - dx);
600 pt[j].setY(pt[j].y() - dy);
601 }
602 shift = G4Translate3D(dx, dy, 0);
603
604 // cout<<name<<" "<<dx<<" "<<dy<<endl;
605
606 G4VSolid* shape = new G4Trap(name.c_str(), pt);
607 // G4VSolid *shape = new BelleCrystal(name.c_str(), 4, pt);
608 return shape;
609 }

◆ istrap()

bool istrap ( ) const
inlineoverridevirtual

is trapped?

Implements shape_t.

Definition at line 444 of file shapes.cc.

444{ return false;}

◆ make_verticies()

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

create map of vertices

Definition at line 447 of file shapes.cc.

448 {
449 assert(_adjusted);
450
451 double h2 = cosd(a1 - 90) * D / 2;
452 map<int, G4ThreeVector> v;
453 v[5] = G4ThreeVector(-A / 2, -h2, -150);
454 v[6] = v[5] + moveto(D, a1);
455 v[10] = v[6] + moveto(B, a1 + a2 - 180);
456 v[8] = G4ThreeVector(A / 2, -h2, -150);
457 v[7] = v[8] + moveto(D, 180 - a1);
458
459 v[1] = v[5] + G4ThreeVector((H_aA * cosd(a1) + H_dD) / sind(a1), H_aA, 300);
460 v[2] = v[1] + moveto(d, a1);
461 v[9] = v[2] + moveto(b, a1 + a2 - 180);
462 v[4] = v[1] + moveto(a, 0);
463 v[3] = v[4] + moveto(d, 180 - a1);
464
465 for (int j = 1; j <= 10; j++) v[j] = G4ThreeVector(v[j].x(), -v[j].y(), -v[j].z());
466 if (wrapthick != 0) {
467 map<int, G4ThreeVector> nv;
468 nv[ 1] = newvertex(wrapthick, v[1], v[5], v[2], v[4]);
469 nv[ 2] = newvertex(wrapthick, v[2], v[6], v[9], v[1]);
470 nv[ 9] = newvertex(wrapthick, v[9], v[10], v[3], v[2]);
471 nv[ 3] = newvertex(wrapthick, v[3], v[7], v[4], v[9]);
472 nv[ 4] = newvertex(wrapthick, v[4], v[8], v[1], v[3]);
473 nv[ 5] = newvertex(wrapthick, v[5], v[1], v[8], v[6]);
474 nv[ 6] = newvertex(wrapthick, v[6], v[2], v[5], v[10]);
475 nv[10] = newvertex(wrapthick, v[10], v[9], v[6], v[7]);
476 nv[ 7] = newvertex(wrapthick, v[7], v[3], v[10], v[8]);
477 nv[ 8] = newvertex(wrapthick, v[8], v[4], v[7], v[5]);
478 std::swap(nv, v);
479 }
480 return v;
481 }

Member Data Documentation

◆ _adjusted

bool _adjusted

are sizes adjusted?

Definition at line 427 of file shapes.cc.

◆ A

double A

Definition at line 423 of file shapes.cc.

◆ a

double a

Definition at line 423 of file shapes.cc.

◆ a1

double a1

Definition at line 423 of file shapes.cc.

◆ a2

double a2

Definition at line 423 of file shapes.cc.

◆ a3

double a3

Definition at line 423 of file shapes.cc.

◆ a4

double a4

Definition at line 423 of file shapes.cc.

◆ a9

double a9

Definition at line 423 of file shapes.cc.

◆ B

double B

Definition at line 423 of file shapes.cc.

◆ b

double b

Definition at line 423 of file shapes.cc.

◆ C

double C

Definition at line 423 of file shapes.cc.

◆ c

double c

Definition at line 423 of file shapes.cc.

◆ D

double D

Definition at line 423 of file shapes.cc.

◆ d

double d

Definition at line 423 of file shapes.cc.

◆ dg13

double dg13

Definition at line 423 of file shapes.cc.

◆ dg24

double dg24

Definition at line 423 of file shapes.cc.

◆ dg57

double dg57

Definition at line 423 of file shapes.cc.

◆ dg68

double dg68

Definition at line 423 of file shapes.cc.

◆ H_aA

double H_aA

Definition at line 423 of file shapes.cc.

◆ H_dD

double H_dD

Definition at line 423 of file shapes.cc.

◆ nshape

int nshape
inherited

shapes

Definition at line 30 of file shapes.h.

◆ t

double t[21] = {}

Definition at line 425 of file shapes.cc.

425{};

◆ Volume

double Volume

Definition at line 423 of file shapes.cc.

◆ Weight

double Weight

Definition at line 423 of file shapes.cc.


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