Belle II Software  release-05-02-19
shapes.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 __h_shapes
12 #define __h_shapes
13 #include <string>
14 #include <vector>
15 #include <G4VSolid.hh>
16 #include <G4Transform3D.hh>
17 #include "ecl/dbobjects/ECLCrystalsShapeAndPosition.h"
18 
19 namespace Belle2 {
24  namespace ECL {
25  double cosd(double);
26  double sind(double);
27  double tand(double);
28 
29 #define UNUSED __attribute__((unused))
30 
31  struct shape_t {
32  int nshape;
33  shape_t(): nshape(0) {}
34  virtual ~shape_t() {}
35 
36  G4VSolid* get_solid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const;
37  virtual G4VSolid* get_tesselatedsolid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
38  virtual G4VSolid* get_trapezoid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
39  virtual G4VSolid* get_extrudedsolid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
40  virtual G4VSolid* get_bellecrystal(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
41  virtual bool istrap() const = 0;
42  };
43 
44  struct cplacement_t {
45  int nshape;
46  double Rphi1, Rtheta, Rphi2; // Eulers' angles
47  double Pr, Ptheta, Pphi; // origin position
48  };
49 
50  std::vector<shape_t*> load_shapes(const std::string& fname);
51  std::vector<cplacement_t> load_placements(const std::string& fname);
52 
53  struct Point_t;
54  Point_t centerofgravity(Point_t*, Point_t*);
55  G4Transform3D get_transform(const cplacement_t& t);
56 
57  inline std::string suf(const std::string& s, int indx)
58  {
59  std::string r(s);
60  r += "_" + std::to_string(indx);
61  return r;
62  }
63 
64  enum ECLParts { forward, barrel, backward };
65  Belle2::ECLCrystalsShapeAndPosition loadCrystalsShapeAndPosition();
66 
67  std::vector<shape_t*> load_shapes(const Belle2::ECLCrystalsShapeAndPosition*, enum ECLParts);
68  std::vector<cplacement_t> load_placements(const Belle2::ECLCrystalsShapeAndPosition*, enum ECLParts);
69 
70  }
72 }
73 #endif //__h_shapes
Belle2::ECL::Point_t
Definition: BelleCrystal.h:40
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::ECLCrystalsShapeAndPosition
Crystal shapes and positions.
Definition: ECLCrystalsShapeAndPosition.h:37
Belle2::ECL::cplacement_t
Definition: shapes.h:52