Analysis Software
Documentation for
sPHENIX
simulation software
Home page
Related Pages
Modules
Namespaces
Classes
Files
Examples
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/Definitions/Algebra.hpp
"
12
#include "
Acts/Surfaces/BoundaryCheck.hpp
"
13
#include "
Acts/Surfaces/PlanarBounds.hpp
"
14
#include "
Acts/Surfaces/SurfaceBounds.hpp
"
15
16
#include <array>
17
#include <cassert>
18
#include <iosfwd>
19
#include <limits>
20
#include <stdexcept>
21
#include <vector>
22
23
namespace
Acts {
24
30
class
RectangleBounds
:
public
PlanarBounds
{
31
public
:
32
enum
BoundValues
:
int
{
33
eMinX
= 0,
34
eMinY
= 1,
35
eMaxX
= 2,
36
eMaxY
= 3,
37
eSize
= 4
38
};
39
40
RectangleBounds
() =
delete
;
41
46
RectangleBounds
(
double
halfX
,
double
halfY
) noexcept(
false
)
47
:
m_min
({-
halfX
, -
halfY
}),
m_max
({
halfX
,
halfY
}) {
48
checkConsistency
();
49
}
50
54
RectangleBounds
(
const
std::array<double, eSize>&
values
) noexcept(
false
)
55
:
m_min
({
values
[
eMinX
],
values
[
eMinY
]}),
56
m_max
({
values
[
eMaxX
],
values
[
eMaxY
]}) {
57
checkConsistency
();
58
}
59
64
RectangleBounds
(
const
Vector2
&
min
,
const
Vector2
&
max
) noexcept(
false
)
65
:
m_min
(
min
),
m_max
(
max
) {
66
checkConsistency
();
67
}
68
69
~RectangleBounds
()
override
=
default
;
70
71
BoundsType
type
() const final;
72
73
std::vector<
double
>
values
() const final;
74
82
bool
inside
(const
Vector2
& lposition,
83
const
BoundaryCheck
& bcheck) const final;
84
93
std::vector<
Vector2
>
vertices
(
unsigned
int
lseg = 1) const final;
94
95
// Bounding box representation
96
const
RectangleBounds
&
boundingBox
() const final;
97
101
std::ostream&
toStream
(std::ostream& sl) const final;
102
105
double
get
(
BoundValues
bValue) const;
106
108
double
halfLengthX
() const;
109
111
double
halfLengthY
() const;
112
115
const
Vector2
&
min
() const;
116
119
const
Vector2
&
max
() const;
120
121
private
:
122
Vector2
m_min
;
123
Vector2
m_max
;
124
127
void
checkConsistency
() noexcept(
false
);
128
};
129
130
inline
SurfaceBounds
::
BoundsType
RectangleBounds
::
type
()
const
{
131
return
SurfaceBounds::eRectangle
;
132
}
133
134
inline
const
Vector2
&
RectangleBounds::min
()
const
{
135
return
m_min
;
136
}
137
138
inline
const
Vector2
&
RectangleBounds::max
()
const
{
139
return
m_max
;
140
}
141
142
inline
double
RectangleBounds::halfLengthX
()
const
{
143
return
0.5 * (
m_max
.x() -
m_min
.x());
144
}
145
146
inline
double
RectangleBounds::halfLengthY
()
const
{
147
return
0.5 * (
m_max
.y() -
m_min
.y());
148
}
149
150
inline
std::vector<double>
RectangleBounds::values
()
const
{
151
return
{
m_min
.x(),
m_min
.y(),
m_max
.x(),
m_max
.y()};
152
}
153
154
inline
double
RectangleBounds::get
(
BoundValues
bValue)
const
{
155
switch
(bValue) {
156
case
eMinX
:
157
return
m_min
.x();
158
case
eMinY
:
159
return
m_min
.y();
160
case
eMaxX
:
161
return
m_max
.x();
162
case
eMaxY
:
163
return
m_max
.y();
164
default
:
165
assert
(
false
and
"Invalid BoundValue enum value"
);
166
return
std::numeric_limits<double>::quiet_NaN();
167
}
168
}
169
170
inline
void
RectangleBounds::checkConsistency
() noexcept(
false
) {
171
if
(
get
(
eMinX
) >
get
(
eMaxX
)) {
172
throw
std::invalid_argument(
"RectangleBounds: invalid local x setup"
);
173
}
174
if
(
get
(
eMinY
) >
get
(
eMaxY
)) {
175
throw
std::invalid_argument(
"RectangleBounds: invalid local y setup"
);
176
}
177
}
178
179
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Surfaces
RectangleBounds.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:34
using
1.8.2 with
sPHENIX GitHub integration