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