Belle II Software development
OffOriginExtension.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/legendre/quadtree/OffOriginExtension.h>
9
10#include <tracking/trackFindingCDC/legendre/quadtree/AxialHitQuadTreeProcessor.h>
11#include <tracking/trackFindingCDC/processing/AxialTrackUtil.h>
12
13#include <tracking/trackFindingCDC/fitting/CDCKarimakiFitter.h>
14#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
15
16#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
17
18#include <tracking/trackingUtilities/numerics/LookupTable.h>
19
20#include <Math/Vector2D.h>
21
22#include <vector>
23
24using namespace Belle2;
25using namespace TrackFindingCDC;
26using namespace TrackingUtilities;
27
28OffOriginExtension::OffOriginExtension(std::vector<const CDCWireHit*> allAxialWireHits,
29 double levelPrecision)
30 : BaseCandidateReceiver(std::move(allAxialWireHits))
31 , m_levelPrecision(levelPrecision)
32{
33}
34
35void OffOriginExtension::operator()(const std::vector<const CDCWireHit*>& inputWireHits,
36 void* qt __attribute__((unused)))
37{
38 // Unset the taken flag and let the postprocessing decide
39 for (const CDCWireHit* wireHit : inputWireHits) {
40 (*wireHit)->setTakenFlag(false);
41 }
42
43 std::vector<const CDCWireHit*> candidateHits = roadSearch(inputWireHits);
47 true);
48}
49
50std::vector<const CDCWireHit*>
51OffOriginExtension::roadSearch(const std::vector<const CDCWireHit*>& wireHits)
52{
54 CDCTrajectory2D trackTrajectory2D = fitter.fit(wireHits);
55
56 double chi2 = trackTrajectory2D.getChi2();
57 ROOT::Math::XYVector refPos = trackTrajectory2D.getGlobalPerigee();
58
59 // change sign of the curvature; should be the same as the charge of the candidate
60 double curv = trackTrajectory2D.getCurvature();
61
62 // theta is the vector normal to the trajectory at the perigee
63 double theta = trackTrajectory2D.getGlobalCircle().phi0() + M_PI_2;
64
65 // Hide the current hits from the road search
66 for (const CDCWireHit* hit : wireHits) {
67 hit->getAutomatonCell().setTakenFlag(true);
68 }
69
70 std::vector<const CDCWireHit*> newWireHits = getHitsWRTtoRefPos(refPos, curv, theta);
71
72 // Unhide the current hits from the road search
73 for (const CDCWireHit* hit : wireHits) {
74 hit->getAutomatonCell().setTakenFlag(false);
75 }
76
77 if (newWireHits.size() == 0) return wireHits;
78
79 std::vector<const CDCWireHit*> combinedWireHits;
80
81 for (const CDCWireHit* hit : wireHits) {
82 combinedWireHits.push_back(hit);
83 }
84
85 for (const CDCWireHit* hit : newWireHits) {
86 combinedWireHits.push_back(hit);
87 }
88
89 CDCTrajectory2D combinedTrajectory2D = fitter.fit(wireHits);
90 double combinedChi2 = combinedTrajectory2D.getChi2();
91
92 if (combinedChi2 < chi2 * 2.) {
93 return combinedWireHits;
94 }
95
96 return wireHits;
97}
98
99std::vector<const CDCWireHit*>
100OffOriginExtension::getHitsWRTtoRefPos(const ROOT::Math::XYVector& refPos, float curv, float theta)
101{
102 float thetaPrecision = M_PI / (pow(2., m_levelPrecision + 1));
103 float curvPrecision = 0.15 / (pow(2., m_levelPrecision));
104
106 YSpan curvSpan{curv - curvPrecision, curv + curvPrecision};
107 LookupTable<ROOT::Math::XYVector> thetaSpan(&VectorUtil::Phi, 1, theta - thetaPrecision, theta + thetaPrecision);
108
109 AxialHitQuadTreeProcessor qtProcessor(refPos, curvSpan, &thetaSpan);
110 qtProcessor.seed(m_allAxialWireHits);
111
112 std::vector<const CDCWireHit*> newWireHits = qtProcessor.getAssignedItems();
113 return newWireHits;
114}
std::vector< TrackingUtilities::CDCTrack > m_tracks
Collected tracks.
BaseCandidateReceiver(std::vector< const TrackingUtilities::CDCWireHit * > allAxialWireHits)
Constructor.
std::vector< const TrackingUtilities::CDCWireHit * > m_allAxialWireHits
Pool of all axial hits from which the road search may select additional hits.
Class implementing the fitter using Karimakis method.
static const CDCKarimakiFitter & getNoDriftVarianceFitter()
Static getter for a general fitter that does not use the drift length variances.
std::vector< const TrackingUtilities::CDCWireHit * > getHitsWRTtoRefPos(const ROOT::Math::XYVector &refPos, float curv, float theta)
Get hits which are compatible with given trajectory.
double m_levelPrecision
Precision level for the width of the off origin hough search.
std::vector< const TrackingUtilities::CDCWireHit * > roadSearch(const std::vector< const TrackingUtilities::CDCWireHit * > &wireHits)
Perform transformation for set of given hits; reference position taken as POCA of the fitted trajecto...
void operator()(const std::vector< const TrackingUtilities::CDCWireHit * > &inputWireHits, void *qt) final
Main entry point for the post processing call from the QuadTreeProcessor.
OffOriginExtension(std::vector< const TrackingUtilities::CDCWireHit * > allAxialWireHits, double levelPrecision=9)
Constructor.
std::vector< AData * > getAssignedItems()
Get items that have been assigned to the seed level The returned elements are unique even if items ar...
void seed(const std::vector< AData * > &datas)
Fill in the items in the given vector.
Particle trajectory as it is seen in xy projection represented as a circle.
PerigeeCircle getGlobalCircle() const
Getter for the circle in global coordinates.
double getChi2() const
Getter for the chi2 value of the circle fit.
ROOT::Math::XYVector getGlobalPerigee() const
Getter for the closest approach on the trajectory to the global origin.
double getCurvature() const
Getter for the curvature as seen from the xy projection.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:56
Class which holds precomputed values of a function.
Definition LookupTable.h:50
double phi0() const
Getter for the azimuth angle of the direction of flight at the perigee.
Abstract base class for different kinds of events.
STL namespace.
static void addCandidateFromHits(const std::vector< const TrackingUtilities::CDCWireHit * > &foundAxialWireHits, const std::vector< const TrackingUtilities::CDCWireHit * > &allAxialWireHits, std::vector< TrackingUtilities::CDCTrack > &axialTracks, bool withPostprocessing=true)
Create CDCTrack using CDCWireHit hits and store it in the list. Then call the postprocessing on it.