EIC Software
Reference for
EIC
simulation and reconstruction software on GitHub
Home page
Related Pages
Modules
Namespaces
Classes
Files
External Links
File List
File Members
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Friends
Macros
Groups
Pages
RectangleBounds.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file RectangleBounds.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2016-2020 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
11
#include "
Acts/Surfaces/PlanarBounds.hpp
"
12
#include "
Acts/Utilities/Definitions.hpp
"
13
14
#include <array>
15
#include <cassert>
16
#include <vector>
17
18
namespace
Acts {
19
25
class
RectangleBounds
:
public
PlanarBounds
{
26
public
:
27
enum
BoundValues
:
int
{
28
eMinX
= 0,
29
eMinY
= 1,
30
eMaxX
= 2,
31
eMaxY
= 3,
32
eSize
= 4
33
};
34
35
RectangleBounds
() =
delete
;
36
41
RectangleBounds
(
double
halfX
,
double
halfY
) noexcept(
false
)
42
:
m_min
({-
halfX
, -
halfY
}),
m_max
({
halfX
,
halfY
}) {
43
checkConsistency
();
44
}
45
49
RectangleBounds
(
const
std::array<double, eSize>&
values
) noexcept(
false
)
50
:
m_min
({
values
[
eMinX
],
values
[
eMinY
]}),
51
m_max
({
values
[
eMaxX
],
values
[
eMaxY
]}) {
52
checkConsistency
();
53
}
54
59
RectangleBounds
(
const
Vector2D
&
min
,
const
Vector2D
&
max
) noexcept(
false
)
60
:
m_min
(
min
),
m_max
(
max
) {
61
checkConsistency
();
62
}
63
64
~RectangleBounds
()
override
=
default
;
65
66
BoundsType
type
() const final;
67
68
std::
vector
<
double
>
values
() const final;
69
77
bool
inside
(const
Vector2D
& lposition,
78
const
BoundaryCheck
& bcheck) const final;
79
88
std::
vector
<
Vector2D
>
vertices
(
unsigned
int
lseg = 1) const final;
89
90
// Bounding box representation
91
const
RectangleBounds
&
boundingBox
() const final;
92
96
std::ostream&
toStream
(std::ostream& sl) const final;
97
100
double
get
(
BoundValues
bValue) const;
101
103
double
halfLengthX
() const;
104
106
double
halfLengthY
() const;
107
110
const
Vector2D
&
min
() const;
111
114
const
Vector2D
&
max
() const;
115
116
private:
117
Vector2D
m_min
;
118
Vector2D
m_max
;
119
122
void
checkConsistency
() noexcept(
false
);
123
};
124
125
inline
SurfaceBounds
::
BoundsType
RectangleBounds
::
type
()
const
{
126
return
SurfaceBounds::eRectangle
;
127
}
128
129
inline
const
Vector2D
&
RectangleBounds::min
()
const
{
130
return
m_min
;
131
}
132
133
inline
const
Vector2D
&
RectangleBounds::max
()
const
{
134
return
m_max
;
135
}
136
137
inline
double
RectangleBounds::halfLengthX
()
const
{
138
return
0.5 * (
m_max
.x() -
m_min
.x());
139
}
140
141
inline
double
RectangleBounds::halfLengthY
()
const
{
142
return
0.5 * (
m_max
.y() -
m_min
.y());
143
}
144
145
inline
std::vector<double>
RectangleBounds::values
()
const
{
146
return
{
m_min
.x(),
m_min
.y(),
m_max
.x(),
m_max
.y()};
147
}
148
149
inline
double
RectangleBounds::get
(
BoundValues
bValue)
const
{
150
switch
(bValue) {
151
case
eMinX
:
152
return
m_min
.x();
153
case
eMinY
:
154
return
m_min
.y();
155
case
eMaxX
:
156
return
m_max
.x();
157
case
eMaxY
:
158
return
m_max
.y();
159
default
:
160
assert(
false
and
"Invalid BoundValue enum value"
);
161
return
std::numeric_limits<double>::quiet_NaN();
162
}
163
}
164
165
inline
void
RectangleBounds::checkConsistency
() noexcept(
false
) {
166
if
(
get
(
eMinX
) >
get
(
eMaxX
)) {
167
throw
std::invalid_argument(
"RectangleBounds: invalid local x setup"
);
168
}
169
if
(
get
(
eMinY
) >
get
(
eMaxY
)) {
170
throw
std::invalid_argument(
"RectangleBounds: invalid local y setup"
);
171
}
172
}
173
174
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Surfaces
RectangleBounds.hpp
Built by
Jin Huang
. updated:
Mon Jan 22 2024 12:43:23
using
1.8.2 with
EIC GitHub integration