Belle II Software development
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/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
9
10#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
11
12#include <tracking/trackingUtilities/eventdata/trajectories/CDCTrajectory2D.h>
13
14#include <cdc/topology/CDCWire.h>
15#include <cdc/topology/EStereoKind.h>
16#include <cdc/topology/ISuperLayer.h>
17
18#include <tracking/trackingUtilities/numerics/ERightLeft.h>
19
20#include <cdc/dataobjects/CDCSimHit.h>
21
22#include <framework/logging/Logger.h>
23
24#include <ostream>
25#include <type_traits>
26
27using namespace Belle2;
28using namespace CDC;
29using namespace TrackingUtilities;
30
31namespace Belle2 {
36 namespace CDC {
37 class WireLine;
38 }
40}
41CDCRLWireHit::CDCRLWireHit(const CDCWireHit* wireHit, ERightLeft rlInfo)
42 : CDCRLWireHit(wireHit, rlInfo, wireHit->getRefDriftLength(), wireHit->getRefDriftLengthVariance())
43{
44}
45
47 ERightLeft rlInfo,
48 double driftLength,
49 double driftLengthVariance)
50 : m_wireHit(wireHit)
51 , m_refDriftLength(driftLength)
52 , m_refDriftLengthVariance(driftLengthVariance)
53 , m_rlInfo(rlInfo)
54{
55}
56
58 const CDCRLWireHit& rlWireHit2)
59{
60 B2ASSERT("Average of two CDCRLWireHits with different wire hits requested.",
61 rlWireHit1.getWireHit() == rlWireHit2.getWireHit());
62
63 B2ASSERT("Average of two CDCRLWireHits with different right left passage information requested.",
64 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo());
65
66 ERightLeft rlInfo = rlWireHit1.getRLInfo();
67 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
68
69 double driftLength = (rlWireHit1.getRefDriftLength() +
70 rlWireHit2.getRefDriftLength()) / 2.0;
71
72 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
73 rlWireHit2.getRefDriftLengthVariance()) / 2.0;
74
75 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
76 return result;
77}
78
80 const CDCRLWireHit& rlWireHit2,
81 const CDCRLWireHit& rlWireHit3)
82{
83 B2ASSERT("Average of three CDCRLWireHits with different wire hits requested.",
84 rlWireHit1.getWireHit() == rlWireHit2.getWireHit() and
85 rlWireHit2.getWireHit() == rlWireHit3.getWireHit());
86
87 B2ASSERT("Average of three CDCRLWireHits with different right left passage information requested.",
88 rlWireHit1.getRLInfo() == rlWireHit2.getRLInfo() and
89 rlWireHit2.getRLInfo() == rlWireHit3.getRLInfo());
90
91
92 ERightLeft rlInfo = rlWireHit1.getRLInfo();
93 const CDCWireHit& wireHit = rlWireHit1.getWireHit();
94
95 double driftLength = (rlWireHit1.getRefDriftLength() +
96 rlWireHit2.getRefDriftLength() +
97 rlWireHit3.getRefDriftLength()) / 3.0;
98
99 double driftLengthVariance = (rlWireHit1.getRefDriftLengthVariance() +
100 rlWireHit2.getRefDriftLengthVariance() +
101 rlWireHit3.getRefDriftLengthVariance()) / 3.0;
102
103 CDCRLWireHit result(&wireHit, rlInfo, driftLength, driftLengthVariance);
104 return result;
105}
106
107
109 const CDCSimHit& simhit)
110{
111 // find out if the wire is right or left of the track ( view in flight direction )
112 ROOT::Math::XYZVector trackPosToWire{simhit.getPosWire() - simhit.getPosTrack()};
113 ROOT::Math::XYZVector directionOfFlight{simhit.getMomentum()};
114
115 ERightLeft rlInfo = VectorUtil::isRightOrLeftOf(VectorUtil::getXYVector(trackPosToWire),
116 VectorUtil::getXYVector(directionOfFlight));
117
118 CDCRLWireHit rlWireHit(wirehit, rlInfo, simhit.getDriftLength(), CDCWireHit::c_simpleDriftLengthVariance);
119
120 return rlWireHit;
121}
122
124{
125 return getWireHit().getHit();
126}
127
129{
130 return getWireHit().getWire();
131}
132
134{
135 return getWire().getWireID();
136}
137
142
147
149{
150 return getWire().isAxial();
151}
152
153const ROOT::Math::XYVector& CDCRLWireHit::getRefPos2D() const
154{
155 return getWire().getRefPos2D();
156}
157
159{
160 return getWire().getRefCylindricalR();
161}
162
163ROOT::Math::XYVector CDCRLWireHit::reconstruct2D(const CDCTrajectory2D& trajectory2D) const
164{
165 const ROOT::Math::XYVector& refPos2D = getRefPos2D();
166 ROOT::Math::XYVector recoPos2D = trajectory2D.getClosest(refPos2D);
167
168 const ROOT::Math::XYVector& wirePos2D = getWire().getRefPos2D();
169 const double driftLength = getRefDriftLength();
170
171 ROOT::Math::XYVector disp2D = recoPos2D - wirePos2D;
172
173 // Fix the displacement to lie on the drift circle.
174 if (disp2D.R() != 0.0) {
175 disp2D *= (driftLength / disp2D.R());
176 }
177 return wirePos2D + disp2D;
178}
179
180ROOT::Math::XYZVector CDCRLWireHit::reconstruct3D(const CDCTrajectory2D& trajectory2D, const double z) const
181{
182 const EStereoKind stereoType = getStereoKind();
183 const ERightLeft rlInfo = getRLInfo();
184
185 if (stereoType == EStereoKind::c_StereoV or stereoType == EStereoKind::c_StereoU) {
186 const WireLine& wireLine = getWire().getWireLine();
187 const double signedDriftLength = isValid(rlInfo) ? static_cast<double>(rlInfo) * getRefDriftLength() : 0.0;
188 return trajectory2D.reconstruct3D(wireLine, signedDriftLength, z);
189
190 } else { /*if (stereoType == EStereoKind::c_Axial)*/
191 const ROOT::Math::XYVector recoPos2D = reconstruct2D(trajectory2D);
192 // for axial wire we can not determine the z coordinate by looking at the xy projection only
193 // we set it the basic assumption.
194 return ROOT::Math::XYZVector(recoPos2D.X(), recoPos2D.Y(), z);
195 }
196}
197
198std::ostream& TrackingUtilities::operator<<(std::ostream& output, const CDCRLWireHit& rlWireHit)
199{
200 output << "CDCRLWireHit(" << rlWireHit.getWireHit() << ","
201 << static_cast<typename std::underlying_type<ERightLeft>::type>(rlWireHit.getRLInfo()) << ")" ;
202 return output;
203}
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:198
B2Vector3D getPosTrack() const
The method to get position on the track.
Definition CDCSimHit.h:216
double getDriftLength() const
The method to get drift length.
Definition CDCSimHit.h:180
B2Vector3D getMomentum() const
The method to get momentum.
Definition CDCSimHit.h:192
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
double getRefCylindricalR() const
Getter for the cylindrical radius at the wire reference position.
Definition CDCWire.h:252
ISuperLayer getISuperLayer() const
Gives the superlayer id ranging from 0 - 8.
Definition CDCWire.h:155
const ROOT::Math::XYVector & getRefPos2D() const
Getter for the wire reference position for 2D tracking Gives the wire's reference position projected ...
Definition CDCWire.h:221
const WireID & getWireID() const
Getter for the wire id.
Definition CDCWire.h:114
bool isAxial() const
Indicates if the wire is axial or stereo.
Definition CDCWire.h:166
EStereoKind getStereoKind() const
Getter for the stereo type of the wire.
Definition CDCWire.h:176
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
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
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.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
CDC::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.
double getRefDriftLength() const
Getter for the drift length at the reference position of the wire.
const ROOT::Math::XYVector & getRefPos2D() const
The two dimensional reference position of the underlying wire.
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.
ERightLeft m_rlInfo
Memory for the right left passage information of the oriented wire hit.
const CDC::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 information.
double m_refDriftLength
Memory for the reestimated drift length.
ROOT::Math::XYZVector reconstruct3D(const CDCTrajectory2D &trajectory2D, double z=0) const
Attempts to reconstruct a three dimensional position (especially of stereo hits).
double m_refDriftLengthVariance
Memory for the reestimated drift length variance.
ROOT::Math::XYVector reconstruct2D(const CDCTrajectory2D &trajectory2D) const
Reconstructs a position of primary ionisation on the drift circle.
const CDCWireHit * m_wireHit
Memory for the reference to the assiziated wire hit.
CDC::EStereoKind getStereoKind() const
Getter for the stereo type of the underlying wire.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Particle trajectory as it is seen in xy projection represented as a circle.
ROOT::Math::XYVector getClosest(const ROOT::Math::XYVector &point) const
Calculates the closest approach on the trajectory to the given point.
ROOT::Math::XYZVector reconstruct3D(const CDC::WireLine &wireLine, double distance=0.0, double z=0) const
Gives the one three dimensional positions 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:56
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:160
const CDC::CDCWire & getWire() const
Getter for the CDCWire the hit is located on.
Definition CDCWireHit.h:169
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:65
Class to identify a wire inside the CDC.
Definition WireID.h:34
EStereoKind
Type for the stereo property of the wire.
Definition EStereoKind.h:20
signed short ISuperLayer
The type of the layer and superlayer ids.
Definition ISuperLayer.h:24
Abstract base class for different kinds of events.