ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigT1
TrigT1NSWSimTools
src
MMT_Road.cxx
Go to the documentation of this file.
1
/*
2
* Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
MMT_Road.h
"
6
#include <stdexcept>
7
8
MMT_Road::MMT_Road
(
const
char
sector,
const
int
roadSize,
9
const
int
UpX,
const
int
DownX,
const
int
UpUV,
const
int
DownUV,
10
const
int
xthr,
const
int
uvthr,
11
const
int
iroadx,
const
int
iroadu,
const
int
iroadv) :
12
m_iroadx
(iroadx),
13
m_iroadu
(iroadu != -1 ? iroadu : iroadx),
14
m_iroadv
(iroadv != -1 ? iroadv : iroadx),
15
m_xthr
(xthr),
16
m_uvthr
(uvthr),
17
m_sector
(sector)
18
{
19
// Pre-calculate slopes
20
m_slopeXlow
= roadSize*
m_iroadx
+ 0.5 - DownX;
21
m_slopeXhigh
= roadSize*(
m_iroadx
+1) + 0.5 + UpX;
22
23
m_slopeUlow
= roadSize*
m_iroadu
+ 0.5 - DownUV;
24
m_slopeUhigh
= roadSize*(
m_iroadu
+1) + 0.5 + UpUV;
25
26
m_slopeVlow
= roadSize*
m_iroadv
+ 0.5 - DownUV;
27
m_slopeVhigh
= roadSize*(
m_iroadv
+1) + 0.5 + UpUV;
28
}
29
30
void
MMT_Road::addHits
(
const
std::vector<std::shared_ptr<MMT_Hit> > &hits) {
31
for
(
const
auto
&hit_i : hits) {
32
double
slow, shigh;
33
if
(hit_i->isX()) {
34
slow = hit_i->getShift() +
m_slopeXlow
* hit_i->getPitchOverZ();
35
shigh = hit_i->getShift() +
m_slopeXhigh
* hit_i->getPitchOverZ();
36
}
37
else
if
(hit_i->isU()) {
38
slow = hit_i->getShift() +
m_slopeUlow
* hit_i->getPitchOverZ();
39
shigh = hit_i->getShift() +
m_slopeUhigh
* hit_i->getPitchOverZ();
40
}
41
else
{
42
slow = hit_i->getShift() +
m_slopeVlow
* hit_i->getPitchOverZ();
43
shigh = hit_i->getShift() +
m_slopeVhigh
* hit_i->getPitchOverZ();
44
}
45
46
const
double
val = hit_i->getRZSlope();
47
bool
has_hit = (val > 0.) ? (val > slow && val < shigh) : (val > shigh && val < slow);
48
if
(!has_hit)
continue
;
49
50
const
int
pl = hit_i->getPlane();
51
if
(std::ranges::any_of(
m_road_hits
, [&pl](
const
auto
&
hit
) {
return
(
hit
.getPlane() == pl); }))
continue
;
52
53
m_road_hits
.emplace_back(*hit_i.get());
54
m_road_hits
.back().setAge(0);
55
}
56
}
57
58
double
MMT_Road::avgSofXUV
(
const
char
type
)
const
{
59
double
sum = 0;
60
unsigned
short
int
N = 0;
61
for
(
const
auto
&
hit
:
m_road_hits
) {
62
if
(
hit
.isX() &&
type
==
'X'
) {
63
sum +=
hit
.getRZSlope();
64
++N;
65
}
66
else
if
(
hit
.isU() &&
type
==
'U'
) {
67
sum +=
hit
.getRZSlope();
68
++N;
69
}
70
else
if
(
hit
.isV() &&
type
==
'V'
) {
71
sum +=
hit
.getRZSlope();
72
++N;
73
}
74
else
continue
;
75
}
76
if
(N == 0)[[
unlikely
]]{
77
throw
std::runtime_error(
"MMT_Road::avgSofXUV: N is zero."
);
78
}
79
return
sum/N;
80
}
81
82
unsigned
int
MMT_Road::countUHits
()
const
{
83
return
std::count_if(
m_road_hits
.begin(),
m_road_hits
.end(),
84
[](
const
auto
&
hit
) { return hit.isU(); });
85
}
86
87
unsigned
int
MMT_Road::countXHits
()
const
{
88
return
std::count_if(
m_road_hits
.begin(),
m_road_hits
.end(),
89
[](
const
auto
&
hit
) { return hit.isX(); });
90
}
91
92
bool
MMT_Road::evaluateLowRes
()
const
{
93
unsigned
short
int
nhits1 = 0, nhits2 = 0;
94
for
(
const
auto
&
hit
:
m_road_hits
) {
95
nhits1 +=
hit
.getPlane() < 4;
96
nhits2 +=
hit
.getPlane() > 3;
97
}
98
return
(nhits1 < 4 || nhits2 < 4);
99
}
100
101
bool
MMT_Road::horizontalCheck
()
const
{
102
unsigned
short
int
nx1 = 0, nx2 = 0;
103
for
(
const
auto
&
hit
:
m_road_hits
) {
104
nx1 +=
hit
.getPlane() < 2;
105
nx2 +=
hit
.getPlane() > 5;
106
107
if
(nx1 > 0 && nx2 > 0 && (nx1+nx2) >=
m_xthr
)
return
true
;
108
}
109
return
false
;
110
}
111
112
void
MMT_Road::incrementAge
(
const
int
bcwind) {
113
unsigned
short
int
old_ihits = 0;
114
for
(
auto
&
hit
:
m_road_hits
) {
115
hit
.setAge(
hit
.getAge()+1);
116
if
(
hit
.getAge() > (bcwind-1)) ++old_ihits;
117
}
118
m_road_hits
.erase(
m_road_hits
.begin(),
m_road_hits
.begin()+old_ihits);
119
}
120
121
bool
MMT_Road::matureCheck
(
const
int
bcwind)
const
{
122
for
(
const
auto
&
hit
:
m_road_hits
) {
123
if
(
hit
.getAge() == (bcwind - 1))
return
true
;
124
}
125
return
false
;
126
}
127
128
double
MMT_Road::mxl
()
const
{
129
std::vector<double> ys, zs;
130
for
(
const
auto
&
hit
:
m_road_hits
) {
131
if
(
hit
.isX()) {
132
ys.push_back(
hit
.getR());
133
zs.push_back(
hit
.getZ());
134
}
135
}
136
double
mxl
= 0;
137
double
avg_z = std::accumulate(zs.begin(), zs.end(), 0.0)/(double)zs.size();
138
double
sum_sq_z = std::inner_product(zs.begin(), zs.end(), zs.begin(), 0.0);
139
for
(
unsigned
int
i = 0; i < ys.size(); i++)
mxl
+= ys[i]*( (zs[i]-avg_z) / (sum_sq_z - zs.size()*std::pow(avg_z,2)) );
140
141
return
mxl
;
142
}
143
144
bool
MMT_Road::stereoCheck
()
const
{
145
unsigned
short
int
nu = 0, nv = 0;
146
for
(
const
auto
&
hit
:
m_road_hits
) {
147
nu +=
hit
.isU();
148
nv +=
hit
.isV();
149
150
if
(nu > 0 && nv > 0 && (nu+nv) >=
m_uvthr
)
return
true
;
151
}
152
return
false
;
153
}
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
MMT_Road.h
MMT_Road::avgSofXUV
double avgSofXUV(const char type) const
Definition
MMT_Road.cxx:58
MMT_Road::m_slopeUlow
double m_slopeUlow
Definition
MMT_Road.h:42
MMT_Road::mxl
double mxl() const
Definition
MMT_Road.cxx:128
MMT_Road::m_slopeXhigh
double m_slopeXhigh
Definition
MMT_Road.h:42
MMT_Road::m_xthr
int m_xthr
Definition
MMT_Road.h:44
MMT_Road::incrementAge
void incrementAge(const int bcwind)
Definition
MMT_Road.cxx:112
MMT_Road::m_slopeXlow
double m_slopeXlow
Definition
MMT_Road.h:42
MMT_Road::m_road_hits
std::vector< MMT_Hit > m_road_hits
Definition
MMT_Road.h:41
MMT_Road::stereoCheck
bool stereoCheck() const
Definition
MMT_Road.cxx:144
MMT_Road::m_iroadu
int m_iroadu
Definition
MMT_Road.h:43
MMT_Road::m_iroadv
int m_iroadv
Definition
MMT_Road.h:43
MMT_Road::m_slopeVlow
double m_slopeVlow
Definition
MMT_Road.h:42
MMT_Road::m_slopeUhigh
double m_slopeUhigh
Definition
MMT_Road.h:42
MMT_Road::addHits
void addHits(const std::vector< std::shared_ptr< MMT_Hit > > &hits)
Definition
MMT_Road.cxx:30
MMT_Road::m_slopeVhigh
double m_slopeVhigh
Definition
MMT_Road.h:42
MMT_Road::m_sector
char m_sector
Definition
MMT_Road.h:45
MMT_Road::evaluateLowRes
bool evaluateLowRes() const
Definition
MMT_Road.cxx:92
MMT_Road::m_uvthr
int m_uvthr
Definition
MMT_Road.h:44
MMT_Road::matureCheck
bool matureCheck(const int bcwind) const
Definition
MMT_Road.cxx:121
MMT_Road::horizontalCheck
bool horizontalCheck() const
Definition
MMT_Road.cxx:101
MMT_Road::m_iroadx
int m_iroadx
Definition
MMT_Road.h:43
MMT_Road::countXHits
unsigned int countXHits() const
Definition
MMT_Road.cxx:87
MMT_Road::countUHits
unsigned int countUHits() const
Definition
MMT_Road.cxx:82
MMT_Road::MMT_Road
MMT_Road(const char sector, const int roadSize, const int UpX, const int DownX, const int UpUV, const int DownUV, const int xthr, const int uvthr, const int iroadx, const int iroadu=-1, const int iroadv=-1)
Definition
MMT_Road.cxx:8
unlikely
#define unlikely(x)
Definition
pythonic_coracool.cxx:9
type
Generated on
for ATLAS Offline Software by
1.17.0