Belle II Software  release-05-01-25
HitGapSegmentPairVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - 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 #include <tracking/trackFindingCDC/filters/segmentPair/HitGapSegmentPairVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCSegmentPair.h>
13 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
14 
15 #include <tracking/trackFindingCDC/topology/CDCWire.h>
16 
17 #include <tracking/trackFindingCDC/numerics/Angle.h>
18 
19 using namespace Belle2;
20 using namespace TrackFindingCDC;
21 
23 {
24  if (not ptrSegmentPair) return false;
25 
26  const CDCSegmentPair& segmentPair = *ptrSegmentPair;
27 
28  const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
29  const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
30 
31  const CDCSegment2D& fromSegment = *ptrFromSegment;
32  const CDCSegment2D& toSegment = *ptrToSegment;
33 
34  const CDCRecoHit2D& fromFirstHit = fromSegment.front();
35  const CDCRecoHit2D& fromLastHit = fromSegment.back();
36 
37  const CDCRecoHit2D& toFirstHit = toSegment.front();
38  const CDCRecoHit2D& toLastHit = toSegment.back();
39 
40  const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
41  const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
42 
43  const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
44  const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
45 
46  const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
47  const Vector2D longHitPosGap = toLastHitPos - fromFirstHitPos;
48 
49  const double hitDistance = hitPosGap.norm();
50  const double longHitDistance = longHitPosGap.norm();
51 
52  const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
53  const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
54 
55  finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
56  finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
57 
58  double fromLastHitAlpha = fromLastHit.getAlpha();
59  double toFirstHitAlpha = toFirstHit.getAlpha();
60  finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
61 
62  finitevar<named("hit_distance")>() = hitDistance;
63  finitevar<named("hit_long_distance")>() = longHitDistance;
64 
65  finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
66 
67  finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
68  finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
69  finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
70 
71  const CDCRecoHit2D& axialHit = toFirstHit.isAxial() ? toFirstHit : fromLastHit;
72  const CDCRecoHit2D& stereoHit = not toFirstHit.isAxial() ? toFirstHit : fromLastHit;
73 
74  const Vector2D axialHitPos = axialHit.getRecoPos2D();
75  const Vector2D axialHitMom = axialHit.getFlightDirection2D();
76 
77  const CDCWire& stereoWire = stereoHit.getWire();
78  const WireLine& wireLine = stereoWire.getWireLine();
79 
80  // Caluculate point were the wire is first method
81  Vector2D relRefPos = wireLine.refPos2D() - axialHitPos;
82  Vector2D movePerZ = wireLine.nominalMovePerZ();
83 
84  double z = -relRefPos.cross(axialHitMom) / movePerZ.cross(axialHitMom);
85  Vector2D stereoHitPos = stereoHit.getRecoPos2D() + movePerZ * z;
86 
87  finitevar<named("hit_reco_z")>() = z;
88  finitevar<named("hit_z_bound_factor")>() = wireLine.outOfZBoundsFactor(z);
89  double arcLengthGap = (stereoHitPos - axialHitPos).dot(axialHitMom);
90  finitevar<named("hit_arclength_gap")>() = toFirstHit.isAxial() ? -arcLengthGap : arcLengthGap;
91 
92  // const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
93  // const Vector2D toStretch = toLastHitPos - toFirstHitPos;
94 
95  // const double fromLength = fromStretch.norm();
96  // const double toLength = toStretch.norm();
97 
98  // const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
99  // const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
100 
101  // const double firstOffset = firstPosGap.norm();
102  // const double lastOffset = lastPosGap.norm();
103 
104  // finitevar<named("hit_ptolemy")>() =
105  // firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
106 
107  return true;
108 }
Belle2::TrackFindingCDC::CDCSegmentPair
Class representing a pair of one reconstructed axial segement and one stereo segment in adjacent supe...
Definition: CDCSegmentPair.h:44
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::CDCRecoHit2D::getRecoPos2D
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:248
Belle2::TrackFindingCDC::HitGapSegmentPairVarSet::extract
bool extract(const CDCSegmentPair *ptrSegmentPair) override
Generate and assign the contained variables.
Definition: HitGapSegmentPairVarSet.cc:22
Belle2::TrackFindingCDC::VarSet< HitGapSegmentPairVarNames >::finitevar
AssignFinite< Float_t > finitevar()
Reference getter for the value of the ith variable. Transforms non-finite values to finite value.
Definition: VarSet.h:140
Belle2::TrackFindingCDC::Vector2D::dot
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:172
Belle2::TrackFindingCDC::CDCSegmentPair::getToSegment
const CDCSegment2D * getToSegment() const
Getter for the to segment.
Definition: CDCSegmentPair.h:132
Belle2::TrackFindingCDC::Vector2D::cross
double cross(const Vector2D &rhs) const
Calculated the two dimensional cross product.
Definition: Vector2D.h:177
Belle2::TrackFindingCDC::WireLine::refPos2D
const Vector2D & refPos2D() const
Returns the xy vector of the reference position.
Definition: WireLine.h:233
Belle2::TrackFindingCDC::CDCRecoHit2D::getWire
const CDCWire & getWire() const
Getter for the wire the reconstructed hit assoziated to.
Definition: CDCRecoHit2D.h:185
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::TrackFindingCDC::WireLine
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:41
Belle2::TrackFindingCDC::WireLine::nominalMovePerZ
const Vector2D & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition: WireLine.h:81
Belle2::TrackFindingCDC::CDCWire::getWireLine
const WireLine & getWireLine() const
Getter for the wire line represenation of the wire.
Definition: CDCWire.h:190
Belle2::TrackFindingCDC::CDCRecoHit2D::isAxial
bool isAxial() const
Indicator if the underlying wire is axial.
Definition: CDCRecoHit2D.h:173
Belle2::TrackFindingCDC::WireLine::outOfZBoundsFactor
double outOfZBoundsFactor(double z) const
Returns the amount how much the given z position is outside the bounds in units of the wire length.
Definition: WireLine.h:152
Belle2::TrackFindingCDC::Vector2D::norm
double norm() const
Calculates the length of the vector.
Definition: Vector2D.h:189
Belle2::TrackFindingCDC::CDCRecoHit2D::getAlpha
double getAlpha() const
Getter for the direction of flight relative to the position.
Definition: CDCRecoHit2D.h:273
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< HitGapSegmentPairVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::CDCSegmentPair::getFromSegment
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
Definition: CDCSegmentPair.h:120
Belle2::TrackFindingCDC::CDCRecoHit2D::getFlightDirection2D
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit2D.h:266
Belle2::TrackFindingCDC::AngleUtil::normalised
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition: Angle.h:43
Belle2::TrackFindingCDC::Vector2D::average
static Vector2D average(const Vector2D &one, const Vector2D &two)
Constructs the average of two vectors.
Definition: Vector2D.h:95