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