Garfield++ v1r0
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"
14
15namespace Heed {
16
17double cos_theta_two_part(double Ep0, double Ep1, double Mp, double Mt) {
18 mfunname("double cos_theta_two_part(...)");
19
20 double Mp2 = Mp * Mp * c_squared * c_squared;
21 Mt *= c_squared;
22 double d0 = Ep0 * Ep0 - Mp2;
23 check_econd11(d0, <= 0, mcerr);
24 double d1 = Ep1 * Ep1 - Mp2;
25 check_econd11(d1, <= 0, mcerr);
26 double r = (-2.0 * Ep0 * Mt + 2.0 * Ep0 * Ep1 + 2.0 * Mt * Ep1 - 2.0 * Mp2) /
27 (2.0 * sqrt(d0) * sqrt(d1));
28 return r;
29}
30
31void theta_two_part(double Ep0, double Ep1, double Mp, double Mt,
32 double& theta_p, double& theta_t) {
33 mfunname("void theta_two_part(...)");
34
35 double Mp2 = Mp * Mp * c_squared * c_squared;
36 Mt *= c_squared;
37 double d0 = Ep0 * Ep0 - Mp2;
38 check_econd11(d0, <= 0, mcerr);
39 double d1 = Ep1 * Ep1 - Mp2;
40 check_econd11(d1, <= 0, mcerr);
41 double ctheta = (-2.0 * Ep0 * Mt + 2.0 * Ep0 * Ep1 + 2.0 * Mt * Ep1 -
42 2.0 * Mp2) / (2.0 * sqrt(d0) * sqrt(d1));
43 if (ctheta < -1.0) ctheta = -1.0;
44 if (ctheta > 1.0) ctheta = 1.0;
45 theta_p = acos(ctheta);
46 //Iprintn(mcout, theta_p);
47 if (theta_p == 0.0)
48 theta_t = 0.5 * M_PI;
49 else {
50 double Pp1 = Ep1 * Ep1 - Mp2;
51 check_econd11(Pp1, < 0, mcerr);
52 if (Pp1 != 0.0) {
53 Pp1 = sqrt(Pp1);
54 //Iprintn(mcout, Pp1);
55 double d3 = Ep0 + Mt - Ep1;
56 double dd1 = d3 * d3 - Mt * Mt;
57 check_econd11(dd1, <= 0, mcerr);
58 double dd2 = sqrt(dd1);
59 check_econd11(dd2, <= 0, mcerr);
60 //Iprintn(mcout, dd2);
61 //Iprintn(mcout, sin(theta_p));
62 double stheta_t = -Pp1 * (sin(theta_p) / dd2);
63 //Iprintn(mcout, stheta_t);
64 if (stheta_t < -1.0) stheta_t = -1.0;
65 if (stheta_t > 1.0) stheta_t = 1.0;
66 theta_t = asin(stheta_t);
67 //Iprintn(mcout, theta_t);
68 } else {
69 theta_t = 0.5 * M_PI;
70 }
71 }
72}
73
74}
DoubleAc asin(const DoubleAc &f)
Definition: DoubleAc.cpp:468
DoubleAc sqrt(const DoubleAc &f)
Definition: DoubleAc.cpp:313
DoubleAc sin(const DoubleAc &f)
Definition: DoubleAc.cpp:383
DoubleAc acos(const DoubleAc &f)
Definition: DoubleAc.cpp:488
#define check_econd11(a, signb, stream)
Definition: FunNameStack.h:366
#define mfunname(string)
Definition: FunNameStack.h:67
Definition: BGMesh.cpp:3
double cos_theta_two_part(double Ep0, double Ep1, double Mp, double Mt)
Definition: kinem.cpp:17
void theta_two_part(double Ep0, double Ep1, double Mp, double Mt, double &theta_p, double &theta_t)
Definition: kinem.cpp:31
#define mcerr
Definition: prstream.h:135