Belle II Software development
PlanarVXDMomentumMeasurement.h
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
9#pragma once
10
11#include <tracking/trackFitting/measurementCreator/measurements/PlanarMomentumMeasurement.h>
12#include <tracking/vxdMomentumEstimation/VXDMomentumEstimation.h>
13#include <tracking/vxdMomentumEstimation/VXDMomentumEstimationTools.h>
14#include <mdst/dataobjects/MCParticle.h>
15#include <tracking/dataobjects/RecoTrack.h>
16
17namespace Belle2 {
26 template <class HitType>
28
29 public:
34 PlanarVXDMomentumMeasurement(const genfit::PlanarMeasurement& parentElement, HitType* hit, const Belle2::RecoTrack* recoTrack) :
35 PlanarMomentumMeasurement(parentElement), m_hit(hit), m_recoTrack(recoTrack)
36 {
37 rawHitCoords_.ResizeTo(1);
38 rawHitCov_.ResizeTo(1, 1);
39
40 setHitId(hit->getArrayIndex());
41 setDetId(getDetId());
42 }
43
45 virtual genfit::AbsMeasurement* clone() const override {return new PlanarVXDMomentumMeasurement(*this);}
46
48 virtual std::vector<genfit::MeasurementOnPlane*> constructMeasurementsOnPlane(const genfit::StateOnPlane& state) const override;
49
52 {
53 m_correctionFitParameters = correctionFitParameters;
54 }
55
57 void setSigma(double sigma)
58 {
59 m_sigma = sigma;
60 }
61
64 {
65 m_fitParameters = fitParameters;
66 }
67
69 void setUseMCInformation(bool useMCInformation)
70 {
71 m_useMCInformation = useMCInformation;
72 }
73
75 void setUseThickness(bool useThickness)
76 {
77 m_useThickness = useThickness;
78 }
79
81 void setUseTrackingSeeds(bool useTrackingSeeds)
82 {
83 m_useTrackingSeeds = useTrackingSeeds;
84 }
85
87 HitType* getHit() const
88 {
89 return m_hit;
90 }
91
92 private:
98 bool m_useThickness = false;
102 bool m_useTrackingSeeds = false;
104 double m_sigma = 0.03;
105
107 HitType* m_hit = nullptr;
109 const RecoTrack* m_recoTrack = nullptr;
110
112 // cppcheck-suppress duplInheritedMember ; intentionally hides the base class member
113 static int getDetId()
114 {
115 return -1;
116 }
117 };
118
122 template <class HitType>
124 const genfit::StateOnPlane& state) const
125 {
128
129 TVectorD rawHitCoordinates(1);
130 TMatrixDSym rawHitCovariance(1);
131
132 // Copy the information from the current state
133 const B2Vector3D& statePosition(state.getPos());
134 const B2Vector3D& stateMomentum(state.getMom());
135 short stateCharge = state.getCharge();
136
137
138 // Copy the information from the reco track.
139 const B2Vector3D& trackPosition(m_recoTrack->getPositionSeed());
140 const B2Vector3D& trackMomentum(m_recoTrack->getMomentumSeed());
141 short trackCharge = m_recoTrack->getChargeSeed();
142
143 // Copy the information from the mc particle (if there is one)
144 const MCParticle* relatedMCParticle = m_hit->template getRelated<MCParticle>("MCParticles");
145
146 ROOT::Math::XYZVector mcMomentum;
147 ROOT::Math::XYZVector mcPosition;
148 short mcCharge;
149
150 if (relatedMCParticle == nullptr) {
151 mcMomentum = ROOT::Math::XYZVector(trackMomentum);
152 mcPosition = ROOT::Math::XYZVector(trackPosition);
153 mcCharge = trackCharge;
154 } else {
155 mcMomentum = relatedMCParticle->getMomentum();
156 mcPosition = relatedMCParticle->getProductionVertex();
157 mcCharge = relatedMCParticle->getCharge();
158 }
159
160 // Copy information from the mc hit
161 const ROOT::Math::XYZVector& hitMCMomentum = momentumEstimationTools.getEntryMomentumOfMCParticle(*m_hit);
162 const ROOT::Math::XYZVector& hitMCPosition = momentumEstimationTools.getEntryPositionOfMCParticle(*m_hit);
163
164
165 if (m_useThickness) {
166 rawHitCoordinates(0) = momentumEstimator.estimateQOverPWithThickness(*m_hit, stateCharge, m_fitParameters,
168 } else {
169 if (m_useTrackingSeeds) {
170 if (m_useMCInformation) {
171 rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, mcMomentum, mcPosition, mcCharge,
174
175 } else {
176 rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, ROOT::Math::XYZVector(trackMomentum),
177 ROOT::Math::XYZVector(trackPosition), trackCharge,
180 }
181 } else {
182 if (m_useMCInformation) {
183 rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, hitMCMomentum, hitMCPosition, stateCharge,
186 } else {
187 rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, ROOT::Math::XYZVector(stateMomentum),
188 ROOT::Math::XYZVector(statePosition), stateCharge,
191 }
192 }
193 }
194
195 rawHitCovariance(0, 0) = m_sigma;
196
197 genfit::MeasurementOnPlane* mop = new genfit::MeasurementOnPlane(rawHitCoordinates, rawHitCovariance,
198 state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
199 return {mop};
200 }
201
203 template<>
205
207 template<>
209
211}
A Class to store the Monte Carlo particle information.
Definition MCParticle.h:32
ROOT::Math::XYZVector getProductionVertex() const
Return production vertex position.
Definition MCParticle.h:178
float getCharge() const
Return the particle charge defined in TDatabasePDG.
Definition MCParticle.cc:34
ROOT::Math::XYZVector getMomentum() const
Return momentum.
Definition MCParticle.h:187
virtual const genfit::AbsHMatrix * constructHMatrix(const genfit::AbsTrackRep *rep) const override
Construct the QP matrix.
PlanarMomentumMeasurement()
Default constructor with 1 dim.
void setUseTrackingSeeds(bool useTrackingSeeds)
Set whether to use tracking seeds not the current state.
VXDMomentumEstimation< HitType >::CorrectionFitParameters m_correctionFitParameters
Parameters for the correction function.
void setSigma(double sigma)
Set the measurement sigma.
bool m_useMCInformation
Use the seeds of the track finder or the seeds of the MC particles.
HitType * getHit() const
Get the underlying hit (cluster).
void setUseMCInformation(bool useMCInformation)
Set whether to use mc information.
const RecoTrack * m_recoTrack
RecoTrack for which the hit is created.
void setUseThickness(bool useThickness)
Set whether to use the thickness.
void setCorrectionFitParameters(const typename VXDMomentumEstimation< HitType >::CorrectionFitParameters &correctionFitParameters)
Set the correction fit parameters.
static int getDetId()
Return the detector ID.
PlanarVXDMomentumMeasurement(const genfit::PlanarMeasurement &parentElement, HitType *hit, const Belle2::RecoTrack *recoTrack)
Initialize the momentum measurement with a planar measurement as a parent, the corresponding hit and ...
virtual genfit::AbsMeasurement * clone() const override
Clone the measurement.
bool m_useTrackingSeeds
Use the tracking seeds in the origin for calculating the path length rather than the current state.
VXDMomentumEstimation< HitType >::FitParameters m_fitParameters
Parameters for the main function.
double m_sigma
Value of the measurement sigma.
bool m_useThickness
Use the thickness of the clusters of the path length for estimating dX.
void setFitParameters(const typename VXDMomentumEstimation< HitType >::FitParameters &fitParameters)
Set the fit parameters.
This is the Reconstruction Event-Data Model Track.
Definition RecoTrack.h:79
Tools needed for the VXD momentum estimation to, e.g.
static const VXDMomentumEstimationTools & getInstance()
Use this class as singleton.
ROOT::Math::XYZVector getEntryMomentumOfMCParticle(const ClusterType &) const
Return the momentum of the simulated MCParticle at this cluster (by using the TrueHit associated with...
ROOT::Math::XYZVector getEntryPositionOfMCParticle(const ClusterType &) const
Return the entry position of the simulated MCParticle at this cluster (by using the TrueHit associate...
Class doing the momentum estimation from dEdX for SVDClusters and PXDClusters.
static double estimateQOverPWithThickness(const ClusterType &cluster, short charge, const FitParameters &fitParameters, const CorrectionFitParameters &correctionFitParameters)
Main function: Estimate p over q for the given cluster and the thickness of the cluster with the fit ...
static double estimateQOverP(const ClusterType &cluster, const ROOT::Math::XYZVector &momentum, const ROOT::Math::XYZVector &position, short charge, const FitParameters &fitParameters, const CorrectionFitParameters &correctionFitParameters)
Main function: Estimate p over q for the given cluster and the path length calculated using the given...
static const VXDMomentumEstimation & getInstance()
Use this class as a singleton.
B2Vector3< double > B2Vector3D
typedef for common usage with double
Definition B2Vector3.h:522
virtual std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
Construct the measurement on the plane set in the parent element.
Abstract base class for different kinds of events.
Struct holding the parameters of the correction function to map them median of the estimation functio...
Struct holding the parameters of the estimation function which maps dEdX to p.