14 if (!diam.ev_roads.empty()) diam.ev_roads.clear();
15 if (!diam.ev_hits.empty()) diam.ev_hits.clear();
23 ATH_MSG_DEBUG(
"createRoads_fillHits: Feeding hitDatas Start");
30 std::string sector = (
par->getSector() ==
'L') ?
"MML" :
"MMS";
37 std::vector<ROOT::Math::XYZVector> planeCoordinates{};
38 planeCoordinates.reserve(8);
39 for (
unsigned int iphi = 0; iphi < 8; iphi++) {
41 int multilayer = (iphi < 4) ? 1 : 2;
42 int gasgap = ((iphi+1)%4 == 0) ? 4 : (iphi+1)%4;
48 int strip = (iphi > 1 && iphi < 6) ?
par->getMissedBottomStereoStrips()+1 :
par->getMissedBottomEtaStrips()+1;
52 ROOT::Math::XYZVector
coord(0.,0.,0.);
54 else ATH_MSG_WARNING(
"Wedge " << sector <<
" phi: " << iphi <<
" mult. " << multilayer <<
" gas " << gasgap <<
" | Unable to retrieve global positions");
55 planeCoordinates.push_back(
coord);
60 int uvfactor =
std::round(
par->getlWidth() / (
B * 0.4 * 2.)/this->getRoadSize() );
63 for (
const auto &hit_entry : hitDatas) {
64 auto myhit = std::make_shared<MMT_Hit>(hit_entry, detManager,
par, planeCoordinates);
65 if (myhit->verifyHit()) {
67 entry.ev_hits.push_back(myhit);
70 entry.side = (std::all_of(
entry.ev_hits.begin(),
entry.ev_hits.end(), [] (
const auto &hit) { return hit->getStationEta() < 0; })) ?
'C' :
'A';
72 for (
int i = 0;
i < nroad;
i++) {
75 entry.ev_roads.push_back(myroad);
78 for (
int uv = 1; uv <= nuv; uv++) {
79 if (
i-uv < 0)
continue;
83 entry.ev_roads.push_back(myroad_0);
87 entry.ev_roads.push_back(myroad_1);
91 entry.ev_roads.push_back(myroad_2);
95 entry.ev_roads.push_back(myroad_3);
99 entry.ev_roads.push_back(myroad_4);
103 entry.ev_roads.push_back(myroad_5);
107 ATH_MSG_DEBUG(
"CreateRoadsAndFillHits: Feeding hitDatas Ended");
114 int bc_start = 999999;
117 unsigned int ibc = 0;
125 ATH_MSG_DEBUG(
"Window Start: " << bc_start <<
" - Window End: " << bc_end);
129 std::vector<std::shared_ptr<MMT_Hit> > hits_now = {};
130 std::vector< std::pair<int, float> > vmm_same = {};
131 std::vector< std::pair<int, int> > addc_same = {};
132 std::vector<int> to_erase = {};
150 for (
unsigned int ib = 0;
ib < 8;
ib++) {
152 for (
int j = 0; j < n_vmm; j++) {
155 for (
auto hit_pointer: hits_now) {
156 if (
static_cast<unsigned int>(hit_pointer->getPlane()) !=
ib)
continue;
157 if (hit_pointer->getVMM() == j){
158 vmm_same.push_back( std::make_pair(
k, hit_pointer->getTime()) );
162 if (vmm_same.size() > 1) {
164 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; });
165 for (
auto pair: vmm_same) to_erase.push_back(pair.first);
167 std::sort(to_erase.rbegin(), to_erase.rend());
169 for (
auto l : to_erase) {
170 hits_now.erase(hits_now.begin() +
l);
175 for (
int ia = 0; ia < n_addc; ia++) {
177 for (
unsigned int k = 0;
k < hits_now.size();
k++) {
178 if ((
unsigned int)(hits_now[
k]->getPlane()) !=
ib)
continue;
179 int istrip = (std::abs(hits_now[
k]->getStationEta())-1) * (64*8*10) + hits_now[
k]->getChannel();
180 if (hits_now[
k]->getART() == ia) addc_same.emplace_back(
k, istrip);
183 if (addc_same.size() > 8) {
187 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; });
188 for (
unsigned int it = 8;
it < addc_same.size();
it++) to_erase.push_back(addc_same[
it].first);
191 std::sort(to_erase.rbegin(), to_erase.rend());
192 for (
auto l : to_erase) {
193 hits_now.erase(hits_now.begin() +
l);
200 road->incrementAge(bc_wind);
201 if (!hits_now.empty()) road->addHits(hits_now);
203 if (road->checkCoincidences(bc_wind) && bc >= (bc_start - 1)) {
205 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
207 ATH_MSG_DEBUG(
"Road (x, u, v, count): (" << road->iRoadx() <<
", " << road->iRoadu() <<
", " << road->iRoadv() <<
", " << road->countHits() <<
")");
208 ATH_MSG_DEBUG(
"------------------------------------------------------------------");
210 std::vector<int> bcidVec;
211 for (
const auto &hit: road->getHitVector()) {
212 bcidVec.push_back(hit->getBC());
214 std::sort(bcidVec.begin(), bcidVec.end());
218 int bcidVal=bcidVec.at(0), bcidCount=1, modeCount=1, bcidMode=bcidVec.at(0);
219 for (
unsigned int i=1;
i<bcidVec.size();
i++){
220 if (bcidVec.at(
i) == bcidVal){
224 bcidVal = bcidVec.at(
i);
226 if (bcidCount > modeCount) {
227 modeCount = bcidCount;
237 slope.
iRoad = road->iRoadx();
238 slope.
iRoadu = road->iRoadu();
239 slope.
iRoadv = road->iRoadv();
240 slope.
uvbkg = road->countUVHits(
true);
241 slope.
xbkg = road->countXHits(
true);
242 slope.
uvmuon = road->countUVHits(
false);
243 slope.
xmuon = road->countXHits(
false);
244 slope.
age = slope.
BC - bc_start;
245 slope.
mxl = road->mxl();
246 slope.
my = road->avgSofX();
247 slope.
uavg = road->avgSofUV(2,4);
248 slope.
vavg = road->avgSofUV(3,5);
249 static const double tan_stereo_angle =
std::tan(0.02618);
250 slope.
mx = (slope.
uavg-slope.
vavg)/(2.*tan_stereo_angle);
255 slope.
side = (slope.
my > 0.) ?
'A' :
'C';
259 slope.
phiShf = phiShifted;
260 slope.
lowRes = road->evaluateLowRes();
267 ATH_MSG_DEBUG(
"Processing roads took " << std::chrono::duration_cast<std::chrono::milliseconds>(
t1 -
t0).
count() <<
" ms");
272 double shift = (
n > 8) ? (16-
n)*
M_PI/8. :
n*
M_PI/8.;
273 if (
n < 8)
return (
Phi + shift);
274 else if (
n == 8)
return (
Phi + ((
Phi > 0.) ? -1. : 1.)*shift);
275 else return (
Phi - shift);
282 slope_t::slope_t(
int ev,
int bc,
unsigned int tC,
unsigned int rC,
int iX,
int iU,
int iV,
unsigned int uvb,
unsigned int xb,
unsigned int uvm,
unsigned int xm,
283 int age,
double mxl,
double my,
double uavg,
double vavg,
double mx,
double th,
double eta,
double dth,
char side,
double phi,
double phiS,
285 event(
ev),
BC(bc), totalCount(tC), realCount(rC), iRoad(
iX), iRoadu(iU), iRoadv(iV), uvbkg(uvb), xbkg(
xb), uvmuon(uvm), xmuon(xm),
286 age(
age), mxl(mxl),
my(
my), uavg(uavg), vavg(vavg),
mx(
mx),
theta(
th),
eta(
eta), dtheta(dth),
side(
side),
phi(
phi), phiShf(phiS), lowRes(lowRes) {}