Belle II Software  release-05-01-25
PlanarVXDMomentumMeasurement.h
1 /**************************************************************************
2  * BASF2 (Belle Analysis Framework 2) *
3  * Copyright(C) 2015 - Belle II Collaboration *
4  * *
5  * Author: The Belle II Collaboration *
6  * Contributors: Nils Braun *
7  * *
8  * This software is provided "as is" without any warranty. *
9  **************************************************************************/
10 
11 #pragma once
12 
13 #include <tracking/trackFitting/measurementCreator/measurements/PlanarMomentumMeasurement.h>
14 #include <tracking/vxdMomentumEstimation/VXDMomentumEstimation.h>
15 #include <tracking/vxdMomentumEstimation/VXDMomentumEstimationTools.h>
16 #include <mdst/dataobjects/MCParticle.h>
17 #include <tracking/dataobjects/RecoTrack.h>
18 
19 namespace Belle2 {
28  template <class HitType>
29  class PlanarVXDMomentumMeasurement : public PlanarMomentumMeasurement {
30 
31  public:
36  PlanarVXDMomentumMeasurement(const genfit::PlanarMeasurement& parentElement, HitType* hit, const Belle2::RecoTrack* recoTrack) :
37  PlanarMomentumMeasurement(parentElement), m_hit(hit), m_recoTrack(recoTrack)
38  {
39  rawHitCoords_.ResizeTo(1);
40  rawHitCov_.ResizeTo(1, 1);
41 
42  setHitId(hit->getArrayIndex());
43  setDetId(getDetId());
44  }
45 
47  virtual genfit::AbsMeasurement* clone() const override {return new PlanarVXDMomentumMeasurement(*this);}
48 
50  virtual std::vector<genfit::MeasurementOnPlane*> constructMeasurementsOnPlane(const genfit::StateOnPlane& state) const override;
51 
53  void setCorrectionFitParameters(const typename VXDMomentumEstimation<HitType>::CorrectionFitParameters& correctionFitParameters)
54  {
55  m_correctionFitParameters = correctionFitParameters;
56  }
57 
59  void setSigma(double sigma)
60  {
61  m_sigma = sigma;
62  }
63 
65  void setFitParameters(const typename VXDMomentumEstimation<HitType>::FitParameters& fitParameters)
66  {
67  m_fitParameters = fitParameters;
68  }
69 
71  void setUseMCInformation(bool useMCInformation)
72  {
73  m_useMCInformation = useMCInformation;
74  }
75 
77  void setUseThickness(bool useThickness)
78  {
79  m_useThickness = useThickness;
80  }
81 
83  void setUseTrackingSeeds(bool useTrackingSeeds)
84  {
85  m_useTrackingSeeds = useTrackingSeeds;
86  }
87 
89  HitType* getHit() const
90  {
91  return m_hit;
92  }
93 
94  private:
100  bool m_useThickness = false;
102  bool m_useMCInformation = true;
104  bool m_useTrackingSeeds = false;
106  double m_sigma = 0.03;
107 
109  HitType* m_hit = nullptr;
111  const RecoTrack* m_recoTrack = nullptr;
112 
114  int getDetId() const
115  {
116  return -1;
117  }
118  };
119 
123  template <class HitType>
124  std::vector<genfit::MeasurementOnPlane*> PlanarVXDMomentumMeasurement<HitType>::constructMeasurementsOnPlane(
125  const genfit::StateOnPlane& state) const
126  {
129 
130  TVectorD rawHitCoordinates(1);
131  TMatrixDSym rawHitCovariance(1);
132 
133  // Copy the information from the current state
134  const TVector3& statePosition(state.getPos());
135  const TVector3& stateMomentum(state.getMom());
136  short stateCharge = state.getCharge();
137 
138 
139  // Copy the information from the reco track.
140  const TVector3& trackPosition(m_recoTrack->getPositionSeed());
141  const TVector3& trackMomentum(m_recoTrack->getMomentumSeed());
142  short trackCharge = m_recoTrack->getChargeSeed();
143 
144  // Copy the information from the mc particle (if there is one)
145  MCParticle* relatedMCParticle = m_hit->template getRelated<MCParticle>("MCParticles");
146 
147  TVector3 mcMomentum;
148  TVector3 mcPostion;
149  short mcCharge;
150 
151  if (relatedMCParticle == nullptr) {
152  mcMomentum = trackMomentum;
153  mcPostion = trackPosition;
154  mcCharge = trackCharge;
155  } else {
156  mcMomentum = relatedMCParticle->getMomentum();
157  mcPostion = relatedMCParticle->getProductionVertex();
158  mcCharge = relatedMCParticle->getCharge();
159  }
160 
161  // Copy information from the mc hit
162  const TVector3& hitMCMomentum = momentumEstimationTools.getEntryMomentumOfMCParticle(*m_hit);
163  const TVector3& hitMCPosition = momentumEstimationTools.getEntryPositionOfMCParticle(*m_hit);
164 
165 
166  if (m_useThickness) {
167  rawHitCoordinates(0) = momentumEstimator.estimateQOverPWithThickness(*m_hit, stateCharge, m_fitParameters,
168  m_correctionFitParameters);
169  } else {
170  if (m_useTrackingSeeds) {
171  if (m_useMCInformation) {
172  rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, mcMomentum, mcPostion, mcCharge,
173  m_fitParameters,
174  m_correctionFitParameters);
175 
176  } else {
177  rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, trackMomentum, trackPosition, trackCharge,
178  m_fitParameters,
179  m_correctionFitParameters);
180  }
181  } else {
182  if (m_useMCInformation) {
183  rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, hitMCMomentum, hitMCPosition, stateCharge,
184  m_fitParameters,
185  m_correctionFitParameters);
186  } else {
187  rawHitCoordinates(0) = momentumEstimator.estimateQOverP(*m_hit, stateMomentum, statePosition, stateCharge,
188  m_fitParameters,
189  m_correctionFitParameters);
190  }
191  }
192  }
193 
194  rawHitCovariance(0, 0) = m_sigma;
195 
196  genfit::MeasurementOnPlane* mop = new genfit::MeasurementOnPlane(rawHitCoordinates, rawHitCovariance,
197  state.getPlane(), state.getRep(), constructHMatrix(state.getRep()));
198  return {mop};
199  }
200 
202  template<>
204 
206  template<>
208 
210 }
Belle2::PlanarVXDMomentumMeasurement::setCorrectionFitParameters
void setCorrectionFitParameters(const typename VXDMomentumEstimation< HitType >::CorrectionFitParameters &correctionFitParameters)
Set the correction fit parameters.
Definition: PlanarVXDMomentumMeasurement.h:61
Belle2::PlanarVXDMomentumMeasurement::clone
virtual genfit::AbsMeasurement * clone() const override
Clone the measurement.
Definition: PlanarVXDMomentumMeasurement.h:55
Belle2::MCParticle::getCharge
float getCharge() const
Return the particle charge defined in TDatabasePDG.
Definition: MCParticle.cc:35
Belle2::PlanarVXDMomentumMeasurement::constructMeasurementsOnPlane
virtual std::vector< genfit::MeasurementOnPlane * > constructMeasurementsOnPlane(const genfit::StateOnPlane &state) const override
Construct the measurement on the plane set in the parent element.
Definition: PlanarVXDMomentumMeasurement.h:132
Belle2::VXDMomentumEstimationTools::getInstance
static const VXDMomentumEstimationTools & getInstance()
Use this class as singleton.
Definition: VXDMomentumEstimationTools.h:55
Belle2::VXDMomentumEstimation::estimateQOverP
double estimateQOverP(const ClusterType &cluster, const TVector3 &momentum, const TVector3 &position, short charge, const FitParameters &fitParameters, const CorrectionFitParameters &correctionFitParameters) const
Main function: Estimate p over q for the given cluster and the path length calculated using the given...
Definition: VXDMomentumEstimation.h:82
Belle2::PlanarVXDMomentumMeasurement::m_useMCInformation
bool m_useMCInformation
Use the seeds of the track finder or the seeds of the MC particles.
Definition: PlanarVXDMomentumMeasurement.h:110
Belle2::PlanarVXDMomentumMeasurement::m_fitParameters
VXDMomentumEstimation< HitType >::FitParameters m_fitParameters
Parameters for the main function.
Definition: PlanarVXDMomentumMeasurement.h:104
genfit::StateOnPlane
A state with arbitrary dimension defined in a DetPlane.
Definition: StateOnPlane.h:47
Belle2::PlanarVXDMomentumMeasurement::setUseTrackingSeeds
void setUseTrackingSeeds(bool useTrackingSeeds)
Set whether to use tracking seeds not the current state.
Definition: PlanarVXDMomentumMeasurement.h:91
Belle2::PlanarVXDMomentumMeasurement::getHit
HitType * getHit() const
Get the underlaying hit (cluster).
Definition: PlanarVXDMomentumMeasurement.h:97
Belle2::VXDMomentumEstimationTools::getEntryPositionOfMCParticle
TVector3 getEntryPositionOfMCParticle(const ClusterType &) const
Return the entry position of the simulated MCParticle at this cluster (by using the TrueHit associate...
Definition: VXDMomentumEstimationTools.h:177
Belle2::PlanarVXDMomentumMeasurement::m_sigma
double m_sigma
Value of the measurement sigma.
Definition: PlanarVXDMomentumMeasurement.h:114
genfit::PlanarMeasurement
Measurement class implementing a planar hit geometry (1 or 2D).
Definition: PlanarMeasurement.h:44
Belle2::VXDMomentumEstimation
Class doing the momentum estimation from dEdX for SVDClusters and PXDClusters.
Definition: VXDMomentumEstimation.h:37
genfit::AbsMeasurement
Contains the measurement and covariance in raw detector coordinates.
Definition: AbsMeasurement.h:42
Belle2::RecoTrack
This is the Reconstruction Event-Data Model Track.
Definition: RecoTrack.h:78
Belle2::PlanarVXDMomentumMeasurement::m_correctionFitParameters
VXDMomentumEstimation< HitType >::CorrectionFitParameters m_correctionFitParameters
Parameters for the correction function.
Definition: PlanarVXDMomentumMeasurement.h:106
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::PlanarVXDMomentumMeasurement::setUseMCInformation
void setUseMCInformation(bool useMCInformation)
Set whether to use mc information.
Definition: PlanarVXDMomentumMeasurement.h:79
Belle2::VXDMomentumEstimation::estimateQOverPWithThickness
double estimateQOverPWithThickness(const ClusterType &cluster, short charge, const FitParameters &fitParameters, const CorrectionFitParameters &correctionFitParameters) const
Main function: Estimate p over q for the given cluster and the thickness of the cluster with the fit ...
Definition: VXDMomentumEstimation.h:96
Belle2::MCParticle::getProductionVertex
TVector3 getProductionVertex() const
Return production vertex position.
Definition: MCParticle.h:200
Belle2::PlanarVXDMomentumMeasurement::setFitParameters
void setFitParameters(const typename VXDMomentumEstimation< HitType >::FitParameters &fitParameters)
Set the fit parameters.
Definition: PlanarVXDMomentumMeasurement.h:73
Belle2::PlanarVXDMomentumMeasurement::setSigma
void setSigma(double sigma)
Set the measurement sigma.
Definition: PlanarVXDMomentumMeasurement.h:67
Belle2::PlanarVXDMomentumMeasurement::m_useThickness
bool m_useThickness
Use the thickness of the clusters of the path length for estimating dX.
Definition: PlanarVXDMomentumMeasurement.h:108
Belle2::PlanarVXDMomentumMeasurement::m_hit
HitType * m_hit
Underlaying hit/cluster.
Definition: PlanarVXDMomentumMeasurement.h:117
Belle2::MCParticle::getMomentum
TVector3 getMomentum() const
Return momentum.
Definition: MCParticle.h:209
Belle2::VXDMomentumEstimation::getInstance
static const VXDMomentumEstimation & getInstance()
Use this class as a singleton.
Definition: VXDMomentumEstimation.h:74
Belle2::PlanarVXDMomentumMeasurement::PlanarVXDMomentumMeasurement
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 ...
Definition: PlanarVXDMomentumMeasurement.h:44
Belle2::PlanarVXDMomentumMeasurement::m_useTrackingSeeds
bool m_useTrackingSeeds
Use the tracking seeds in the origin for calculating the path length rather than the current state.
Definition: PlanarVXDMomentumMeasurement.h:112
Belle2::MCParticle
A Class to store the Monte Carlo particle information.
Definition: MCParticle.h:43
Belle2::VXDMomentumEstimationTools
Tools needed for the VXD momentum estimation to, e.g.
Definition: VXDMomentumEstimationTools.h:43
Belle2::PlanarMomentumMeasurement
Measurement class implementing a planar hit geometry (1 or 2D) with only a momentum measurement.
Definition: PlanarMomentumMeasurement.h:36
Belle2::PlanarVXDMomentumMeasurement::getDetId
int getDetId() const
Return the detector ID.
Definition: PlanarVXDMomentumMeasurement.h:122
genfit::MeasurementOnPlane
Measured coordinates on a plane.
Definition: MeasurementOnPlane.h:46
Belle2::PlanarVXDMomentumMeasurement::m_recoTrack
const RecoTrack * m_recoTrack
RecoTrack for which the hit is created.
Definition: PlanarVXDMomentumMeasurement.h:119
Belle2::VXDMomentumEstimationTools::getEntryMomentumOfMCParticle
TVector3 getEntryMomentumOfMCParticle(const ClusterType &) const
Return the momentum of the simulated MCParticle at this cluster (by using the TrueHit associated with...
Definition: VXDMomentumEstimationTools.h:169
Belle2::PlanarVXDMomentumMeasurement::setUseThickness
void setUseThickness(bool useThickness)
Set whether to use the thickness.
Definition: PlanarVXDMomentumMeasurement.h:85