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