Geant4  10.00.p03
G4VHadronPhysics.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 // $Id: G4VHadronPhysics.cc 71043 2013-06-10 09:29:56Z gcosmo $
27 //
28 //---------------------------------------------------------------------------
29 //
30 // ClassName: G4VHadronPhysics
31 //
32 // Author: 28 June 2009 V.Ivanchenko
33 //
34 // Modified:
35 //
36 //----------------------------------------------------------------------------
37 //
38 
39 #include "G4VHadronPhysics.hh"
40 #include "G4SystemOfUnits.hh"
41 #include "G4ParticleDefinition.hh"
43 #include "G4HadronicProcessType.hh"
49 #include "G4Neutron.hh"
50 #include "G4MesonConstructor.hh"
51 #include "G4BaryonConstructor.hh"
52 #include "G4IonConstructor.hh"
54 #include "G4ProcessVector.hh"
55 #include "G4ProcessManager.hh"
56 
57 G4ThreadLocal std::vector<G4VHadronModelBuilder*>* G4VHadronPhysics::builders = 0;
58 
60  : G4VPhysicsConstructor(aName)
61 {
62  SetVerboseLevel(verb);
63  if (verboseLevel>1) {
64  G4cout << "### G4VHadronPhysics: <" << aName << "> is created "
65  << G4endl;
66  }
67 }
68 
70 {
71  G4int n = builders->size();
72  if(n > 0) {
73  for(G4int i=0; i<n; i++) {delete (*builders)[i];}
74  }
75  delete builders;
76 }
77 
79 {
80  G4MesonConstructor pMesonConstructor;
81  pMesonConstructor.ConstructParticle();
82 
83  G4BaryonConstructor pBaryonConstructor;
84  pBaryonConstructor.ConstructParticle();
85 
86  G4IonConstructor pIonConstructor;
87  pIonConstructor.ConstructParticle();
88 
89  G4ShortLivedConstructor pShortLivedConstructor;
90  pShortLivedConstructor.ConstructParticle();
91 }
92 
95  G4double emin,
96  G4double emax)
97 {
98  if ( builders == 0 ) builders = new std::vector<G4VHadronModelBuilder*>;
99  builders->push_back(mBuilder);
100  G4HadronicInteraction* model = mBuilder->GetModel();
101  model->SetMinEnergy(emin);
102  model->SetMaxEnergy(emax);
103  if (verboseLevel>1) {
104  G4cout << "### G4VHadronPhysics <"
105  << model->GetModelName() << " Emin(GeV)= "
106  << emin/GeV << " Emax(GeV)= " << emax/GeV
107  << G4endl;
108  }
109 
110  return model;
111 }
112 
115  G4double emin,
116  G4double emax)
117 {
118  if(!model) return model;
119  model->SetMinEnergy(emin);
120  model->SetMaxEnergy(emax);
121  if (verboseLevel>1) {
122  G4cout << "### G4VHadronPhysics <"
123  << model->GetModelName() << " Emin(GeV)= "
124  << emin/GeV << " Emax(GeV)= " << emax/GeV
125  << G4endl;
126  }
127  return model;
128 }
129 
130 void
133 {
134  const G4ParticleDefinition* p =
136  if(!p) {
137  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
138  << pname << G4endl;
139  } else {
140  AddInelasticCrossSection(p, xsec);
141  }
142 }
143 
144 void
147 {
148  if(!p) return;
150  if(!had) return;
151  had->AddDataSet(xsec);
152  if (verboseLevel>1) {
153  G4cout << "### G4VHadronPhysics: the inelastic cross section "
154  << " is added for " << p->GetParticleName()
155  << G4endl;
156  }
157 }
158 
159 void
162 {
163  const G4ParticleDefinition* p =
165  if(!p) {
166  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
167  << pname << G4endl;
168  } else {
169  AddElasticCrossSection(p, xsec);
170  }
171 }
172 
173 void
176 {
177  if(!p) return;
179  if(!had) return;
180  had->AddDataSet(xsec);
181  if (verboseLevel>1) {
182  G4cout << "### G4VHadronPhysics: the inelastic cross section "
183  << " is added for " << p->GetParticleName()
184  << G4endl;
185  }
186 }
187 
188 void
190 {
192  if(!had) return;
193  had->AddDataSet(xsec);
194  if (verboseLevel>1) {
195  G4cout << "### G4VHadronPhysics: the capture cross section "
196  << " is added for neutron"
197  << G4endl;
198  }
199 }
200 
201 void
203 {
205  if(!had) return;
206  had->AddDataSet(xsec);
207  if (verboseLevel>1) {
208  G4cout << "### G4VHadronPhysics: the fission cross section "
209  << " is added for neutron"
210  << G4endl;
211  }
212 }
213 
216 {
217  G4HadronicProcess* had = 0;
218  const G4ParticleDefinition* p =
220  if(!p) {
221  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
222  << pname << G4endl;
223  return had;
224  }
225  return FindInelasticProcess(p);
226 }
227 
230 {
231  G4HadronicProcess* had = 0;
232  if(!p) return had;
233  G4ProcessManager* pmanager = p->GetProcessManager();
234  G4ProcessVector* pv = pmanager->GetProcessList();
235  size_t n = pv->size();
236  if(0 < n) {
237  for(size_t i=0; i<n; ++i) {
238  if(fHadronInelastic == ((*pv)[i])->GetProcessSubType()) {
239  had = static_cast<G4HadronicProcess*>((*pv)[i]);
240  return had;
241  }
242  }
243  }
244  G4ParticleDefinition* part = const_cast<G4ParticleDefinition*>(p);
245  had = new G4HadronInelasticProcess(part->GetParticleName()+"Inelastic",part);
246  pmanager->AddDiscreteProcess(had);
247  return had;
248 }
249 
252 {
253  G4HadronicProcess* had = 0;
254  const G4ParticleDefinition* p =
256  if(!p) {
257  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
258  << pname << G4endl;
259  return had;
260  }
261  return FindElasticProcess(p);
262 }
263 
266 {
267  G4HadronicProcess* had = 0;
268  if(!p) return had;
269  G4ProcessManager* pmanager = p->GetProcessManager();
270  G4ProcessVector* pv = pmanager->GetProcessList();
271  size_t n = pv->size();
272  if(0 < n) {
273  for(size_t i=0; i<n; ++i) {
274  if(fHadronElastic == ((*pv)[i])->GetProcessSubType()) {
275  had = static_cast<G4HadronicProcess*>((*pv)[i]);
276  return had;
277  }
278  }
279  }
280  had = new G4HadronElasticProcess("hElastic");
281  pmanager->AddDiscreteProcess(had);
282  return had;
283 }
284 
286 {
287  G4HadronicProcess* had = 0;
288  G4ProcessManager* pmanager =
290  G4ProcessVector* pv = pmanager->GetProcessList();
291  size_t n = pv->size();
292  if(0 < n) {
293  for(size_t i=0; i<n; ++i) {
294  if(fCapture == ((*pv)[i])->GetProcessSubType()) {
295  had = static_cast<G4HadronicProcess*>((*pv)[i]);
296  return had;
297  }
298  }
299  }
300  had = new G4HadronCaptureProcess("nCapture");
301  pmanager->AddDiscreteProcess(had);
302  return had;
303 }
304 
306 {
307  G4HadronicProcess* had = 0;
308  G4ProcessManager* pmanager =
310  G4ProcessVector* pv = pmanager->GetProcessList();
311  size_t n = pv->size();
312  if(0 < n) {
313  for(size_t i=0; i<n; ++i) {
314  if(fFission == ((*pv)[i])->GetProcessSubType()) {
315  had = static_cast<G4HadronicProcess*>((*pv)[i]);
316  return had;
317  }
318  }
319  }
320  had = new G4HadronFissionProcess("nFission");
321  pmanager->AddDiscreteProcess(had);
322  return had;
323 }
324 
G4HadronicProcess * FindCaptureProcess()
void AddCaptureCrossSection(G4VCrossSectionDataSet *)
G4ParticleDefinition * FindParticle(G4int PDGEncoding)
G4HadronicProcess * FindFissionProcess()
G4int AddDiscreteProcess(G4VProcess *aProcess, G4int ord=ordDefault)
static void ConstructParticle()
const G4String & GetModelName() const
#define G4ThreadLocal
Definition: tls.hh:52
static void ConstructParticle()
G4ProcessManager * GetProcessManager() const
int G4int
Definition: G4Types.hh:78
const G4String & GetParticleName() const
G4VHadronPhysics(const G4String &name="hInelastic", G4int verbose=0)
G4HadronicInteraction * GetModel()
static void ConstructParticle()
void SetMinEnergy(G4double anEnergy)
void AddDataSet(G4VCrossSectionDataSet *aDataSet)
G4GLOB_DLL std::ostream G4cout
G4HadronicProcess * FindInelasticProcess(const G4String &)
static const double GeV
Definition: G4SIunits.hh:196
void AddInelasticCrossSection(const G4String &, G4VCrossSectionDataSet *)
static G4Neutron * Neutron()
Definition: G4Neutron.cc:104
virtual ~G4VHadronPhysics()
const G4int n
void SetVerboseLevel(G4int value)
void AddElasticCrossSection(const G4String &, G4VCrossSectionDataSet *)
G4int size() const
G4HadronicInteraction * NewModel(G4HadronicInteraction *, G4double emin, G4double emax)
static G4ParticleTable * GetParticleTable()
void AddFissionCrossSection(G4VCrossSectionDataSet *)
void SetMaxEnergy(const G4double anEnergy)
#define G4endl
Definition: G4ios.hh:61
virtual void ConstructParticle()
double G4double
Definition: G4Types.hh:76
G4HadronicInteraction * BuildModel(G4VHadronModelBuilder *, G4double emin, G4double emax)
static G4ThreadLocal std::vector< G4VHadronModelBuilder * > * builders
G4ProcessVector * GetProcessList() const
G4HadronicProcess * FindElasticProcess(const G4String &)