File indexing completed on 2025-01-18 09:58:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043 #ifndef G4MuonRadiativeDecayChannelWithSpin_hh
0044 #define G4MuonRadiativeDecayChannelWithSpin_hh 1
0045
0046 #include "G4ThreeVector.hh"
0047 #include "G4VDecayChannel.hh"
0048 #include "Randomize.hh"
0049 #include "globals.hh"
0050
0051 #include <CLHEP/Units/PhysicalConstants.h>
0052
0053 class G4MuonRadiativeDecayChannelWithSpin : public G4VDecayChannel
0054 {
0055 public:
0056 G4MuonRadiativeDecayChannelWithSpin(const G4String& theParentName, G4double theBR);
0057 ~G4MuonRadiativeDecayChannelWithSpin() override = default;
0058
0059 G4DecayProducts* DecayIt(G4double) override;
0060
0061 protected:
0062
0063 G4MuonRadiativeDecayChannelWithSpin(const G4MuonRadiativeDecayChannelWithSpin&) = default;
0064 G4MuonRadiativeDecayChannelWithSpin& operator=(const G4MuonRadiativeDecayChannelWithSpin&);
0065
0066 private:
0067 G4MuonRadiativeDecayChannelWithSpin() = default;
0068
0069 G4double fron(G4double Pmu, G4double x, G4double y, G4double cthetaE, G4double cthetaG,
0070 G4double cthetaEG);
0071
0072
0073
0074 void rn3dim(G4double& x, G4double& y, G4double& z, G4double xlong);
0075
0076 G4double atan4(G4double x, G4double y);
0077 };
0078
0079
0080
0081
0082
0083 inline void G4MuonRadiativeDecayChannelWithSpin::rn3dim(G4double& x, G4double& y, G4double& z,
0084 G4double xlong)
0085 {
0086 G4double a = 0.;
0087 G4double b = 0.;
0088 G4double c = 0.;
0089 G4double r = 0.;
0090
0091 do {
0092 a = G4UniformRand() - 0.5;
0093 b = G4UniformRand() - 0.5;
0094 c = G4UniformRand() - 0.5;
0095 r = a * a + b * b + c * c;
0096 } while (r > 0.25);
0097
0098 G4double rinv = xlong / (std::sqrt(r));
0099 x = a * rinv;
0100 y = b * rinv;
0101 z = c * rinv;
0102
0103 return;
0104 }
0105
0106 inline G4double G4MuonRadiativeDecayChannelWithSpin::atan4(G4double x, G4double y)
0107 {
0108 G4double phi = 0.;
0109
0110 if (x == 0. && y > 0.) {
0111 phi = 0.5 * CLHEP::pi;
0112 }
0113 else if (x == 0. && y < 0.) {
0114 phi = 1.5 * CLHEP::pi;
0115 }
0116 else if (y == 0. && x > 0.) {
0117 phi = 0.;
0118 }
0119 else if (y == 0. && x < 0.) {
0120 phi = CLHEP::pi;
0121 }
0122 else if (x > 0.) {
0123 phi = std::atan(y / x);
0124 }
0125 else if (x < 0.) {
0126 phi = std::atan(y / x) + CLHEP::pi;
0127 }
0128
0129 return phi;
0130 }
0131
0132 #endif