GFMaterialEffects.h
Go to the documentation of this file.
1 /* Copyright 2008-2009, Technische Universitaet Muenchen,
2  Authors: Christian Hoeppner & Sebastian Neubert
3 
4  This file is part of GENFIT.
5 
6  GENFIT is free software: you can redistribute it and/or modify
7  it under the terms of the GNU Lesser General Public License as published
8  by the Free Software Foundation, either version 3 of the License, or
9  (at your option) any later version.
10 
11  GENFIT is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  GNU Lesser General Public License for more details.
15 
16  You should have received a copy of the GNU Lesser General Public License
17  along with GENFIT. If not, see <http://www.gnu.org/licenses/>.
18 */
19 
20 /** @addtogroup RKTrackRep
21  * @{
22  */
23 
24 #ifndef GFMATERIALEFFECTS_H
25 #define GFMATERIALEFFECTS_H
26 
27 #include "TObject.h"
28 #include <vector>
29 #include "TVector3.h"
30 
31 class TGeoMaterial;
32 
33 /** @brief Handles energy loss classes. Contains stepper and energy loss/noise matrix calculation
34  *
35  *
36  * @author Christian H&ouml;ppner (Technische Universit&auml;t M&uuml;nchen, original author)
37  * @author Sebastian Neubert (Technische Universit&auml;t M&uuml;nchen, original author)
38  * @author Johannes Rauch (Technische Universit&auml;t M&uuml;nchen, author)
39  *
40  * This class handles the different energy loss classes that inherit from GFAbsEnergyLoss.
41  * It provides functionality to limit the stepsize of an extrapolation in order not to
42  * exceed a specified maximum momentum loss. After propagation, the energy loss
43  * for the given length and (optionally) the noise matrix can be calculated.
44  *
45  *
46  */
47 
48 namespace genf {
49 
50 class GFMaterialEffects : public TObject{
51  private:
52 
54  virtual ~GFMaterialEffects();
56 
57  public:
59  static void destruct();
60 
63  void setNoiseCoulomb(bool opt = true){fNoiseCoulomb=opt;}
65  void setNoiseBrems(bool opt = true){fNoiseBrems=opt;}
66 
67  //! Calculates energy loss in the travelled path, optional calculation of noise matrix
68  double effects(const std::vector<TVector3>& points,
69  const std::vector<double>& pointPaths,
70  const double& mom,
71  const int& pdg,
72  const bool& doNoise = false,
73  TMatrixT<Double_t>* noise = NULL,
74  const TMatrixT<Double_t>* jacobian = NULL,
75  const TVector3* directionBefore = NULL,
76  const TVector3* directionAfter = NULL);
77 
78  //! Returns maximum length so that a specified momentum loss will not be exceeded
79  /** The stepper returns the maximum length that the particle may travel, so that a specified relative momentum loss will not be exceeded.
80  */
81  double stepper(const double& maxDist,
82  const double& posx,
83  const double& posy,
84  const double& posz,
85  const double& dirx,
86  const double& diry,
87  const double& dirz,
88  const double& mom,
89  const int& pdg);
90  double stepper(const double& maxDist,
91  const TVector3& pos,
92  const TVector3& dir,
93  const double& mom,
94  const int& pdg){
95  return stepper(maxDist, pos.X(),pos.Y(),pos.Z(),dir.X(),dir.Y(),dir.Z(),mom,pdg);};
96 
97  private:
98  //! contains energy loss classes
99  // std::vector<GFAbsEnergyLoss*> fEnergyLoss;
100  //! interface to material and geometry
101  //GFGeoMatManager *geoMatManager;
102  void getParameters();
103 
104  //! sets fbeta, fgamma, fgammasquare; must only be used after calling getParameters()
105  void calcBeta(double mom);
106 
107  //! Returns energy loss
108  /** Uses Bethe Bloch formula to calculate energy loss.
109  * Calcuates and sets fdedx which needed also for noiseBetheBloch.
110  * Therefore it is not a const function!
111  *
112  */
113  double energyLossBetheBloch(const double& mom);
114 
115  //! calculation of energy loss straggling
116  /** For the energy loss straggeling, different formulas are used for different regions:
117  * - Vavilov-Gaussian regime
118  * - Urban/Landau approximation
119  * - truncated Landau distribution
120  * - Urban model
121  *
122  * Needs fdedx, which is calculated in energyLossBetheBloch, so it has to be calles afterwards!
123  */
124  void noiseBetheBloch(const double& mom,
125  TMatrixT<double>* noise) const;
126 
127  //! calculation of multiple scattering
128  /** With the calculated multiple scattering angle, two noise matrices are calculated:
129  * - with respect to #directionBefore: #noiseBefore, which is then propagated with the jacobian
130  * - with respect to #directionAfter: #noiseAfter
131  * The mean value of these two matrices is added to the noise matrix #noise.
132  * This method gives better results than either calculating only noiseBefore or noiseAfter.
133  * \n\n
134  * This is a detailed description of the mathematics involved:
135  * \n
136  *
137  * We define a local coordinate system cs' with initial momentum in z-direction:
138  * \f[
139  * \left(\begin{array}{c}
140  * x'\\
141  * y'\\
142  * z'\\
143  * a_{x}'\\
144  * a_{y}'\\
145  * a_{z}'\\
146  * \frac{q}{p}'\end{array}\right)=\left(\begin{array}{ccccccc}
147  * \cos\psi & \sin\psi & 0\\
148  * -\cos\vartheta\sin\psi & \cos\vartheta\cos\psi & \sin\psi\\
149  * \sin\vartheta\sin\psi & -\sin\vartheta\cos\psi & \cos\vartheta\\
150  * & & & \cos\psi & \sin\psi & 0\\
151  * & & & -\cos\vartheta\sin\psi & \cos\vartheta\cos\psi & \sin\psi\\
152  * & & & \sin\vartheta\sin\psi & -\sin\vartheta\cos\psi & \cos\vartheta\\
153  * & & & & & & 1\end{array}\right)\left(\begin{array}{c}
154  * x\\
155  * y\\
156  * z\\
157  * a_{x}\\
158  * a_{y}\\
159  * a_{z}\\
160  * \frac{q}{p}\end{array}\right)=R^{T}\left(\begin{array}{c}
161  * x\\
162  * y\\
163  * z\\
164  * a_{x}\\
165  * a_{y}\\
166  * a_{z}\\
167  * \frac{q}{p}\end{array}\right)\f]
168  *
169  * \n
170  *
171  * Now the global coordinate system cs is:\n
172  * \f[
173  * \left(\begin{array}{c}
174  * x\\
175  * y\\
176  * z\\
177  * a_{x}\\
178  * a_{y}\\
179  * a_{z}\\
180  * \frac{q}{p}\end{array}\right)=\left(\begin{array}{ccccccc}
181  * \cos\psi & -\cos\vartheta\sin\psi & \sin\vartheta\sin\psi\\
182  * \sin\psi & \cos\vartheta\cos\psi & -\sin\vartheta\cos\psi\\
183  * 0 & \sin\psi & \cos\vartheta\\
184  * & & & \cos\psi & -\cos\vartheta\sin\psi & \sin\vartheta\sin\psi\\
185  * & & & \sin\psi & \cos\vartheta\cos\psi & -\sin\vartheta\cos\psi\\
186  * & & & 0 & \sin\psi & \cos\vartheta\\
187  * & & & & & & 1\end{array}\right)\left(\begin{array}{c}
188  * x'\\
189  * y'\\
190  * z'\\
191  * a_{x}'\\
192  * a_{y}'\\
193  * a_{z}'\\
194  * \frac{q}{p}'\end{array}\right)=R\left(\begin{array}{c}
195  * x'\\
196  * y'\\
197  * z'\\
198  * a_{x}'\\
199  * a_{y}'\\
200  * a_{z}'\\
201  * \frac{q}{p}'\end{array}\right) \f]
202  *
203  * \n
204  *
205  * with the Euler angles
206  *
207  * \f{eqnarray*}
208  * \psi & = &
209  * \begin{cases}
210  * \begin{cases}
211  * \frac{\pi}{2} & a_{x} \geq 0 \\
212  * \frac{3\pi}{2} & a_{x} < 0
213  * \end{cases}
214  * & a_{y}=0 \mbox{ resp. } |a_{y}|<10^{-14} \\
215  * - \arctan \frac{a_{x}}{a_{y}} & a_{y} < 0 \\
216  * \pi - \arctan \frac{a_{x}}{a_{y}} & a_{y} > 0
217  * \end{cases} \\
218  * \vartheta & = & \arccos a_{z}
219  * \f}
220  *
221  * \n
222  * \f$M\f$ is the multiple scattering error-matrix in the \f$\theta\f$ coordinate system.
223  * \f$\theta_{1/2}=0\f$ are the multiple scattering angles. There is only an error in direction
224  * (which later leads to an error in position, when \f$N_{before}\f$ is propagated with \f$T\f$).
225  * \f[
226  * M=\left(\begin{array}{cc}
227  * \sigma^{2} & 0\\
228  * 0 & \sigma^{2}\end{array}\right)\f]
229  *
230  * \n
231  * This translates into the noise matrix \f$\overline{M}\f$ in the local cs' via jacobian J.
232  * The mean scattering angle is always 0, this means that \f$\theta_{1/2}=0\f$):
233  *
234  * \f{eqnarray*}
235  * x' & = & x'\\
236  * y' & = & y'\\
237  * z' & = & z'\\
238  * a_{x}' & = & \sin\theta_{1}\\
239  * a_{y}' & = & \sin\theta_{2}\\
240  * a_{z}' & = & \sqrt{1-\sin^{2}\theta_{1}-\sin^{2}\theta_{2}}\\
241  * \frac{q}{p}' & = & \frac{q}{p}'\f}
242  *
243  *
244  * \f[
245  * M=\left(\begin{array}{cc}
246  * \sigma^{2} & 0\\
247  * 0 & \sigma^{2}\end{array}\right)\f]
248  *
249  * \n
250  *
251  * \f[
252  * J=\frac{\partial\left(x',y',z',a_{x}',a_{y}',a_{z}',\frac{q}{p}'\right)}{\partial\left(\theta_{1},\theta_{2}\right)}\f]
253  *
254  * \n
255  *
256  * \f[
257  * J=\left(\begin{array}{cc}
258  * 0 & 0\\
259  * 0 & 0\\
260  * 0 & 0\\
261  * \cos\theta_{1} & 0\\
262  * 0 & \cos\theta_{2}\\
263  * -\frac{\cos\theta_{1}\sin\theta_{1}}{\sqrt{\cos^{2}\theta_{1}-\sin^{2}\theta_{2}}} & -\frac{\cos\theta_{2}\sin\theta_{2}}{\sqrt{\cos^{2}\theta_{1}-\sin^{2}\theta_{2}}}\\
264  * 0 & 0\end{array}\right) \overset{\theta_{1/2}=0}{=} \left(\begin{array}{cc}
265  * 0 & 0\\
266  * 0 & 0\\
267  * 0 & 0\\
268  * 1 & 0\\
269  * 0 & 1\\
270  * 0 & 0\\
271  * 0 & 0\end{array}\right)\f]
272  * \n
273  *
274  * \f[
275  * \overline{M}=J\: M\: J^{T}=\left(\begin{array}{ccccccc}
276  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
277  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
278  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
279  * 0 & 0 & 0 & \sigma^{2} & 0 & 0 & 0\\
280  * 0 & 0 & 0 & 0 & \sigma^{2} & 0 & 0\\
281  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
282  * 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)\f]
283  *
284  *
285  * The following transformation brings the noise matrix into the global coordinate system cs, resulting in \f$N\f$ :
286  *
287  *\f[
288  * N=R\overline{M}R^{T}=\sigma^{2}\left(\begin{array}{ccccccc}
289  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
290  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
291  * 0 & 0 & 0 & 0 & 0 & 0 & 0\\
292  * 0 & 0 & 0 & \cos^{2}\psi+\cos^{2}\theta-\cos^{2}\theta\cos^{2}\psi & \cos\psi\sin\psi\sin^{2}\theta & -\cos\theta\sin\psi\sin\theta & 0\\
293  * 0 & 0 & 0 & \cos\psi\sin\psi\sin^{2}\theta & \sin^{2}\psi+\cos^{2}\theta\cos^{2}\psi & \cos\theta\cos\psi\sin\theta & 0\\
294  * 0 & 0 & 0 & -\cos\theta\sin\psi\sin\theta & \cos\theta\cos\psi\sin\theta & \sin^{2}\theta & 0\\
295  * 0 & 0 & 0 & 0 & 0 & 0 & 0\end{array}\right)\f]
296  *
297  * \n
298  *
299  *
300  * Now two \f$N\f$ are calculated: \f$N_{before}\f$ (at the start point, with initial direction #directionBefore)
301  * and \f$N_{after}\f$ (at the final point, with direction #directionAfter).
302  * \f$N_{before}\f$ is the propagated with the #jacobian of extrapolation \f$T\f$.
303  * The new covariance matrix with multiple scattering in global cs is:
304  *
305  * \f{eqnarray*}
306  * C_{new} & = C_{old} + 0.5 \cdot T N_{before} T^{T} + 0.5 \cdot N_{after} \f}
307  *
308  *
309  * \n
310  * \n
311  * See also: Track following in dense media and inhomogeneous magnetic fields,
312  * A.Fontana, P.Genova, L.Lavezzi and A.Rotondi;
313  * PANDA Report PV/01-07
314  * \n
315  * \n
316  */
317  void noiseCoulomb(const double& mom,
318  TMatrixT<double>* noise,
319  const TMatrixT<double>* jacobian,
320  const TVector3* directionBefore,
321  const TVector3* directionAfter) const;
322 
323  //! Returns energy loss
324  /** Can be called with any pdg, but only calculates energy loss for electrons and positrons (otherwise returns 0).
325  * Uses a gaussian approximation (Bethe-Heitler formula with Migdal corrections).
326  * For positrons the energy loss is weighed with a correction factor.
327  */
328  double energyLossBrems(const double& mom) const;
329 
330  //! calculation of energy loss straggeling
331  /** Can be called with any pdg, but only calculates straggeling for electrons and positrons.
332  *
333  */
334  void noiseBrems(const double& mom,
335  TMatrixT<double>* noise) const;
336  double MeanExcEnergy_get(int Z);
337  double MeanExcEnergy_get(TGeoMaterial*);
338 
344 
345  const double me; // electron mass (GeV)
346 
347  double fstep; // stepsize
348 
349  // cached values for energy loss and noise calculations
350  double fbeta;
351  double fdedx;
352  double fgamma;
353  double fgammaSquare;
354 
355  double fmatDensity;
356  double fmatZ;
357  double fmatA;
359  double fmEE; // mean excitation energy
360 
361  int fpdg;
362  double fcharge;
363  double fmass;
364 
365 
366  // public:
367  //classDef(GFMaterialEffects,1)
368 
369 };
370 
371 } // end namespace
372 
373 #endif
374 
375 /** @} */
static GFMaterialEffects * getInstance()
void noiseBrems(const double &mom, TMatrixT< double > *noise) const
calculation of energy loss straggeling
void noiseCoulomb(const double &mom, TMatrixT< double > *noise, const TMatrixT< double > *jacobian, const TVector3 *directionBefore, const TVector3 *directionAfter) const
calculation of multiple scattering
void setNoiseBrems(bool opt=true)
Generic Interface to magnetic fields in GENFIT.
Definition: GFAbsBField.h:35
opt
Definition: train.py:196
void setNoiseBetheBloch(bool opt=true)
double energyLossBrems(const double &mom) const
Returns energy loss.
void noiseBetheBloch(const double &mom, TMatrixT< double > *noise) const
calculation of energy loss straggling
void setEnergyLossBrems(bool opt=true)
string dir
double stepper(const double &maxDist, const TVector3 &pos, const TVector3 &dir, const double &mom, const int &pdg)
void setNoiseCoulomb(bool opt=true)
void setEnergyLossBetheBloch(bool opt=true)
static GFMaterialEffects * finstance
void calcBeta(double mom)
sets fbeta, fgamma, fgammasquare; must only be used after calling getParameters() ...
double effects(const std::vector< TVector3 > &points, const std::vector< double > &pointPaths, const double &mom, const int &pdg, const bool &doNoise=false, TMatrixT< Double_t > *noise=NULL, const TMatrixT< Double_t > *jacobian=NULL, const TVector3 *directionBefore=NULL, const TVector3 *directionAfter=NULL)
Calculates energy loss in the travelled path, optional calculation of noise matrix.
void getParameters()
contains energy loss classes
double energyLossBetheBloch(const double &mom)
Returns energy loss.
double stepper(const double &maxDist, const double &posx, const double &posy, const double &posz, const double &dirx, const double &diry, const double &dirz, const double &mom, const int &pdg)
Returns maximum length so that a specified momentum loss will not be exceeded.