Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
VolumeBounds.hpp
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file VolumeBounds.hpp
1 // This file is part of the Acts project.
2 //
3 // Copyright (C) 2016-2018 CERN for the benefit of the Acts project
4 //
5 // This Source Code Form is subject to the terms of the Mozilla Public
6 // License, v. 2.0. If a copy of the MPL was not distributed with this
7 // file, You can obtain one at http://mozilla.org/MPL/2.0/.
8 
9 #pragma once
10 
13 #include "Acts/Geometry/Volume.hpp"
15 
16 #include <cmath>
17 #include <iostream>
18 #include <memory>
19 #include <utility>
20 #include <vector>
21 
22 namespace Acts {
23 
24 class Surface;
25 class VolumeBounds;
26 class Direction;
27 
28 using VolumeBoundsPtr = std::shared_ptr<const VolumeBounds>;
29 
30 using OrientedSurface = std::pair<std::shared_ptr<Surface>, Direction>;
31 using OrientedSurfaces = std::vector<OrientedSurface>;
32 
33 // Planar definitions to help construct the boundary surfaces
34 static const Transform3 s_planeXY = Transform3::Identity();
35 static const Transform3 s_planeYZ = AngleAxis3(0.5 * M_PI, Vector3::UnitY()) *
36  AngleAxis3(0.5 * M_PI, Vector3::UnitZ()) *
37  Transform3::Identity();
38 static const Transform3 s_planeZX = AngleAxis3(-0.5 * M_PI, Vector3::UnitX()) *
39  AngleAxis3(-0.5 * M_PI, Vector3::UnitZ()) *
40  Transform3::Identity();
41 
53 
54 class VolumeBounds {
55  public:
56  // @enum BoundsType
59  enum BoundsType : int {
60  eCone = 0,
61  eCuboid = 1,
63  eCylinder = 3,
66  eOther = 6
67  };
68 
69  VolumeBounds() = default;
70 
71  virtual ~VolumeBounds() = default;
72 
76  virtual BoundsType type() const = 0;
77 
82  virtual std::vector<double> values() const = 0;
83 
90  virtual bool inside(const Vector3& gpos, double tol = 0.) const = 0;
91 
103  const Transform3& transform = Transform3::Identity()) const = 0;
104 
111  const Transform3* trf = nullptr, const Vector3& envelope = {0, 0, 0},
112  const Volume* entity = nullptr) const = 0;
113 
119  virtual Vector3 binningOffset(BinningValue bValue) const;
120 
126  virtual double binningBorder(BinningValue bValue) const;
127 
131  virtual std::ostream& toStream(std::ostream& sl) const = 0;
132 };
133 
136  BinningValue /*bValue*/) const { // standard offset is 0.,0.,0.
137  return Vector3(0., 0., 0.);
138 }
139 
140 inline double VolumeBounds::binningBorder(BinningValue /*bValue*/) const {
141  return 0.;
142 }
143 
145 std::ostream& operator<<(std::ostream& sl, const VolumeBounds& vb);
146 
147 inline bool operator==(const VolumeBounds& lhs, const VolumeBounds& rhs) {
148  if (&lhs == &rhs) {
149  return true;
150  }
151  return (lhs.type() == rhs.type()) && (lhs.values() == rhs.values());
152 }
153 
154 } // namespace Acts