7 MMT_Road::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,
8 const int iroadx,
const int iroadu,
const int iroadv) {
11 m_iroadu = (iroadu != -1) ? iroadu : iroadx;
12 m_iroadv = (iroadv != -1) ? iroadv : iroadx;
24 for (
const auto &hit_i :
hits) {
25 if (
m_sector != hit_i->getSector())
continue;
28 unsigned short int olow = 0, ohigh = 0;
34 else if (hit_i->isU()) {
39 else if (hit_i->isV()) {
46 double val = hit_i->getShift();
47 double slow =
val + (
m_roadSize*iroad + 0.5 - olow )*hit_i->getPitchOverZ();
48 double shigh =
val + (
m_roadSize*(iroad+1) + 0.5 + ohigh)*hit_i->getPitchOverZ();
50 val = hit_i->getRZSlope();
51 bool has_hit = (
val > 0.) ? (
val > slow &&
val < shigh) : (
val > shigh &&
val < slow);
52 if (!has_hit)
continue;
55 unsigned short int bo = hit_i->getPlane();
56 auto it = std::find_if(
m_road_hits.begin(),
m_road_hits.end(), [&bo](
const auto &hit) { return (hit->getPlane() == bo); });
59 if (!hit_i->isNoise() && (*it)->isNoise()) {
65 if (has_hit)
continue;
66 m_road_hits.emplace_back(std::make_unique<MMT_Hit>(hit_i.get()));
72 std::vector<double> sl;
74 int bo = hit->getPlane();
75 if (bo < 2 || bo > 5) sl.push_back(hit->getRZSlope());
82 std::vector<double> sl;
84 int bo = hit->getPlane();
85 if (bo == uv1 || bo == uv2) sl.push_back(hit->getRZSlope());
92 std::vector<double> zs;
94 int bo = hit->getPlane();
95 if (bo == uv1 || bo == uv2) zs.push_back(hit->getZ());
103 if (!passHorizontalCheck)
return false;
105 if (!passStereoCheck)
return false;
107 return (passHorizontalCheck && passStereoCheck && passMatureCheck);
113 if (hit->isNoise() ==
false) nreal++;
119 unsigned int nuv = 0;
121 if (hit->getPlane() == 2 || hit->getPlane() == 4) {
122 if (hit->isNoise() ==
flag) nuv++;
124 if (hit->getPlane() == 3 || hit->getPlane() == 5) {
125 if (hit->isNoise() ==
flag) nuv++;
134 if (hit->getPlane() < 2 || hit->getPlane() > 5) {
135 if (hit->isNoise() ==
flag) nx++;
142 unsigned int nhits1 = 0, nhits2 = 0;
144 if (hit->getPlane() < 4 && !hit->isNoise()) nhits1++;
145 else if (hit->getPlane() > 3 && !hit->isNoise()) nhits2++;
147 return (nhits1 < 4 || nhits2 < 4);
151 int nx1 = 0, nx2 = 0;
153 if (hit->getPlane() >-1 && hit->getPlane() < 2) nx1++;
154 if (hit->getPlane() > 5 && hit->getPlane() < 8) nx2++;
156 return (nx1 > 0 && nx2 > 0 && (nx1+nx2) >=
m_xthr);
160 std::vector<unsigned int> old_ihits;
161 for (
unsigned int j = 0; j <
m_road_hits.size(); j++) {
163 if (
m_road_hits[j]->getAge() > (bcwind-1)) old_ihits.push_back(j);
170 if (hit->getAge() == (bcwind - 1))
return true;
176 std::vector<double> ys, zs;
178 int bo = hit->getPlane();
179 if (bo < 2 || bo > 5) {
180 ys.push_back(hit->getR());
181 zs.push_back(hit->getZ());
186 double sum_sq_z = std::inner_product(zs.begin(), zs.end(), zs.begin(), 0.0);
187 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)) );
202 if (hit->getPlane() == 2 || hit->getPlane() == 4) nu++;
203 if (hit->getPlane() == 3 || hit->getPlane() == 5) nv++;
206 return (nu > 0 && nv > 0 && (nu+nv) >=
m_uvthr);