10 #include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
12 #include <tracking/trackFindingCDC/hough/perigee/SimpleRLTaggedWireHitHoughTree.h>
13 #include <tracking/trackFindingCDC/hough/perigee/SimpleSegmentHoughTree.h>
14 #include <tracking/trackFindingCDC/hough/perigee/StandardBinSpec.h>
16 #include <tracking/trackFindingCDC/hough/algorithms/InPhi0CurvTanLBox.h>
21 using namespace TrackFindingCDC;
22 using namespace PerigeeBinSpec;
27 const int maxLevel = 13;
31 const int phi0Divisions = 2;
32 const int discretePhi0Overlap = 4;
33 const int discretePhi0Width = 5;
34 const int nPhi0Bins = std::pow(phi0Divisions, maxLevel);
35 const Phi0BinsSpec phi0BinsSpec(nPhi0Bins,
42 const int curvDivisions = 2;
43 const double maxCurv = 0.13;
44 const double minCurv = -0.018;
45 const double maxCurvAcceptance = 0.13;
47 const int discreteCurvOverlap = 4;
48 const int discreteCurvWidth = 5;
49 const int nCurvBins = std::pow(curvDivisions, maxLevel);
50 const CurvBinsSpec curvBinsSpec(minCurv,
59 const int tanLDivisions = 2;
60 const double maxTanL = 3.27;
61 const double minTanL = -1.73;
63 const int discreteTanLOverlap = 1;
64 const int discreteTanLWidth = 2;
65 const int nTanLBins = std::pow(tanLDivisions, maxLevel);
66 ImpactBinsSpec tanLBinsSpec(minTanL,
72 const double curlCurv = 0.018;
74 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_tanl_hits)
76 std::string svgFileName =
"phi0_curv_tanl_hits.svg";
78 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
79 Helix higherCurvOriginHelix(0.020, 3.0718, 0, -0.2, 0);
84 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
85 saveDisplay(svgFileName);
87 using SimpleRLTaggedWireHitPhi0CurvHough =
88 SimpleRLTaggedWireHitHoughTree<InPhi0CurvTanLBox, phi0Divisions, curvDivisions, tanLDivisions>;
89 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel, curlCurv);
90 using HoughBox = SimpleRLTaggedWireHitPhi0CurvHough::HoughBox;
92 const double minWeight = 50.0;
100 houghTree.assignArray<ContinuousTanL>({{minTanL, maxTanL}}, tanLBinsSpec.getOverlap());
102 houghTree.initialize();
105 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
108 TimeItResult timeItResult = timeIt(1,
true, [&]() {
111 houghTree.seed(m_wireHits);
114 candidates = houghTree.findBest(minWeight, maxCurvAcceptance);
116 ASSERT_EQ(m_mcTracks.size(), candidates.size());
119 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
120 EXPECT_GE(candidates[iCand].second.size(), 30);
125 std::size_t nNodes = houghTree.getTree()->getNNodes();
126 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
131 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
132 const HoughBox& houghBox = candidate.first;
133 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
135 B2DEBUG(100,
"Candidate");
136 B2DEBUG(100,
"size " << taggedHits.size());
138 B2DEBUG(100,
"Lower Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
139 B2DEBUG(100,
"Upper Phi0 " << houghBox.getUpperBound<DiscretePhi0>()->phi());
140 B2DEBUG(100,
"Lower Curv " << houghBox.getLowerBound<DiscreteCurvWithArcLength2DCache>());
141 B2DEBUG(100,
"Upper Curv " << houghBox.getUpperBound<DiscreteCurvWithArcLength2DCache>());
142 B2DEBUG(100,
"Lower TanL " << houghBox.getLowerBound<ContinuousTanL>());
143 B2DEBUG(100,
"Upper TanL " << houghBox.getUpperBound<ContinuousTanL>());
144 B2DEBUG(100,
"Tags of the hits");
145 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
147 "rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
" " <<
148 "dl = " << rlTaggedWireHit.getRefDriftLength());
151 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
152 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
153 std::string color =
"blue";
154 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
156 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
161 draw(wireHit, strokeAttr);
166 saveDisplay(svgFileName);
168 timeItResult.printSummary();
171 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_tanl_segments)
173 std::string svgFileName =
"phi0_curv_tanl_segments.svg";
175 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
176 Helix higherCurvOriginHelix(0.020, 3.0718, 0, -0.2, 0);
178 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
179 saveDisplay(svgFileName);
181 using SimpleSegmentPhi0CurvHoughTree =
182 SimpleSegmentHoughTree<InPhi0CurvTanLBox, phi0Divisions, curvDivisions, tanLDivisions>;
183 SimpleSegmentPhi0CurvHoughTree houghTree(maxLevel, curlCurv);
184 using HoughBox = SimpleSegmentPhi0CurvHoughTree::HoughBox;
186 const double minWeight = 50.0;
189 houghTree.assignArray<DiscreteCurvWithArcLength2DCache>(curvBinsSpec.
constructCacheArray(),
192 houghTree.assignArray<ContinuousTanL>({{minTanL, maxTanL}}, tanLBinsSpec.getOverlap());
193 houghTree.initialize();
196 std::vector<const CDCSegment2D*> m_ptrSegment2Ds;
197 m_ptrSegment2Ds.reserve(m_mcSegment2Ds.size());
198 for (
const CDCSegment2D& segment2D : m_mcSegment2Ds) {
199 m_ptrSegment2Ds.push_back(&segment2D);
203 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
206 TimeItResult timeItResult = timeIt(1,
true, [&]() {
209 houghTree.seed(m_ptrSegment2Ds);
212 candidates = houghTree.findBest(minWeight, maxCurvAcceptance);
214 ASSERT_EQ(m_mcTracks.size(), candidates.size());
218 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
219 EXPECT_GE(candidates[iCand].second.size(), 4);
224 int nNodes = houghTree.getTree()->getNNodes();
225 B2INFO(
"Tree generated " << nNodes <<
" nodes");
230 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
231 const HoughBox& houghBox = candidate.first;
232 const std::vector<const CDCSegment2D*>& segments = candidate.second;
234 B2DEBUG(100,
"Candidate");
235 B2DEBUG(100,
"size " << segments.size());
236 B2DEBUG(100,
"Lower Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
237 B2DEBUG(100,
"Upper Phi0 " << houghBox.getUpperBound<DiscretePhi0>()->phi());
238 B2DEBUG(100,
"Lower Curv " << houghBox.getLowerBound<DiscreteCurvWithArcLength2DCache>());
239 B2DEBUG(100,
"Upper Curv " << houghBox.getUpperBound<DiscreteCurvWithArcLength2DCache>());
240 B2DEBUG(100,
"Lower TanL " << houghBox.getLowerBound<ContinuousTanL>());
241 B2DEBUG(100,
"Upper TanL " << houghBox.getUpperBound<ContinuousTanL>());
242 for (
const CDCSegment2D* segment2D : segments) {
244 draw(*segment2D, strokeAttr);
248 saveDisplay(svgFileName);
249 timeItResult.printSummary();