Belle II Software development
Phi0ImpactCurv.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/InPhi0ImpactCurvBox.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_curv_onHits)
25 {
26 std::string svgFileName = "phi0_impact_curv_on_hits.svg";
27
28 Helix lowerCurvHelix(0.015, 2.52033, -20, 0, 0);
29 Helix higherCurvHelix(0.027, 3.0718, 20, 0, 0);
30
31 // Helix lowerCurvHelix(0.015, 2.52033, 0, 0, 0);
32 // Helix higherCurvHelix(0.027, 3.0718, 0, 0, 0);
33
34
35 simulate({lowerCurvHelix, higherCurvHelix});
36 saveDisplay(svgFileName);
37
38 using SimpleWireHitPhi0ImpactCurvHoughTree =
40
41 SimpleWireHitPhi0ImpactCurvHoughTree houghTree(maxLevel, curlCurv);
42 using HoughBox = SimpleWireHitPhi0ImpactCurvHoughTree::HoughBox;
43
44 const double minWeight = 70.0;
45
46 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.constructArray(), phi0BinsSpec.getNOverlap());
47 //houghTree.assignArray<DiscreteImpact>(impactBinsSpec.constructArray(), impactBinsSpec.getNOverlap()); // Discrete
48 houghTree.assignArray<ContinuousImpact>({{minImpact, maxImpact}}, impactBinsSpec.getOverlap()); // Continuous
49 houghTree.assignArray<DiscreteCurv>(curvBinsSpec.constructArray(), curvBinsSpec.getNOverlap());
50 houghTree.initialize();
51
52 // Execute the finding a couple of time to find a stable execution time.
53 std::vector< std::pair<HoughBox, std::vector<CDCRLWireHit> > > candidates;
54
55 // Is this still C++? Looks like JavaScript to me :-).
56 TimeItResult timeItResult = timeIt(100, true, [&]() {
57 houghTree.fell();
58 houghTree.seed(m_axialWireHits);
59
60 candidates = houghTree.find(minWeight, maxCurvAcceptance);
61 // candidates = houghTree.findBest(minWeight, maxCurvAcceptance);
62
63 ASSERT_EQ(m_mcTracks.size(), candidates.size());
64 // Check for the parameters of the track candidates
65 // The actual hit numbers are more than 30, but this is somewhat a lower bound
66 for (size_t iCand = 0; iCand < candidates.size(); ++iCand) {
67 EXPECT_GE(candidates[iCand].second.size(), 30);
68 }
69 });
70
71 std::size_t nNodes = houghTree.getTree()->getNNodes();
72 B2INFO("Tree generated " << nNodes << " nodes");
73 houghTree.fell();
74 houghTree.raze();
75
76
77 size_t iColor = 0;
78 for (std::pair<HoughBox, std::vector<CDCRLWireHit> >& candidate : candidates) {
79 const HoughBox& houghBox = candidate.first;
80 const std::vector<CDCRLWireHit>& taggedHits = candidate.second;
81
82 B2DEBUG(100, "Candidate");
83 B2DEBUG(100, "size " << taggedHits.size());
84 B2DEBUG(100, "Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
85 B2DEBUG(100, "Curv " << houghBox.getLowerBound<DiscreteCurv>());
86 B2DEBUG(100, "Impact " << houghBox.getLowerBound<ContinuousImpact>());
87
88 B2DEBUG(100, "Tags of the hits");
89 for (const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
90 B2DEBUG(100, " " <<
91 "rl = " << static_cast<int>(rlTaggedWireHit.getRLInfo()) << " " <<
92 "dl = " << rlTaggedWireHit.getRefDriftLength());
93 }
94
95 for (const CDCRLWireHit& rlTaggedWireHit : taggedHits) {
96 const CDCWireHit& wireHit = rlTaggedWireHit.getWireHit();
97 std::string color = "blue";
98 if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Right) {
99 color = "green";
100 } else if (rlTaggedWireHit.getRLInfo() == ERightLeft::c_Left) {
101 color = "red";
102 }
103 //EventDataPlotter::AttributeMap strokeAttr {{"stroke", color}};
104 EventDataPlotter::AttributeMap strokeAttr {{"stroke", m_colors[iColor % m_colors.size()] }};
105 draw(wireHit, strokeAttr);
106 }
107 ++iColor;
108 }
109 saveDisplay(svgFileName);
110
111 timeItResult.printSummary();
112 }
113}
114
115namespace {
116 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_SimpleHitBasedHough_phi0_impact_curv_onSegment)
117 {
118 std::string svgFileName = "phi0_impact_curv_on_segments.svg";
119
120 Helix lowerCurvHelix(0.015, 2.52033, -20, 0, 0);
121 Helix higherCurvHelix(0.027, 3.0718, 20, 0, 0);
122
123 simulate({lowerCurvHelix, higherCurvHelix});
124 saveDisplay(svgFileName);
125
126 using SimpleSegmentPhi0ImpactCurvHoughTree =
128
129 SimpleSegmentPhi0ImpactCurvHoughTree houghTree(maxLevel, curlCurv);
130 using HoughBox = SimpleSegmentPhi0ImpactCurvHoughTree::HoughBox;
131
132 const double minWeight = 70.0;
133
134 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.constructArray(), phi0BinsSpec.getNOverlap());
135 //houghTree.assignArray<DiscreteImpact>(impactBinsSpec.constructArray(), impactBinsSpec.getNOverlap()); // Discrete
136 houghTree.assignArray<ContinuousImpact>({{minImpact, maxImpact}}, impactBinsSpec.getOverlap()); // Continuous
137 houghTree.assignArray<DiscreteCurv>(curvBinsSpec.constructArray(), curvBinsSpec.getNOverlap());
138 houghTree.initialize();
139
140 // Execute the finding a couple of time to find a stable execution time.
141 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
142
143 // Is this still C++? Looks like JavaScript to me :-).
144 TimeItResult timeItResult = timeIt(100, true, [&]() {
145 // Exclude the timing of the resource release for comparision with the legendre test.
146 houghTree.fell();
147
148 houghTree.seed(m_mcAxialSegment2Ds);
149
150 candidates = houghTree.find(minWeight, maxCurvAcceptance);
151 // candidates = houghTree.findBest(minWeight, maxCurvAcceptance);
152
153 ASSERT_EQ(m_mcTracks.size(), candidates.size());
154
155 // Check for the parameters of the track candidates
156 // The actual hit numbers are more than 4 segment, but this is somewhat a lower bound
157 for (size_t iCand = 0; iCand < candidates.size(); ++iCand) {
158 EXPECT_GE(candidates[iCand].second.size(), 4);
159 }
160 });
161
163 std::size_t nNodes = houghTree.getTree()->getNNodes();
164 B2INFO("Tree generated " << nNodes << " nodes");
165 houghTree.fell();
166 houghTree.raze();
167
168 size_t iColor = 0;
169 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
170 const HoughBox& houghBox = candidate.first;
171 const std::vector<const CDCSegment2D*>& segments = candidate.second;
172
173 B2DEBUG(100, "Candidate");
174 B2DEBUG(100, "size " << segments.size());
175 B2DEBUG(100, "Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
176 B2DEBUG(100, "Curv " << houghBox.getLowerBound<DiscreteCurv>());
177 B2DEBUG(100, "Impact " << houghBox.getLowerBound<ContinuousImpact>());
178
179 for (const CDCSegment2D* segment2D : segments) {
180 EventDataPlotter::AttributeMap strokeAttr {{"stroke", m_colors[iColor % m_colors.size()] }};
181 draw(*segment2D, strokeAttr);
182 }
183 ++iColor;
184 }
185 saveDisplay(svgFileName);
186 timeItResult.printSummary();
187 }
188
189 // cppcheck-suppress syntaxError
190 TEST_F(TrackFindingCDCTestWithSimpleSimulation, hough_perigee_phi0_impact_curv_prepared_event_segments)
191 {
192 std::string svgFileName = "phi0_impact_curv_on_prepared_event_segments.svg";
193 loadPreparedEvent();
194 saveDisplay(svgFileName);
195
196 using SimpleSegmentPhi0ImpactCurvHoughTree =
198
199 using HoughBox = SimpleSegmentPhi0ImpactCurvHoughTree::HoughBox;
200 SimpleSegmentPhi0ImpactCurvHoughTree houghTree(maxLevel);
201
202 houghTree.assignArray<DiscretePhi0>(phi0BinsSpec.constructArray(),
203 phi0BinsSpec.getNOverlap());
204 houghTree.assignArray<ContinuousImpact>({{minImpact, maxImpact}},
205 impactBinsSpec.getOverlap()); // Continuous
206 houghTree.assignArray<DiscreteCurv>(curvBinsSpec.constructArray(),
207 curvBinsSpec.getNOverlap());
208
209 houghTree.initialize();
210 const double minWeight = 30.0;
211
212 // Execute the finding a couple of time to find a stable execution time.
213 std::vector< std::pair<HoughBox, std::vector<const CDCSegment2D*> > > candidates;
214
215 // Is this still C++? Looks like JavaScript to me :-).
216 TimeItResult timeItResult = timeIt(1, true, [&]() {
217 // Exclude the timing of the resource release for comparision with the legendre test.
218 houghTree.fell();
219 houghTree.seed(m_mcAxialSegment2Ds);
220
221 // candidates = houghTree.find(minWeight, maxCurvAcceptance);
222 candidates = houghTree.findBest(minWeight, maxCurvAcceptance);
223
224 ASSERT_EQ(m_mcTracks.size(), candidates.size());
225 // Check for the parameters of the track candidates
226 // The actual hit numbers are more than 30, but this is somewhat a lower bound
227 for (size_t iCand = 0; iCand < candidates.size(); ++iCand) {
228 EXPECT_GE(candidates[iCand].second.size(), 3);
229 }
230 });
231
233 std::size_t nNodes = houghTree.getTree()->getNNodes();
234 B2DEBUG(100, "Tree generated " << nNodes << " nodes");
235 houghTree.fell();
236 houghTree.raze();
237
238 size_t iColor = 0;
239 for (std::pair<HoughBox, std::vector<const CDCSegment2D*> >& candidate : candidates) {
240 const HoughBox& houghBox = candidate.first;
241 const std::vector<const CDCSegment2D*>& segments = candidate.second;
242
243 B2DEBUG(100, "Candidate");
244 B2DEBUG(100, "size " << segments.size());
245 B2DEBUG(100, "Phi0 " << houghBox.getLowerBound<DiscretePhi0>()->phi());
246 B2DEBUG(100, "Curv " << houghBox.getLowerBound<DiscreteCurv>());
247 B2DEBUG(100, "Impact " << houghBox.getLowerBound<ContinuousImpact>());
248
249 for (const CDCSegment2D* segment2D : segments) {
250 EventDataPlotter::AttributeMap strokeAttr {{"stroke", m_colors[iColor % m_colors.size()] }};
251 draw(*segment2D, strokeAttr);
252 }
253 ++iColor;
254 }
255 saveDisplay(svgFileName);
256 timeItResult.printSummary();
257 }
258
259}
Helix parameter class.
Definition: Helix.h:48
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
Type to have values not based on discrete positions from an array.
DiscreteCurv::Array constructArray() const
Constuct the array of discrete curv positions.
Definition: CurvRep.h:40
int getNOverlap() const
Getter for the overlap in discrete number of positions.
Definition: CurvRep.h:68
Representation for a discrete position in an array of discrete positions.
Definition: DiscreteValue.h:23
PrimitivePlotter::AttributeMap AttributeMap
Forward the Attributre map from the primitive plotter.
double getOverlap() const
Getter for the overlap in real impact to investigate the value that results from the discrete overlap...
Definition: ImpactRep.cc:45
DiscretePhi0::Array constructArray() const
Constuct the array of discrete phi0 positions.
Definition: Phi0Rep.cc:23
int getNOverlap() const
Getter for the overlap in discrete number of positions.
Definition: Phi0Rep.h:47
A convenience class based on a BoxDivisionHoughTree for "hit-like" classes.
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.