ECCE @ EIC Software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
G4VHadronPhysics.cc
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file G4VHadronPhysics.cc
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 //
27 //---------------------------------------------------------------------------
28 //
29 // ClassName: G4VHadronPhysics
30 //
31 // Author: 28 June 2009 V.Ivanchenko
32 //
33 // Modified:
34 //
35 //----------------------------------------------------------------------------
36 //
37 
38 #include "G4VHadronPhysics.hh"
39 #include "G4SystemOfUnits.hh"
40 #include "G4ParticleDefinition.hh"
42 #include "G4HadronicProcessType.hh"
48 #include "G4Neutron.hh"
49 #include "G4MesonConstructor.hh"
50 #include "G4BaryonConstructor.hh"
51 #include "G4IonConstructor.hh"
53 #include "G4ProcessVector.hh"
54 #include "G4ProcessManager.hh"
56 
57 G4ThreadLocal std::vector<G4VHadronModelBuilder*>* G4VHadronPhysics::builders = nullptr;
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  for(G4int i=0; i<n; ++i) {delete (*builders)[i];}
74  }
75  delete builders;
76  builders = nullptr;
77 }
78 
80 {
81  G4MesonConstructor pMesonConstructor;
82  pMesonConstructor.ConstructParticle();
83 
84  G4BaryonConstructor pBaryonConstructor;
85  pBaryonConstructor.ConstructParticle();
86 
87  G4IonConstructor pIonConstructor;
88  pIonConstructor.ConstructParticle();
89 
90  G4ShortLivedConstructor pShortLivedConstructor;
91  pShortLivedConstructor.ConstructParticle();
92 }
93 
96  G4double emin,
97  G4double emax)
98 {
99  if ( builders == 0 ) builders = new std::vector<G4VHadronModelBuilder*>;
100  builders->push_back(mBuilder);
101  G4HadronicInteraction* model = mBuilder->GetModel();
102  model->SetMinEnergy(emin);
103  model->SetMaxEnergy(emax);
104  if (verboseLevel>1) {
105  G4cout << "### G4VHadronPhysics <"
106  << model->GetModelName() << " Emin(GeV)= "
107  << emin/GeV << " Emax(GeV)= " << emax/GeV
108  << G4endl;
109  }
110 
111  return model;
112 }
113 
116  G4double emin,
117  G4double emax)
118 {
119  if(!model) return model;
120  model->SetMinEnergy(emin);
121  model->SetMaxEnergy(emax);
122  if (verboseLevel>1) {
123  G4cout << "### G4VHadronPhysics <"
124  << model->GetModelName() << " Emin(GeV)= "
125  << emin/GeV << " Emax(GeV)= " << emax/GeV
126  << G4endl;
127  }
128  return model;
129 }
130 
131 void
134 {
135  const G4ParticleDefinition* p =
137  if(!p) {
138  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
139  << pname << G4endl;
140  } else {
141  AddInelasticCrossSection(p, xsec);
142  }
143 }
144 
145 void
148 {
149  if(!p) return;
151  if(!had) return;
152  had->AddDataSet(xsec);
153  if (verboseLevel>1) {
154  G4cout << "### G4VHadronPhysics: the inelastic cross section "
155  << " is added for " << p->GetParticleName()
156  << G4endl;
157  }
158 }
159 
160 void
163 {
164  const G4ParticleDefinition* p =
166  if(!p) {
167  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
168  << pname << G4endl;
169  } else {
170  AddElasticCrossSection(p, xsec);
171  }
172 }
173 
174 void
177 {
178  if(!p) return;
180  if(!had) return;
181  had->AddDataSet(xsec);
182  if (verboseLevel>1) {
183  G4cout << "### G4VHadronPhysics: the inelastic cross section "
184  << " is added for " << p->GetParticleName()
185  << G4endl;
186  }
187 }
188 
189 void
191 {
193  if(!had) return;
194  had->AddDataSet(xsec);
195  if (verboseLevel>1) {
196  G4cout << "### G4VHadronPhysics: the capture cross section "
197  << " is added for neutron"
198  << G4endl;
199  }
200 }
201 
202 void
204 {
206  if(!had) return;
207  had->AddDataSet(xsec);
208  if (verboseLevel>1) {
209  G4cout << "### G4VHadronPhysics: the fission cross section "
210  << " is added for neutron"
211  << G4endl;
212  }
213 }
214 
217 {
218  G4VComponentCrossSection* component =
220  G4CrossSectionInelastic* ptr = (component)
221  ? new G4CrossSectionInelastic(component) : nullptr;
222  return ptr;
223 }
224 
227 {
228  G4HadronicProcess* had = nullptr;
229  const G4ParticleDefinition* p =
231  if(!p) {
232  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
233  << pname << G4endl;
234  return had;
235  }
236  return FindInelasticProcess(p);
237 }
238 
241 {
242  G4HadronicProcess* had = nullptr;
243  if(!p) return had;
244  G4ProcessManager* pmanager = p->GetProcessManager();
245  G4ProcessVector* pv = pmanager->GetProcessList();
246  size_t n = pv->size();
247  if(0 < n) {
248  for(size_t i=0; i<n; ++i) {
249  if(fHadronInelastic == ((*pv)[i])->GetProcessSubType()) {
250  had = static_cast<G4HadronicProcess*>((*pv)[i]);
251  return had;
252  }
253  }
254  }
256  had = new G4HadronInelasticProcess(part->GetParticleName()+"Inelastic",part);
257  pmanager->AddDiscreteProcess(had);
258  return had;
259 }
260 
263 {
264  G4HadronicProcess* had = nullptr;
265  const G4ParticleDefinition* p =
267  if(!p) {
268  G4cout << "### G4VHadronPhysics WARNING: fails to find particle "
269  << pname << G4endl;
270  return had;
271  }
272  return FindElasticProcess(p);
273 }
274 
277 {
278  G4HadronicProcess* had = nullptr;
279  if(!p) return had;
280  G4ProcessManager* pmanager = p->GetProcessManager();
281  G4ProcessVector* pv = pmanager->GetProcessList();
282  size_t n = pv->size();
283  if(0 < n) {
284  for(size_t i=0; i<n; ++i) {
285  if(fHadronElastic == ((*pv)[i])->GetProcessSubType()) {
286  had = static_cast<G4HadronicProcess*>((*pv)[i]);
287  return had;
288  }
289  }
290  }
291  had = new G4HadronElasticProcess("hElastic");
292  pmanager->AddDiscreteProcess(had);
293  return had;
294 }
295 
297 {
298  G4HadronicProcess* had = nullptr;
299  G4ProcessManager* pmanager =
301  G4ProcessVector* pv = pmanager->GetProcessList();
302  size_t n = pv->size();
303  if(0 < n) {
304  for(size_t i=0; i<n; ++i) {
305  if(fCapture == ((*pv)[i])->GetProcessSubType()) {
306  had = static_cast<G4HadronicProcess*>((*pv)[i]);
307  return had;
308  }
309  }
310  }
311  had = new G4HadronCaptureProcess("nCapture");
312  pmanager->AddDiscreteProcess(had);
313  return had;
314 }
315 
317 {
318  G4HadronicProcess* had = nullptr;
319  G4ProcessManager* pmanager =
321  G4ProcessVector* pv = pmanager->GetProcessList();
322  size_t n = pv->size();
323  if(0 < n) {
324  for(size_t i=0; i<n; ++i) {
325  if(fFission == ((*pv)[i])->GetProcessSubType()) {
326  had = static_cast<G4HadronicProcess*>((*pv)[i]);
327  return had;
328  }
329  }
330  }
331  had = new G4HadronFissionProcess("nFission");
332  pmanager->AddDiscreteProcess(had);
333  return had;
334 }
335