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
HoughVectors.hpp
Go to the documentation of this file.
Or view
the newest version in sPHENIX GitHub for file HoughVectors.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/Logger.hpp
"
12
13
#include <sstream>
14
#include <stdexcept>
15
#include <vector>
16
17
template
<
typename
T>
18
class
vector2D
{
19
private
:
20
size_t
m_d1
,
m_d2
;
21
std::vector<T>
m_data
;
22
24
const
Acts::Logger
&
logger
()
const
{
return
*
m_logger
; }
25
27
std::unique_ptr<const Acts::Logger>
m_logger
;
28
29
public
:
30
vector2D
() :
m_d1
(0),
m_d2
(0) {
31
m_logger
=
Acts::getDefaultLogger
(
"HoughVectors"
,
Acts::Logging::ERROR
);
32
}
33
34
vector2D
(
size_t
d1,
size_t
d2,
T
const
&
t
=
T
())
35
:
m_d1
(d1),
m_d2
(d2),
m_data
(d1 * d2,
t
) {
36
m_logger
=
Acts::getDefaultLogger
(
"HoughVectors"
,
Acts::Logging::ERROR
);
37
}
38
39
size_t
size
(
int
dim
)
const
{
40
if
(dim == 0) {
41
return
m_d1
;
42
}
43
if
(dim == 1) {
44
return
m_d2
;
45
}
else
{
46
ACTS_ERROR
(
"vector2D: Argument to size() must be 0 or 1"
);
47
return
0;
48
}
49
}
50
51
void
resize
(
size_t
x1,
size_t
x2,
T
const
&
t
=
T
()) {
52
m_d1
= x1;
53
m_d2
= x2;
54
m_data
.resize(x1 * x2,
t
);
55
}
56
57
T
&
operator()
(
size_t
i
,
size_t
j
) {
58
if
(i >=
m_d1
|| j >=
m_d2
) {
59
std::stringstream
s
;
60
s <<
"vector2D out of bounds: request ("
<< i <<
","
<< j <<
") size ("
61
<<
m_d1
<<
","
<<
m_d2
<<
")"
;
62
ACTS_ERROR
(s.str());
63
}
64
return
m_data
[i *
m_d2
+
j
];
65
}
66
67
T
const
&
operator()
(
size_t
i
,
size_t
j
)
const
{
68
if
(i >=
m_d1
|| j >=
m_d2
) {
69
std::stringstream
s
;
70
s <<
"vector2D out of bounds: request ("
<< i <<
","
<< j <<
") size ("
71
<<
m_d1
<<
","
<<
m_d2
<<
")"
;
72
ACTS_ERROR
(s.str());
73
}
74
return
m_data
[i *
m_d2
+
j
];
75
}
76
77
T
*
operator[]
(
size_t
i
) {
78
if
(i >=
m_d1
) {
79
std::stringstream
s
;
80
s <<
"vector2D out of bounds: request "
<< i <<
" size ("
<<
m_d1
<<
","
81
<<
m_d2
<<
")"
;
82
ACTS_ERROR
(s.str());
83
}
84
return
m_data
.data() + (i *
m_d2
);
85
}
86
87
const
T
*
operator[]
(
size_t
i
)
const
{
88
if
(i >=
m_d1
) {
89
std::stringstream
s
;
90
s <<
"vector2D out of bounds: request "
<< i <<
" size ("
<<
m_d1
<<
","
91
<<
m_d2
<<
")"
;
92
ACTS_ERROR
(s.str());
93
}
94
return
m_data
.data() + (i *
m_d2
);
95
}
96
97
T
*
data
() {
return
m_data
.data(); }
98
99
const
T
*
data
()
const
{
return
m_data
.data(); }
100
};
101
102
template
<
typename
T>
103
class
vector3D
{
104
private
:
105
size_t
m_d1
,
m_d2
,
m_d3
;
106
std::vector<T>
m_data
;
108
const
Acts::Logger
&
logger
()
const
{
return
*
m_logger
; }
109
111
std::unique_ptr<const Acts::Logger>
m_logger
;
112
113
public
:
114
vector3D
() :
m_d1
(0),
m_d2
(0),
m_d3
(0) {
115
m_logger
=
Acts::getDefaultLogger
(
"HoughVectors"
,
Acts::Logging::ERROR
);
116
}
117
118
vector3D
(
size_t
d1,
size_t
d2,
size_t
d3,
T
const
&
t
=
T
())
119
:
m_d1
(d1),
m_d2
(d2),
m_d3
(d3),
m_data
(d1 * d2 * d3,
t
) {
120
m_logger
=
Acts::getDefaultLogger
(
"HoughVectors"
,
Acts::Logging::ERROR
);
121
}
122
123
T
&
operator()
(
size_t
i
,
size_t
j
,
size_t
k
) {
124
if
(i >=
m_d1
|| j >=
m_d2
|| k >=
m_d3
) {
125
std::stringstream
s
;
126
s <<
"vector3D out of bounds: request ("
<< i <<
","
<< j <<
","
<< k
127
<<
") size ("
<<
m_d1
<<
","
<<
m_d2
<<
","
<<
m_d3
<<
")"
;
128
ACTS_ERROR
(s.str());
129
}
130
return
m_data
[i *
m_d2
*
m_d3
+ j *
m_d3
+
k
];
131
}
132
133
T
const
&
operator()
(
size_t
i
,
size_t
j
,
size_t
k
)
const
{
134
if
(i >=
m_d1
|| j >=
m_d2
|| k >=
m_d3
) {
135
std::stringstream
s
;
136
s <<
"vector3D out of bounds: request ("
<< i <<
","
<< j <<
","
<< k
137
<<
") size ("
<<
m_d1
<<
","
<<
m_d2
<<
","
<<
m_d3
<<
")"
;
138
ACTS_ERROR
(s.str());
139
}
140
return
m_data
[i *
m_d2
*
m_d3
+ j *
m_d3
+
k
];
141
}
142
143
void
resize
(
size_t
x1,
size_t
x2,
size_t
x3,
T
const
&
t
=
T
()) {
144
m_d1
= x1;
145
m_d2
= x2;
146
m_d3
= x3;
147
m_data
.resize(x1 * x2 * x3,
t
);
148
}
149
150
T
*
data
() {
return
m_data
.data(); }
151
};
acts
blob
sPHENIX
Examples
Algorithms
TrackFinding
include
ActsExamples
TrackFinding
HoughVectors.hpp
Built by
Jin Huang
. updated:
Sat Feb 17 2024 22:17:37
using
1.8.2 with
sPHENIX GitHub integration