Belle II Software development
Phi0Impact.test.cc
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8#include <tracking/trackFindingCDC/testFixtures/TrackFindingCDCTestWithSimpleSimulation.h>
9
10#include <tracking/trackFindingCDC/hough/perigee/SimpleRLTaggedWireHitHoughTree.h>
11#include <tracking/trackFindingCDC/hough/perigee/SimpleSegmentHoughTree.h>
12#include <tracking/trackFindingCDC/hough/perigee/StandardBinSpec.h>
13
14#include <tracking/trackFindingCDC/hough/algorithms/InPhi0ImpactBox.h>
15
16#include <vector>
17
18using namespace Belle2;
19using namespace TrackFindingCDC;
20using namespace PerigeeBinSpec;
21
22namespace {
23
24 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_SimpleHitBasedHough_phi0_impact_onHits)
25 {
26 std::string svgFileName = "phi0_impact_on_hits.svg";
27
28 Helix lowerHelix(0.00, 2.52033, -20, 0, 0);
29 Helix higherHelix(0.00, 3.0718, 20, 0, 0);
30
31 simulate({lowerHelix, higherHelix});
32 saveDisplay(svgFileName);
33
34 using SimpleRLTaggedWireHitHoughTree =
35 SimpleRLTaggedWireHitHoughTree<InPhi0ImpactBox, phi0Divisions, impactDivisions>;
36
37 SimpleRLTaggedWireHitHoughTree houghTree(maxLevel);
39
40 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.constructArray(), phi0BinsSpec.getNOverlap());
41 //houghTree.assignArray<DiscreteImpact>(impactBinsSpec.constructArray(), impactBinsSpec.getNOverlap()); // Discrete
42 houghTree.assignArray<ContinuousImpact>({{minImpact, maxImpact}}, impactBinsSpec.getOverlap()); // Continuous
43 houghTree.initialize();
44
45 // Execute the finding a couple of time to find a stable execution time.
46 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
47
48 // Is this still C++? Looks like JavaScript to me :-).
49 TimeItResult timeItResult = timeIt(100, true, [&]() {
50 houghTree.fell();
51 houghTree.seed(m_axialWireHits);
52
53 const double minWeight = 30.0;
54 candidates = houghTree.find(minWeight);
55 // candidates = houghTree.findBest(minWeight);
56
57 ASSERT_EQ(m_mcTracks.size(), candidates.size());
58 // Check for the parameters of the track candidates
59 // The actual hit numbers are more than 30, but this is somewhat a lower bound
60 for (size_t iCand = 0; iCand < candidates.size(); ++iCand) {
61 EXPECT_GE(candidates[iCand].second.size(), 30);
62 }
63 });
64
65 std::size_t nNodes = houghTree.getTree()->getNNodes();
66 B2INFO("Tree generated " << nNodes << " nodes");
67 houghTree.fell();
68 houghTree.raze();
69
70
71 size_t iColor = 0;
72 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
73 const HoughBox& houghBox = candidate.first;
74 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
75
76 B2DEBUG(100, "Candidate");
77 B2DEBUG(100, "size " << taggedHits.size());
78 B2DEBUG(100, "Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
79 B2DEBUG(100, "Impact " << houghBox.getLowerBound<ContinuousImpact>());
80
81 B2DEBUG(100, "Tags of the hits");
82 for (const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
83 B2DEBUG(100, " " <<
84 "rl = " << static_cast<int>(rlTaggedWireHit.getRLInfo()) << " " <<
85 "dl = " << rlTaggedWireHit.getRefDriftLength());
86 }
87
88 for (const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
89 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
90 std::string color = "blue";
91 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
92 color = "green";
93 } else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
94 color = "red";
95 }
96 //EventDataPlotter::AttributeMap strokeAttr {{"stroke", color}};
97 EventDataPlotter::AttributeMap strokeAttr {{"stroke", m_colors[iColor % m_colors.size()] }};
98 draw(wireHit, strokeAttr);
99 }
100 ++iColor;
101 }
102 saveDisplay(svgFileName);
103
104 timeItResult.printSummary();
105 }
106}
107
108
109namespace {
110 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_SimpleHitBasedHough_phi0_impact_onSegment)
111 {
112 std::string svgFileName = "phi0_impact_on_segments.svg";
113
114 Helix lowerHelix(0.00, 2.52033, -20, 0, 0);
115 Helix higherHelix(0.00, 3.0718, 20, 0, 0);
116
117 simulate({lowerHelix, higherHelix});
118 saveDisplay(svgFileName);
119
120 using SimpleSegmentPhi0ImpactHoughTree =
121 SimpleSegmentHoughTree<InPhi0ImpactBox, phi0Divisions, impactDivisions>;
122 SimpleSegmentPhi0ImpactHoughTree houghTree(maxLevel);
123
124 using HoughBox = SimpleSegmentPhi0ImpactHoughTree::HoughBox;
125
126 B2INFO("yes");
127 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.constructArray(), phi0BinsSpec.getNOverlap());
128 //houghTree.assignArray<DiscreteImpact>(impactBinsSpec.constructArray(), impactBinsSpec.getNOverlap()); // Discrete
129 houghTree.assignArray<ContinuousImpact>({{minImpact, maxImpact}}, impactBinsSpec.getOverlap()); // Continuous
130 houghTree.initialize();
131
132 // Execute the finding a couple of time to find a stable execution time.
133 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
134
135 // Is this still C++? Looks like JavaScript to me :-).
136 TimeItResult timeItResult = timeIt(100, true, [&]() {
137 // Exclude the timing of the resource release for comparison with the Legendre test.
138 houghTree.fell();
139
140 houghTree.seed(m_mcAxialSegment2Ds);
141
142 const double minWeight = 40.0;
143 candidates = houghTree.find(minWeight);
144 // candidates = houghTree.findBest(minWeight);
145
146 ASSERT_EQ(m_mcTracks.size(), candidates.size());
147
148 // Check for the parameters of the track candidates
149 // The actual hit numbers are more than 4 segment, but this is somewhat a lower bound
150 for (size_t iCand = 0; iCand < candidates.size(); ++iCand) {
151 EXPECT_GE(candidates[iCand].second.size(), 4);
152 }
153 });
154
156 std::size_t nNodes = houghTree.getTree()->getNNodes();
157 B2INFO("Tree generated " << nNodes << " nodes");
158 houghTree.fell();
159 houghTree.raze();
160
161 size_t iColor = 0;
162 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
163 const HoughBox& houghBox = candidate.first;
164 const std::vector<const CDCSegment2D*>& segments = candidate.second;
165
166 B2DEBUG(100, "Candidate");
167 B2DEBUG(100, "size " << segments.size());
168 B2DEBUG(100, "Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
169 B2DEBUG(100, "Impact " << houghBox.getLowerBound<ContinuousImpact>());
170
171 for (const CDCSegment2D* segment2D : segments) {
172 EventDataPlotter::AttributeMap strokeAttr {{"stroke", m_colors[iColor % m_colors.size()] }};
173 draw(*segment2D, strokeAttr);
174 }
175 ++iColor;
176 }
177 saveDisplay(svgFileName);
178 timeItResult.printSummary();
179 }
180}
Helix parameter class.
Definition Helix.h:48
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:55
PrimitivePlotter::AttributeMap AttributeMap
Forward the Attribute map from the primitive plotter.
Class to capture the time a repeated execution took.
Definition TimeIt.h:29
void printSummary() const
Print a summary of the collected time to the console.
Definition TimeIt.h:57
Abstract base class for different kinds of events.