64void 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 {
67 std::sort(hits.begin(), hits.end(), [](
const auto &h1,
const auto &h2){ return h1->getBC() < h2->getBC(); });
68 const int bc_start = hits.front()->getBC();
69 const int bc_end = hits.front()->getBC() + 16;
70 ATH_MSG_DEBUG(
"Window Start: " << bc_start <<
" - Window End: " << bc_end);
72 std::vector<std::shared_ptr<MMT_Hit> > hits_now;
73 std::vector< std::pair<int, float> > vmm_same;
74 std::vector< std::pair<int, int> > addc_same;
75 std::vector<int> to_erase;
79 for (
int bc = hits.front()->getBC(); bc < bc_end; bc++) {
83 for (
unsigned int j = ibc; j < hits.size(); j++) {
84 if (hits[j]->getBC() == bc) hits_now.push_back(hits[j]);
85 else if (hits[j]->getBC() > bc) {
92 for (
unsigned int ib = 0; ib < 8; ib++) {
94 for (
int j = 0; j < n_vmm; j++) {
97 for (
const auto &hit_pointer: hits_now) {
98 if (
static_cast<unsigned int>(hit_pointer->getPlane()) != ib)
continue;
99 if (hit_pointer->getVMM() == j){
100 vmm_same.push_back( std::make_pair(k, hit_pointer->getTime()) );
104 if (vmm_same.size() > 1) {
106 std::sort(vmm_same.begin(), vmm_same.end(), [](
const std::pair<int, float>& p1,
const std::pair<int, float>& p2) { return p1.second < p2.second; });
107 for (
auto pair: vmm_same) to_erase.push_back(
pair.first);
109 std::sort(to_erase.rbegin(), to_erase.rend());
111 for (
auto l : to_erase) {
112 hits_now.erase(hits_now.begin() + l);
117 for (
int ia = 0; ia < n_addc; ia++) {
119 for (
unsigned int k = 0; k < hits_now.size(); k++) {
120 if ((
unsigned int)(hits_now[k]->getPlane()) != ib)
continue;
121 int istrip = (std::abs(hits_now[k]->getStationEta())-1) * (64*8*10) + hits_now[k]->getChannel();
122 if (hits_now[k]->getART() == ia) addc_same.emplace_back(k, istrip);
125 if (addc_same.size() > 8) {
129 std::sort(addc_same.begin(), addc_same.end(), [](
const std::pair<int, int>& p1,
const std::pair<int, int>& p2) { return p1.second < p2.second; });
130 for (
unsigned int it = 8; it < addc_same.size(); it++) to_erase.push_back(addc_same[it].first);
133 std::sort(to_erase.rbegin(), to_erase.rend());
134 for (
auto l : to_erase) {
135 hits_now.erase(hits_now.begin() + l);
141 for (
auto &road : roads) {
143 if (!road.getHitVector().empty()) road.incrementAge(bc_wind);
144 if (!hits_now.empty()) road.addHits(hits_now);
146 if (road.checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
148 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
150 ATH_MSG_DEBUG(
"Road (x, u, v, count): (" << road.iRoadx() <<
", " << road.iRoadu() <<
", " << road.iRoadv() <<
", " << road.countHits() <<
")");
151 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
153 std::vector<int> bcidVec;
154 for (
const auto &hit: road.getHitVector()) {
155 bcidVec.push_back(hit.getBC());
157 std::sort(bcidVec.begin(), bcidVec.end());
161 int bcidVal=bcidVec[0], bcidCount=1, modeCount=1, bcidMode=bcidVec[0];
162 for (
unsigned int i=1; i<bcidVec.size(); i++){
163 if (bcidVec[i] == bcidVal){
167 bcidVal = bcidVec[i];
169 if (bcidCount > modeCount) {
170 modeCount = bcidCount;
179 slope.
iRoad = road.iRoadx();
180 slope.
iRoadu = road.iRoadu();
181 slope.
iRoadv = road.iRoadv();
182 slope.
uvbkg = road.countUVHits(
true);
183 slope.
xbkg = road.countXHits(
true);
184 slope.
uvmuon = road.countUVHits(
false);
185 slope.
xmuon = road.countXHits(
false);
186 slope.
age = slope.
BC - bc_start;
187 slope.
mxl = road.mxl();
188 slope.
my = road.avgSofX();
189 slope.
uavg = road.avgSofUV(2,4);
190 slope.
vavg = road.avgSofUV(3,5);
191 slope.
mx = (slope.
uavg-slope.
vavg)/(2.*tan_stereo_angle);
192 const double theta = std::atan(std::sqrt(std::pow(slope.
mx,2) + std::pow(slope.
my,2)));
194 slope.
eta = -1.*std::log(std::tan(slope.
theta/2.));
196 slope.
side = (slope.
my > 0.) ?
'A' :
'C';
197 slope.
phi = std::atan(slope.
mx/slope.
my);
199 slope.
lowRes = road.evaluateLowRes();
201 diamondSlopes.push_back(slope);