Belle II Software  release-05-01-25
DriftLengthEstimator.cc
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2016 - 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/utils/DriftLengthEstimator.h>
11 
12 #include <tracking/trackFindingCDC/eventdata/utils/FlightTimeEstimator.h>
13 
14 #include <tracking/trackFindingCDC/eventdata/tracks/CDCTrack.h>
15 
16 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment3D.h>
17 #include <tracking/trackFindingCDC/eventdata/segments/CDCSegment2D.h>
18 
19 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit3D.h>
20 #include <tracking/trackFindingCDC/eventdata/hits/CDCRecoHit2D.h>
21 #include <tracking/trackFindingCDC/eventdata/hits/CDCFacet.h>
22 #include <tracking/trackFindingCDC/eventdata/hits/CDCRLWireHit.h>
23 #include <tracking/trackFindingCDC/eventdata/hits/CDCWireHit.h>
24 
25 #include <tracking/trackFindingCDC/topology/CDCWire.h>
26 
27 #include <tracking/trackFindingCDC/geometry/UncertainParameterLine2D.h>
28 #include <tracking/trackFindingCDC/geometry/ParameterLine2D.h>
29 #include <tracking/trackFindingCDC/geometry/Vector2D.h>
30 #include <tracking/trackFindingCDC/geometry/Vector3D.h>
31 
32 #include <tracking/trackFindingCDC/numerics/ERightLeft.h>
33 #include <tracking/trackFindingCDC/numerics/Quadratic.h>
34 
35 #include <framework/core/ModuleParamList.templateDetails.h>
36 #include <tracking/trackFindingCDC/utilities/StringManipulation.h>
37 
38 #include <cdc/translators/RealisticTDCCountTranslator.h>
39 #include <cdc/dataobjects/CDCHit.h>
40 
41 using namespace Belle2;
42 using namespace TrackFindingCDC;
43 
44 
45 void DriftLengthEstimator::exposeParameters(ModuleParamList* moduleParamList, const std::string& prefix)
46 {
47  moduleParamList->addParameter(prefixed(prefix, "useAlphaInDriftLength"),
49  "Switch to serve the alpha angle to the drift length translator",
51 
52  moduleParamList->addParameter(prefixed(prefix, "tofMassScale"),
54  "Mass to estimate the velocity in the flight time to the hit",
56 }
57 
59 {
60  CDC::RealisticTDCCountTranslator tdcCountTranslator;
61  const FlightTimeEstimator& flightTimeEstimator = FlightTimeEstimator::instance();
62 
63  Vector2D flightDirection = recoHit2D.getFlightDirection2D();
64  Vector2D recoPos2D = recoHit2D.getRecoPos2D();
65  double alpha = recoPos2D.angleWith(flightDirection);
66  const double beta = 1;
67  double flightTimeEstimate = flightTimeEstimator.getFlightTime2D(recoPos2D, alpha, beta);
68 
69  const CDCWire& wire = recoHit2D.getWire();
70  const CDCHit* hit = recoHit2D.getWireHit().getHit();
71  const bool rl = recoHit2D.getRLInfo() == ERightLeft::c_Right;
72 
74  alpha = 0;
75  }
76 
77  double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
78  wire.getWireID(),
79  flightTimeEstimate,
80  rl,
81  wire.getRefZ(),
82  alpha);
83  if (driftLength > -2 and driftLength < 16) {
84  bool snapRecoPos = true;
85  recoHit2D.setRefDriftLength(driftLength, snapRecoPos);
86  }
87  return driftLength;
88 }
89 
91 {
92  CDC::RealisticTDCCountTranslator tdcCountTranslator;
93  const FlightTimeEstimator& flightTimeEstimator = FlightTimeEstimator::instance();
94 
95  const UncertainParameterLine2D& line = facet.getFitLine();
96  Vector2D flightDirection = line->tangential();
97  Vector2D centralPos2D = line->closest(facet.getMiddleWire().getRefPos2D());
98  double alpha = centralPos2D.angleWith(flightDirection);
100  alpha = 0;
101  }
102 
103  auto doUpdate = [&](CDCRLWireHit & rlWireHit, Vector2D recoPos2D) {
104  const CDCWire& wire = rlWireHit.getWire();
105  const CDCHit* hit = rlWireHit.getWireHit().getHit();
106  const bool rl = rlWireHit.getRLInfo() == ERightLeft::c_Right;
107  const double beta = 1;
108  double flightTimeEstimate = flightTimeEstimator.getFlightTime2D(recoPos2D, alpha, beta);
109  double driftLength = tdcCountTranslator.getDriftLength(hit->getTDCCount(),
110  wire.getWireID(),
111  flightTimeEstimate,
112  rl,
113  wire.getRefZ(),
114  alpha);
115  rlWireHit.setRefDriftLength(driftLength);
116  };
117 
118  doUpdate(facet.getStartRLWireHit(), facet.getStartRecoPos2D());
119  doUpdate(facet.getMiddleRLWireHit(), facet.getMiddleRecoPos2D());
120  doUpdate(facet.getEndRLWireHit(), facet.getEndRecoPos2D());
121 
122  // More accurate implementation
123  // double startDriftLength = updateDriftLength(facet.getStartRecoHit2D());
124  // facet.getStartRLWireHit().setRefDriftLength(startDriftLength);
125 
126  // double middleDriftLength = updateDriftLength(facet.getMiddleRecoHit2D());
127  // facet.getMiddleRLWireHit().setRefDriftLength(middleDriftLength);
128 
129  // double endDriftLength = updateDriftLength(facet.getEndRecoHit2D());
130  // facet.getEndRLWireHit().setRefDriftLength(endDriftLength);
131 }
132 
134 {
135  for (CDCRecoHit2D& recoHit2D : segment) {
136  updateDriftLength(recoHit2D);
137  }
138 }
139 
141  double tanLambda)
142 {
143  CDC::RealisticTDCCountTranslator tdcCountTranslator;
144  const FlightTimeEstimator& flightTimeEstimator = FlightTimeEstimator::instance();
145 
146  Vector2D flightDirection = recoHit3D.getFlightDirection2D();
147  const Vector3D& recoPos3D = recoHit3D.getRecoPos3D();
148  const Vector2D& recoPos2D = recoPos3D.xy();
149  double alpha = recoPos2D.angleWith(flightDirection);
150  const double beta = 1;
151  double flightTimeEstimate = flightTimeEstimator.getFlightTime2D(recoPos2D, alpha, beta);
152 
153  if (std::isnan(tanLambda)) {
154  tanLambda = recoPos3D.z() / recoPos3D.cylindricalR();
155  }
156  const double theta = M_PI / 2 - std::atan(tanLambda);
157  flightTimeEstimate *= hypot2(1, tanLambda);
158 
159  const CDCWire& wire = recoHit3D.getWire();
160  const CDCHit* hit = recoHit3D.getWireHit().getHit();
161  const bool rl = recoHit3D.getRLInfo() == ERightLeft::c_Right;
162  double driftLength =
163  tdcCountTranslator.getDriftLength(hit->getTDCCount(),
164  wire.getWireID(),
165  flightTimeEstimate,
166  rl,
167  recoPos3D.z(),
168  alpha,
169  theta,
170  hit->getADCCount());
171  if (driftLength > -2 and driftLength < 16) {
172  bool snapRecoPos = true;
173  recoHit3D.setRecoDriftLength(driftLength, snapRecoPos);
174  }
175  return driftLength;
176 }
177 
178 
180  const double tanLambda)
181 {
182  for (CDCRecoHit3D& recoHit3D : segment3D) {
183  updateDriftLength(recoHit3D, tanLambda);
184  }
185 }
186 
187 void DriftLengthEstimator::updateDriftLength(CDCTrack& track,
188  const double tanLambda)
189 {
190  for (CDCRecoHit3D& recoHit3D : track) {
191  updateDriftLength(recoHit3D, tanLambda);
192  }
193 }
Belle2::TrackFindingCDC::CDCRecoHit3D::getWire
const CDCWire & getWire() const
Getter for the wire.
Definition: CDCRecoHit3D.h:236
Belle2::TrackFindingCDC::CDCFacet::getStartRecoPos2D
Vector2D getStartRecoPos2D() const
Getter for the reconstructed position at the first hit on the fit line.
Definition: CDCFacet.cc:73
Belle2::TrackFindingCDC::CDCRecoHit3D
Class representing a three dimensional reconstructed hit.
Definition: CDCRecoHit3D.h:62
Belle2::TrackFindingCDC::Vector2D
A two dimensional vector which is equipped with functions for correct handeling of orientation relat...
Definition: Vector2D.h:37
Belle2::TrackFindingCDC::FlightTimeEstimator::getFlightTime2D
virtual double getFlightTime2D(const Vector2D &, double, double=1) const
Default estimator for the flight time.
Definition: FlightTimeEstimator.h:45
Belle2::CDC::RealisticTDCCountTranslator
Translator mirroring the realistic Digitization.
Definition: RealisticTDCCountTranslator.h:36
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::CDCRecoHit2D::getRecoPos2D
Vector2D getRecoPos2D() const
Getter for the position in the reference plane.
Definition: CDCRecoHit2D.h:248
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::CDCWire::getRefZ
double getRefZ() const
Getter for the wire reference z coordinate Gives the wire's reference z coordinate.
Definition: CDCWire.h:238
Belle2::TrackFindingCDC::CDCRLWireHit::getWire
const CDCWire & getWire() const
Getter for the wire the oriented hit associated to.
Definition: CDCRLWireHit.cc:133
Belle2::TrackFindingCDC::DriftLengthEstimator::m_param_tofMassScale
double m_param_tofMassScale
Parameter : Mass to estimate the velocity in the flight time to the hit.
Definition: DriftLengthEstimator.h:69
Belle2::TrackFindingCDC::CDCWireHit::getHit
const CDCHit * getHit() const
Getter for the CDCHit pointer into the StoreArray.
Definition: CDCWireHit.h:167
Belle2::TrackFindingCDC::CDCRecoHit3D::getWireHit
const CDCWireHit & getWireHit() const
Getter for the wire hit.
Definition: CDCRecoHit3D.h:248
Belle2::TrackFindingCDC::CDCSegment3D
A segment consisting of three dimensional reconstructed hits.
Definition: CDCSegment3D.h:36
Belle2::TrackFindingCDC::FlightTimeEstimator
Helper struct to provide consistent flight time estimation throughout the CDC track finding.
Definition: FlightTimeEstimator.h:37
Belle2::TrackFindingCDC::CDCRecoHit3D::getRLInfo
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRecoHit3D.h:277
Belle2::TrackFindingCDC::DriftLengthEstimator::m_param_useAlphaInDriftLength
bool m_param_useAlphaInDriftLength
Parameter : Switch to serve the alpha angle to the drift length translator.
Definition: DriftLengthEstimator.h:66
Belle2::TrackFindingCDC::CDCRecoHit2D::setRefDriftLength
void setRefDriftLength(double driftLength, bool snapRecoPos)
Setter for the drift length at the wire reference position.
Definition: CDCRecoHit2D.cc:115
Belle2::TrackFindingCDC::DriftLengthEstimator::updateDriftLength
double updateDriftLength(CDCRecoHit2D &recoHit2D)
Update the drift length of the reconstructed hit in place.
Definition: DriftLengthEstimator.cc:58
Belle2::TrackFindingCDC::CDCRecoHit2D::getWire
const CDCWire & getWire() const
Getter for the wire the reconstructed hit assoziated to.
Definition: CDCRecoHit2D.h:185
Belle2::TrackFindingCDC::CDCRecoHit3D::getFlightDirection2D
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit3D.h:322
Belle2::ModuleParamList::addParameter
void addParameter(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module list.
Definition: ModuleParamList.templateDetails.h:38
Belle2::TrackFindingCDC::CDCRecoHit2D
Class representing a two dimensional reconstructed hit in the central drift chamber.
Definition: CDCRecoHit2D.h:57
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::Vector3D
A three dimensional vector.
Definition: Vector3D.h:34
Belle2::CDC::RealisticTDCCountTranslator::getDriftLength
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.
Definition: RealisticTDCCountTranslator.cc:106
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getMiddleWire
const CDCWire & getMiddleWire() const
Getter for the wire the second oriented wire hit is based on.
Definition: CDCRLWireHitTriple.h:176
Belle2::TrackFindingCDC::CDCFacet::getEndRecoPos2D
Vector2D getEndRecoPos2D() const
Getter for the reconstructed position at the third hit on the fit line.
Definition: CDCFacet.cc:83
Belle2::TrackFindingCDC::CDCRLWireHit::setRefDriftLength
void setRefDriftLength(double driftLength)
Setter for the drift length at the reference position of the wire.
Definition: CDCRLWireHit.h:220
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getMiddleRLWireHit
CDCRLWireHit & getMiddleRLWireHit()
Getter for the second oriented wire hit.
Definition: CDCRLWireHitTriple.h:243
Belle2::TrackFindingCDC::CDCWire::getWireID
const WireID & getWireID() const
Getter for the wire id.
Definition: CDCWire.h:124
Belle2::TrackFindingCDC::CDCFacet
Class representing a triple of neighboring oriented wire with additional trajectory information.
Definition: CDCFacet.h:42
Belle2::TrackFindingCDC::Vector3D::xy
const Vector2D & xy() const
Getter for the xy projected vector ( reference ! )
Definition: Vector3D.h:500
Belle2::TrackFindingCDC::FlightTimeEstimator::instance
static const FlightTimeEstimator & instance(std::unique_ptr< FlightTimeEstimator > replacement=nullptr)
Getter for the instance.
Definition: FlightTimeEstimator.cc:23
Belle2::TrackFindingCDC::CDCWire
Class representing a sense wire in the central drift chamber.
Definition: CDCWire.h:60
Belle2::TrackFindingCDC::CDCSegment2D
A reconstructed sequence of two dimensional hits in one super layer.
Definition: CDCSegment2D.h:40
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getEndRLWireHit
CDCRLWireHit & getEndRLWireHit()
Getter for the third oriented wire hit.
Definition: CDCRLWireHitTriple.h:249
Belle2::TrackFindingCDC::CDCRecoHit3D::setRecoDriftLength
void setRecoDriftLength(double driftLength, bool snapRecoPos)
Setter to update the drift length of the hit.
Definition: CDCRecoHit3D.cc:189
Belle2::TrackFindingCDC::Vector2D::angleWith
double angleWith(const Vector2D &rhs) const
The angle between this and rhs.
Definition: Vector2D.h:211
Belle2::TrackFindingCDC::Vector3D::z
double z() const
Getter for the z coordinate.
Definition: Vector3D.h:488
Belle2::TrackFindingCDC::DriftLengthEstimator::exposeParameters
void exposeParameters(ModuleParamList *moduleParamList, const std::string &prefix)
Add the parameters of the estimator to the module.
Definition: DriftLengthEstimator.cc:45
Belle2::TrackFindingCDC::UncertainParameterLine2D
A parameter line including including an line covariance matrix which is interpreted as located in the...
Definition: UncertainParameterLine2D.h:34
Belle2::ModuleParamList
The Module parameter list class.
Definition: ModuleParamList.h:46
Belle2::TrackFindingCDC::CDCRecoHit3D::getRecoPos3D
const Vector3D & getRecoPos3D() const
Getter for the 3d position of the hit.
Definition: CDCRecoHit3D.h:295
Belle2::TrackFindingCDC::CDCRecoHit2D::getFlightDirection2D
Vector2D getFlightDirection2D() const
Getter for the direction of flight.
Definition: CDCRecoHit2D.h:266
Belle2::TrackFindingCDC::CDCRLWireHitTriple::getStartRLWireHit
CDCRLWireHit & getStartRLWireHit()
Getter for the first oriented wire hit.
Definition: CDCRLWireHitTriple.h:237
Belle2::TrackFindingCDC::Vector3D::cylindricalR
double cylindricalR() const
Getter for the cylindrical radius ( xy projected norm )
Definition: Vector3D.h:526
Belle2::TrackFindingCDC::CDCFacet::getMiddleRecoPos2D
Vector2D getMiddleRecoPos2D() const
Getter for the reconstructed position at the second hit on the fit line.
Definition: CDCFacet.cc:78
Belle2::TrackFindingCDC::CDCRecoHit2D::getWireHit
const CDCWireHit & getWireHit() const
Getter for the wire hit assoziated with the reconstructed hit.
Definition: CDCRecoHit2D.h:203
Belle2::TrackFindingCDC::CDCFacet::getFitLine
const UncertainParameterLine2D & getFitLine() const
Getter for the contained line fit information.
Definition: CDCFacet.h:71
Belle2::TrackFindingCDC::CDCRecoHit2D::getRLInfo
ERightLeft getRLInfo() const
Getter for the right left passage information.
Definition: CDCRecoHit2D.h:215