66void MMT_Diamond::findDiamonds(std::vector<std::shared_ptr<MMT_Hit> >& hits, std::vector<MMT_Road>& roads, std::vector<slope_t>& diamondSlopes,
const int sectorPhi)
const {
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);
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;
81 for (
int bc = hits.front()->getBC(); bc < bc_end; bc++) {
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) {
94 for (
unsigned int ib = 0; ib < 8; ib++) {
96 for (
int j = 0; j < n_vmm; j++) {
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()) );
106 if (vmm_same.size() > 1) {
108 std::ranges::sort(vmm_same, {}, &std::pair<int, float>::second);
109 for (
auto pair: vmm_same) to_erase.push_back(
pair.first);
111 std::sort(to_erase.rbegin(), to_erase.rend());
113 for (
auto l : to_erase) {
114 hits_now.erase(hits_now.begin() + l);
119 for (
int ia = 0; ia < n_addc; ia++) {
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);
127 if (addc_same.size() > 8) {
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);
135 std::sort(to_erase.rbegin(), to_erase.rend());
136 for (
auto l : to_erase) {
137 hits_now.erase(hits_now.begin() + l);
143 for (
auto &road : roads) {
145 if (!road.getHitVector().empty()) road.incrementAge(bc_wind);
146 if (!hits_now.empty()) road.addHits(hits_now);
148 if (road.checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
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(
"------------------------------------------------------------------");
155 std::vector<int> bcidVec;
156 for (
const auto &hit: road.getHitVector()) {
157 bcidVec.push_back(hit.getBC());
159 std::ranges::sort(bcidVec);
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){
169 bcidVal = bcidVec[i];
171 if (bcidCount > modeCount) {
172 modeCount = bcidCount;
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();
200 diamondSlopes.push_back(slope);
MMT_Diamond(const int diamXthreshold, const bool uv, const int diamUVthreshold, const int roadSize, const int olapEtaUp, const int olapEtaDown, const int olapStereoUp, const int olapStereoDown)