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/trackFindingCDC/geometry/Vector2D.h>
14
15#include <tracking/trackFindingCDC/numerics/ERightLeft.h>
16#include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
17
18#include <vector>
19#include <iterator>
20
21namespace Belle2 {
26 namespace TrackFindingCDC {
27 class CDCTrajectory2D;
28 class CDCWire;
29 class CDCWireHit;
30 class CDCRLWireHit;
31 class CDCRLWireHitPair;
32 class CDCRLWireHitTriple;
33 class CDCFacet;
34 class CDCRecoHit2D;
35 class CDCRecoHit3D;
36 class CDCWireHitSegment;
37 class CDCSegment2D;
38 class CDCSegment3D;
39 class CDCAxialSegmentPair;
40 class CDCTrack;
41
44
45 public:
50 explicit CDCObservations2D(EFitPos fitPos = EFitPos::c_RecoPos,
51 EFitVariance fitVariance = EFitVariance::c_Proper)
52 : m_fitPos(fitPos)
53 , m_fitVariance(fitVariance)
54 {
55 }
56
57 public:
68 static double getPseudoDriftLengthVariance(double driftLength,
69 double driftLengthVariance)
70 {
71 return driftLength * driftLength + driftLengthVariance;
72 }
73
75 static double getPseudoDriftLengthVariance(const CDCWireHit& wireHit);
76
78 std::size_t size() const
79 {
80 return m_observations.size() / 4;
81 }
82
84 double* data()
85 {
86 return m_observations.data();
87 }
88
90 bool empty() const
91 {
92 return m_observations.empty();
93 }
94
96 void clear()
97 {
98 m_observations.clear();
99 }
100
102 void reserve(std::size_t nObservations)
103 {
104 m_observations.reserve(nObservations * 4);
105 }
106
108 double getX(int iObservation) const
109 {
110 return m_observations[iObservation * 4];
111 }
112
114 double getY(int iObservation) const
115 {
116 return m_observations[iObservation * 4 + 1];
117 }
118
120 double getDriftLength(int iObservation) const
121 {
122 return m_observations[iObservation * 4 + 2];
123 }
124
126 double getWeight(int iObservation) const
127 {
128 return m_observations[iObservation * 4 + 3];
129 }
130
144 std::size_t fill(double x, double y, double signedRadius = 0.0, double weight = 1.0);
145
158 std::size_t fill(const Vector2D& pos2D, double signedRadius = 0.0, double weight = 1.0);
159
171 std::size_t append(const CDCWireHit& wireHit, ERightLeft rlInfo = ERightLeft::c_Unknown);
172
183 std::size_t append(const CDCWireHit* wireHit, ERightLeft rlInfo = ERightLeft::c_Unknown);
184
195 std::size_t append(const CDCRLWireHit& rlWireHit);
196
198 std::size_t append(const CDCRLWireHitPair& rlWireHitPair);
199
201 std::size_t append(const CDCRLWireHitTriple& rlWireHitTriple);
202
204 std::size_t append(const CDCFacet& facet);
205
207 std::size_t append(const CDCRecoHit2D& recoHit2D);
208
210 std::size_t append(const CDCRecoHit3D& recoHit3D);
211
216 std::size_t appendRange(const CDCSegment2D& segment2D);
217
222 std::size_t appendRange(const CDCSegment3D& segment3D);
223
228 std::size_t appendRange(const CDCAxialSegmentPair& axialSegmentPair);
229
234 std::size_t appendRange(const CDCTrack& track);
235
241 std::size_t appendRange(const std::vector<const CDCWire*>& wires);
242
248 std::size_t appendRange(const CDCWireHitSegment& wireHits);
249
251 template<class ARange>
252 std::size_t appendRange(const ARange& range)
253 {
254 std::size_t nAppendedHits = 0;
255 using std::begin;
256 using std::end;
257 for (const auto& item : range) {
258 nAppendedHits += append(item);
259 }
260 return nAppendedHits;
261 }
262
265 {
266 return empty() ? Vector2D() : Vector2D(getX(0), getY(0));
267 }
268
271 {
272 return empty() ? Vector2D() : Vector2D(getX(size() - 1), getY(size() - 1));
273 }
274
279 double getTotalPerpS(const CDCTrajectory2D& trajectory2D) const;
280
285 bool isForwardTrajectory(const CDCTrajectory2D& trajectory2D) const
286 {
287 return getTotalPerpS(trajectory2D) > 0.0;
288 }
289
296 {
297 return static_cast<EForwardBackward>(sign(getTotalPerpS(trajectory2D)));
298 }
299
302
304 void passiveMoveBy(const Vector2D& origin);
305
308
310 std::size_t getNObservationsWithDriftRadius() const;
311
312 public:
314 EFitPos getFitPos() const
315 {
316 return m_fitPos;
317 }
318
320 void setFitPos(EFitPos fitPos)
321 {
322 m_fitPos = fitPos;
323 }
324
326 void setFitVariance(EFitVariance fitVariance)
327 {
328 m_fitVariance = fitVariance;
329 }
330
331 private:
336 std::vector<double> m_observations;
337
343 EFitPos m_fitPos;
344
350 EFitVariance m_fitVariance;
351
352 };
353
354 }
356}
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 serving as a storage of observed drift circles to present to the Riemann fitter.
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.
Vector2D getBackPos2D() const
Get the position of the first observation.
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.
Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
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 CDCWireHit &wireHit, ERightLeft rlInfo=ERightLeft::c_Unknown)
Appends the hit circle at wire reference position without a right left passage hypotheses.
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.
Vector2D getFrontPos2D() const
Get the position of the first observation.
std::size_t appendRange(const CDCSegment2D &segment2D)
Appends all reconstructed hits from the two dimensional segment.
std::size_t fill(double x, double y, double signedRadius=0.0, double weight=1.0)
Appends the observed position.
double * data()
Return the pointer to the number buffer.
void passiveMoveBy(const Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
double getTotalPerpS(const CDCTrajectory2D &trajectory2D) const
Calculate the total transverse travel distance traversed by these observations comparing the travel d...
EForwardBackward isCoaligned(const CDCTrajectory2D &trajectory2D) const
Checks if the last observation in the vector lies at greater or lower travel distance than the last o...
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.
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.
bool isForwardTrajectory(const CDCTrajectory2D &trajectory2D) const
Checks if the last position of these observations lies at greater travel distance than the first.
std::vector< double > m_observations
Memory for the individual observations.
Class representing a triple of neighboring wire hits.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:47
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:52
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:39
A segment consisting of three dimensional reconstructed hits.
Definition: CDCSegment3D.h:26
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:41
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:55
A two dimensional vector which is equipped with functions for correct handling of orientation relate...
Definition: Vector2D.h:32
EForwardBackward
Enumeration to represent the distinct possibilities of the right left passage information.
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.