10 #include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
12 #include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.h>
13 #include <tracking/trackFindingCDC/hough/perigee/AxialLegendreLeafProcessor.icc.h>
15 #include <tracking/trackFindingCDC/hough/perigee/SimpleRLTaggedWireHitHoughTree.h>
16 #include <tracking/trackFindingCDC/hough/perigee/SimpleSegmentHoughTree.h>
17 #include <tracking/trackFindingCDC/hough/perigee/StandardBinSpec.h>
19 #include <tracking/trackFindingCDC/hough/algorithms/InPhi0CurvBox.h>
21 #include <framework/core/ModuleParamList.templateDetails.h>
22 #include <framework/core/ModuleParam.h>
27 using namespace TrackFindingCDC;
28 using namespace PerigeeBinSpec;
31 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_hits)
33 std::string svgFileName =
"phi0_curv_on_hits.svg";
35 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
36 Helix higherCurvOriginHelix(0.027, 3.0718, 0, 0, 0);
41 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
42 saveDisplay(svgFileName);
44 using SimpleRLTaggedWireHitPhi0CurvHough =
45 SimpleRLTaggedWireHitHoughTree<InPhi0CurvBox, phi0Divisions, curvDivisions>;
46 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel);
47 using HoughBox = SimpleRLTaggedWireHitPhi0CurvHough::HoughBox;
49 const double minWeight = 30.0;
53 houghTree.initialize();
57 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
60 TimeItResult timeItResult = timeIt(100,
true, [&]() {
62 houghTree.seed(m_axialWireHits);
64 candidates = houghTree.find(minWeight, maxCurvAcceptance);
67 ASSERT_EQ(m_mcTracks.size(), candidates.size());
70 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
71 EXPECT_GE(candidates[iCand].second.size(), 30);
76 std::size_t nNodes = houghTree.getTree()->getNNodes();
77 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
82 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
83 const HoughBox& houghBox = candidate.first;
84 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
86 B2DEBUG(100,
"Candidate");
87 B2DEBUG(100,
"size " << taggedHits.size());
88 B2DEBUG(100,
"Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
89 B2DEBUG(100,
"Curv " << houghBox.getLowerBound<DiscreteCurv>());
90 B2DEBUG(100,
"Tags of the hits");
92 B2DEBUG(100,
"Tags of the hits");
93 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
95 "rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
" " <<
96 "dl = " << rlTaggedWireHit.getRefDriftLength());
99 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
100 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
101 std::string color =
"blue";
102 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
104 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
109 draw(wireHit, strokeAttr);
114 saveDisplay(svgFileName);
116 timeItResult.printSummary();
121 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_on_segments)
123 std::string svgFileName =
"phi0_curv_on_segments.svg";
125 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
126 Helix higherCurvOriginHelix(0.027, 3.0718, 0, 0, 0);
131 simulate({lowerCurvOriginHelix, higherCurvOriginHelix});
132 saveDisplay(svgFileName);
134 using SimpleSegmentPhi0CurvHoughTree =
135 SimpleSegmentHoughTree<InPhi0CurvBox, phi0Divisions, curvDivisions>;
136 SimpleSegmentPhi0CurvHoughTree houghTree(maxLevel);
137 using HoughBox = SimpleSegmentPhi0CurvHoughTree::HoughBox;
139 const double minWeight = 30.0;
143 houghTree.initialize();
146 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
149 TimeItResult timeItResult = timeIt(100,
true, [&]() {
153 houghTree.seed(m_mcAxialSegment2Ds);
155 candidates = houghTree.find(minWeight, maxCurvAcceptance);
158 ASSERT_EQ(m_mcTracks.size(), candidates.size());
162 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
163 EXPECT_GE(candidates[iCand].second.size(), 4);
168 std::size_t nNodes = houghTree.getTree()->getNNodes();
169 B2INFO(
"Tree generated " << nNodes <<
" nodes");
174 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
175 const HoughBox& houghBox = candidate.first;
176 const std::vector<const CDCSegment2D*>& segments = candidate.second;
178 B2DEBUG(100,
"Candidate");
179 B2DEBUG(100,
"size " << segments.size());
180 B2DEBUG(100,
"Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
181 B2DEBUG(100,
"Curv " << houghBox.getLowerBound<DiscreteCurv>());
183 for (
const CDCSegment2D* segment2D : segments) {
185 draw(*segment2D, strokeAttr);
189 saveDisplay(svgFileName);
190 timeItResult.printSummary();
196 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_hits_using_leaf_processing)
198 std::string svgFileName =
"phi0_curv_on_hits.svg";
200 Helix zeroCurvOriginHelix(0.000, 1.52033, 0, -0.5, 0);
201 Helix lowerCurvOriginHelix(0.015, 2.52033, 0, 1, 0);
202 Helix higherCurvOriginHelix(0.027, 3.0718, 3, 0, 0);
207 simulate({zeroCurvOriginHelix, lowerCurvOriginHelix, higherCurvOriginHelix});
208 saveDisplay(svgFileName);
210 using SimpleRLTaggedWireHitPhi0CurvHough =
211 SimpleRLTaggedWireHitHoughTree<InPhi0CurvBox, phi0Divisions, curvDivisions>;
212 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel, curlCurv);
216 houghTree.initialize();
218 const double minWeight = 30.0;
219 using Node =
typename SimpleRLTaggedWireHitPhi0CurvHough::Node;
220 AxialLegendreLeafProcessor<Node> leafProcessor(maxLevel);
223 const std::string prefix =
"";
224 leafProcessor.exposeParameters(&moduleParamList, prefix);
225 moduleParamList.
getParameter<
double>(
"minWeight").setDefaultValue(minWeight);
226 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
229 std::vector< std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> > > candidates;
232 TimeItResult timeItResult = this->timeIt(100,
true, [&]() {
235 for (
const CDCWireHit* wireHit : m_axialWireHits) {
236 AutomatonCell& automatonCell = wireHit->getAutomatonCell();
238 automatonCell.unsetTemporaryFlags();
241 houghTree.seed(m_axialWireHits);
243 leafProcessor.clear();
246 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(curlCurv);
247 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(2);
248 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(4);
249 leafProcessor.beginWalk();
250 houghTree.findUsing(leafProcessor);
252 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
253 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(3);
254 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(0);
255 leafProcessor.beginWalk();
256 houghTree.findUsing(leafProcessor);
258 candidates = leafProcessor.getCandidates();
260 ASSERT_EQ(m_mcTracks.size(), candidates.size());
263 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
264 EXPECT_GE(candidates[iCand].second.size(), 30);
269 std::size_t nNodes = houghTree.getTree()->getNNodes();
270 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
275 for (std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> >& candidate : candidates) {
276 const CDCTrajectory2D& trajectory2D = candidate.first;
277 const std::vector<CDCRLWireHit >& taggedHits = candidate.second;
279 B2DEBUG(100,
"Candidate");
280 B2DEBUG(100,
"size " << taggedHits.size());
281 B2DEBUG(100,
"Impact " << trajectory2D.getGlobalCircle().impact());
282 B2DEBUG(100,
"Phi0 " << trajectory2D.getGlobalCircle().phi0());
283 B2DEBUG(100,
"Curv " << trajectory2D.getCurvature());
284 B2DEBUG(100,
"Support " << trajectory2D.getSupport());
285 B2DEBUG(100,
"Tags of the hits");
287 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
288 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
289 " dl = " << rlTaggedWireHit.getRefDriftLength());
292 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
293 const CDCWireHit wireHit = rlTaggedWireHit.getWireHit();
294 std::string color =
"blue";
295 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
297 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
302 draw(wireHit, strokeAttr);
307 saveDisplay(svgFileName);
308 timeItResult.printSummary();
313 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_prepared_event_hits_using_leaf_processing)
315 std::string svgFileName =
"phi0_curv_on_prepared_event_hits_using_leaf_processing.svg";
317 saveDisplay(svgFileName);
320 using SimpleRLTaggedWireHitPhi0CurvHough =
321 SimpleRLTaggedWireHitHoughTree<InPhi0CurvBox, phi0Divisions, curvDivisions>;
322 SimpleRLTaggedWireHitPhi0CurvHough houghTree(maxLevel, curlCurv);
326 houghTree.initialize();
328 const double minWeight = 30.0;
329 using Node =
typename SimpleRLTaggedWireHitPhi0CurvHough::Node;
330 AxialLegendreLeafProcessor<Node> leafProcessor(maxLevel);
333 const std::string prefix =
"";
334 leafProcessor.exposeParameters(&moduleParamList, prefix);
335 moduleParamList.
getParameter<
double>(
"minWeight").setDefaultValue(minWeight);
336 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
339 std::vector< std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> > > candidates;
342 TimeItResult timeItResult = timeIt(100,
true, [&]() {
346 for (
const CDCWireHit* wireHit : m_axialWireHits) {
347 AutomatonCell& automatonCell = wireHit->getAutomatonCell();
349 automatonCell.unsetTemporaryFlags();
352 houghTree.seed(m_axialWireHits);
354 leafProcessor.clear();
357 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(curlCurv);
358 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(2);
359 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(4);
360 leafProcessor.beginWalk();
361 houghTree.findUsing(leafProcessor);
363 moduleParamList.
getParameter<
double>(
"maxCurv").setDefaultValue(maxCurvAcceptance);
364 moduleParamList.
getParameter<
int>(
"nRoadSearches").setDefaultValue(3);
365 moduleParamList.
getParameter<
int>(
"roadLevel").setDefaultValue(0);
366 leafProcessor.beginWalk();
367 houghTree.findUsing(leafProcessor);
369 candidates = leafProcessor.getCandidates();
371 ASSERT_EQ(m_mcTracks.size(), candidates.size());
374 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
375 EXPECT_GE(candidates[iCand].second.size(), 30);
380 std::size_t nNodes = houghTree.getTree()->getNNodes();
381 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
386 for (std::pair<CDCTrajectory2D, std::vector<CDCRLWireHit> >& candidate : candidates) {
387 const CDCTrajectory2D& trajectory2D = candidate.first;
388 const std::vector<CDCRLWireHit >& taggedHits = candidate.second;
390 B2DEBUG(100,
"Candidate");
391 B2DEBUG(100,
"size " << taggedHits.size());
392 B2DEBUG(100,
"Impact " << trajectory2D.getGlobalCircle().impact());
393 B2DEBUG(100,
"Phi0 " << trajectory2D.getGlobalCircle().phi0());
394 B2DEBUG(100,
"Curv " << trajectory2D.getCurvature());
395 B2DEBUG(100,
"Support " << trajectory2D.getSupport());
396 B2DEBUG(100,
"Tags of the hits");
398 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
399 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
400 " dl = " << rlTaggedWireHit.getRefDriftLength());
403 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
404 const CDCWireHit wireHit = rlTaggedWireHit.getWireHit();
405 std::string color =
"blue";
406 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
408 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
413 draw(wireHit, strokeAttr);
418 saveDisplay(svgFileName);
419 timeItResult.printSummary();
422 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_curv_prepared_event_hits)
424 std::string svgFileName =
"phi0_curv_on_prepared_event_hits.svg";
426 saveDisplay(svgFileName);
428 using RLTaggedWireHitPhi0CurvHough = SimpleRLTaggedWireHitHoughTree<InPhi0CurvBox, phi0Divisions, curvDivisions>;
429 using Phi0CurvBox = RLTaggedWireHitPhi0CurvHough::HoughBox;
430 RLTaggedWireHitPhi0CurvHough houghTree(maxLevel);
432 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.
constructArray(),
435 houghTree.assignArray<DiscreteCurv>(curvBinsSpec.
constructArray(),
438 houghTree.initialize();
439 const double minWeight = 30.0;
442 std::vector< std::pair<Phi0CurvBox, std::vector<CDCRLWireHit> > > candidates;
445 TimeItResult timeItResult = timeIt(100,
true, [&]() {
448 houghTree.seed(m_axialWireHits);
450 candidates = houghTree.find(minWeight, maxCurvAcceptance);
453 ASSERT_EQ(m_mcTracks.size(), candidates.size());
456 for (
size_t iCand = 0; iCand < candidates.size(); ++iCand) {
457 EXPECT_GE(candidates[iCand].second.size(), 30);
462 std::size_t nNodes = houghTree.getTree()->getNNodes();
463 B2DEBUG(100,
"Tree generated " << nNodes <<
" nodes");
468 for (std::pair<Phi0CurvBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
469 const Phi0CurvBox& phi0CurvBox = candidate.first;
470 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
472 B2DEBUG(100,
"Candidate");
473 B2DEBUG(100,
"size " << taggedHits.size());
474 B2DEBUG(100,
"Phi0 " << phi0CurvBox.getLowerBound<DiscretePhi0>()->phi());
475 B2DEBUG(100,
"Curv " << phi0CurvBox.getLowerBound<DiscreteCurv>());
476 B2DEBUG(100,
"Tags of the hits");
478 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
479 B2DEBUG(100,
" rl = " <<
static_cast<int>(rlTaggedWireHit.getRLInfo()) <<
480 " dl = " << rlTaggedWireHit.getRefDriftLength());
483 for (
const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
484 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
485 std::string color =
"blue";
486 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
488 }
else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
493 draw(wireHit, strokeAttr);
497 saveDisplay(svgFileName);
498 timeItResult.printSummary();