Belle II Software  release-06-02-00
SensorInfo.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 
9 #include <pxd/geometry/SensorInfo.h>
10 #include <framework/gearbox/Unit.h>
11 #include <framework/gearbox/Const.h>
12 #include <framework/geometry/BFieldManager.h>
13 #include <vxd/geometry/GeoCache.h>
14 
15 using namespace std;
16 using namespace Belle2;
17 using namespace Belle2::PXD;
18 
19 
20 double SensorInfo::getElectronMobility(double E) const
21 {
22  // Electron parameters - maximum velocity, critical intensity, beta factor
23  static double vmElec = 1.53 * pow(m_temperature, -0.87) * 1.E9 * Unit::cm
24  / Unit::s;
25  static double EcElec = 1.01 * pow(m_temperature, +1.55) * Unit::V
26  / Unit::cm;
27  static double betaElec = 2.57 * pow(m_temperature, +0.66) * 1.E-2;
28 
29  return (vmElec / EcElec * 1.
30  / (pow(1. + pow((fabs(E) / EcElec), betaElec), (1. / betaElec))));
31 }
32 
33 const TVector3 SensorInfo::getEField(const TVector3& point) const
34 {
35  // FIXME: Get rid of the gateDepth
36  double depletionVoltage = 0.5 * Unit::e * m_bulkDoping
37  / Const::permSi * m_thickness * m_thickness;
38  double gateZ = 0.5 * m_thickness - m_gateDepth;
39  double Ez = 2 * depletionVoltage * (point.Z() - gateZ) / m_thickness
40  / m_thickness;
41  TVector3 E(0, 0, Ez);
42  return E;
43 }
44 
45 const TVector3 SensorInfo::getBField(const TVector3& point) const
46 {
47  TVector3 pointGlobal = pointToGlobal(point, true);
48  TVector3 bGlobal = BFieldManager::getField(pointGlobal);
49  TVector3 bLocal = vectorToLocal(bGlobal, true);
50  return bLocal;
51 }
52 
53 const TVector3 SensorInfo::getDriftVelocity(const TVector3& E,
54  const TVector3& B) const
55 {
56  // Set mobility parameters
57  double mobility = -getElectronMobility(E.Mag());
58  double mobilityH = m_hallFactor * mobility;
59  // Calculate products
60  TVector3 EcrossB = E.Cross(B);
61  TVector3 BEdotB = E.Dot(B) * B;
62  TVector3 v = mobility * E + mobility * mobilityH * EcrossB
63  + mobility * mobilityH * mobilityH * BEdotB;
64  v *= 1.0 / (1.0 + mobilityH * mobilityH * B.Mag2());
65  return v;
66 }
67 
68 int SensorInfo::getPixelKind(const VxdID sensorID, double v) const
69 {
70  const SensorInfo& Info = dynamic_cast<const SensorInfo&>(VXD::GeoCache::get(sensorID));
71  int i_pixelKind = Info.getVPitchID(v);
72  if (Info.getID().getLayerNumber() == 2) i_pixelKind += 4;
73  if (Info.getID().getSensorNumber() == 2) i_pixelKind += 2;
74  return i_pixelKind;
75 }
76 
77 int SensorInfo::getPixelKindNew(const VxdID& sensorID, int vID) const
78 {
79  const SensorInfo& Info = dynamic_cast<const SensorInfo&>(VXD::GeoCache::get(sensorID));
80  double v = Info.getVCellPosition(vID);
81  double vPitch = Info.getVPitch(v);
82  int i_pixelKind = 0;
83 
84  if (std::fabs(vPitch - 0.0055) < 0.0001)
85  i_pixelKind = 0;
86  else if (std::fabs(vPitch - 0.0060) < 0.0001)
87  i_pixelKind = 1;
88  else if (std::fabs(vPitch - 0.0070) < 0.0001)
89  i_pixelKind = 2;
90  else if (std::fabs(vPitch - 0.0085) < 0.0001)
91  i_pixelKind = 3;
92  else
93  B2FATAL("Unexpected pixel vPitch.");
94  return i_pixelKind;
95 }
96 
97 
98 const TVector3 SensorInfo::getLorentzShift(double u, double v) const
99 {
100  // Constants for the 5-point Gauss quadrature formula
101  const double alphaGL = 1.0 / 3.0 * sqrt(5.0 + 2.0 * sqrt(10.0 / 7.0));
102  const double betaGL = 1.0 / 3.0 * sqrt(5.0 - 2.0 * sqrt(10.0 / 7.0));
103  const double walpha = (322 - 13.0 * sqrt(70)) / 900;
104  const double wbeta = (322 + 13.0 * sqrt(70)) / 900;
105  const double distanceToPlane = 0.5 * m_thickness - m_gateDepth;
106  const double midpoint = 0.5 * distanceToPlane;
107  const double h = 0.5 * distanceToPlane;
108  const double weightGL[5] = {
109  h * walpha, h * wbeta, h * 128.0 / 225.0, h * wbeta, h* walpha
110  };
111  const double zKnots[5] = {
112  midpoint - alphaGL * h, midpoint - betaGL * h, midpoint, midpoint + betaGL * h, midpoint + alphaGL* h
113  };
114  // Integrate v/v_z from z = 0 to z = distanceToPlane
115  TVector3 position(u, v, 0);
116  TVector3 currentBField = getBField(position);
117  for (int iz = 0; iz < 5; ++iz) {
118  // This is OK as long as E only depends on z
119  TVector3 currentEField = getEField(TVector3(0, 0, zKnots[iz]));
120  TVector3 velocity = getDriftVelocity(currentEField, currentBField);
121  position += weightGL[iz] / velocity.Z() * velocity;
122  } // for knots
123  position.SetZ(0);
124  position.SetX(position.X() - u);
125  position.SetY(position.Y() - v);
126  return position;
127 }
128 
129 void SensorInfo::cook()
130 {
131  m_iup = m_uCells / m_width;
132  m_up = m_width / m_uCells;
133 
134  m_vsplit = m_length * (m_splitLength - 0.5);
135 
136  m_vp = m_length * m_splitLength / m_vCells;
137  m_ivp = 1 / m_vp;
138 
139  m_vp2 = m_length * (1 - m_splitLength) / m_vCells2;
140  m_ivp2 = 1 / m_vp2;
141 
142  m_hxIG = 0.5 * m_up - m_clearBorderSmallPitch;
143  m_mIGL = 0.5 * (m_vp - m_sourceBorderLargePitch + m_drainBorderLargePitch);
144  m_sIGL = 0.5 * (m_vp - m_sourceBorderLargePitch - m_drainBorderLargePitch);
145  m_mIGS = 0.5 * (m_vp2 - m_sourceBorderSmallPitch + m_drainBorderSmallPitch);
146  m_sIGS = 0.5 * (m_vp2 - m_sourceBorderSmallPitch - m_drainBorderSmallPitch);
147 }
148 
149 int SensorInfo::getTrappedID(double x, double y) const
150 {
151  double huCells = 0.5 * m_uCells;
152  double ix = floor(x * m_iup + huCells);
153  int jx = ix;
154  double x0 = (ix + 0.5 - huCells) * m_up;
155 
156  if (fabs(x - x0) < m_hxIG) {
157  if ((unsigned)jx >= (unsigned)m_uCells) return -1;
158  double ys = y - m_vsplit;
159  if (ys >= 0) {
160  double iy = floor(ys * m_ivp2);
161  int jy = iy;
162  iy = jy / 2;
163  double y0 = iy * m_vp2 * 2 + m_vp2;
164  double yl = fabs(ys - y0);
165  if (fabs(yl - m_mIGS) < m_sIGS) {
166  if ((unsigned)jy >= (unsigned)m_vCells2) return -1;
167  return jx + m_uCells * (jy + m_vCells);
168  }
169  return -1;
170  } else {
171  ys = y + 0.5 * m_length;
172  double iy = floor(ys * m_ivp);
173  int jy = iy;
174  iy = jy / 2;
175  double y0 = iy * m_vp * 2 + m_vp;
176  double yl = fabs(ys - y0);
177  if (fabs(yl - m_mIGL) < m_sIGL) {
178  if ((unsigned)jy >= (unsigned)m_vCells) return -1;
179  return jx + m_uCells * jy;
180  }
181  return -1;
182  }
183  }
184  return -1;
185 }
Specific implementation of SensorInfo for PXD Sensors which provides additional pixel specific inform...
Definition: SensorInfo.h:23
double getVCellPosition(int vID) const
Return the position of a specific strip/pixel in v direction.
VxdID getID() const
Return the ID of the Sensor.
double getVPitch(double v=0) const
Return the pitch of the sensor.
int getVPitchID(double v=0) const
Return the pitch ID of the sensor.
Class to uniquely identify a any structure of the PXD and SVD.
Definition: VxdID.h:33
baseType getSensorNumber() const
Get the sensor id.
Definition: VxdID.h:100
baseType getLayerNumber() const
Get the layer id.
Definition: VxdID.h:96
Namespace to encapsulate code needed for simulation and reconstrucion of the PXD.
Abstract base class for different kinds of events.