6 #define sq(x) ((x) * (x))
14 for (
auto & seg : segs) {
15 int isBarrel = seg.dcs()[0].id().isBarrel();
18 if (seg.hitsMl2() == 0) {
19 ml1segs.push_back(seg);
20 }
else if (seg.hitsMl1() == 0) {
21 ml2segs.push_back(seg);
25 if (ml1segs.empty() || ml2segs.empty())
return;
29 double chamberMidPtY = (ml1LocVec2D.
y() + ml2LocVec2D.
y()) / 2.0;
32 std::cout <<
"CurvedSegmentsFinder begining match with " << ml1segs.size() <<
" ML1 segments and " << ml2segs.size()
33 <<
" ML2 segments" << std::endl;
34 for (
auto & ml1seg : ml1segs) {
36 const double tanML1 =
std::tan(ml1seg.line().phi());
37 const double mid1 = (chamberMidPtY - ml1seg.line().position().y()) / tanML1 + ml1seg.line().position().x();
38 const double y01 = ml1seg.line().position().y() - ml1seg.line().position().x() * tanML1;
39 for (
auto & ml2seg : ml2segs) {
41 const double deltaAlpha = ml1seg.line().phi() - ml2seg.line().phi();
43 const double tanML2 =
std::tan(ml2seg.line().phi());
45 const double mid2 = (chamberMidPtY - ml2seg.line().position().y()) / tanML2 + ml2seg.line().position().x();
46 const double y02 = ml2seg.line().position().y() - ml2seg.line().position().x() * tanML2;
47 double deltab = (mid2 * tanML1 - chamberMidPtY + y01) / std::hypot(1, tanML1);
48 const double deltab2 = (mid1 * tanML2 - chamberMidPtY + y02) / std::hypot(1, tanML2);
49 if (std::abs(deltab2) < std::abs(deltab)) deltab = deltab2;
55 std::cout <<
"CurvedSegment combination found with parameters (DeltaAlpha,Deltab) = (" << deltaAlpha <<
", "
56 << deltab <<
")" << std::endl;
59 dcs.insert(dcs.end(), ml2seg.dcs().begin(), ml2seg.dcs().end());
60 double segChi2 = ml1seg.chi2() + ml2seg.chi2();
61 double segNDoF = ml1seg.ndof() + ml2seg.ndof();
62 Segment seg(ml1seg.line(), dcs, segChi2, segNDoF, ml1seg.dtheta(), ml1seg.dy0());
64 const double xb = ml2seg.line().position().x() - (ml2seg.line().position().y() - chamberMidPtY) /
tan(ml2seg.line().phi());
68 seg.
deltas(ml1seg.deltas() + ml2seg.deltas());
69 seg.
hitsOutOfTime(ml1seg.hitsOutOfTime() + ml2seg.hitsOutOfTime());
70 seg.
hitsOnTrack(ml1seg.hitsOnTrack() + ml2seg.hitsOnTrack());
71 seg.
hitsPerMl(ml1seg.hitsMl1(), ml2seg.hitsMl2());
72 seg.
closeHits(ml1seg.closeHits() + ml2seg.closeHits());
81 if (
m_debugLevel >= 5) std::cout <<
"Finished CurvedSegments Finding, and found " << nCurved <<
" CurvedSegments" << std::endl;