Belle II Software  release-05-01-25
HitGapAxialSegmentPairVarSet.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - 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/axialSegmentPair/HitGapAxialSegmentPairVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/tracks/CDCAxialSegmentPair.h>
13 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
14 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
15 
16 #include <tracking/trackFindingCDC/numerics/Angle.h>
17 
18 using namespace Belle2;
19 using namespace TrackFindingCDC;
20 
22 {
23  if (not ptrAxialSegmentPair) return false;
24 
25  const CDCAxialSegmentPair& axialSegmentPair = *ptrAxialSegmentPair;
26 
27  const CDCSegment2D* ptrFromSegment = axialSegmentPair.getStartSegment();
28  const CDCSegment2D* ptrToSegment = axialSegmentPair.getEndSegment();
29 
30  const CDCSegment2D& fromSegment = *ptrFromSegment;
31  const CDCSegment2D& toSegment = *ptrToSegment;
32 
33  const CDCRecoHit2D& fromFirstHit = fromSegment.front();
34  const CDCRecoHit2D& fromLastHit = fromSegment.back();
35 
36  const CDCRecoHit2D& toFirstHit = toSegment.front();
37  const CDCRecoHit2D& toLastHit = toSegment.back();
38 
39  const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
40  const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
41 
42  const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
43  const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
44 
45  const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
46  const Vector2D longHitPosGap = toLastHitPos - fromFirstHitPos;
47 
48  const double hitDistance = hitPosGap.norm();
49  const double longHitDistance = longHitPosGap.norm();
50 
51  const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
52  const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
53 
54  finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
55  finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
56 
57  double fromLastHitAlpha = fromLastHit.getAlpha();
58  double toFirstHitAlpha = toFirstHit.getAlpha();
59  finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
60 
61  finitevar<named("hit_distance")>() = hitDistance;
62  finitevar<named("hit_long_distance")>() = longHitDistance;
63 
64  finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
65 
66  finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
67  finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
68  finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
69 
70  const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
71  const Vector2D toStretch = toLastHitPos - toFirstHitPos;
72 
73  const double fromLength = fromStretch.norm();
74  const double toLength = toStretch.norm();
75 
76  const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
77  const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
78 
79  const double firstOffset = firstPosGap.norm();
80  const double lastOffset = lastPosGap.norm();
81 
82  finitevar<named("hit_ptolemy")>() =
83  firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
84 
85  return true;
86 }
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getStartSegment
const CDCAxialSegment2D * getStartSegment() const
Getter for the start segment.
Definition: CDCAxialSegmentPair.h:99
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::VarSet< HitGapAxialSegmentPairVarNames >::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::HitGapAxialSegmentPairVarSet::extract
bool extract(const CDCAxialSegmentPair *ptrAxialSegmentPair) override
Generate and assign the contained variables.
Definition: HitGapAxialSegmentPairVarSet.cc:21
Belle2::TrackFindingCDC::Vector2D::dot
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:172
Belle2::TrackFindingCDC::CDCAxialSegmentPair::getEndSegment
const CDCAxialSegment2D * getEndSegment() const
Getter for the end segment.
Definition: CDCAxialSegmentPair.h:111
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
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::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::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::VarSet< HitGapAxialSegmentPairVarNames >::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::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