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/numerics/ESign.h>
14#include <tracking/trackingUtilities/numerics/ERightLeft.h>
15#include <tracking/trackingUtilities/numerics/EForwardBackward.h>
16
17#include <Math/Vector2D.h>
18
19#include <vector>
20#include <iterator>
21
22namespace Belle2 {
27 namespace CDC {
28 class CDCWire;
29 }
30
31 namespace TrackingUtilities {
32 class CDCRLWireHit;
33 class CDCTrajectory2D;
34 class CDCWireHit;
35 class CDCTrack;
36 class CDCRecoHit3D;
37 class CDCRecoHit2D;
38 class CDCRLWireHitPair;
40 class CDCFacet;
42 class CDCSegment2D;
43 class CDCSegment3D;
45 }
46 namespace TrackFindingCDC {
47
50
51 public:
56 explicit CDCObservations2D(EFitPos fitPos = EFitPos::c_RecoPos,
57 EFitVariance fitVariance = EFitVariance::c_Proper)
58 : m_fitPos(fitPos)
59 , m_fitVariance(fitVariance)
60 {
61 }
62
63 public:
74 static double getPseudoDriftLengthVariance(double driftLength,
75 double driftLengthVariance)
76 {
77 return driftLength * driftLength + driftLengthVariance;
78 }
79
82
84 std::size_t size() const
85 {
86 return m_observations.size() / 4;
87 }
88
90 double* data()
91 {
92 return m_observations.data();
93 }
94
96 bool empty() const
97 {
98 return m_observations.empty();
99 }
100
102 void clear()
103 {
104 m_observations.clear();
105 }
106
108 void reserve(std::size_t nObservations)
109 {
110 m_observations.reserve(nObservations * 4);
111 }
112
114 double getX(int iObservation) const
115 {
116 return m_observations[iObservation * 4];
117 }
118
120 double getY(int iObservation) const
121 {
122 return m_observations[iObservation * 4 + 1];
123 }
124
126 double getDriftLength(int iObservation) const
127 {
128 return m_observations[iObservation * 4 + 2];
129 }
130
132 double getWeight(int iObservation) const
133 {
134 return m_observations[iObservation * 4 + 3];
135 }
136
150 std::size_t fill(double x, double y, double signedRadius = 0.0, double weight = 1.0);
151
164 std::size_t fill(const ROOT::Math::XYVector& pos2D, double signedRadius = 0.0, double weight = 1.0);
165
177 std::size_t append(const TrackingUtilities::CDCWireHit& wireHit,
178 TrackingUtilities::ERightLeft rlInfo = TrackingUtilities::ERightLeft::c_Unknown);
179
190 std::size_t append(const TrackingUtilities::CDCWireHit* wireHit,
191 TrackingUtilities::ERightLeft rlInfo = TrackingUtilities::ERightLeft::c_Unknown);
192
203 std::size_t append(const TrackingUtilities::CDCRLWireHit& rlWireHit);
204
206 std::size_t append(const TrackingUtilities::CDCRLWireHitPair& rlWireHitPair);
207
209 std::size_t append(const TrackingUtilities::CDCRLWireHitTriple& rlWireHitTriple);
210
212 std::size_t append(const TrackingUtilities::CDCFacet& facet);
213
215 std::size_t append(const TrackingUtilities::CDCRecoHit2D& recoHit2D);
216
218 std::size_t append(const TrackingUtilities::CDCRecoHit3D& recoHit3D);
219
224 std::size_t appendRange(const TrackingUtilities::CDCSegment2D& segment2D);
225
230 std::size_t appendRange(const TrackingUtilities::CDCSegment3D& segment3D);
231
236 std::size_t appendRange(const TrackingUtilities::CDCAxialSegmentPair& axialSegmentPair);
237
242 std::size_t appendRange(const TrackingUtilities::CDCTrack& track);
243
249 std::size_t appendRange(const std::vector<const CDC::CDCWire*>& wires);
250
256 std::size_t appendRange(const TrackingUtilities::CDCWireHitSegment& wireHits);
257
259 template<class ARange>
260 std::size_t appendRange(const ARange& range)
261 {
262 std::size_t nAppendedHits = 0;
263 using std::begin;
264 using std::end;
265 for (const auto& item : range) {
266 nAppendedHits += append(item);
267 }
268 return nAppendedHits;
269 }
270
272 ROOT::Math::XYVector getFrontPos2D() const
273 {
274 return empty() ? ROOT::Math::XYVector() : ROOT::Math::XYVector(getX(0), getY(0));
275 }
276
278 ROOT::Math::XYVector getBackPos2D() const
279 {
280 return empty() ? ROOT::Math::XYVector() : ROOT::Math::XYVector(getX(size() - 1), getY(size() - 1));
281 }
282
287 double getTotalPerpS(const TrackingUtilities::CDCTrajectory2D& trajectory2D) const;
288
294 {
295 return getTotalPerpS(trajectory2D) > 0.0;
296 }
297
303 TrackingUtilities::EForwardBackward isCoaligned(const TrackingUtilities::CDCTrajectory2D& trajectory2D) const
304 {
305 return static_cast<TrackingUtilities::EForwardBackward>(TrackingUtilities::sign(getTotalPerpS(trajectory2D)));
306 }
307
309 ROOT::Math::XYVector getCentralPoint() const;
310
312 void passiveMoveBy(const ROOT::Math::XYVector& origin);
313
315 ROOT::Math::XYVector centralize();
316
318 std::size_t getNObservationsWithDriftRadius() const;
319
320 public:
322 EFitPos getFitPos() const
323 {
324 return m_fitPos;
325 }
326
328 void setFitPos(EFitPos fitPos)
329 {
330 m_fitPos = fitPos;
331 }
332
334 void setFitVariance(EFitVariance fitVariance)
335 {
336 m_fitVariance = fitVariance;
337 }
338
339 private:
344 std::vector<double> m_observations;
345
351 EFitPos m_fitPos;
352
358 EFitVariance m_fitVariance;
359
360 };
361
362 }
364}
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.
ROOT::Math::XYVector getBackPos2D() const
Get the position of the first observation.
ROOT::Math::XYVector getFrontPos2D() const
Get the position of the first observation.
ROOT::Math::XYVector centralize()
Picks one observation as a reference point and transform all observations to that new origin.
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.
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.
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.
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.
void clear()
Removes all observations stored.
void passiveMoveBy(const ROOT::Math::XYVector &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
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::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.
ROOT::Math::XYVector getCentralPoint() const
Extracts the observation center that is at the index in the middle.
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:33
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:37
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:56
Abstract base class for different kinds of events.