Garfield++ 3.0
A toolkit for the detailed simulation of particle detectors based on ionisation measurement in gases and semiconductors
Loading...
Searching...
No Matches
kinem.cpp
Go to the documentation of this file.
1#ifdef VISUAL_STUDIO
2#define _USE_MATH_DEFINES
3// see comment in math.h:
4/* Define _USE_MATH_DEFINES before including math.h to expose these macro
5 * definitions for common math constants. These are placed under an #ifdef
6 * since these commonly-defined names are not part of the C/C++ standards.
7 */
8#endif
9#include <cmath>
11#include "wcpplib/math/kinem.h"
13
14namespace Heed {
15
16double cos_theta_two_part(const double Ep0, const double Ep1, const double Mp,
17 const double Mt) {
18 mfunname("double cos_theta_two_part(...)");
19
20 const double Mp2 = Mp * Mp;
21 const double d0 = Ep0 * Ep0 - Mp2;
22 check_econd11(d0, <= 0, mcerr);
23 const double d1 = Ep1 * Ep1 - Mp2;
24 check_econd11(d1, <= 0, mcerr);
25 return (-Ep0 * Mt + Ep0 * Ep1 + Mt * Ep1 - Mp2) / sqrt(d0 * d1);
26}
27
28void theta_two_part(const double Ep0, const double Ep1, const double Mp,
29 const double Mt, double& theta_p, double& theta_t) {
30 mfunname("void theta_two_part(...)");
31
32 const double Mp2 = Mp * Mp;
33 const double d0 = Ep0 * Ep0 - Mp2;
34 check_econd11(d0, <= 0, mcerr);
35 const double d1 = Ep1 * Ep1 - Mp2;
36 check_econd11(d1, <= 0, mcerr);
37 double ctheta = (-Ep0 * Mt + Ep0 * Ep1 + Mt * Ep1 - Mp2) / sqrt(d0 * d1);
38 if (ctheta < -1.0) ctheta = -1.0;
39 if (ctheta > 1.0) ctheta = 1.0;
40 theta_p = acos(ctheta);
41 if (theta_p == 0.0) {
42 theta_t = CLHEP::halfpi;
43 return;
44 }
45 double Pp1 = Ep1 * Ep1 - Mp2;
46 check_econd11(Pp1, < 0, mcerr);
47 if (Pp1 == 0.0) {
48 theta_t = CLHEP::halfpi;
49 return;
50 }
51 Pp1 = sqrt(Pp1);
52 const double d3 = Ep0 + Mt - Ep1;
53 const double dd1 = d3 * d3 - Mt * Mt;
54 check_econd11(dd1, <= 0, mcerr);
55 const double dd2 = sqrt(dd1);
56 check_econd11(dd2, <= 0, mcerr);
57 double stheta_t = -Pp1 * (sin(theta_p) / dd2);
58 if (stheta_t < -1.0) stheta_t = -1.0;
59 if (stheta_t > 1.0) stheta_t = 1.0;
60 theta_t = asin(stheta_t);
61}
62}
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:155
#define mfunname(string)
Definition: FunNameStack.h:45
Definition: BGMesh.cpp:6
double cos_theta_two_part(const double Ep0, const double Ep1, const double Mp, const double Mt)
Definition: kinem.cpp:16
void theta_two_part(const double Ep0, const double Ep1, const double Mp, const double Mt, double &theta_p, double &theta_t)
Scattering angles as function of incident and final projectile energy.
Definition: kinem.cpp:28
DoubleAc acos(const DoubleAc &f)
Definition: DoubleAc.cpp:490
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:384
DoubleAc asin(const DoubleAc &f)
Definition: DoubleAc.cpp:470
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:314
#define mcerr
Definition: prstream.h:128