Geant4 9.6.0
Toolkit for the simulation of the passage of particles through matter
Loading...
Searching...
No Matches
G4PiMinusStopMaterial.cc
Go to the documentation of this file.
1//
2// ********************************************************************
3// * License and Disclaimer *
4// * *
5// * The Geant4 software is copyright of the Copyright Holders of *
6// * the Geant4 Collaboration. It is provided under the terms and *
7// * conditions of the Geant4 Software License, included in the file *
8// * LICENSE and available at http://cern.ch/geant4/license . These *
9// * include a list of copyright holders. *
10// * *
11// * Neither the authors of this software system, nor their employing *
12// * institutes,nor the agencies providing financial support for this *
13// * work make any representation or warranty, express or implied, *
14// * regarding this software system or assume any liability for its *
15// * use. Please see the license in the file LICENSE and URL above *
16// * for the full disclaimer and the limitation of liability. *
17// * *
18// * This code implementation is the result of the scientific and *
19// * technical work of the GEANT4 collaboration. *
20// * By using, copying, modifying or distributing the software (or *
21// * any work based on the software) you agree to acknowledge its *
22// * use in resulting scientific publications, and indicate your *
23// * acceptance of all terms of the Geant4 Software license. *
24// ********************************************************************
25//
26// File name: G4PiMinusStopMaterial
27//
28// Author: Maria Grazia Pia ([email protected])
29//
30// Creation date: 8 May 1998
31//
32// -------------------------------------------------------------------
33
34#include <vector>
35
37
38#include "globals.hh"
39#include "G4ios.hh"
40#include "Randomize.hh"
42#include "G4Proton.hh"
43#include "G4Neutron.hh"
44#include "G4PionMinus.hh"
45#include "G4ParticleTypes.hh"
48#include "G4LorentzVector.hh"
51
52
53// Constructor
54
56{
57 _definitions = 0;
58 _momenta = 0;
61 theR = 0.5;
62}
63
64
65// Destructor
66
68{
69 if (_definitions != 0) delete _definitions;
70 _definitions = 0;
71
72 //A.R. 26-Jul-2012 Coverity fix
73 if (_momenta != 0) {
74 for (unsigned int i=0; i<_momenta->size(); i++) delete(*_momenta)[i];
75 delete _momenta;
76 }
77
78 delete _distributionE;
79 delete _distributionAngle;
80}
81
82std::vector<G4ParticleDefinition*>* G4PiMinusStopMaterial::DefinitionVector()
83{
84
85 _definitions->push_back(G4Neutron::Neutron());
86
87 G4double ranflat = G4UniformRand();
88 if (ranflat < theR)
89 { _definitions->push_back(G4Proton::Proton()); }
90 else
91 { _definitions->push_back(G4Neutron::Neutron()); }
92
93 return _definitions;
94
95}
96
97std::vector<G4LorentzVector*>*
99 const G4double massNucleus)
100{
101 // Generate energy of direct absorption products according to experimental
102 // data. The energy distribution of the two nucleons is assumed to be the
103 // same for protons and neutrons.
104
105 G4double eKin1;
106 G4double eKin2;
107 G4double eRecoil;
108
109 // Assume absorption on two nucleons
110 G4int nNucleons = 2;
111 G4double availableE = G4PionMinus::PionMinus()->GetPDGMass() - nNucleons * binding;
114
115 do
116 {
117 G4double ranflat;
118 G4double p;
119 G4double energy;
120 G4double mass;
121
122 ranflat = G4UniformRand();
123 eKin1 = _distributionE->Generate(ranflat);
124 mass = (*_definitions)[0]->GetPDGMass();
125 energy = eKin1 + mass;
126 p = std::sqrt(energy*energy - mass*mass);
127 G4double theta1 = pi*G4UniformRand();
128 G4double phi1 = GenerateAngle(2.*pi);
129 p1 = MakeP4(p,theta1,phi1,energy);
130
131 ranflat = G4UniformRand();
132 eKin2 = _distributionE->Generate(ranflat);
133 mass = (*_definitions)[1]->GetPDGMass();
134 energy = eKin2 + mass;
135 p = std::sqrt(energy*energy - mass*mass);
136 ranflat = G4UniformRand();
137 G4double opAngle = _distributionAngle->Generate(ranflat);
138 G4double theta2 = theta1 + opAngle;
139 G4double phi2 = phi1 + opAngle;
140
141 p2 = MakeP4(p,theta2,phi2,energy);
142
143 G4double pNucleus = (p1.vect() + p2.vect()).mag();
144 eRecoil = std::sqrt(pNucleus*pNucleus + massNucleus*massNucleus) - massNucleus;
145
146 // ---- Debug
147 // G4cout << " ---- binding = " << binding << ", nucleus mass = " << massNucleus
148 // << ", p nucleus = " << pNucleus << G4endl;
149 // G4cout << "eKin1,2 " << eKin1 << " " << eKin2 << " eRecoil " << eRecoil
150 // << " availableE " << availableE << G4endl;
151 // ----
152
153 } while ((eKin1 + eKin2 + eRecoil) > availableE);
154
155 //A.R. 26-Jul-2012 Coverity fix
156 if (_momenta != 0) {
157 _momenta->push_back(new G4LorentzVector(p1));
158 _momenta->push_back(new G4LorentzVector(p2));
159 }
160
161 return _momenta;
162
163}
164
166{
167 G4double ranflat = G4UniformRand();
168 G4double value = ranflat * x;
169 return value;
170}
171
173{
174 // G4LorentzVector p4;
175 G4double px = p * std::sin(theta) * std::cos(phi);
176 G4double py = p * std::sin(theta) * std::sin(phi);
177 G4double pz = p * std::cos(theta);
178 G4LorentzVector p4(px,py,pz,e);
179 return p4;
180}
181
183{
184 G4ThreeVector p(0.,0.,0.);
185
186 //A.R. 26-Jul-2012 Coverity fix
187 if (_momenta != 0) {
188 for (unsigned int i = 0; i< _momenta->size(); i++)
189 {
190 p = p + (*_momenta)[i]->vect();
191 }
192 }
193
194 G4double pNucleus = p.mag();
195 G4double eNucleus = std::sqrt(pNucleus*pNucleus + mass*mass);
196
197 return eNucleus;
198}
199
CLHEP::HepLorentzVector G4LorentzVector
double G4double
Definition: G4Types.hh:64
int G4int
Definition: G4Types.hh:66
#define G4UniformRand()
Definition: Randomize.hh:53
double mag() const
Hep3Vector vect() const
G4double Generate(G4double ranflat)
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
std::vector< G4ParticleDefinition * > * _definitions
G4DistributionGenerator * _distributionE
G4double GenerateAngle(G4double range)
virtual std::vector< G4ParticleDefinition * > * DefinitionVector()
std::vector< G4LorentzVector * > * _momenta
G4LorentzVector MakeP4(G4double p, G4double theta, G4double phi, G4double e)
virtual std::vector< G4LorentzVector * > * P4Vector(const G4double binding, const G4double mass)
G4double RecoilEnergy(const G4double mass)
G4DistributionGenerator * _distributionAngle
static G4PionMinus * PionMinus()
Definition: G4PionMinus.cc:98
static G4Proton * Proton()
Definition: G4Proton.cc:93