Belle II Software  release-08-01-10
CDCRLWireHit.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/eventdata/hits/CDCRLWireHit.h>
9 
10 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/trajectories/CDCTrajectory2D.h>
13 
14 #include <tracking/trackFindingCDC/topology/CDCWire.h>
15 #include <tracking/trackFindingCDC/topology/EStereoKind.h>
16 #include <tracking/trackFindingCDC/topology/ISuperLayer.h>
17 
18 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
19 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
20 
21 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
22 
23 #include <cdc/dataobjects/CDCSimHit.h>
24 
25 #include <framework/logging/Logger.h>
26 
27 #include <ostream>
28 #include <type_traits>
29 
30 using namespace Belle2;
31 using namespace TrackFindingCDC;
32 
33 namespace Belle2 {
38  namespace TrackFindingCDC {
39  class WireLine;
40  }
42 }
44  : CDCRLWireHit(wireHit, rlInfo, wireHit->getRefDriftLength(), wireHit->getRefDriftLengthVariance())
45 {
46 }
47 
49  ERightLeft rlInfo,
50  double driftLength,
51  double driftLengthVariance)
52  : m_wireHit(wireHit)
53  , m_rlInfo(rlInfo)
54  , m_refDriftLength(driftLength)
55  , m_refDriftLengthVariance(driftLengthVariance)
56 {
57 }
58 
60  const CDCRLWireHit& rlWireHit2)
61 {
62  B2ASSERT("Average of two CDCRLWireHits with different wire hits requested.",
63  rlWireHit1.getWireHit() == rlWireHit2.getWireHit());
64 
65  B2ASSERT("Average of two CDCRLWireHits with different right left passage information requested.",
66  rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo());
67 
68  ERightLeft rlInfo = rlWireHit1.getRLInfo();
69  const CDCWireHit& wireHit = rlWireHit1.getWireHit();
70 
71  double driftLength = (rlWireHit1.getRefDriftLength() +
72  rlWireHit2.getRefDriftLength()) / 2.0;
73 
74  double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
75  rlWireHit2.getRefDriftLengthVariance()) / 2.0;
76 
77  CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
78  return result;
79 }
80 
82  const CDCRLWireHit& rlWireHit2,
83  const CDCRLWireHit& rlWireHit3)
84 {
85  B2ASSERT("Average of three CDCRLWireHits with different wire hits requested.",
86  rlWireHit1.getWireHit() == rlWireHit2.getWireHit() and
87  rlWireHit2.getWireHit() == rlWireHit3.getWireHit());
88 
89  B2ASSERT("Average of three CDCRLWireHits with different right left passage information requested.",
90  rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo() and
91  rlWireHit2.getRLInfo() == rlWireHit3.getRLInfo());
92 
93 
94  ERightLeft rlInfo = rlWireHit1.getRLInfo();
95  const CDCWireHit& wireHit = rlWireHit1.getWireHit();
96 
97  double driftLength = (rlWireHit1.getRefDriftLength() +
98  rlWireHit2.getRefDriftLength() +
99  rlWireHit3.getRefDriftLength()) / 3.0;
100 
101  double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
102  rlWireHit2.getRefDriftLengthVariance() +
103  rlWireHit3.getRefDriftLengthVariance()) / 3.0;
104 
105  CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
106  return result;
107 }
108 
109 
111  const CDCSimHit& simhit)
112 {
113  // find out if the wire is right or left of the track ( view in flight direction )
114  Vector3D trackPosToWire{simhit.getPosWire() - simhit.getPosTrack()};
115  Vector3D directionOfFlight{simhit.getMomentum()};
116 
117  ERightLeft rlInfo = trackPosToWire.xy().isRightOrLeftOf(directionOfFlight.xy());
118 
119  CDCRLWireHit rlWireHit(wirehit, rlInfo, simhit.getDriftLength(), CDCWireHit::c_simpleDriftLengthVariance);
120 
121  return rlWireHit;
122 }
123 
125 {
126  return getWireHit().getHit();
127 }
128 
130 {
131  return getWireHit().getWire();
132 }
133 
135 {
136  return getWire().getWireID();
137 }
138 
139 ISuperLayer CDCRLWireHit::getISuperLayer() const
140 {
141  return getWire().getISuperLayer();
142 }
143 
144 EStereoKind CDCRLWireHit::getStereoKind() const
145 {
146  return getWire().getStereoKind();
147 }
148 
150 {
151  return getWire().isAxial();
152 }
153 
155 {
156  return getWire().getRefPos2D();
157 }
158 
160 {
161  return getWire().getRefCylindricalR();
162 }
163 
165 {
166  const Vector2D& refPos2D = getRefPos2D();
167  Vector2D recoPos2D = trajectory2D.getClosest(refPos2D);
168 
169  const Vector2D& wirePos2D = getWire().getRefPos2D();
170  const double driftLength = getRefDriftLength();
171 
172  Vector2D disp2D = recoPos2D - wirePos2D;
173 
174  // Fix the displacement to lie on the drift circle.
175  disp2D.normalizeTo(driftLength);
176  return wirePos2D + disp2D;
177 }
178 
179 Vector3D CDCRLWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D, const double z) const
180 {
181  const EStereoKind stereoType = getStereoKind();
182  const ERightLeft rlInfo = getRLInfo();
183 
184  if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
185  const WireLine& wireLine = getWire().getWireLine();
186  const double signedDriftLength = isValid(rlInfo) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
187  return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
188 
189  } else { /*if (stereoType == EStereoKind::c_Axial)*/
190  const Vector2D recoPos2D = reconstruct2D(trajectory2D);
191  // for axial wire we can not determine the z coordinate by looking at the xy projection only
192  // we set it the basic assumption.
193  return Vector3D(recoPos2D, z);
194  }
195 }
196 
197 std::ostream& TrackFindingCDC::operator<<(std::ostream& output, const CDCRLWireHit& rlWireHit)
198 {
199  output << "CDCRLWireHit(" << rlWireHit.getWireHit() << ","
200  << static_cast<typename std::underlying_type<ERightLeft>::type>(rlWireHit.getRLInfo()) << ")" ;
201  return output;
202 }
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition: CDCHit.h:40
Example Detector.
Definition: CDCSimHit.h:21
B2Vector3D getPosWire() const
The method to get position on wire.
Definition: CDCSimHit.h:199
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition: CDCSimHit.h:217
double getDriftLength() const
The method to get drift length.
Definition: CDCSimHit.h:181
B2Vector3D getMomentum() const
The method to get momentum.
Definition: CDCSimHit.h:193
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
Definition: CDCRLWireHit.h:41
double getRefCylindricalR() const
The distance from the beam line at reference position of the underlying wire.
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
ISuperLayer getISuperLayer() const
Getter for the superlayer id.
double getRefDriftLengthVariance() const
Getter for the variance of the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:222
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:204
const WireID & getWireID() const
Getter for the WireID of the wire the hit is located on.
bool isAxial() const
Indicator if the underlying wire is axial.
CDCRLWireHit()=default
Default constructor for ROOT.
const CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
static CDCRLWireHit fromSimHit(const CDCWireHit *wirehit, const CDCSimHit &simhit)
Constructs an oriented wire hit from a CDCSimHit and the associated wirehit.
static CDCRLWireHit average(const CDCRLWireHit &rlWireHit1, const CDCRLWireHit &rlWireHit2)
Constructs the average of two wire hits with right left passage informations.
Definition: CDCRLWireHit.cc:59
Vector2D reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
const Vector2D & getRefPos2D() const
The two dimensional reference position of the underlying wire.
EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
Definition: CDCRLWireHit.h:192
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRLWireHit.h:234
Vector3D reconstruct3D(const CDCTrajectory2D &trajectory2D, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
Particle trajectory as it is seen in xy projection represented as a circle.
Vector2D getClosest(const Vector2D &point) const
Calculates the closest approach on the trajectory to the given point.
Vector3D reconstruct3D(const WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional postions within the CDC closest to the given z where the given drift ...
Class representing a hit wire in the central drift chamber.
Definition: CDCWireHit.h:55
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:159
static constexpr const double c_simpleDriftLengthVariance
A default value for the drift length variance if no variance from the drift length translation is ava...
Definition: CDCWireHit.h:64
const CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition: CDCWireHit.h:168
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:58
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition: CDCWire.h:260
ISuperLayer getISuperLayer() const
Gives the superlayer id ranging from 0 - 8.
Definition: CDCWire.h:163
bool isAxial() const
Indicates if the wire is axial or stereo.
Definition: CDCWire.h:174
const WireLine & getWireLine() const
Getter for the wire line represenation of the wire.
Definition: CDCWire.h:188
const Vector2D & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition: CDCWire.h:229
const WireID & getWireID() const
Getter for the wire id.
Definition: CDCWire.h:122
EStereoKind getStereoKind() const
Getter for the stereo type of the wire.
Definition: CDCWire.h:184
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:35
double normalizeTo(const double toLength)
Normalizes the vector to the given length.
Definition: Vector2D.h:325
A three dimensional vector.
Definition: Vector3D.h:33
A three dimensional limited line represented by its closest approach to the z-axes (reference positio...
Definition: WireLine.h:31
Class to identify a wire inside the CDC.
Definition: WireID.h:34
std::ostream & operator<<(std::ostream &output, const IntervalOfValidity &iov)
HepGeom::Vector3D< double > Vector3D
3D Vector
Definition: Cell.h:34
ERightLeft
Enumeration to represent the distinct possibilities of the right left passage.
Definition: ERightLeft.h:25
Abstract base class for different kinds of events.