Geant4  10.01.p02
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 85579 2014-10-31 09:04:00Z 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  if ( builders ) {
72  G4int n = builders->size();
73  if(n > 0) {
74  for(G4int i=0; i<n; i++) {delete (*builders)[i];}
75  }
76  delete builders;
77  }
78 }
79 
81 {
82  G4MesonConstructor pMesonConstructor;
83  pMesonConstructor.ConstructParticle();
84 
85  G4BaryonConstructor pBaryonConstructor;
86  pBaryonConstructor.ConstructParticle();
87 
88  G4IonConstructor pIonConstructor;
89  pIonConstructor.ConstructParticle();
90 
91  G4ShortLivedConstructor pShortLivedConstructor;
92  pShortLivedConstructor.ConstructParticle();
93 }
94 
97  G4double emin,
98  G4double emax)
99 {
100  if ( builders == 0 ) builders = new std::vector<G4VHadronModelBuilder*>;
101  builders->push_back(mBuilder);
102  G4HadronicInteraction* model = mBuilder->GetModel();
103  model->SetMinEnergy(emin);
104  model->SetMaxEnergy(emax);
105  if (verboseLevel>1) {
106  G4cout << "### G4VHadronPhysics <"
107  << model->GetModelName() << " Emin(GeV)= "
108  << emin/GeV << " Emax(GeV)= " << emax/GeV
109  << G4endl;
110  }
111 
112  return model;
113 }
114 
117  G4double emin,
118  G4double emax)
119 {
120  if(!model) return model;
121  model->SetMinEnergy(emin);
122  model->SetMaxEnergy(emax);
123  if (verboseLevel>1) {
124  G4cout << "### G4VHadronPhysics <"
125  << model->GetModelName() << " Emin(GeV)= "
126  << emin/GeV << " Emax(GeV)= " << emax/GeV
127  << G4endl;
128  }
129  return model;
130 }
131 
132 void
135 {
136  const G4ParticleDefinition* p =
138  if(!p) {
139  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
140  << pname << G4endl;
141  } else {
142  AddInelasticCrossSection(p, xsec);
143  }
144 }
145 
146 void
149 {
150  if(!p) return;
152  if(!had) return;
153  had->AddDataSet(xsec);
154  if (verboseLevel>1) {
155  G4cout << "### G4VHadronPhysics: the inelastic cross section "
156  << " is added for " << p->GetParticleName()
157  << G4endl;
158  }
159 }
160 
161 void
164 {
165  const G4ParticleDefinition* p =
167  if(!p) {
168  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
169  << pname << G4endl;
170  } else {
171  AddElasticCrossSection(p, xsec);
172  }
173 }
174 
175 void
178 {
179  if(!p) return;
181  if(!had) return;
182  had->AddDataSet(xsec);
183  if (verboseLevel>1) {
184  G4cout << "### G4VHadronPhysics: the inelastic cross section "
185  << " is added for " << p->GetParticleName()
186  << G4endl;
187  }
188 }
189 
190 void
192 {
194  if(!had) return;
195  had->AddDataSet(xsec);
196  if (verboseLevel>1) {
197  G4cout << "### G4VHadronPhysics: the capture cross section "
198  << " is added for neutron"
199  << G4endl;
200  }
201 }
202 
203 void
205 {
207  if(!had) return;
208  had->AddDataSet(xsec);
209  if (verboseLevel>1) {
210  G4cout << "### G4VHadronPhysics: the fission cross section "
211  << " is added for neutron"
212  << G4endl;
213  }
214 }
215 
218 {
219  G4HadronicProcess* had = 0;
220  const G4ParticleDefinition* p =
222  if(!p) {
223  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
224  << pname << G4endl;
225  return had;
226  }
227  return FindInelasticProcess(p);
228 }
229 
232 {
233  G4HadronicProcess* had = 0;
234  if(!p) return had;
235  G4ProcessManager* pmanager = p->GetProcessManager();
236  G4ProcessVector* pv = pmanager->GetProcessList();
237  size_t n = pv->size();
238  if(0 < n) {
239  for(size_t i=0; i<n; ++i) {
240  if(fHadronInelastic == ((*pv)[i])->GetProcessSubType()) {
241  had = static_cast<G4HadronicProcess*>((*pv)[i]);
242  return had;
243  }
244  }
245  }
246  G4ParticleDefinition* part = const_cast<G4ParticleDefinition*>(p);
247  had = new G4HadronInelasticProcess(part->GetParticleName()+"Inelastic",part);
248  pmanager->AddDiscreteProcess(had);
249  return had;
250 }
251 
254 {
255  G4HadronicProcess* had = 0;
256  const G4ParticleDefinition* p =
258  if(!p) {
259  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
260  << pname << G4endl;
261  return had;
262  }
263  return FindElasticProcess(p);
264 }
265 
268 {
269  G4HadronicProcess* had = 0;
270  if(!p) return had;
271  G4ProcessManager* pmanager = p->GetProcessManager();
272  G4ProcessVector* pv = pmanager->GetProcessList();
273  size_t n = pv->size();
274  if(0 < n) {
275  for(size_t i=0; i<n; ++i) {
276  if(fHadronElastic == ((*pv)[i])->GetProcessSubType()) {
277  had = static_cast<G4HadronicProcess*>((*pv)[i]);
278  return had;
279  }
280  }
281  }
282  had = new G4HadronElasticProcess("hElastic");
283  pmanager->AddDiscreteProcess(had);
284  return had;
285 }
286 
288 {
289  G4HadronicProcess* had = 0;
290  G4ProcessManager* pmanager =
292  G4ProcessVector* pv = pmanager->GetProcessList();
293  size_t n = pv->size();
294  if(0 < n) {
295  for(size_t i=0; i<n; ++i) {
296  if(fCapture == ((*pv)[i])->GetProcessSubType()) {
297  had = static_cast<G4HadronicProcess*>((*pv)[i]);
298  return had;
299  }
300  }
301  }
302  had = new G4HadronCaptureProcess("nCapture");
303  pmanager->AddDiscreteProcess(had);
304  return had;
305 }
306 
308 {
309  G4HadronicProcess* had = 0;
310  G4ProcessManager* pmanager =
312  G4ProcessVector* pv = pmanager->GetProcessList();
313  size_t n = pv->size();
314  if(0 < n) {
315  for(size_t i=0; i<n; ++i) {
316  if(fFission == ((*pv)[i])->GetProcessSubType()) {
317  had = static_cast<G4HadronicProcess*>((*pv)[i]);
318  return had;
319  }
320  }
321  }
322  had = new G4HadronFissionProcess("nFission");
323  pmanager->AddDiscreteProcess(had);
324  return had;
325 }
326 
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:89
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 &)