Belle II Software  release-05-02-19
BelleCrystal.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016-2018 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Alexei Sibidanov *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #ifndef BelleCrystal_HH
12 #define BelleCrystal_HH
13 
14 #include "G4Types.hh"
15 
16 #include "G4CSGSolid.hh"
17 #include "G4Polyhedron.hh"
18 #include <vector>
19 
20 namespace Belle2 {
25  namespace ECL {
26  struct Plane_t {
27  G4ThreeVector n;// Normal unit vector (a,b,c)
28  double d; // offset (d)
29  // => n.x*x + n.y*y + n.z*z + d = 0
30  };
31 
32  struct Point_t {
33  double x, y;
34  };
35 
37  class BelleCrystal : public G4CSGSolid {
38  public:
40  explicit BelleCrystal(const G4String& pName);
42  BelleCrystal(const G4String& pName, int, const G4ThreeVector*);
43 
45  virtual ~BelleCrystal() ;
46 
47  Plane_t GetSidePlane(G4int n) const {return fPlanes[n];}
48 
49  // Methods for solid
50 
51  G4double GetCubicVolume();
52  G4double GetSurfaceArea();
55  void ComputeDimensions(G4VPVParameterisation* p,
56  const G4int n,
57  const G4VPhysicalVolume* pRep);
58 
60  G4bool CalculateExtent(const EAxis pAxis,
61  const G4VoxelLimits& pVoxelLimit,
62  const G4AffineTransform& pTransform,
63  G4double& pMin, G4double& pMax) const;
64 
65  EInside Inside(const G4ThreeVector& p) const;
66 
67  G4ThreeVector SurfaceNormal(const G4ThreeVector& p) const;
68 
69  G4double DistanceToIn(const G4ThreeVector& p, const G4ThreeVector& v) const;
70 
71  G4double DistanceToIn(const G4ThreeVector& p) const;
72 
73  G4double DistanceToOut(const G4ThreeVector& p, const G4ThreeVector& v,
74  const G4bool calcNorm = false,
75  G4bool* validNorm = 0, G4ThreeVector* n = 0) const;
76 
77  G4double DistanceToOut(const G4ThreeVector& p) const;
78 
79  G4GeometryType GetEntityType() const;
80 
81  G4ThreeVector GetPointOnSurface() const;
82 
83  G4VSolid* Clone() const;
84 
85  std::ostream& StreamInfo(std::ostream& os) const;
86 
87  // Visualisation functions
88 
89  void DescribeYourselfTo(G4VGraphicsScene& scene) const;
90  G4Polyhedron* CreatePolyhedron() const;
91 
93  void BoundingLimits(G4ThreeVector& pMin, G4ThreeVector& pMax) const;
94 
95  public: // without description
96 
102  explicit BelleCrystal(__void__&);
103 
105  BelleCrystal(const BelleCrystal& rhs);
107  BelleCrystal& operator=(const BelleCrystal& rhs);
108 
109  G4ThreeVector vertex(unsigned int i) const;
110 
111  protected: // with description
112 
113  G4bool MakePlane(const G4ThreeVector& p1,
114  const G4ThreeVector& p2,
115  const G4ThreeVector& p3,
116  const G4ThreeVector& p4,
117  Plane_t& plane) const;
118 
119  private:
120  G4ThreeVector GetPointOnTriangle(int) const;
121  double area(int, double&) const;
122  double getvolarea() const;
123  const unsigned int* ivertx(unsigned int i) const;
124  private:
125  unsigned int nsides;
126  double fDz;
127  std::vector<Plane_t> fPlanes;
128  std::vector<Point_t> fx;
129 
130  mutable std::vector<double> fareas;
131  };
132 
134  class PolyhedronBelleCrystal: public G4Polyhedron {
135  public:
136  PolyhedronBelleCrystal(int, const G4ThreeVector*);
137  virtual ~PolyhedronBelleCrystal();
138  };
139 
140  }
142 }
143 #endif
Belle2::ECL::BelleCrystal::GetPointOnTriangle
G4ThreeVector GetPointOnTriangle(int) const
Returns a random point on the surface of one of the faces.
Definition: BelleCrystal.cc:626
Belle2::ECL::BelleCrystal::BoundingLimits
void BoundingLimits(G4ThreeVector &pMin, G4ThreeVector &pMax) const
Two vectors define an axis-parallel bounding box for the shape.
Definition: BelleCrystal.cc:725
Belle2::ECL::BelleCrystal::ivertx
const unsigned int * ivertx(unsigned int i) const
get the ith vertex
Definition: BelleCrystal.cc:564
Belle2::ECL::BelleCrystal::BelleCrystal
BelleCrystal(const G4String &pName)
Constructor for "nominal" BelleCrystal.
Definition: BelleCrystal.cc:137
Belle2::ECL::BelleCrystal::CalculateExtent
G4bool CalculateExtent(const EAxis pAxis, const G4VoxelLimits &pVoxelLimit, const G4AffineTransform &pTransform, G4double &pMin, G4double &pMax) const
calculate the extent of the volume
Definition: BelleCrystal.cc:246
Belle2::ECL::PolyhedronBelleCrystal::PolyhedronBelleCrystal
PolyhedronBelleCrystal(int, const G4ThreeVector *)
constructor
Definition: BelleCrystal.cc:700
Belle2::ECL::BelleCrystal::GetSurfaceArea
G4double GetSurfaceArea()
get the surface area
Definition: BelleCrystal.cc:676
Belle2::ECL::BelleCrystal::~BelleCrystal
virtual ~BelleCrystal()
Destructor.
Definition: BelleCrystal.cc:150
Belle2::ECL::BelleCrystal::ComputeDimensions
void ComputeDimensions(G4VPVParameterisation *p, const G4int n, const G4VPhysicalVolume *pRep)
compute the dimensions
Definition: BelleCrystal.cc:222
Belle2::ECL::BelleCrystal::nsides
unsigned int nsides
the number of sides
Definition: BelleCrystal.h:133
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECL::BelleCrystal
a Belle crystal in Geant4
Definition: BelleCrystal.h:45
Plane_t
Definition: BelleLathe.cc:33
Belle2::ECL::Plane_t
Definition: BelleCrystal.h:34
Belle2::ECL::PolyhedronBelleCrystal
Belle crystal in polyhedron.
Definition: BelleCrystal.h:142
Belle2::ECL::BelleCrystal::GetCubicVolume
G4double GetCubicVolume()
get the Cubic volume
Definition: BelleCrystal.cc:666
Belle2::ECL::BelleCrystal::area
double area(int, double &) const
triangle area
Definition: BelleCrystal.cc:640
Belle2::ECL::PolyhedronBelleCrystal::~PolyhedronBelleCrystal
virtual ~PolyhedronBelleCrystal()
destructor
Definition: BelleCrystal.cc:714
Belle2::ECL::BelleCrystal::operator=
BelleCrystal & operator=(const BelleCrystal &rhs)
assignment operator
Definition: BelleCrystal.cc:167