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
RangeXD.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file RangeXD.hpp
1
// This file is part of the Acts project.
2
//
3
// Copyright (C) 2021 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/Utilities/Range1D.hpp
"
12
13
#include <algorithm>
14
#include <array>
15
#include <limits>
16
#include <sstream>
17
#include <string>
18
19
namespace
Acts {
29
template
<std::size_t Dims,
typename
Type,
30
template
<
typename
, std::
size_t
>
typename
Vector
=
std::array
>
31
class
RangeXD
{
32
public
:
34
using
coordinate_t
= Vector<Type, Dims>;
35
43
bool
degenerate
(
void
)
const
{
44
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
45
if
(
m_dims
[
i
].
degenerate
()) {
46
return
true
;
47
}
48
}
49
return
false
;
50
}
51
61
bool
contains
(
const
coordinate_t
&
v
)
const
{
62
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
63
if
(!
m_dims
[
i
].
contains
(v[
i
])) {
64
return
false
;
65
}
66
}
67
68
return
true
;
69
}
70
75
Range1D<Type>
&
operator[]
(
const
std::size_t&
i
) {
return
m_dims
[
i
]; }
76
81
const
Range1D<Type>
&
operator[]
(
const
std::size_t&
i
)
const
{
82
return
m_dims
[
i
];
83
}
84
94
bool
operator==
(
const
RangeXD<Dims, Type, Vector>
& o)
const
{
95
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
96
if
(!(this->
m_dims
[
i
] == o[
i
])) {
97
return
false
;
98
}
99
}
100
101
return
true
;
102
}
103
116
bool
operator<=(const RangeXD<Dims, Type, Vector>& o)
const
{
117
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
118
if
(!(this->
m_dims
[
i
] <= o[
i
])) {
119
return
false
;
120
}
121
}
122
123
return
true
;
124
}
125
139
bool
operator>=
(
const
RangeXD<Dims, Type, Vector>
& o)
const
{
140
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
141
if
(!(this->
m_dims
[
i
] >= o[
i
])) {
142
return
false
;
143
}
144
}
145
146
return
true
;
147
}
148
159
RangeXD<Dims, Type, Vector>
operator&
(
160
const
RangeXD<Dims, Type, Vector>
& o)
const
{
161
RangeXD<Dims, Type>
res;
162
163
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
164
res[
i
] =
m_dims
[
i
] & o[
i
];
165
}
166
167
return
res;
168
}
169
179
RangeXD<Dims, Type, Vector>
&
operator&=
(
180
const
RangeXD<Dims, Type, Vector>
& o) {
181
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
182
m_dims
[
i
] &= o[
i
];
183
}
184
185
return
*
this
;
186
}
187
197
bool
operator&&
(
const
RangeXD<Dims, Type, Vector>
&
r
)
const
{
198
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
199
if
(!(
m_dims
[
i
] && r[
i
])) {
200
return
false
;
201
}
202
}
203
204
return
true
;
205
}
206
213
std::string
toString
(
void
)
const
{
214
std::stringstream
s
;
215
216
for
(std::size_t
i
= 0;
i
< Dims; ++
i
) {
217
s <<
m_dims
[
i
].min() <<
" <= v["
<<
i
<<
"] <= "
<<
m_dims
[
i
].max();
218
if
(
i
!= Dims - 1) {
219
s <<
", "
;
220
}
221
}
222
223
return
s.str();
224
}
225
226
private
:
227
std::array<Range1D<Type>, Dims>
m_dims
;
228
};
229
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Utilities
RangeXD.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:35
using
1.8.2 with
sPHENIX GitHub integration