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/trackingUtilities/eventdata/tracks/CDCTrack.h>
13#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
14
15#include <tracking/trackingUtilities/utilities/StringManipulation.h>
16
17#include <framework/core/ModuleParamList.templateDetails.h>
18
19using namespace Belle2;
20using namespace TrackFindingCDC;
21using namespace TrackingUtilities;
22
24std::unique_ptr<AxialHitQuadTreeProcessor> AxialTrackCreatorHitLegendre::constructQTProcessor(EPass pass)
25{
27 using PrecisionFunction = PrecisionUtil::PrecisionFunction;
28 const int maxTheta = std::pow(2, PrecisionUtil::getLookupGridLevel());
29
30 if (pass == EPass::NonCurlers) {
31 int maxLevel = 12;
32 int seedLevel = 4;
33 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.14}});
34 PrecisionFunction precisionFunction = &PrecisionUtil::getOriginCurvPrecision;
35
36 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
37
38 } else if (pass == EPass::NonCurlersWithIncreasingThreshold) {
39 int maxLevel = 10;
40 int seedLevel = 4;
41 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.14}});
42 PrecisionFunction precisionFunction = &PrecisionUtil::getNonOriginCurvPrecision;
43
44 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
45
46 } else if (pass == EPass::FullRange) {
47 int maxLevel = 10;
48 int seedLevel = 1;
49 XYSpans xySpans({{0, maxTheta}, {0.00, 0.30}});
50 PrecisionFunction precisionFunction = &PrecisionUtil::getNonOriginCurvPrecision;
51
52 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
53
54 } else if (pass == EPass::Straight) {
55 int maxLevel = 10;
56 int seedLevel = 4;
57 XYSpans xySpans({{0, maxTheta}, { -0.02, 0.02}});
58// PrecisionFunction precisionFunction = &PrecisionUtil::getBasicCurvPrecision; //That is 0.3 / pow(2, 16)
59 PrecisionFunction precisionFunction = [this](double curv __attribute__((unused))) {return m_param_precision ;};
60
61 return std::make_unique<AxialHitQuadTreeProcessor>(maxLevel, seedLevel, xySpans, precisionFunction);
62
63 }
64 B2FATAL("Invalid pass");
65}
66
67
69
74
76{
77 return "Generates axial tracks from hits using several increasingly relaxed legendre space search over phi0 and curvature.";
78}
79
81 const std::string& prefix)
82{
83 moduleParamList->addParameter(prefixed(prefix, "minNHits"),
85 "Parameter to define minimal threshold of number of hits.",
87 if (m_pass == EPass::Straight) {
88 moduleParamList->addParameter(prefixed(prefix, "precision"),
90 "Parameter to define precision of quadtree search.",
92 }
93}
94
99
100void AxialTrackCreatorHitLegendre::apply(const std::vector<const TrackingUtilities::CDCWireHit*>& axialWireHits,
101 std::vector<TrackingUtilities::CDCTrack>& tracks)
102{
103 // Prepare vector of unused hits to provide to the qt processor
104 // Also reset the mask flag and select only the untaken hits
105 std::vector<const TrackingUtilities::CDCWireHit*> unusedAxialWireHits;
106 for (const TrackingUtilities::CDCWireHit* wireHit : axialWireHits) {
107 (*wireHit)->setMaskedFlag(false);
108 if ((*wireHit)->hasTakenFlag()) continue;
109 unusedAxialWireHits.push_back(wireHit);
110 }
111
112 // Create quadtree processor
113 std::unique_ptr<AxialHitQuadTreeProcessor> qtProcessor = constructQTProcessor(m_pass);
114 qtProcessor->seed(unusedAxialWireHits);
115// qtProcessor->drawHits(unusedAxialWireHits, 9);
116
117 // Create object which contains interface between quadtree processor and track processor (module)
118 std::unique_ptr<BaseCandidateReceiver> receiver;
119 if (not(m_pass == EPass::Straight)) {
120 receiver = std::make_unique<OffOriginExtension>(unusedAxialWireHits);
121 } else {
122 receiver = std::make_unique<BaseCandidateReceiver>(unusedAxialWireHits);
123 }
124
125 // Start candidate finding
126 this->executeRelaxation(std::ref(*receiver), *qtProcessor);
127
128 const std::vector<CDCTrack>& newTracks = receiver->getTracks();
129 tracks.insert(tracks.end(), newTracks.begin(), newTracks.end());
130}
131
133 AxialHitQuadTreeProcessor& qtProcessor)
134{
135 // radius of the CDC
136 const double rCDC = 113.;
137
138 // Curvature for high pt particles that leave the CDC
139 const double curlCurv = 2. / rCDC;
140
141 // find leavers
142 qtProcessor.fill(candidateReceiver, 50, curlCurv);
143
144 // find curlers with diameter higher than half of radius of CDC
145 qtProcessor.fill(candidateReceiver, 70, 2 * curlCurv);
146
147 // Start relaxation loop
148 int minNHits = m_pass == EPass::FullRange ? 30 : 50;
149 double maxCurv = m_pass == EPass::FullRange ? 0.15 : 0.07;
150 do {
151 qtProcessor.fill(candidateReceiver, minNHits, maxCurv);
152
153 minNHits = minNHits * m_param_stepScale;
154
155 if (m_pass != EPass::NonCurlers) {
156 maxCurv *= 2.;
157 if (maxCurv > 0.15) maxCurv = 0.15;
158 }
159
160 } while (minNHits >= m_param_minNHits);
161}
The Module parameter list class.
void apply(const std::vector< const TrackingUtilities::CDCWireHit * > &axialWireHits, std::vector< TrackingUtilities::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 ...
static double getOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
static double getNonOriginCurvPrecision(double curv)
Function which estimates desired curvature resolution of quadtree node in the given pt region paramet...
static constexpr int getLookupGridLevel()
Returns desired deepness of the trigonometrical lookup table. Used as template parameter for the Trig...
std::function< double(double)> PrecisionFunction
Function type which is used for resolution calculations (resolution=f(curvature)) Takes a curvature v...
void fill(const CandidateReceiver &candidateReceiver, int nHitsThreshold)
Start filling the already created tree.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:58
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.