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
Range1D.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file Range1D.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 <algorithm>
12
#include <limits>
13
14
namespace
Acts {
24
template
<
typename
Type>
25
class
Range1D
{
26
public
:
31
Range1D
()
32
:
m_min
(std::numeric_limits<Type>::lowest()),
33
m_max
(std::numeric_limits<Type>::
max
()) {}
34
43
Range1D
(Type
min
, Type
max
) :
m_min
(min),
m_max
(max) {}
44
52
Range1D
(
const
std::pair<Type, Type>&
p
) :
m_min
(p.first),
m_max
(p.second) {}
53
60
Range1D
(
const
Range1D<Type>
& o) :
m_min
(o.
min
()),
m_max
(o.
max
()) {}
61
71
void
setMin
(
const
Type&
v
) {
m_min
=
v
; }
72
82
void
setMax
(
const
Type&
v
) {
m_max
=
v
; }
83
97
void
set
(
const
Type&
min
,
const
Type&
max
) {
98
m_min
=
min
;
99
m_max
=
max
;
100
}
101
109
void
shrinkMin
(
const
Type&
v
) {
m_min
= std::max(
m_min
, v); }
110
118
void
shrinkMax
(
const
Type&
v
) {
m_max
=
std::min
(
m_max
, v); }
119
132
void
shrink
(
const
Type&
min
,
const
Type&
max
) {
133
shrinkMin
(min);
134
shrinkMax
(max);
135
}
136
144
void
expandMin
(
const
Type&
v
) {
m_min
=
std::min
(
m_min
, v); }
145
153
void
expandMax
(
const
Type&
v
) {
m_max
= std::max(
m_max
, v); }
154
167
void
expand
(
const
Type&
min
,
const
Type&
max
) {
168
expandMin
(min);
169
expandMax
(max);
170
}
171
173
Type
min
(
void
)
const
{
return
m_min
; }
174
176
Type
max
(
void
)
const
{
return
m_max
; }
177
190
Type
size
(
void
)
const
{
191
return
std::max(static_cast<Type>(0),
m_max
-
m_min
);
192
}
193
201
bool
degenerate
(
void
)
const
{
return
m_min
>=
m_max
; }
202
212
bool
contains
(
const
Type&
v
)
const
{
return
m_min
<= v && v <
m_max
; }
213
224
bool
operator&&
(
const
Range1D<Type>
& o)
const
{
225
return
m_min
< o.
max
() && o.
min
() <
m_max
;
226
}
227
241
bool
operator==
(
const
Range1D<Type>
& o)
const
{
242
return
min
() == o.
min
() &&
max
() == o.
max
();
243
}
244
256
bool
operator<=(const Range1D<Type>& o)
const
{
257
return
min
() >= o.min() &&
max
() <= o.max();
258
}
259
271
bool
operator>=
(
const
Range1D<Type>
& o)
const
{
272
return
min
() <= o.
min
() &&
max
() >= o.
max
();
273
}
274
284
Range1D<Type>
&
operator=
(
const
Range1D<Type>
& o) {
285
m_min
= o.
min
();
286
m_max
= o.
max
();
287
288
return
*
this
;
289
}
290
300
Range1D<Type>
operator&
(
const
Range1D<Type>
& o)
const
{
301
return
Range1D<Type>
(std::max(
m_min
, o.
min
()),
std::min
(
m_max
, o.
max
()));
302
}
303
313
Range1D<Type>
&
operator&=
(
const
Range1D<Type>
& o) {
314
m_min
= std::max(
m_min
, o.
min
());
315
m_max
=
std::min
(m_max, o.
max
());
316
317
return
*
this
;
318
}
319
320
private
:
321
Type
m_min
,
m_max
;
322
};
323
}
// namespace Acts
acts
blob
sPHENIX
Core
include
Acts
Utilities
Range1D.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:35
using
1.8.2 with
sPHENIX GitHub integration