Belle II Software  release-06-01-15
shapes.h
1 /**************************************************************************
2  * basf2 (Belle II Analysis Software Framework) *
3  * Author: The Belle II Collaboration *
4  * *
5  * See git log for contributors and copyright holders. *
6  * This file is licensed under LGPL-3.0, see LICENSE.md. *
7  **************************************************************************/
8 
9 #pragma once
10 #include <string>
11 #include <vector>
12 #include <G4VSolid.hh>
13 #include <G4Transform3D.hh>
14 #include "ecl/dbobjects/ECLCrystalsShapeAndPosition.h"
15 
16 namespace Belle2 {
21  namespace ECL {
22  double cosd(double);
23  double sind(double);
24  double tand(double);
25 
26 #define UNUSED __attribute__((unused))
27 
28  struct shape_t {
29  int nshape;
30  shape_t(): nshape(0) {}
31  virtual ~shape_t() {}
32 
33  G4VSolid* get_solid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const;
34  virtual G4VSolid* get_tesselatedsolid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
35  virtual G4VSolid* get_trapezoid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
36  virtual G4VSolid* get_extrudedsolid(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
37  virtual G4VSolid* get_bellecrystal(const std::string& prefix, double wrapthick, G4Translate3D& shift) const = 0;
38  virtual bool istrap() const = 0;
39  };
40 
41  struct cplacement_t {
42  int nshape;
43  double Rphi1, Rtheta, Rphi2; // Eulers' angles
44  double Pr, Ptheta, Pphi; // origin position
45  };
46 
47  std::vector<shape_t*> load_shapes(const std::string& fname);
48  std::vector<cplacement_t> load_placements(const std::string& fname);
49 
50  struct Point_t;
51  Point_t centerofgravity(Point_t*, Point_t*);
52  G4Transform3D get_transform(const cplacement_t& t);
53 
54  inline std::string suf(const std::string& s, int indx)
55  {
56  std::string r(s);
57  r += "_" + std::to_string(indx);
58  return r;
59  }
60 
61  enum ECLParts { forward, barrel, backward };
62  Belle2::ECLCrystalsShapeAndPosition loadCrystalsShapeAndPosition();
63 
64  std::vector<shape_t*> load_shapes(const Belle2::ECLCrystalsShapeAndPosition*, enum ECLParts);
65  std::vector<cplacement_t> load_placements(const Belle2::ECLCrystalsShapeAndPosition*, enum ECLParts);
66 
67  }
69 }
Abstract base class for different kinds of events.