10 #include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
12 #include <tracking/trackFindingCDC/hough/perigee/SimpleRLTaggedWireHitHoughTree.h>
13 #include <tracking/trackFindingCDC/hough/perigee/SimpleSegmentHoughTree.h>
15 #include <tracking/trackFindingCDC/hough/algorithms/InPhi0TanLBox.h>
17 #include <tracking/trackFindingCDC/hough/perigee/Phi0Rep.h>
18 #include <tracking/trackFindingCDC/hough/axes/StandardAxes.h>
19 #include <tracking/trackFindingCDC/hough/perigee/ImpactRep.h>
24 using namespace TrackFindingCDC;
55 const int maxLevel = 13;
56 const int phi0Divisions = 2;
57 const int tanLDivisions = 2;
59 const int discretePhi0Overlap = 4;
60 const int discretePhi0Width = 5;
62 const int nPhi0Bins = std::pow(phi0Divisions, maxLevel);
63 Phi0BinsSpec phi0BinsSpec(nPhi0Bins,
67 const double maxTanL = 3.27;
68 const double minTanL = -1.73;
70 const int discreteTanLOverlap = 1;
71 const int discreteTanLWidth = 2;
72 const int nTanLBins = std::pow(tanLDivisions, maxLevel);
73 ImpactBinsSpec tanLBinsSpec(minTanL,
79 const double curlCurv = 0.018;
82 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_tanl_on_hits)
84 std::string svgFileName =
"phi0_tanl_on_hits.svg";
86 Helix originLine0(0.0, -1.0, 0, 0.2, 0);
87 Helix originLine1(0.0, 1.0, 0, -0.5, 0);
89 simulate({originLine0, originLine1});
90 saveDisplay(svgFileName);
92 using SimpleRLTaggedWireHitPhi0TanLHoughTree =
93 SimpleRLTaggedWireHitHoughTree< InPhi0TanLBox, phi0Divisions, tanLDivisions>;
95 SimpleRLTaggedWireHitPhi0TanLHoughTree houghTree(maxLevel, 0.018);
96 using HoughBox = SimpleRLTaggedWireHitPhi0TanLHoughTree::HoughBox;
98 houghTree.assignArray<ContinuousTanL>({{minTanL, maxTanL}}, tanLBinsSpec.getOverlap());
101 houghTree.initialize();
103 std::vector<CDCRLWireHit> mcTaggedWireHits;
104 for (
const CDCTrack& mcTrack : m_mcTracks) {
105 for (
const CDCRecoHit3D& recoHit3D : mcTrack) {
106 const CDCWireHit& wireHit = recoHit3D.getWireHit();
107 mcTaggedWireHits.emplace_back(&wireHit);
108 mcTaggedWireHits.back().setRLInfo(recoHit3D.getRLInfo());
113 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
116 TimeItResult timeItResult = timeIt(100,
true, [&]() {
120 houghTree.seed(mcTaggedWireHits);
122 const double minWeight = 50.0;
124 candidates = houghTree.findBest(minWeight);
126 ASSERT_EQ(m_mcTracks.size(), candidates.size());
129 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
130 EXPECT_GE(candidates[iCand].second.size(), 30);
134 std::size_t nNodes = houghTree.getTree()->getNNodes();
135 B2INFO(
"Tree generated " << nNodes <<
" nodes");
141 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
142 const HoughBox& houghBox = candidate.first;
143 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
145 B2DEBUG(100,
"Candidate");
146 B2DEBUG(100,
"size " << taggedHits.size());
147 B2DEBUG(100,
"Lower Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
148 B2DEBUG(100,
"Upper Phi0 " << houghBox.getUpperBound<DiscretePhi0>()->phi());
149 B2DEBUG(100,
"Lower TanL " << houghBox.getLowerBound<ContinuousTanL>());
150 B2DEBUG(100,
"Upper TanL " << houghBox.getUpperBound<ContinuousTanL>());
153 B2DEBUG(100,
"Tags of the hits");
154 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
156 "rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
" " <<
157 "dl = " << rlTaggedWireHit.getRefDriftLength());
160 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
161 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
162 std::string color =
"blue";
163 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
165 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
170 draw(wireHit, strokeAttr);
174 saveDisplay(svgFileName);
176 timeItResult.printSummary();
179 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_tanl_on_segments)
181 std::string svgFileName =
"phi0_tanl_on_segments.svg";
183 Helix originLine0(0.0, -1.0, 0, 0.2, 0);
184 Helix originLine1(0.0, 1.0, 0, -0.5, 0);
186 simulate({originLine0, originLine1});
187 saveDisplay(svgFileName);
189 using SimpleSegmentPhi0TanLHoughTree =
190 SimpleSegmentHoughTree<InPhi0TanLBox, phi0Divisions, tanLDivisions>;
192 SimpleSegmentPhi0TanLHoughTree houghTree(maxLevel, curlCurv);
193 using HoughBox = SimpleSegmentPhi0TanLHoughTree::HoughBox;
195 houghTree.assignArray<ContinuousTanL>({{minTanL, maxTanL}}, tanLBinsSpec.getOverlap());
198 houghTree.initialize();
201 std::vector<const CDCSegment2D*> m_ptrSegment2Ds;
202 m_ptrSegment2Ds.reserve(m_mcSegment2Ds.size());
203 for (
const CDCSegment2D& segment2D : m_mcSegment2Ds) {
204 m_ptrSegment2Ds.push_back(&segment2D);
208 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
211 TimeItResult timeItResult = timeIt(100,
true, [&]() {
214 houghTree.seed(m_ptrSegment2Ds);
216 const double minWeight = 50.0;
218 candidates = houghTree.findBest(minWeight);
220 ASSERT_EQ(m_mcTracks.size(), candidates.size());
224 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
225 EXPECT_GE(candidates[iCand].second.size(), 7);
230 std::size_t nNodes = houghTree.getTree()->getNNodes();
231 B2INFO(
"Tree generated " << nNodes <<
" nodes");
236 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
237 const HoughBox& houghBox = candidate.first;
238 const std::vector<const CDCSegment2D*>& segments = candidate.second;
240 B2DEBUG(100,
"Candidate");
241 B2DEBUG(100,
"size " << segments.size());
242 B2DEBUG(100,
"Lower Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
243 B2DEBUG(100,
"Upper Phi0 " << houghBox.getUpperBound<DiscretePhi0>()->phi());
244 B2DEBUG(100,
"Lower TanL " << houghBox.getLowerBound<ContinuousTanL>());
245 B2DEBUG(100,
"Upper TanL " << houghBox.getUpperBound<ContinuousTanL>());
247 for (
const CDCSegment2D* segment2D : segments) {
249 draw(*segment2D, strokeAttr);
253 saveDisplay(svgFileName);
254 timeItResult.printSummary();