Belle II Software  release-05-01-25
VXDMomentumEstimationTools.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/spacePointCreation/SpacePoint.h>
14 #include <vxd/dataobjects/VxdID.h>
15 #include <framework/geometry/B2Vector3.h>
16 #include <TVector3.h>
17 #include <framework/dataobjects/Helix.h>
18 #include <vxd/geometry/GeoCache.h>
19 #include <vxd/geometry/SensorInfoBase.h>
20 #include <algorithm>
21 #include <cmath>
22 #include <framework/logging/Logger.h>
23 
24 
25 namespace Belle2 {
30  class SVDCluster;
31  class PXDCluster;
32 
34  template <class ClusterType>
35  class VXDMomentumEstimationTools {
36 
37  private:
44 
45  public:
48  {
49  static VXDMomentumEstimationTools instance;
50  return instance;
51  }
52 
54  double getDEDX(const ClusterType& cluster, const TVector3& momentum, const TVector3& position, short charge) const
55  {
56 
57  const Helix trajectory(position, momentum, charge, 1.5);
58  const double calibratedCharge = getCalibratedCharge(cluster);
59  const double pathLength = getPathLength(cluster, trajectory);
60 
61  return calibratedCharge / pathLength;
62  }
63 
65  double getDEDXWithThickness(const ClusterType& cluster) const
66  {
67  const double calibratedCharge = getCalibratedCharge(cluster);
68  const double pathLength = getThicknessOfCluster(cluster);
69 
70  return calibratedCharge / pathLength;
71  }
72 
74  double getThicknessOfCluster(const ClusterType& cluster) const
75  {
76  const VxdID& vxdID = cluster.getSensorID();
77  const VXD::SensorInfoBase& sensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(vxdID);
78  return sensorInfoBase.getThickness();
79  }
80 
82  double getWidthOfCluster(const ClusterType& cluster) const
83  {
84  const VxdID& vxdID = cluster.getSensorID();
85  const VXD::SensorInfoBase& sensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(vxdID);
86  return sensorInfoBase.getWidth();
87  }
88 
90  double getLengthOfCluster(const ClusterType& cluster) const
91  {
92  const VxdID& vxdID = cluster.getSensorID();
93  const VXD::SensorInfoBase& sensorInfoBase = VXD::GeoCache::getInstance().getSensorInfo(vxdID);
94  return sensorInfoBase.getLength();
95  }
96 
98  double getRadiusOfCluster(const ClusterType& cluster) const
99  {
100  const SpacePoint* spacePoint = cluster.template getRelated<SpacePoint>("SpacePoints");
101 
102  double radius = 0;
103  if (spacePoint == nullptr) {
104  // Fallback function
105  VxdID vxdID = cluster.getSensorID();
107  radius = m_layerPositions[layer - 1] / 100.0;
108  B2WARNING("Could not determine SpacePoint for this cluster. Falling back to geometrical information.");
109  } else {
110  // The positions is the one with w = 0 which is the one on the lowest detector plane.
111  radius = spacePoint->getPosition().Perp();
112  }
113  return radius;
114  }
115 
117  VxdID::baseType getLayerOfCluster(const ClusterType& cluster) const
118  {
119  VxdID vxdID = cluster.getSensorID();
120  VxdID::baseType layer = vxdID.getLayerNumber();
121  return layer;
122  }
123 
125  VxdID::baseType getLadderOfCluster(const ClusterType& cluster) const
126  {
127  VxdID vxdID = cluster.getSensorID();
128  VxdID::baseType ladder = vxdID.getLadderNumber();
129  return ladder;
130  }
131 
133  VxdID::baseType getSensorNumberOfCluster(const ClusterType& cluster) const
134  {
135  VxdID vxdID = cluster.getSensorID();
136  VxdID::baseType sensorNumber = vxdID.getSensorNumber();
137  return sensorNumber;
138  }
139 
141  VxdID::baseType getSegmentNumberOfCluster(const ClusterType& cluster) const
142  {
143  VxdID vxdID = cluster.getSensorID();
144  VxdID::baseType segmentNumber = vxdID.getSegmentNumber();
145  return segmentNumber;
146  }
147 
151  double getCalibratedCharge(const ClusterType& cluster) const
152  {
153  const double charge = cluster.getCharge();
154  const double calibration = getCalibration();
155 
156  return calibration * charge;
157  }
158 
161  TVector3 getEntryMomentumOfMCParticle(const ClusterType&) const
162  {
163  B2FATAL("Can not deal with this cluster type!");
164  return TVector3();
165  }
166 
169  TVector3 getEntryPositionOfMCParticle(const ClusterType&) const
170  {
171  B2FATAL("Can not deal with this cluster type!");
172  return TVector3();
173  }
174 
181  double getPathLength(const ClusterType& cluster, const Helix& trajectory) const
182  {
183  // This is not quite correct but we can not do better without doing an extrapolation with material effects.
184  // If the distance_3D is nan, it means that the helix does not reach into the cluster or curls that much
185  // that it does not reach the far end of the cluster. The first case is strange
186  // because the track is associated with the cluster (so it should normally reach it). The second case should be
187  // really rare (because the clusters are that thin), but we have to deal with it.
188  // There is also the possibility that the track curls that much that it interacts with the same sensor twice.
189  // This can not be handled properly in this stage.
190 
191  const double thickness = getThicknessOfCluster(cluster);
192  const double radius = getRadiusOfCluster(cluster);
193  const double width = getWidthOfCluster(cluster);
194  const double length = getLengthOfCluster(cluster);
195 
196  const double perp_s_at_cluster_entry = trajectory.getArcLength2DAtCylindricalR(radius);
197 
198  if (std::isnan(perp_s_at_cluster_entry)) {
199  // This case is really strange. I do not know how to deal with it probably.
200  return thickness;
201  }
202 
203  const TVector3& position_at_inner_radius = trajectory.getPositionAtArcLength2D(perp_s_at_cluster_entry);
204 
205  const double perp_s_at_cluster_exit = trajectory.getArcLength2DAtCylindricalR(radius + thickness);
206 
207  if (std::isnan(perp_s_at_cluster_exit)) {
208  return std::min(width, length);
209  }
210 
211  const TVector3& position_at_outer_radius = trajectory.getPositionAtArcLength2D(perp_s_at_cluster_exit);
212 
213  const double distance_3D = (position_at_outer_radius - position_at_inner_radius).Mag();
214 
215  return distance_3D;
216  }
217 
218  private:
220  const double m_layerPositions[6] = {1.42, 2.18, 3.81, 8.0, 10.51, 13.51};
221 
223  double getCalibration() const
224  {
225  return 1;
226  }
227  };
228 
230  template<>
232 
234  template <>
236 
238  template <>
240 
242  template <>
244 
246  template <>
249 }
Belle2::VXDMomentumEstimationTools::getWidthOfCluster
double getWidthOfCluster(const ClusterType &cluster) const
Return the thickness of a cluster.
Definition: VXDMomentumEstimationTools.h:90
Belle2::VXDMomentumEstimationTools::getSegmentNumberOfCluster
VxdID::baseType getSegmentNumberOfCluster(const ClusterType &cluster) const
Return the segment number of the cluster.
Definition: VXDMomentumEstimationTools.h:149
Belle2::B2Vector3::Perp
DataType Perp() const
The transverse component (R in cylindrical coordinate system).
Definition: B2Vector3.h:199
Belle2::VxdID
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:43
Belle2::VXDMomentumEstimationTools::getLadderOfCluster
VxdID::baseType getLadderOfCluster(const ClusterType &cluster) const
Return the ladder of the cluster.
Definition: VXDMomentumEstimationTools.h:133
Belle2::VXDMomentumEstimationTools::getInstance
static const VXDMomentumEstimationTools & getInstance()
Use this class as singleton.
Definition: VXDMomentumEstimationTools.h:55
Belle2::VxdID::getLadderNumber
baseType getLadderNumber() const
Get the ladder id.
Definition: VxdID.h:108
Belle2::VXD::SensorInfoBase
Base class to provide Sensor Information for PXD and SVD.
Definition: SensorInfoBase.h:40
Belle2::VXD::SensorInfoBase::getWidth
double getWidth(double v=0) const
Return the width of the sensor.
Definition: SensorInfoBase.h:91
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::VXDMomentumEstimationTools::getLengthOfCluster
double getLengthOfCluster(const ClusterType &cluster) const
Return the thickness of a cluster.
Definition: VXDMomentumEstimationTools.h:98
Belle2::SpacePoint
SpacePoint typically is build from 1 PXDCluster or 1-2 SVDClusters.
Definition: SpacePoint.h:52
Belle2::SpacePoint::getPosition
const B2Vector3< double > & getPosition() const
return the position vector in global coordinates
Definition: SpacePoint.h:148
Belle2::VXDMomentumEstimationTools::VXDMomentumEstimationTools
VXDMomentumEstimationTools()
Do not create this class.
Definition: VXDMomentumEstimationTools.h:47
Belle2::VXDMomentumEstimationTools::m_layerPositions
const double m_layerPositions[6]
the layer positions in the case we do not have a SpacePoint we can look at.
Definition: VXDMomentumEstimationTools.h:228
Belle2::VXDMomentumEstimationTools::getThicknessOfCluster
double getThicknessOfCluster(const ClusterType &cluster) const
Return the thickness of a cluster.
Definition: VXDMomentumEstimationTools.h:82
Belle2::VxdID::baseType
unsigned short baseType
The base integer type for VxdID.
Definition: VxdID.h:46
Belle2::VXD::SensorInfoBase::getLength
double getLength() const
Return the length of the sensor.
Definition: SensorInfoBase.h:116
Belle2::VXD::GeoCache::getInstance
static GeoCache & getInstance()
Return a reference to the singleton instance.
Definition: GeoCache.cc:215
Belle2
Abstract base class for different kinds of events.
Definition: MillepedeAlgorithm.h:19
Belle2::VXD::SensorInfoBase::getThickness
double getThickness() const
Return the thickness of the sensor.
Definition: SensorInfoBase.h:121
Belle2::VXDMomentumEstimationTools::operator=
VXDMomentumEstimationTools & operator=(const VXDMomentumEstimationTools &)
Do not create this class.
Belle2::VXDMomentumEstimationTools::getRadiusOfCluster
double getRadiusOfCluster(const ClusterType &cluster) const
Returns the distance from the interaction point to the cluster in the r-phi-plane.
Definition: VXDMomentumEstimationTools.h:106
Belle2::VXDMomentumEstimationTools::getPathLength
double getPathLength(const ClusterType &cluster, const Helix &trajectory) const
Return the path length of a particle with the given helix that goes through the cluster.
Definition: VXDMomentumEstimationTools.h:189
Belle2::PXDCluster
The PXD Cluster class This class stores all information about reconstructed PXD clusters The position...
Definition: PXDCluster.h:41
Belle2::VxdID::getSensorNumber
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:110
Belle2::CDC::Helix
Helix parameter class.
Definition: Helix.h:51
Belle2::SVDCluster
The SVD Cluster class This class stores all information about reconstructed SVD clusters.
Definition: SVDCluster.h:38
Belle2::VXDMomentumEstimationTools::getCalibratedCharge
double getCalibratedCharge(const ClusterType &cluster) const
Return the charge of the cluster (in ADC count) calibrated with a factor of ~0.6 for pxd hits.
Definition: VXDMomentumEstimationTools.h:159
Belle2::VXD::GeoCache::getSensorInfo
const SensorInfoBase & getSensorInfo(Belle2::VxdID id) const
Return a referecne to the SensorInfo of a given SensorID.
Definition: GeoCache.cc:68
Belle2::VxdID::getLayerNumber
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:106
Belle2::VXDMomentumEstimationTools
Tools needed for the VXD momentum estimation to, e.g.
Definition: VXDMomentumEstimationTools.h:43
Belle2::VXDMomentumEstimationTools::getDEDX
double getDEDX(const ClusterType &cluster, const TVector3 &momentum, const TVector3 &position, short charge) const
Main function: return dEdX for a cluster and the given momentum, position and charge seeds.
Definition: VXDMomentumEstimationTools.h:62
Belle2::VXDMomentumEstimationTools::getDEDXWithThickness
double getDEDXWithThickness(const ClusterType &cluster) const
Return dEdX but not with dX = path length but with dX = thickness of cluster.
Definition: VXDMomentumEstimationTools.h:73
Belle2::VXDMomentumEstimationTools::getLayerOfCluster
VxdID::baseType getLayerOfCluster(const ClusterType &cluster) const
Return the layer of the cluster.
Definition: VXDMomentumEstimationTools.h:125
Belle2::VXDMomentumEstimationTools::getCalibration
double getCalibration() const
For SVD the calibration is 1, for PXD (see below) it is ~0.6.
Definition: VXDMomentumEstimationTools.h:231
Belle2::VxdID::getSegmentNumber
baseType getSegmentNumber() const
Get the sensor segment.
Definition: VxdID.h:112
Belle2::VXDMomentumEstimationTools::getSensorNumberOfCluster
VxdID::baseType getSensorNumberOfCluster(const ClusterType &cluster) const
Return the sensor number of the cluster.
Definition: VXDMomentumEstimationTools.h:141
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