File indexing completed on 2023-10-25 10:04:26
0001 #include <cmath>
0002 #include "SimG4Core/CustomPhysics/interface/Decay3Body.h"
0003
0004 #include "CLHEP/Units/GlobalSystemOfUnits.h"
0005 #include "CLHEP/Units/GlobalPhysicalConstants.h"
0006 #include "DataFormats/Math/interface/Vector3D.h"
0007 #include "DataFormats/Math/interface/LorentzVector.h"
0008 #include "Math/GenVector/Rotation3D.h"
0009 #include "Math/GenVector/EulerAngles.h"
0010 #include "Math/GenVector/Boost.h"
0011 #include <vector>
0012 #include <cmath>
0013
0014 #include "Randomize.hh"
0015
0016 Decay3Body::Decay3Body() {}
0017
0018 Decay3Body::~Decay3Body() {}
0019
0020 void Decay3Body::doDecay(const G4LorentzVector& mother,
0021 G4LorentzVector& daughter1,
0022 G4LorentzVector& daughter2,
0023 G4LorentzVector& daughter3) {
0024 double m0 = mother.m();
0025 double m1 = daughter1.m();
0026 double m2 = daughter2.m();
0027 double m3 = daughter3.m();
0028 double sumM2 = m0 * m0 + m1 * m1 + m2 * m2 + m3 * m3;
0029 double tolerance = 1.0e-9;
0030
0031 math::XYZTLorentzVectorD mmm(mother.px(), mother.py(), mother.pz(), mother.e());
0032
0033 if (m0 < m1 + m2 + m3) {
0034 std::cout << "Error: Daughters too heavy!" << std::endl;
0035 std::cout << "M: " << m0 / GeV << " < m1+m2+m3: " << m1 / GeV + m2 / GeV + m3 / GeV << std::endl;
0036 return;
0037 } else {
0038 double m2_12max = sqr(m0 - m3);
0039 double m2_12min = sqr(m1 + m2);
0040 double m2_23max = sqr(m0 - m1);
0041 double m2_23min = sqr(m2 + m3);
0042
0043 double x1, x2;
0044 double m2_12 = 0.0;
0045 double m2_23 = 0.0;
0046 double E2_12, E3_12;
0047 double m2_23max_12, m2_23min_12;
0048
0049 do {
0050
0051 x1 = G4UniformRand();
0052 m2_12 = m2_12min + x1 * (m2_12max - m2_12min);
0053 x2 = G4UniformRand();
0054 m2_23 = m2_23min + x2 * (m2_23max - m2_23min);
0055
0056
0057
0058 E2_12 = (m2_12 - m1 * m1 + m2 * m2) / (2.0 * sqrt(m2_12));
0059 E3_12 = (m0 * m0 - m2_12 - m3 * m3) / (2.0 * sqrt(m2_12));
0060 m2_23max_12 = sqr(E2_12 + E3_12) - sqr(sqrt(sqr(E2_12) - m2 * m2) - sqrt(sqr(E3_12) - m3 * m3));
0061 m2_23min_12 = sqr(E2_12 + E3_12) - sqr(sqrt(sqr(E2_12) - m2 * m2) + sqrt(sqr(E3_12) - m3 * m3));
0062 } while ((m2_23 > m2_23max_12) || (m2_23 < m2_23min_12));
0063
0064
0065 double m2_13 = sumM2 - m2_12 - m2_23;
0066
0067
0068 double e1 = (m0 * m0 + m1 * m1 - m2_23) / (2.0 * m0);
0069 double e2 = (m0 * m0 + m2 * m2 - m2_13) / (2.0 * m0);
0070 double e3 = (m0 * m0 + m3 * m3 - m2_12) / (2.0 * m0);
0071 double p1 = sqrt(e1 * e1 - m1 * m1);
0072 double p2 = sqrt(e2 * e2 - m2 * m2);
0073 double p3 = sqrt(e3 * e3 - m3 * m3);
0074
0075
0076 double cos12 = (m1 * m1 + m2 * m2 + 2.0 * e1 * e2 - m2_12) / (2.0 * p1 * p2);
0077 double cos13 = (m1 * m1 + m3 * m3 + 2.0 * e1 * e3 - m2_13) / (2.0 * p1 * p3);
0078 double cos23 = (m2 * m2 + m3 * m3 + 2.0 * e2 * e3 - m2_23) / (2.0 * p2 * p3);
0079 if (fabs(cos12) > 1.0)
0080 std::cout << "Error: Undefined angle12!" << std::endl;
0081 if (fabs(cos13) > 1.0)
0082 std::cout << "Error: Undefined angle13!" << std::endl;
0083 if (fabs(cos23) > 1.0)
0084 std::cout << "Error: Undefined angle23!" << std::endl;
0085
0086
0087 double xi = 2.0 * pi * G4UniformRand();
0088 math::XYZVectorD q1(0.0, 0.0, p1);
0089 math::XYZVectorD q2(sin(acos(cos12)) * cos(xi) * p2, sin(acos(cos12)) * sin(xi) * p2, cos12 * p2);
0090 math::XYZVectorD q3(-sin(acos(cos13)) * cos(xi) * p3, -sin(acos(cos13)) * sin(xi) * p3, cos13 * p3);
0091
0092
0093 double theta = acos(2.0 * G4UniformRand() - 1.0);
0094 double phi = 2.0 * pi * G4UniformRand();
0095 double psi = 2.0 * pi * G4UniformRand();
0096
0097 ROOT::Math::EulerAngles ang(phi, theta, psi);
0098 ROOT::Math::Rotation3D rot(ang);
0099
0100 math::XYZVectorD q1rot = rot * q1;
0101 math::XYZVectorD q2rot = rot * q2;
0102 math::XYZVectorD q3rot = rot * q3;
0103
0104 math::XYZTLorentzVectorD daughter1_orig(q1rot.X(), q1rot.Y(), q1rot.Z(), e1);
0105 math::XYZTLorentzVectorD daughter2_orig(q2rot.X(), q2rot.Y(), q2rot.Z(), e2);
0106 math::XYZTLorentzVectorD daughter3_orig(q3rot.X(), q3rot.Y(), q3rot.Z(), e3);
0107
0108 ROOT::Math::Boost cmboost(mmm.BoostToCM());
0109
0110
0111 if (acos(cos12) + acos(cos13) + acos(cos23) - 2.0 * pi > tolerance)
0112 std::cout << "Error: Total angle not 2pi! " << acos(cos12) + acos(cos13) + acos(cos23) - 2.0 * pi << std::endl;
0113 if (fabs(daughter1_orig.px() + daughter2_orig.px() + daughter3_orig.px()) / GeV > tolerance)
0114 std::cout << "Error: Total 3B Px not conserved! "
0115 << (daughter1_orig.px() + daughter2_orig.px() + daughter3_orig.px()) / GeV << std::endl;
0116 if (fabs(daughter1_orig.py() + daughter2_orig.py() + daughter3_orig.py()) / GeV > tolerance)
0117 std::cout << "Error: Total 3B Py not conserved! "
0118 << (daughter1_orig.py() + daughter2_orig.py() + daughter3_orig.py()) / GeV << std::endl;
0119 if (fabs(daughter1_orig.pz() + daughter2_orig.pz() + daughter3_orig.pz()) / GeV > tolerance)
0120 std::cout << "Error: Total 3B Pz not conserved! " << (daughter1.pz() + daughter2.pz() + daughter3.pz()) / GeV
0121 << std::endl;
0122
0123
0124
0125 math::XYZTLorentzVectorD temp1(cmboost(daughter1_orig));
0126 math::XYZTLorentzVectorD temp2(cmboost(daughter2_orig));
0127 math::XYZTLorentzVectorD temp3(cmboost(daughter3_orig));
0128
0129 daughter1.setPx(temp1.Px());
0130 daughter1.setPy(temp1.Py());
0131 daughter1.setPz(temp1.Pz());
0132 daughter1.setE(temp1.e());
0133
0134 daughter2.setPx(temp2.Px());
0135 daughter2.setPy(temp2.Py());
0136 daughter2.setPz(temp2.Pz());
0137 daughter2.setE(temp2.e());
0138
0139 daughter3.setPx(temp3.Px());
0140 daughter3.setPy(temp3.Py());
0141 daughter3.setPz(temp3.Pz());
0142 daughter3.setE(temp3.e());
0143
0144 return;
0145 }
0146 }
0147
0148 double Decay3Body::sqr(double a) { return a * a; }