Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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 (pia@genova.infn.it)
29 //
30 // Creation date: 8 May 1998
31 //
32 // -------------------------------------------------------------------
33 
34 #include <vector>
35 
36 #include "G4PiMinusStopMaterial.hh"
37 
38 #include "globals.hh"
39 #include "G4ios.hh"
40 #include "Randomize.hh"
41 #include "G4PhysicalConstants.hh"
42 #include "G4Proton.hh"
43 #include "G4Neutron.hh"
44 #include "G4PionMinus.hh"
45 #include "G4ParticleTypes.hh"
46 #include "G4ReactionKinematics.hh"
48 #include "G4LorentzVector.hh"
49 #include "G4PiMinusStopMaterial.hh"
51 
52 
53 // Constructor
54 
56 {
57  _definitions = 0;
58  _momenta = 0;
59  _distributionE = 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 
82 std::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 
97 std::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;
112  G4LorentzVector p1;
113  G4LorentzVector p2;
114 
115  do
116  {
117  G4double ranflat;
118  G4double p;
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