Belle II Software  release-05-02-19
HitGapSegmentRelationVarSet.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/segmentRelation/HitGapSegmentRelationVarSet.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
13 
14 #include <tracking/trackFindingCDC/numerics/Angle.h>
15 
16 using namespace Belle2;
17 using namespace TrackFindingCDC;
18 
20 {
21  if (not ptrSegmentRelation) return false;
22 
23  const Relation<const CDCSegment2D>& segmentPair = *ptrSegmentRelation;
24 
25  const CDCSegment2D* ptrFromSegment = segmentPair.getFrom();
26  const CDCSegment2D* ptrToSegment = segmentPair.getTo();
27 
28  const CDCSegment2D& fromSegment = *ptrFromSegment;
29  const CDCSegment2D& toSegment = *ptrToSegment;
30 
31  const CDCRecoHit2D& fromFirstHit = fromSegment.front();
32  const CDCRecoHit2D& fromLastHit = fromSegment.back();
33 
34  const CDCRecoHit2D& toFirstHit = toSegment.front();
35  const CDCRecoHit2D& toLastHit = toSegment.back();
36 
37  const Vector2D fromLastHitPos = fromLastHit.getRecoPos2D();
38  const Vector2D fromFirstHitPos = fromFirstHit.getRecoPos2D();
39 
40  const Vector2D toFirstHitPos = toFirstHit.getRecoPos2D();
41  const Vector2D toLastHitPos = toLastHit.getRecoPos2D();
42 
43  const Vector2D hitPosGap = toFirstHitPos - fromLastHitPos;
44  const Vector2D longHitPosGap = toLastHitPos - fromFirstHitPos;
45 
46  const double hitDistance = hitPosGap.norm();
47  const double longHitDistance = longHitPosGap.norm();
48 
49  const Vector2D fromLastHitMom = fromLastHit.getFlightDirection2D();
50  const Vector2D toFirstHitMom = toFirstHit.getFlightDirection2D();
51 
52  finitevar<named("delta_hit_pos_phi")>() = fromLastHitPos.angleWith(toFirstHitPos);
53  finitevar<named("delta_hit_mom_phi")>() = fromLastHitMom.angleWith(toFirstHitMom);
54 
55  double fromLastHitAlpha = fromLastHit.getAlpha();
56  double toFirstHitAlpha = toFirstHit.getAlpha();
57  finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
58 
59  finitevar<named("hit_distance")>() = hitDistance;
60  finitevar<named("hit_long_distance")>() = longHitDistance;
61 
62  finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
63 
64  finitevar<named("from_hit_forward")>() = hitPosGap.dot(fromLastHitMom);
65  finitevar<named("to_hit_forward")>() = hitPosGap.dot(toFirstHitMom);
66  finitevar<named("hit_forward")>() = hitPosGap.dot(Vector2D::average(fromLastHitMom, toFirstHitMom));
67 
68  const Vector2D fromStretch = fromLastHitPos - fromFirstHitPos;
69  const Vector2D toStretch = toLastHitPos - toFirstHitPos;
70 
71  const double fromLength = fromStretch.norm();
72  const double toLength = toStretch.norm();
73 
74  const Vector2D firstPosGap = toFirstHitPos - fromFirstHitPos;
75  const Vector2D lastPosGap = toLastHitPos - fromLastHitPos;
76 
77  const double firstOffset = firstPosGap.norm();
78  const double lastOffset = lastPosGap.norm();
79 
80  finitevar<named("hit_ptolemy")>() =
81  firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
82 
83  return true;
84 }
Belle2::TrackFindingCDC::Relation::getFrom
From * getFrom() const
Getter for the pointer to the from side object.
Definition: Relation.h:69
Belle2::TrackFindingCDC::Relation
Type for two related objects.
Definition: CDCSegment2D.h:37
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< HitGapSegmentRelationVarNames >::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::HitGapSegmentRelationVarSet::extract
bool extract(const Relation< const CDCSegment2D > *ptrSegmentRelation) override
Generate and assign the contained variables.
Definition: HitGapSegmentRelationVarSet.cc:19
Belle2::TrackFindingCDC::Vector2D::dot
double dot(const Vector2D &rhs) const
Calculates the two dimensional dot product.
Definition: Vector2D.h:172
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::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< HitGapSegmentRelationVarNames >::named
constexpr static int named(const char *name)
Getter for the index from the name.
Definition: VarSet.h:88
Belle2::TrackFindingCDC::Relation::getTo
To * getTo() const
Getter for the pointer to the to side object.
Definition: Relation.h:75
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