Belle II Software development
CDCObservations2D.h
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#pragma once
9
10#include <tracking/trackFindingCDC/fitting/EFitPos.h>
11#include <tracking/trackFindingCDC/fitting/EFitVariance.h>
12
13#include <tracking/trackingUtilities/geometry/Vector2D.h>
14
15#include <tracking/trackingUtilities/numerics/ERightLeft.h>
16#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
17
18#include <vector>
19#include <iterator>
20
21namespace Belle2 {
26 namespace CDC {
27 class CDCWire;
28 }
29
30 namespace TrackingUtilities {
31 class CDCRLWireHit;
32 class CDCTrajectory2D;
33 class CDCWireHit;
34 class CDCTrack;
35 class CDCRecoHit3D;
36 class CDCRecoHit2D;
37 class CDCRLWireHitPair;
39 class CDCFacet;
41 class CDCSegment2D;
42 class CDCSegment3D;
44 }
45 namespace TrackFindingCDC {
46
49
50 public:
55 explicit CDCObservations2D(EFitPos fitPos = EFitPos::c_RecoPos,
56 EFitVariance fitVariance = EFitVariance::c_Proper)
57 : m_fitPos(fitPos)
58 , m_fitVariance(fitVariance)
59 {
60 }
61
62 public:
73 static double getPseudoDriftLengthVariance(double driftLength,
74 double driftLengthVariance)
75 {
76 return driftLength * driftLength + driftLengthVariance;
77 }
78
81
83 std::size_t size() const
84 {
85 return m_observations.size() / 4;
86 }
87
89 double* data()
90 {
91 return m_observations.data();
92 }
93
95 bool empty() const
96 {
97 return m_observations.empty();
98 }
99
101 void clear()
102 {
103 m_observations.clear();
104 }
105
107 void reserve(std::size_t nObservations)
108 {
109 m_observations.reserve(nObservations * 4);
110 }
111
113 double getX(int iObservation) const
114 {
115 return m_observations[iObservation * 4];
116 }
117
119 double getY(int iObservation) const
120 {
121 return m_observations[iObservation * 4 + 1];
122 }
123
125 double getDriftLength(int iObservation) const
126 {
127 return m_observations[iObservation * 4 + 2];
128 }
129
131 double getWeight(int iObservation) const
132 {
133 return m_observations[iObservation * 4 + 3];
134 }
135
149 std::size_t fill(double x, double y, double signedRadius = 0.0, double weight = 1.0);
150
163 std::size_t fill(const TrackingUtilities::Vector2D& pos2D, double signedRadius = 0.0, double weight = 1.0);
164
176 std::size_t append(const TrackingUtilities::CDCWireHit& wireHit,
177 TrackingUtilities::ERightLeft rlInfo = TrackingUtilities::ERightLeft::c_Unknown);
178
189 std::size_t append(const TrackingUtilities::CDCWireHit* wireHit,
190 TrackingUtilities::ERightLeft rlInfo = TrackingUtilities::ERightLeft::c_Unknown);
191
202 std::size_t append(const TrackingUtilities::CDCRLWireHit& rlWireHit);
203
205 std::size_t append(const TrackingUtilities::CDCRLWireHitPair& rlWireHitPair);
206
208 std::size_t append(const TrackingUtilities::CDCRLWireHitTriple& rlWireHitTriple);
209
211 std::size_t append(const TrackingUtilities::CDCFacet& facet);
212
214 std::size_t append(const TrackingUtilities::CDCRecoHit2D& recoHit2D);
215
217 std::size_t append(const TrackingUtilities::CDCRecoHit3D& recoHit3D);
218
223 std::size_t appendRange(const TrackingUtilities::CDCSegment2D& segment2D);
224
229 std::size_t appendRange(const TrackingUtilities::CDCSegment3D& segment3D);
230
235 std::size_t appendRange(const TrackingUtilities::CDCAxialSegmentPair& axialSegmentPair);
236
241 std::size_t appendRange(const TrackingUtilities::CDCTrack& track);
242
248 std::size_t appendRange(const std::vector<const CDC::CDCWire*>& wires);
249
255 std::size_t appendRange(const TrackingUtilities::CDCWireHitSegment& wireHits);
256
258 template<class ARange>
259 std::size_t appendRange(const ARange& range)
260 {
261 std::size_t nAppendedHits = 0;
262 using std::begin;
263 using std::end;
264 for (const auto& item : range) {
265 nAppendedHits += append(item);
266 }
267 return nAppendedHits;
268 }
269
275
281
286 double getTotalPerpS(const TrackingUtilities::CDCTrajectory2D& trajectory2D) const;
287
293 {
294 return getTotalPerpS(trajectory2D) > 0.0;
295 }
296
302 TrackingUtilities::EForwardBackward isCoaligned(const TrackingUtilities::CDCTrajectory2D& trajectory2D) const
303 {
304 return static_cast<TrackingUtilities::EForwardBackward>(TrackingUtilities::sign(getTotalPerpS(trajectory2D)));
305 }
306
309
311 void passiveMoveBy(const TrackingUtilities::Vector2D& origin);
312
315
317 std::size_t getNObservationsWithDriftRadius() const;
318
319 public:
321 EFitPos getFitPos() const
322 {
323 return m_fitPos;
324 }
325
327 void setFitPos(EFitPos fitPos)
328 {
329 m_fitPos = fitPos;
330 }
331
333 void setFitVariance(EFitVariance fitVariance)
334 {
335 m_fitVariance = fitVariance;
336 }
337
338 private:
343 std::vector<double> m_observations;
344
350 EFitPos m_fitPos;
351
357 EFitVariance m_fitVariance;
358
359 };
360
361 }
363}
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
EFitPos m_fitPos
Indicator which positional information should preferably be extracted from hits in calls to append.
static double getPseudoDriftLengthVariance(double driftLength, double driftLengthVariance)
Gets the pseudo variance.
double getX(int iObservation) const
Getter for the x value of the observation at the given index.
TrackingUtilities::Vector2D centralize()
Picks one observation as a reference point and transform all observations to that new origin.
void reserve(std::size_t nObservations)
Reserves enough space for nObservations.
void setFitVariance(EFitVariance fitVariance)
Setter for the indicator that the drift variance should be used.
std::size_t appendRange(const ARange &range)
Append all hits from a generic range.
double getY(int iObservation) const
Getter for the y value of the observation at the given index.
bool empty() const
Returns true if there are no observations stored.
TrackingUtilities::Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
bool isForwardTrajectory(const TrackingUtilities::CDCTrajectory2D &trajectory2D) const
Checks if the last position of these observations lies at greater travel distance than the first.
CDCObservations2D(EFitPos fitPos=EFitPos::c_RecoPos, EFitVariance fitVariance=EFitVariance::c_Proper)
Constructor taking the flag if the reconstructed position of the hits should be used when they are av...
std::size_t append(const TrackingUtilities::CDCWireHit &wireHit, TrackingUtilities::ERightLeft rlInfo=TrackingUtilities::ERightLeft::c_Unknown)
Appends the hit circle at wire reference position without a right left passage hypotheses.
void passiveMoveBy(const TrackingUtilities::Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
std::size_t appendRange(const TrackingUtilities::CDCSegment2D &segment2D)
Appends all reconstructed hits from the two dimensional segment.
EFitPos getFitPos() const
Getter for the indicator that the reconstructed position should be favoured.
double getDriftLength(int iObservation) const
Getter for the signed drift radius of the observation at the given index.
double getWeight(int iObservation) const
Getter for the weight / inverse variance of the observation at the given index.
std::size_t fill(double x, double y, double signedRadius=0.0, double weight=1.0)
Appends the observed position.
double getTotalPerpS(const TrackingUtilities::CDCTrajectory2D &trajectory2D) const
Calculate the total transverse travel distance traversed by these observations comparing the travel d...
double * data()
Return the pointer to the number buffer.
TrackingUtilities::Vector2D getFrontPos2D() const
Get the position of the first observation.
void clear()
Removes all observations stored.
EFitVariance m_fitVariance
Indicator which variance information should preferably be extracted from hits in calls to append.
std::size_t size() const
Returns the number of observations stored.
TrackingUtilities::Vector2D getBackPos2D() const
Get the position of the first observation.
TrackingUtilities::EForwardBackward isCoaligned(const TrackingUtilities::CDCTrajectory2D &trajectory2D) const
Checks if the last observation in the vector lies at greater or lower travel distance than the last o...
void setFitPos(EFitPos fitPos)
Setter for the indicator that the reconstructed position should be favoured.
std::size_t getNObservationsWithDriftRadius() const
Returns the number of observations having a drift radius radius.
std::vector< double > m_observations
Memory for the individual observations.
Class representing a pair of reconstructed axial segments in adjacent superlayer.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition CDCFacet.h:32
Class representing a triple of neighboring wire hits.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Class representing a two dimensional reconstructed hit in the central drift chamber.
Class representing a three dimensional reconstructed hit.
A reconstructed sequence of two dimensional hits in one super layer.
A segment consisting of three dimensional reconstructed hits.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:39
Particle trajectory as it is seen in xy projection represented as a circle.
A segment consisting of two dimensional reconstructed hits.
Class representing a hit wire in the central drift chamber.
Definition CDCWireHit.h:58
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition Vector2D.h:36
Abstract base class for different kinds of events.