Belle II Software development
HitGapSegmentPairVarSet.cc
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#include <tracking/trackFindingCDC/filters/segmentPair/HitGapSegmentPairVarSet.h>
9
10#include <tracking/trackingUtilities/eventdata/tracks/CDCSegmentPair.h>
11#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
12#include <tracking/trackingUtilities/geometry/VectorUtil.h>
13#include <tracking/trackingUtilities/numerics/Angle.h>
14
15#include <cdc/topology/CDCWire.h>
16
17#include <framework/geometry/VectorUtil.h>
18
19#include <Math/Vector2D.h>
20#include <Math/VectorUtil.h>
21
22using namespace Belle2;
23using namespace CDC;
24using namespace TrackFindingCDC;
25using namespace TrackingUtilities;
26
28{
29 if (not ptrSegmentPair) return false;
30
31 const CDCSegmentPair& segmentPair = *ptrSegmentPair;
32
33 const CDCSegment2D* ptrFromSegment = segmentPair.getFromSegment();
34 const CDCSegment2D* ptrToSegment = segmentPair.getToSegment();
35
36 const CDCSegment2D& fromSegment = *ptrFromSegment;
37 const CDCSegment2D& toSegment = *ptrToSegment;
38
39 const CDCRecoHit2D& fromFirstHit = fromSegment.front();
40 const CDCRecoHit2D& fromLastHit = fromSegment.back();
41
42 const CDCRecoHit2D& toFirstHit = toSegment.front();
43 const CDCRecoHit2D& toLastHit = toSegment.back();
44
45 const ROOT::Math::XYVector fromLastHitPos = fromLastHit.getRecoPos2D();
46 const ROOT::Math::XYVector fromFirstHitPos = fromFirstHit.getRecoPos2D();
47
48 const ROOT::Math::XYVector toFirstHitPos = toFirstHit.getRecoPos2D();
49 const ROOT::Math::XYVector toLastHitPos = toLastHit.getRecoPos2D();
50
51 const ROOT::Math::XYVector hitPosGap = toFirstHitPos - fromLastHitPos;
52 const ROOT::Math::XYVector longHitPosGap = toLastHitPos - fromFirstHitPos;
53
54 const double hitDistance = hitPosGap.R();
55 const double longHitDistance = longHitPosGap.R();
56
57 const ROOT::Math::XYVector fromLastHitMom = fromLastHit.getFlightDirection2D();
58 const ROOT::Math::XYVector toFirstHitMom = toFirstHit.getFlightDirection2D();
59
60 finitevar<named("delta_hit_pos_phi")>() = ROOT::Math::VectorUtil::DeltaPhi(fromLastHitPos, toFirstHitPos);
61 finitevar<named("delta_hit_mom_phi")>() = ROOT::Math::VectorUtil::DeltaPhi(fromLastHitMom, toFirstHitMom);
62
63 double fromLastHitAlpha = fromLastHit.getAlpha();
64 double toFirstHitAlpha = toFirstHit.getAlpha();
65 finitevar<named("delta_hit_alpha")>() = AngleUtil::normalised(toFirstHitAlpha - fromLastHitAlpha);
66
67 finitevar<named("hit_distance")>() = hitDistance;
68 finitevar<named("hit_long_distance")>() = longHitDistance;
69
70 finitevar<named("delta_hit_distance")>() = longHitDistance - hitDistance;
71
72 finitevar<named("from_hit_forward")>() = hitPosGap.Dot(fromLastHitMom);
73 finitevar<named("to_hit_forward")>() = hitPosGap.Dot(toFirstHitMom);
74 finitevar<named("hit_forward")>() = hitPosGap.Dot(VectorUtil::average(fromLastHitMom, toFirstHitMom));
75
76 const CDCRecoHit2D& axialHit = toFirstHit.isAxial() ? toFirstHit : fromLastHit;
77 const CDCRecoHit2D& stereoHit = not toFirstHit.isAxial() ? toFirstHit : fromLastHit;
78
79 const ROOT::Math::XYVector axialHitPos = axialHit.getRecoPos2D();
80 const ROOT::Math::XYVector axialHitMom = axialHit.getFlightDirection2D();
81
82 const CDCWire& stereoWire = stereoHit.getWire();
83 const WireLine& wireLine = stereoWire.getWireLine();
84
85 // Calculate point were the wire is first method
86 ROOT::Math::XYVector relRefPos = wireLine.refPos2D() - axialHitPos;
87 ROOT::Math::XYVector movePerZ = wireLine.nominalMovePerZ();
88
89 double z = VectorUtil::Cross(-relRefPos, axialHitMom) / VectorUtil::Cross(movePerZ, axialHitMom);
90 ROOT::Math::XYVector stereoHitPos = stereoHit.getRecoPos2D() + movePerZ * z;
91
92 finitevar<named("hit_reco_z")>() = z;
93 finitevar<named("hit_z_bound_factor")>() = wireLine.outOfZBoundsFactor(z);
94 double arcLengthGap = (stereoHitPos - axialHitPos).Dot(axialHitMom);
95 finitevar<named("hit_arclength_gap")>() = toFirstHit.isAxial() ? -arcLengthGap : arcLengthGap;
96
97 // const ROOT::Math::XYVector fromStretch = fromLastHitPos - fromFirstHitPos;
98 // const ROOT::Math::XYVector toStretch = toLastHitPos - toFirstHitPos;
99
100 // const double fromLength = fromStretch.R();
101 // const double toLength = toStretch.R();
102
103 // const ROOT::Math::XYVector firstPosGap = toFirstHitPos - fromFirstHitPos;
104 // const ROOT::Math::XYVector lastPosGap = toLastHitPos - fromLastHitPos;
105
106 // const double firstOffset = firstPosGap.R();
107 // const double lastOffset = lastPosGap.R();
108
109 // finitevar<named("hit_ptolemy")>() =
110 // firstOffset * lastOffset - longHitDistance * hitDistance - fromLength * toLength;
111
112 return true;
113}
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
const WireLine & getWireLine() const
Getter for the wire line representation of the wire.
Definition CDCWire.h:180
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition WireLine.h:33
const ROOT::Math::XYVector & nominalMovePerZ() const
Gives the positional move in the xy projection per unit z.
Definition WireLine.h:79
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:160
const ROOT::Math::XYVector & refPos2D() const
Returns the xy vector of the reference position.
Definition WireLine.h:241
bool extract(const TrackingUtilities::CDCSegmentPair *ptrSegmentPair) override
Generate and assign the contained variables.
Class representing a two dimensional reconstructed hit in the central drift chamber.
bool isAxial() const
Indicator if the underlying wire is axial.
ROOT::Math::XYVector getFlightDirection2D() const
Getter for the direction of flight.
ROOT::Math::XYVector getRecoPos2D() const
Getter for the position in the reference plane.
const CDC::CDCWire & getWire() const
Getter for the wire the reconstructed hit associated to.
double getAlpha() const
Getter for the direction of flight relative to the position.
A reconstructed sequence of two dimensional hits in one super layer.
Class representing a pair of one reconstructed axial segment and one stereo segment in adjacent super...
const CDCSegment2D * getToSegment() const
Getter for the to segment.
const CDCSegment2D * getFromSegment() const
Getter for the from segment.
static constexpr int named(const char *name)
Definition VarSet.h:78
Abstract base class for different kinds of events.
static double normalised(const double angle)
Normalise an angle to lie in the range from [-pi, pi].
Definition Angle.h:33