66 {
67
68
69 std::ranges::sort(hits, [](
const auto &h1,
const auto &h2){
return h1->getBC() < h2->getBC(); });
70 const int bc_start =
hits.front()->getBC();
71 const int bc_end =
hits.front()->getBC() + 16;
72 ATH_MSG_DEBUG(
"Window Start: " << bc_start <<
" - Window End: " << bc_end);
73
74 std::vector<std::shared_ptr<MMT_Hit> > hits_now;
75 std::vector< std::pair<int, float> > vmm_same;
76 std::vector< std::pair<int, int> > addc_same;
77 std::vector<int> to_erase;
78
79
80 unsigned int ibc = 0;
81 for (
int bc =
hits.front()->getBC(); bc < bc_end; bc++) {
82
83 hits_now.clear();
84
85 for (
unsigned int j = ibc; j <
hits.size(); j++) {
86 if (hits[j]->getBC() == bc) hits_now.push_back(hits[j]);
87 else if (hits[j]->getBC() > bc) {
88 ibc = j;
89 break;
90 }
91 }
92
93
94 for (
unsigned int ib = 0;
ib < 8;
ib++) {
95
96 for (int j = 0; j < n_vmm; j++) {
97 vmm_same.clear();
99 for (const auto &hit_pointer: hits_now) {
100 if (static_cast<unsigned int>(hit_pointer->getPlane()) != ib) continue;
101 if (hit_pointer->getVMM() == j){
102 vmm_same.push_back( std::make_pair(k, hit_pointer->getTime()) );
103 }
105 }
106 if (vmm_same.size() > 1) {
107 to_erase.clear();
108 std::ranges::sort(vmm_same, {}, &std::pair<int, float>::second);
109 for (auto pair: vmm_same) to_erase.push_back(pair.first);
110
111 std::sort(to_erase.rbegin(), to_erase.rend());
112 to_erase.pop_back();
113 for (auto l : to_erase) {
114 hits_now.erase(hits_now.begin() + l);
115 }
116 }
117 }
118
119 for (int ia = 0; ia < n_addc; ia++) {
120 addc_same.clear();
121 for (
unsigned int k = 0;
k < hits_now.size();
k++) {
122 if ((unsigned int)(hits_now[k]->getPlane()) != ib) continue;
123 int istrip = (std::abs(hits_now[k]->getStationEta())-1) * (64*8*10) + hits_now[
k]->getChannel();
124 if (hits_now[k]->getART() == ia) addc_same.emplace_back(k, istrip);
125 }
126
127 if (addc_same.size() > 8) {
128
129 to_erase.clear();
130
131 std::ranges::sort(addc_same, {}, &std::pair<int, int>::second);
132 for (
unsigned int it = 8;
it < addc_same.size();
it++) to_erase.push_back(addc_same[it].first);
133
134
135 std::sort(to_erase.rbegin(), to_erase.rend());
136 for (auto l : to_erase) {
137 hits_now.erase(hits_now.begin() + l);
138 }
139 }
140 }
141 }
142
143 for (auto &road : roads) {
144
145 if (!road.getHitVector().empty()) road.incrementAge(bc_wind);
146 if (!hits_now.empty()) road.addHits(hits_now);
147
148 if (road.checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
149
150 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
152 ATH_MSG_DEBUG(
"Road (x, u, v, count): (" << road.iRoadx() <<
", " << road.iRoadu() <<
", " << road.iRoadv() <<
", " << road.countHits() <<
")");
153 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
154
155 std::vector<int> bcidVec;
156 for (const auto &hit: road.getHitVector()) {
157 bcidVec.push_back(hit.getBC());
158 }
159 std::ranges::sort(bcidVec);
160
161
162
163 int bcidVal=bcidVec[0], bcidCount=1, modeCount=1, bcidMode=bcidVec[0];
164 for (
unsigned int i=1;
i<bcidVec.size();
i++){
165 if (bcidVec[i] == bcidVal){
166 bcidCount++;
167 } else {
168 bcidCount = 1;
169 bcidVal = bcidVec[
i];
170 }
171 if (bcidCount > modeCount) {
172 modeCount = bcidCount;
173 bcidMode = bcidVal;
174 }
175 }
176
177 slope_t slope;
180 slope.
iRoad = road.iRoadx();
181 slope.
iRoadu = road.iRoadu();
182 slope.
iRoadv = road.iRoadv();
183 slope.
xCount = road.countXHits();
184 slope.
uCount = road.countUHits();
185 slope.
age = slope.
BC - bc_start;
186 slope.
mxl = road.mxl();
187 slope.
my = road.avgSofXUV(
'X');
188 slope.
uavg = road.avgSofXUV(
'U');
189 slope.
vavg = road.avgSofXUV(
'V');
190 slope.
mx = (slope.
uavg-slope.
vavg)/(2.*tan_stereo_angle);
191 const double theta = std::atan(std::sqrt(std::pow(slope.
mx,2) + std::pow(slope.
my,2)));
193 slope.
eta = -1.*std::log(std::tan(slope.
theta/2.));
195 slope.
side = (slope.
my > 0.) ?
'A' :
'C';
196 slope.
phi = std::atan(slope.
mx/slope.
my);
198 slope.
lowRes = road.evaluateLowRes();
199
200 diamondSlopes.push_back(slope);
201 }
202 }
203 }
204}
Scalar theta() const
theta method
double phiShift(const int n, const double phi, const char side) const
void sort(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end)
Specialization of sort for DataVector/List.