CMS 3D CMS Logo

EnergyLossUpdator.cc
Go to the documentation of this file.
3 
6 
7 void oldComputeBetheBloch(const LocalVector& localP, const MediumProperties& materialConstants, double mass);
8 void oldComputeElectrons(const LocalVector& localP,
9  const MediumProperties& materialConstants,
10  const PropagationDirection propDir);
11 
12 //
13 // Computation of contribution of energy loss to momentum and covariance
14 // matrix of local parameters based on Bethe-Bloch. For electrons
15 // contribution of radiation acc. to Bethe & Heitler.
16 //
18  const PropagationDirection propDir,
19  Effect& effect) const {
20  //
21  // Get surface
22  //
23  const Surface& surface = TSoS.surface();
24  //
25  //
26  // Now get information on medium
27  //
28  if (surface.mediumProperties().isValid()) {
29  //
30  // Bethe-Bloch
31  //
32  if (mass() > 0.001)
33  computeBetheBloch(TSoS.localMomentum(), surface.mediumProperties(), effect);
34  //
35  // Special treatment for electrons (currently rather crude
36  // distinction using mass)
37  //
38  else
39  computeElectrons(TSoS.localMomentum(), surface.mediumProperties(), propDir, effect);
40  if (propDir != alongMomentum)
41  effect.deltaP *= -1.;
42  }
43 }
44 //
45 // Computation of energy loss according to Bethe-Bloch
46 //
48  const MediumProperties& materialConstants,
49  Effect& effect) const {
50  //
51  // calculate absolute momentum and correction to path length from angle
52  // of incidence
53  //
54 
55  typedef float Float;
56 
57  Float p2 = localP.mag2();
58  Float xf = std::abs(std::sqrt(p2) / localP.z());
59 
60  // constants
61  const Float m2 = mass() * mass(); // use mass hypothesis from constructor
62 
63  constexpr Float emass = 0.511e-3;
64  constexpr Float poti = 16.e-9 * 10.75; // = 16 eV * Z**0.9, for Si Z=14
65  const Float eplasma = 28.816e-9 * sqrt(2.33 * 0.498); // 28.816 eV * sqrt(rho*(Z/A)) for Si
66  const Float delta0 = 2 * log(eplasma / poti) - 1.;
67 
68  // calculate general physics things
69  Float im2 = Float(1.) / m2;
70  Float e2 = p2 + m2;
71  Float e = std::sqrt(e2);
72  Float beta2 = p2 / e2;
73  Float eta2 = p2 * im2;
74  Float ratio2 = (emass * emass) * im2;
75  Float emax = Float(2.) * emass * eta2 / (Float(1.) + Float(2.) * emass * e * im2 + ratio2);
76 
77  Float xi = materialConstants.xi() * xf;
78  xi /= beta2;
79 
80  Float dEdx = xi * (unsafe_logf<2>(Float(2.) * emass * emax / (poti * poti)) - Float(2.) * (beta2)-delta0);
81 
82  Float dEdx2 = xi * emax * (Float(1.) - Float(0.5) * beta2);
83  Float dP = dEdx / std::sqrt(beta2);
84  Float sigp2 = dEdx2 / (beta2 * p2 * p2);
85  effect.deltaP += -dP;
86  using namespace materialEffect;
87  effect.deltaCov[elos] += sigp2;
88 
89  // std::cout << "pion new " << theDeltaP << " " << theDeltaCov(0,0) << std::endl;
90  // oldComputeBetheBloch (localP, materialConstants, mass());
91 }
92 //
93 // Computation of energy loss for electrons
94 //
96  const MediumProperties& materialConstants,
97  const PropagationDirection propDir,
98  Effect& effect) const {
99  //
100  // calculate absolute momentum and correction to path length from angle
101  // of incidence
102  //
103  float p2 = localP.mag2();
104  float p = std::sqrt(p2);
105  float normalisedPath = std::abs(p / localP.z()) * materialConstants.radLen();
106  //
107  // Energy loss and variance according to Bethe and Heitler, see also
108  // Comp. Phys. Comm. 79 (1994) 157.
109  //
110  const float l3ol2 = std::log(3.) / std::log(2.);
111  float z = unsafe_expf<3>(-normalisedPath);
112  float varz = unsafe_expf<3>(-normalisedPath * l3ol2) - z * z;
113  // exp(-2*normalisedPath);
114 
115  if (propDir == oppositeToMomentum) {
116  //
117  // for backward propagation: delta(1/p) is linear in z=p_outside/p_inside
118  // convert to obtain equivalent delta(p). Sign of deltaP is corrected
119  // in method compute -> deltaP<0 at this place!!!
120  //
121  effect.deltaP += -p * (1.f / z - 1.f);
122  using namespace materialEffect;
123  effect.deltaCov[elos] += varz / p2;
124  } else {
125  //
126  // for forward propagation: calculate in p (linear in 1/z=p_inside/p_outside),
127  // then convert sig(p) to sig(1/p).
128  //
129  effect.deltaP += p * (z - 1.f);
130  // float f = 1/p/z/z;
131  // patch to ensure consistency between for- and backward propagation
132  float f2 = 1.f / (p2 * z * z);
133  using namespace materialEffect;
134  effect.deltaCov[elos] += f2 * varz;
135  }
136 
137  // std::cout << "electron new " << theDeltaP << " " << theDeltaCov(0,0) << std::endl;
138  // oldComputeElectrons (localP, materialConstants, propDir);
139 }
140 
142 
143 void oldComputeBetheBloch(const LocalVector& localP, const MediumProperties& materialConstants, double mass) {
144  double theDeltaP = 0., theDeltaCov = 0;
145 
146  //
147  // calculate absolute momentum and correction to path length from angle
148  // of incidence
149  //
150  double p = localP.mag();
151  double xf = fabs(p / localP.z());
152  // constants
153  const double m = mass; // use mass hypothesis from constructor
154 
155  const double emass = 0.511e-3;
156  const double poti = 16.e-9 * 10.75; // = 16 eV * Z**0.9, for Si Z=14
157  const double eplasma = 28.816e-9 * sqrt(2.33 * 0.498); // 28.816 eV * sqrt(rho*(Z/A)) for Si
158  const double delta0 = 2 * log(eplasma / poti) - 1.;
159 
160  // calculate general physics things
161  double e = sqrt(p * p + m * m);
162  double beta = p / e;
163  double gamma = e / m;
164  double eta2 = beta * gamma;
165  eta2 *= eta2;
166  // double lnEta2 = log(eta2);
167  double ratio = emass / m;
168  double emax = 2. * emass * eta2 / (1. + 2. * ratio * gamma + ratio * ratio);
169  // double delta = delta0 + lnEta2;
170 
171  // calculate the mean and sigma of energy loss
172  // xi = d[g/cm2] * 0.307075MeV/(g/cm2) * Z/A * 1/2
173  double xi = materialConstants.xi() * xf;
174  xi /= (beta * beta);
175 
176  // double dEdx = xi*(log(2.*emass*eta2*emax/(poti*poti)) - 2.*(beta*beta));
177  //double dEdx = xi*(log(2.*emass*emax/(poti*poti))+lnEta2 - 2.*(beta*beta) - delta);
178 
179  double dEdx = xi * (log(2. * emass * emax / (poti * poti)) - 2. * (beta * beta) - delta0);
180  double dEdx2 = xi * emax * (1. - 0.5 * (beta * beta));
181  double dP = dEdx / beta;
182  double sigp2 = dEdx2 * e * e / (p * p * p * p * p * p);
183  theDeltaP += -dP;
184  theDeltaCov += sigp2;
185 
186  std::cout << "pion old " << theDeltaP << " " << theDeltaCov << std::endl;
187 }
188 
189 void oldComputeElectrons(const LocalVector& localP,
190  const MediumProperties& materialConstants,
191  const PropagationDirection propDir) {
192  double theDeltaP = 0., theDeltaCov = 0;
193 
194  //
195  // calculate absolute momentum and correction to path length from angle
196  // of incidence
197  //
198  double p = localP.mag();
199  double normalisedPath = fabs(p / localP.z()) * materialConstants.radLen();
200  //
201  // Energy loss and variance according to Bethe and Heitler, see also
202  // Comp. Phys. Comm. 79 (1994) 157.
203  //
204  double z = exp(-normalisedPath);
205  double varz = exp(-normalisedPath * log(3.) / log(2.)) - z * z;
206  // exp(-2*normalisedPath);
207 
208  if (propDir == oppositeToMomentum) {
209  //
210  // for backward propagation: delta(1/p) is linear in z=p_outside/p_inside
211  // convert to obtain equivalent delta(p). Sign of deltaP is corrected
212  // in method compute -> deltaP<0 at this place!!!
213  //
214  theDeltaP += -p * (1 / z - 1);
215  theDeltaCov += varz / (p * p);
216  } else {
217  //
218  // for forward propagation: calculate in p (linear in 1/z=p_inside/p_outside),
219  // then convert sig(p) to sig(1/p).
220  //
221  theDeltaP += p * (z - 1);
222  // double f = 1/p/z/z;
223  // patch to ensure consistency between for- and backward propagation
224  double f = 1. / (p * z);
225  theDeltaCov += f * f * varz;
226  }
227 
228  std::cout << "electron old " << theDeltaP << " " << theDeltaCov << std::endl;
229 }
T z() const
Definition: PV3DBase.h:61
void oldComputeBetheBloch(const LocalVector &localP, const MediumProperties &materialConstants, double mass)
void computeElectrons(const LocalVector &, const MediumProperties &, const PropagationDirection, Effect &effect) const
void compute(const TrajectoryStateOnSurface &, const PropagationDirection, Effect &effect) const override
PropagationDirection
T mag2() const
Definition: PV3DBase.h:63
const SurfaceType & surface() const
T sqrt(T t)
Definition: SSEVec.h:23
float radLen() const
T mag() const
Definition: PV3DBase.h:64
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double f[11][100]
void oldComputeElectrons(const LocalVector &localP, const MediumProperties &materialConstants, const PropagationDirection propDir)
void computeBetheBloch(const LocalVector &, const MediumProperties &, Effect &effect) const
const MediumProperties & mediumProperties() const
Definition: Surface.h:83
float xi() const
bool isValid() const