Belle II Software development
DriftLengthEstimator.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/utils/DriftLengthEstimator.h>
9
10#include <tracking/trackFindingCDC/eventdata/utils/FlightTimeEstimator.h>
11
12#include <tracking/trackingUtilities/eventdata/tracks/CDCTrack.h>
13
14#include <tracking/trackingUtilities/eventdata/segments/CDCSegment3D.h>
15#include <tracking/trackingUtilities/eventdata/segments/CDCSegment2D.h>
16
17#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit3D.h>
18#include <tracking/trackingUtilities/eventdata/hits/CDCRecoHit2D.h>
19#include <tracking/trackingUtilities/eventdata/hits/CDCFacet.h>
20#include <tracking/trackingUtilities/eventdata/hits/CDCRLWireHit.h>
21#include <tracking/trackingUtilities/eventdata/hits/CDCWireHit.h>
22
23#include <cdc/topology/CDCWire.h>
24
25#include <tracking/trackingUtilities/geometry/UncertainParameterLine2D.h>
26#include <tracking/trackingUtilities/geometry/ParameterLine2D.h>
27
28#include <tracking/trackingUtilities/numerics/ERightLeft.h>
29#include <tracking/trackingUtilities/numerics/Quadratic.h>
30
31#include <tracking/trackingUtilities/utilities/StringManipulation.h>
32
33#include <cdc/translators/RealisticTDCCountTranslator.h>
34#include <cdc/dataobjects/CDCHit.h>
35
36#include <framework/core/ModuleParamList.templateDetails.h>
37#include <framework/geometry/VectorUtil.h>
38
39#include <Math/Vector3D.h>
40#include <Math/Vector2D.h>
41#include <Math/VectorUtil.h>
42
43using namespace Belle2;
44using namespace CDC;
45using namespace TrackFindingCDC;
46using namespace TrackingUtilities;
47
48
49void DriftLengthEstimator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
50{
51 moduleParamList->addParameter(prefixed(prefix, "useAlphaInDriftLength"),
53 "Switch to serve the alpha angle to the drift length translator",
55
56 moduleParamList->addParameter(prefixed(prefix, "tofMassScale"),
58 "Mass to estimate the velocity in the flight time to the hit",
60}
61
63{
64 CDC::RealisticTDCCountTranslator tdcCountTranslator;
65
66 ROOT::Math::XYVector flightDirection = recoHit2D.getFlightDirection2D();
67 ROOT::Math::XYVector recoPos2D = recoHit2D.getRecoPos2D();
68 double alpha = ROOT::Math::VectorUtil::DeltaPhi(recoPos2D, flightDirection);
69 const double beta = 1;
70 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
71
72 const CDCWire& wire = recoHit2D.getWire();
73 const CDCHit* hit = recoHit2D.getWireHit().getHit();
74 const bool rl = recoHit2D.getRLInfo() == ERightLeft::c_Right;
75
77 alpha = 0;
78 }
79
80 double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
81 wire.getWireID(),
82 flightTimeEstimate,
83 rl,
84 wire.getRefZ(),
85 alpha);
86 if (driftLength > -2 and driftLength < 16) {
87 bool snapRecoPos = true;
88 recoHit2D.setRefDriftLength(driftLength, snapRecoPos);
89 }
90 return driftLength;
91}
92
94{
95 CDC::RealisticTDCCountTranslator tdcCountTranslator;
96
97 const UncertainParameterLine2D& line = facet.getFitLine();
98 ROOT::Math::XYVector flightDirection = line->tangential();
99 ROOT::Math::XYVector centralPos2D = line->closest(facet.getMiddleWire().getRefPos2D());
100 double alpha = ROOT::Math::VectorUtil::DeltaPhi(centralPos2D, flightDirection);
102 alpha = 0;
103 }
104
105 auto doUpdate = [&](CDCRLWireHit & rlWireHit, ROOT::Math::XYVector recoPos2D) {
106 const CDCWire& wire = rlWireHit.getWire();
107 const CDCHit* hit = rlWireHit.getWireHit().getHit();
108 const bool rl = rlWireHit.getRLInfo() == ERightLeft::c_Right;
109 const double beta = 1;
110 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
111 double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
112 wire.getWireID(),
113 flightTimeEstimate,
114 rl,
115 wire.getRefZ(),
116 alpha);
117 rlWireHit.setRefDriftLength(driftLength);
118 };
119
120 doUpdate(facet.getStartRLWireHit(), facet.getStartRecoPos2D());
121 doUpdate(facet.getMiddleRLWireHit(), facet.getMiddleRecoPos2D());
122 doUpdate(facet.getEndRLWireHit(), facet.getEndRecoPos2D());
123
124 // More accurate implementation
125 // double startDriftLength = updateDriftLength(facet.getStartRecoHit2D());
126 // facet.getStartRLWireHit().setRefDriftLength(startDriftLength);
127
128 // double middleDriftLength = updateDriftLength(facet.getMiddleRecoHit2D());
129 // facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
130
131 // double endDriftLength = updateDriftLength(facet.getEndRecoHit2D());
132 // facet.getEndRLWireHit().setRefDriftLength(endDriftLength);
133}
134
136{
137 for (CDCRecoHit2D& recoHit2D : segment) {
138 updateDriftLength(recoHit2D);
139 }
140}
141
143 double tanLambda)
144{
145 CDC::RealisticTDCCountTranslator tdcCountTranslator;
146
147 ROOT::Math::XYVector flightDirection = recoHit3D.getFlightDirection2D();
148 const ROOT::Math::XYZVector& recoPos3D = recoHit3D.getRecoPos3D();
149 const ROOT::Math::XYVector& recoPos2D = VectorUtil::getXYVector(recoPos3D);
150 double alpha = ROOT::Math::VectorUtil::DeltaPhi(recoPos2D, flightDirection);
151 const double beta = 1;
152 double flightTimeEstimate = FlightTimeEstimator::instance().getFlightTime2D(recoPos2D, alpha, beta);
153
154 if (std::isnan(tanLambda)) {
155 tanLambda = recoPos3D.z() / recoPos3D.Rho();
156 }
157 const double theta = M_PI / 2 - std::atan(tanLambda);
158 flightTimeEstimate *= hypot2(1, tanLambda);
159
160 const CDCWire& wire = recoHit3D.getWire();
161 const CDCHit* hit = recoHit3D.getWireHit().getHit();
162 const bool rl = recoHit3D.getRLInfo() == ERightLeft::c_Right;
163 double driftLength =
164 tdcCountTranslator.getDriftLength(hit->getTDCCount(),
165 wire.getWireID(),
166 flightTimeEstimate,
167 rl,
168 recoPos3D.z(),
169 alpha,
170 theta,
171 hit->getADCCount());
172 if (driftLength > -2 and driftLength < 16) {
173 bool snapRecoPos = true;
174 recoHit3D.setRecoDriftLength(driftLength, snapRecoPos);
175 }
176 return driftLength;
177}
178
179
181 const double tanLambda)
182{
183 for (CDCRecoHit3D& recoHit3D : segment3D) {
184 updateDriftLength(recoHit3D, tanLambda);
185 }
186}
187
189 const double tanLambda)
190{
191 for (CDCRecoHit3D& recoHit3D : track) {
192 updateDriftLength(recoHit3D, tanLambda);
193 }
194}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
short getTDCCount() const
Getter for TDC count.
Definition CDCHit.h:219
unsigned short getADCCount() const
Getter for integrated charge.
Definition CDCHit.h:230
Class representing a sense wire in the central drift chamber.
Definition CDCWire.h:50
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
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition CDCWire.h:228
Translator mirroring the realistic Digitization.
double getDriftLength(unsigned short tdcCount, const WireID &wireID=WireID(), double timeOfFlightEstimator=0, bool leftRight=false, double z=0, double alpha=0, double theta=static_cast< double >(TMath::Pi()/2.), unsigned short adcCount=0) override
Get Drift length.
The Module parameter list class.
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
virtual double getFlightTime2D(const ROOT::Math::XYVector &, double, double=1) const
Default estimator for the flight time.
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition CDCFacet.h:33
ROOT::Math::XYVector getMiddleRecoPos2D() const
Getter for the reconstructed position at the second hit on the fit line.
Definition CDCFacet.cc:76
ROOT::Math::XYVector getEndRecoPos2D() const
Getter for the reconstructed position at the third hit on the fit line.
Definition CDCFacet.cc:81
const UncertainParameterLine2D & getFitLine() const
Getter for the contained line fit information.
Definition CDCFacet.h:62
ROOT::Math::XYVector getStartRecoPos2D() const
Getter for the reconstructed position at the first hit on the fit line.
Definition CDCFacet.cc:71
const CDC::CDCWire & getMiddleWire() const
Getter for the wire the second oriented wire hit is based on.
CDCRLWireHit & getStartRLWireHit()
Getter for the first oriented wire hit.
CDCRLWireHit & getEndRLWireHit()
Getter for the third oriented wire hit.
CDCRLWireHit & getMiddleRLWireHit()
Getter for the second oriented wire hit.
Class representing an oriented hit wire including a hypotheses whether the causing track passes left ...
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the oriented hit.
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
const CDC::CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Class representing a two dimensional reconstructed hit in the central drift chamber.
const CDCWireHit & getWireHit() const
Getter for the wire hit associated with the reconstructed hit.
void setRefDriftLength(double driftLength, bool snapRecoPos)
Setter for the drift length at the wire reference position.
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.
ERightLeft getRLInfo() const
Getter for the right left passage information.
Class representing a three dimensional reconstructed hit.
const CDCWireHit & getWireHit() const
Getter for the wire hit.
const ROOT::Math::XYZVector & getRecoPos3D() const
Getter for the 3d position of the hit.
ROOT::Math::XYVector getFlightDirection2D() const
Getter for the direction of flight.
const CDC::CDCWire & getWire() const
Getter for the wire.
void setRecoDriftLength(double driftLength, bool snapRecoPos)
Setter to update the drift length of the hit.
ERightLeft getRLInfo() const
Getter for the right left passage information.
A reconstructed sequence of two dimensional hits in one super layer.
A segment consisting of three dimensional reconstructed hits.
Class representing a sequence of three dimensional reconstructed hits.
Definition CDCTrack.h:37
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition CDCWireHit.h:160
A parameter line including including an line covariance matrix which is interpreted as located in the...
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Abstract base class for different kinds of events.
double m_param_tofMassScale
Parameter : Mass to estimate the velocity in the flight time to the hit.
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Add the parameters of the estimator to the module.
double updateDriftLength(TrackingUtilities::CDCRecoHit2D &recoHit2D)
Update the drift length of the reconstructed hit in place.
bool m_param_useAlphaInDriftLength
Parameter : Switch to serve the alpha angle to the drift length translator.