Belle II Software  release-05-01-25
CDCObservations2D.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2014 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Oliver Frost *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 #pragma once
11 
12 #include <tracking/trackFindingCDC/fitting/EFitPos.h>
13 #include <tracking/trackFindingCDC/fitting/EFitVariance.h>
14 
15 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
16 
17 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
18 #include <tracking/trackFindingCDC/numerics/EForwardBackward.h>
19 
20 #include <vector>
21 #include <iterator>
22 
23 namespace Belle2 {
28  namespace TrackFindingCDC {
29  class CDCTrajectory2D;
30  class CDCWire;
31  class CDCWireHit;
32  class CDCRLWireHit;
33  class CDCRLWireHitPair;
34  class CDCRLWireHitTriple;
35  class CDCFacet;
36  class CDCRecoHit2D;
37  class CDCRecoHit3D;
38  class CDCWireHitSegment;
39  class CDCSegment2D;
40  class CDCSegment3D;
41  class CDCAxialSegmentPair;
42  class CDCTrack;
43 
45  class CDCObservations2D {
46 
47  public:
52  explicit CDCObservations2D(EFitPos fitPos = EFitPos::c_RecoPos,
53  EFitVariance fitVariance = EFitVariance::c_Proper)
54  : m_fitPos(fitPos)
55  , m_fitVariance(fitVariance)
56  {
57  }
58 
59  public:
70  static double getPseudoDriftLengthVariance(double driftLength,
71  double driftLengthVariance)
72  {
73  return driftLength * driftLength + driftLengthVariance;
74  }
75 
77  static double getPseudoDriftLengthVariance(const CDCWireHit& wireHit);
78 
80  std::size_t size() const
81  {
82  return m_observations.size() / 4;
83  }
84 
86  double* data()
87  {
88  return m_observations.data();
89  }
90 
92  bool empty() const
93  {
94  return m_observations.empty();
95  }
96 
98  void clear()
99  {
100  m_observations.clear();
101  }
102 
104  void reserve(std::size_t nObservations)
105  {
106  m_observations.reserve(nObservations * 4);
107  }
108 
110  double getX(int iObservation) const
111  {
112  return m_observations[iObservation * 4];
113  }
114 
116  double getY(int iObservation) const
117  {
118  return m_observations[iObservation * 4 + 1];
119  }
120 
122  double getDriftLength(int iObservation) const
123  {
124  return m_observations[iObservation * 4 + 2];
125  }
126 
128  double getWeight(int iObservation) const
129  {
130  return m_observations[iObservation * 4 + 3];
131  }
132 
146  std::size_t fill(double x, double y, double signedRadius = 0.0, double weight = 1.0);
147 
160  std::size_t fill(const Vector2D& pos2D, double signedRadius = 0.0, double weight = 1.0);
161 
173  std::size_t append(const CDCWireHit& wireHit, ERightLeft rlInfo = ERightLeft::c_Unknown);
174 
185  std::size_t append(const CDCWireHit* wireHit, ERightLeft rlInfo = ERightLeft::c_Unknown);
186 
197  std::size_t append(const CDCRLWireHit& rlWireHit);
198 
200  std::size_t append(const CDCRLWireHitPair& rlWireHitPair);
201 
203  std::size_t append(const CDCRLWireHitTriple& rlWireHitTriple);
204 
206  std::size_t append(const CDCFacet& facet);
207 
209  std::size_t append(const CDCRecoHit2D& recoHit2D);
210 
212  std::size_t append(const CDCRecoHit3D& recoHit3D);
213 
218  std::size_t appendRange(const CDCSegment2D& segment2D);
219 
224  std::size_t appendRange(const CDCSegment3D& segment3D);
225 
230  std::size_t appendRange(const CDCAxialSegmentPair& axialSegmentPair);
231 
236  std::size_t appendRange(const CDCTrack& track);
237 
243  std::size_t appendRange(const std::vector<const CDCWire*>& wires);
244 
250  std::size_t appendRange(const CDCWireHitSegment& wireHits);
251 
253  template<class ARange>
254  std::size_t appendRange(const ARange& range)
255  {
256  std::size_t nAppendedHits = 0;
257  using std::begin;
258  using std::end;
259  for (const auto& item : range) {
260  nAppendedHits += append(item);
261  }
262  return nAppendedHits;
263  }
264 
266  Vector2D getFrontPos2D() const
267  {
268  return empty() ? Vector2D() : Vector2D(getX(0), getY(0));
269  }
270 
272  Vector2D getBackPos2D() const
273  {
274  return empty() ? Vector2D() : Vector2D(getX(size() - 1), getY(size() - 1));
275  }
276 
281  double getTotalPerpS(const CDCTrajectory2D& trajectory2D) const;
282 
287  bool isForwardTrajectory(const CDCTrajectory2D& trajectory2D) const
288  {
289  return getTotalPerpS(trajectory2D) > 0.0;
290  }
291 
297  EForwardBackward isCoaligned(const CDCTrajectory2D& trajectory2D) const
298  {
299  return static_cast<EForwardBackward>(sign(getTotalPerpS(trajectory2D)));
300  }
301 
303  Vector2D getCentralPoint() const;
304 
306  void passiveMoveBy(const Vector2D& origin);
307 
309  Vector2D centralize();
310 
312  std::size_t getNObservationsWithDriftRadius() const;
313 
314  public:
316  EFitPos getFitPos() const
317  {
318  return m_fitPos;
319  }
320 
322  void setFitPos(EFitPos fitPos)
323  {
324  m_fitPos = fitPos;
325  }
326 
328  void setFitVariance(EFitVariance fitVariance)
329  {
330  m_fitVariance = fitVariance;
331  }
332 
333  private:
338  std::vector<double> m_observations;
339 
345  EFitPos m_fitPos;
346 
352  EFitVariance m_fitVariance;
353 
354  };
355 
356  }
358 }
Belle2::TrackFindingCDC::CDCObservations2D::size
std::size_t size() const
Returns the number of observations stored.
Definition: CDCObservations2D.h:88
Belle2::TrackFindingCDC::CDCObservations2D::isCoaligned
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...
Definition: CDCObservations2D.h:305
Belle2::TrackFindingCDC::CDCRecoHit3D
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:62
Belle2::TrackFindingCDC::CDCTrack
Class representing a sequence of three dimensional reconstructed hits.
Definition: CDCTrack.h:51
Belle2::TrackFindingCDC::CDCObservations2D::getX
double getX(int iObservation) const
Getter for the x value of the observation at the given index.
Definition: CDCObservations2D.h:118
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::CDCObservations2D::m_observations
std::vector< double > m_observations
Memory for the individual observations.
Definition: CDCObservations2D.h:346
Belle2::TrackFindingCDC::CDCObservations2D::passiveMoveBy
void passiveMoveBy(const Vector2D &origin)
Moves all observations passively such that the given vector becomes to origin of the new coordinate s...
Definition: CDCObservations2D.cc:347
Belle2::TrackFindingCDC::CDCObservations2D::clear
void clear()
Removes all observations stored.
Definition: CDCObservations2D.h:106
Belle2::TrackFindingCDC::CDCRLWireHitTriple
Class representing a triple of neighboring wire hits.
Definition: CDCRLWireHitTriple.h:45
Belle2::TrackFindingCDC::CDCSegment3D
A segment consisting of three dimensional reconstructed hits.
Definition: CDCSegment3D.h:36
Belle2::TrackFindingCDC::CDCTrajectory2D
Particle trajectory as it is seen in xy projection represented as a circle.
Definition: CDCTrajectory2D.h:46
Belle2::TrackFindingCDC::CDCObservations2D::setFitPos
void setFitPos(EFitPos fitPos)
Setter for the indicator that the reconstructed position should be favoured.
Definition: CDCObservations2D.h:330
Belle2::TrackFindingCDC::CDCObservations2D::getY
double getY(int iObservation) const
Getter for the y value of the observation at the given index.
Definition: CDCObservations2D.h:124
Belle2::TrackFindingCDC::CDCObservations2D::getTotalPerpS
double getTotalPerpS(const CDCTrajectory2D &trajectory2D) const
Calculate the total transvers travel distance traversed by these observations comparing the travel di...
Definition: CDCObservations2D.cc:311
Belle2::TrackFindingCDC::CDCObservations2D::reserve
void reserve(std::size_t nObservations)
Reserves enough space for nObservations.
Definition: CDCObservations2D.h:112
Belle2::TrackFindingCDC::CDCObservations2D::CDCObservations2D
CDCObservations2D(EFitPos fitPos=EFitPos::c_RecoPos, EFitVariance fitVariance=EFitVariance::c_Proper)
Constructor taking the flag if the reconstructed positon of the hits should be used when they are ava...
Definition: CDCObservations2D.h:60
Belle2::TrackFindingCDC::CDCObservations2D::appendRange
std::size_t appendRange(const CDCSegment2D &segment2D)
Appends all reconstructed hits from the two dimensional segment.
Definition: CDCObservations2D.cc:242
Belle2::TrackFindingCDC::CDCWireHitSegment
A segment consisting of two dimensional reconsturcted hits.
Definition: CDCWireHitSegment.h:34
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
Belle2::TrackFindingCDC::CDCObservations2D::empty
bool empty() const
Returns true if there are no observations stored.
Definition: CDCObservations2D.h:100
Belle2::TrackFindingCDC::CDCAxialSegmentPair
Class representing a pair of reconstructed axial segements in adjacent superlayer.
Definition: CDCAxialSegmentPair.h:41
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::CDCObservations2D::getBackPos2D
Vector2D getBackPos2D() const
Get the postion of the first observation.
Definition: CDCObservations2D.h:280
Belle2::TrackFindingCDC::CDCRLWireHit
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:51
Belle2::TrackFindingCDC::CDCObservations2D::getFitPos
EFitPos getFitPos() const
Getter for the indicator that the reconstructed position should be favoured.
Definition: CDCObservations2D.h:324
Belle2::TrackFindingCDC::CDCObservations2D::setFitVariance
void setFitVariance(EFitVariance fitVariance)
Setter for the indicator that the drift variance should be used.
Definition: CDCObservations2D.h:336
Belle2::TrackFindingCDC::NRightLeft::ERightLeft
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:35
Belle2::TrackFindingCDC::CDCObservations2D::getDriftLength
double getDriftLength(int iObservation) const
Getter for the signed drift radius of the observation at the given index.
Definition: CDCObservations2D.h:130
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::CDCRLWireHitPair
A pair of oriented wire hits.
Definition: CDCRLWireHitPair.h:37
Belle2::TrackFindingCDC::CDCObservations2D::getWeight
double getWeight(int iObservation) const
Getter for the weight / inverse variance of the observation at the given index.
Definition: CDCObservations2D.h:136
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::CDCObservations2D::getNObservationsWithDriftRadius
std::size_t getNObservationsWithDriftRadius() const
Returns the number of observations having a drift radius radius.
Definition: CDCObservations2D.cc:316
Belle2::TrackFindingCDC::CDCObservations2D::centralize
Vector2D centralize()
Picks one observation as a reference point and transform all observations to that new origin.
Definition: CDCObservations2D.cc:354
Belle2::TrackFindingCDC::CDCObservations2D::getFrontPos2D
Vector2D getFrontPos2D() const
Get the postion of the first observation.
Definition: CDCObservations2D.h:274
Belle2::TrackFindingCDC::CDCWireHit
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:65
Belle2::TrackFindingCDC::CDCObservations2D::getPseudoDriftLengthVariance
static double getPseudoDriftLengthVariance(double driftLength, double driftLengthVariance)
Gets the pseudo variance.
Definition: CDCObservations2D.h:78
Belle2::TrackFindingCDC::CDCObservations2D::fill
std::size_t fill(double x, double y, double signedRadius=0.0, double weight=1.0)
Appends the observed position.
Belle2::TrackFindingCDC::CDCObservations2D::m_fitPos
EFitPos m_fitPos
Indicator which positional information should preferably be extracted from hits in calls to append.
Definition: CDCObservations2D.h:353
Belle2::TrackFindingCDC::CDCObservations2D::m_fitVariance
EFitVariance m_fitVariance
Indicator which variance information should preferably be extracted from hits in calls to append.
Definition: CDCObservations2D.h:360
Belle2::TrackFindingCDC::CDCObservations2D::data
double * data()
Return the pointer to the number buffer.
Definition: CDCObservations2D.h:94
Belle2::TrackFindingCDC::CDCObservations2D::getCentralPoint
Vector2D getCentralPoint() const
Extracts the observation center that is at the index in the middle.
Definition: CDCObservations2D.cc:330
Belle2::TrackFindingCDC::CDCObservations2D::isForwardTrajectory
bool isForwardTrajectory(const CDCTrajectory2D &trajectory2D) const
Checks if the last position of these observations lies at greater travel distance than the first.
Definition: CDCObservations2D.h:295
Belle2::TrackFindingCDC::CDCObservations2D::append
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.