Belle II Software development
AxialTrackCreatorHitLegendre.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/findlets/minimal/AxialTrackCreatorHitLegendre.h>
9
10#include <tracking/trackFindingCDC/legendre/quadtree/OffOriginExtension.h>
11
12#include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
13#include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
14
15#include <tracking/trackFindingCDC/utilities/StringManipulation.h>
16
17#include <framework/core/ModuleParamList.templateDetails.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21
23std::unique_ptr<AxialHitQuadTreeProcessor> AxialTrackCreatorHitLegendre::constructQTProcessor(EPass pass)
24{
26 using PrecisionFunction = PrecisionUtil::PrecisionFunction;
27 const int maxTheta = std::pow(2, PrecisionUtil::getLookupGridLevel());
28
29 if (pass == EPass::NonCurlers) {
30 int maxLevel = 12;
31 int seedLevel = 4;
32 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.14}});
33 PrecisionFunction precisionFunction = &PrecisionUtil::getOriginCurvPrecision;
34
35 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
36
37 } else if (pass == EPass::NonCurlersWithIncreasingThreshold) {
38 int maxLevel = 10;
39 int seedLevel = 4;
40 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.14}});
41 PrecisionFunction precisionFunction = &PrecisionUtil::getNonOriginCurvPrecision;
42
43 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
44
45 } else if (pass == EPass::FullRange) {
46 int maxLevel = 10;
47 int seedLevel = 1;
48 XYSpans xySpans({{0, maxTheta}, {0.00, 0.30}});
49 PrecisionFunction precisionFunction = &PrecisionUtil::getNonOriginCurvPrecision;
50
51 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
52
53 } else if (pass == EPass::Straight) {
54 int maxLevel = 10;
55 int seedLevel = 4;
56 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.02}});
57// PrecisionFunction precisionFunction = &PrecisionUtil::getBasicCurvPrecision; //That is 0.3 / pow(2, 16)
58 PrecisionFunction precisionFunction = [this](double curv __attribute__((unused))) {return m_param_precision ;};
59
60 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
61
62 }
63 B2FATAL("Invalid pass");
64}
65
66
68
70 : m_pass(pass)
71{
72}
73
75{
76 return "Generates axial tracks from hits using several increasingly relaxed legendre space search over phi0 and curvature.";
77}
78
80 const std::string& prefix)
81{
82 moduleParamList->addParameter(prefixed(prefix, "minNHits"),
84 "Parameter to define minimal threshold of number of hits.",
86 if (m_pass == EPass::Straight) {
87 moduleParamList->addParameter(prefixed(prefix, "precision"),
89 "Parameter to define precision of quadtree search.",
91 }
92}
93
95{
97}
98
99void AxialTrackCreatorHitLegendre::apply(const std::vector<const CDCWireHit*>& axialWireHits,
100 std::vector<CDCTrack>& tracks)
101{
102 // Prepare vector of unused hits to provide to the qt processor
103 // Also reset the mask flag and select only the untaken hits
104 std::vector<const CDCWireHit*> unusedAxialWireHits;
105 for (const CDCWireHit* wireHit : axialWireHits) {
106 (*wireHit)->setMaskedFlag(false);
107 if ((*wireHit)->hasTakenFlag()) continue;
108 unusedAxialWireHits.push_back(wireHit);
109 }
110
111 // Create quadtree processor
112 std::unique_ptr<AxialHitQuadTreeProcessor> qtProcessor = constructQTProcessor(m_pass);
113 qtProcessor->seed(unusedAxialWireHits);
114// qtProcessor->drawHits(unusedAxialWireHits, 9);
115
116 // Create object which contains interface between quadtree processor and track processor (module)
117 std::unique_ptr<BaseCandidateReceiver> receiver;
118 if (not(m_pass == EPass::Straight)) {
119 receiver = std::make_unique<OffOriginExtension>(unusedAxialWireHits);
120 } else {
121 receiver = std::make_unique<BaseCandidateReceiver>(unusedAxialWireHits);
122 }
123
124 // Start candidate finding
125 this->executeRelaxation(std::ref(*receiver), *qtProcessor);
126
127 const std::vector<CDCTrack>& newTracks = receiver->getTracks();
128 tracks.insert(tracks.end(), newTracks.begin(), newTracks.end());
129}
130
132 AxialHitQuadTreeProcessor& qtProcessor)
133{
134 // radius of the CDC
135 const double rCDC = 113.;
136
137 // Curvature for high pt particles that leave the CDC
138 const double curlCurv = 2. / rCDC;
139
140 // find leavers
141 qtProcessor.fill(candidateReceiver, 50, curlCurv);
142
143 // find curlers with diameter higher than half of radius of CDC
144 qtProcessor.fill(candidateReceiver, 70, 2 * curlCurv);
145
146 // Start relaxation loop
147 int minNHits = m_pass == EPass::FullRange ? 30 : 50;
148 double maxCurv = m_pass == EPass::FullRange ? 0.15 : 0.07;
149 do {
150 qtProcessor.fill(candidateReceiver, minNHits, maxCurv);
151
152 minNHits = minNHits * m_param_stepScale;
153
154 if (m_pass != EPass::NonCurlers) {
155 maxCurv *= 2.;
156 if (maxCurv > 0.15) maxCurv = 0.15;
157 }
158
159 } while (minNHits >= m_param_minNHits);
160}
The Module parameter list class.
void apply(const std::vector< const CDCWireHit * > &axialWireHits, std::vector< CDCTrack > &tracks) final
Execute one pass over a quad tree.
EPass m_pass
The pass key for lookup of the parameters for this pass.
const double m_param_stepScale
Parameter to define multiplier for hits threshold for the next quadtree iteration.
void initialize() final
Initialisation before the event processing starts.
int m_param_minNHits
Parameter to define minimal threshold of hit.
std::string getDescription() final
Short description of the findlet.
AxialHitQuadTreeProcessor::CandidateReceiver CandidateReceiver
lambda function used for postprocessing
void executeRelaxation(const CandidateReceiver &candidateReceiver, AxialHitQuadTreeProcessor &qtProcessor)
Performs quadtree search.
std::unique_ptr< AxialHitQuadTreeProcessor > constructQTProcessor(EPass pass)
Method to create QTProcessor that performs the search.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix) final
Expose the parameters to a module.
double m_param_precision
Parameter to define precision of quadtree search in case of straight pass.
EPass
Pass keys for the different sets of predefined parameters for a pass if legendre search Note: Naming ...
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
void initialize() override
Receive and dispatch signal before the start of the event processing.
static double getOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
Definition: PrecisionUtil.h:65
static double getNonOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
Definition: PrecisionUtil.h:90
static constexpr int getLookupGridLevel()
Returns desired deepness of the trigonometrical lookup table. Used as template parameter for the Trig...
Definition: PrecisionUtil.h:29
std::function< double(double)> PrecisionFunction
Function type which is used for resolution calculations (resolution=f(curvature)) Takes a curvature v...
Definition: PrecisionUtil.h:43
std::pair< XSpan, YSpan > XYSpans
This pair of spans describes the span of a node.
void fill(const CandidateReceiver &candidateReceiver, int nHitsThreshold)
Start filling the already created tree.
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.