GEMC  2.3
Geant4 Monte-Carlo Framework
PhysicsList.cc
Go to the documentation of this file.
1 // GEMC PHYSICS LIST
2 //
3 // -----------------
4 //
5 // The
6 
7 
8 
9 // c++ headers
10 #include <iostream>
11 using namespace std;
12 
13 // gemc headers
14 #include "PhysicsList.h"
15 #include "PhysicsListMessenger.h"
16 #include "string_utilities.h"
17 
18 // geant4 headers
19 #include "G4LossTableManager.hh"
20 #include "G4PhysListFactory.hh"
21 #include "G4Gamma.hh"
22 #include "G4Electron.hh"
23 #include "G4Positron.hh"
24 #include "G4Proton.hh"
25 
26 // geant4 physics headers
27 #include "G4DecayPhysics.hh"
28 #include "G4EmStandardPhysics.hh"
29 #include "G4EmStandardPhysics_option1.hh"
30 #include "G4EmStandardPhysics_option2.hh"
31 #include "G4EmStandardPhysics_option3.hh"
32 #include "G4EmStandardPhysics_option4.hh"
33 #include "G4EmLivermorePhysics.hh"
34 #include "G4EmPenelopePhysics.hh"
35 #include "G4EmExtraPhysics.hh"
36 #include "G4HadronElasticPhysics.hh"
37 #include "G4HadronElasticPhysicsHP.hh"
38 #include "G4IonBinaryCascadePhysics.hh"
39 #include "G4IonPhysics.hh"
40 #include "G4NeutronTrackingCut.hh"
41 
42 // CLHEP units
43 #include "CLHEP/Units/PhysicalConstants.h"
44 using namespace CLHEP;
45 
47 {
48 
49  gemcOpt = opts;
50  verbosity = gemcOpt.optMap["PHYS_VERBOSITY"].arg ;
51  ingredientsList = gemcOpt.optMap["PHYSICS"].args ;
52 
53  // default physics lists
54  hadronicPhys = "none";
55  EMPhys = "STD";
56  opticalPhys = "none";
57  HPPhys = "none";
58 
59  // loading hadronic and em physics lists
60  G4PhysListFactory factory;
61  g4HadronicList = factory.AvailablePhysLists();
62  // em comes with "_", stripping it
63  vector<G4String> allEM = factory.AvailablePhysListsEM();
64  g4EMList.push_back("STD");
65  for(unsigned i=0; i<allEM.size(); i++)
66  {
67  vector<string> emstripped = get_strings(allEM[i], "_");
68  string stripped;
69 
70  if(emstripped.size() == 2) stripped = TrimSpaces(emstripped[1]);
71  if(stripped != "")
72  g4EMList.push_back(stripped);
73  }
74 
75  G4LossTableManager::Instance();
76  defaultCutValue = gemcOpt.optMap["PRODUCTIONCUT"].arg;
77  cutForGamma = defaultCutValue;
78  cutForElectron = defaultCutValue;
79  cutForPositron = defaultCutValue;
80  cutForProton = defaultCutValue;
81 
82  physIngredients = get_strings(ingredientsList, "+");
83 
84  g4EMPhysics = NULL;
85  g4ParticleList = NULL;
86  g4HadronicPhysics.clear();
87 
88  // validateIngredients will also set hadronicPhys, EMPhys, opticalPhys
89  if(!validateIngredients())
90  {
91  cout << " !!! Error: physics ingredients list not valid: >" << ingredientsList << "<" << endl;
92  list();
93 
94  cout << " Exiting." << endl;
95  exit(0);
96  }
97  else
98  cookPhysics();
99 
100 }
101 
102 
103 
104 
106 {
107  ;
108 }
109 
110 
112 {
113  cout << " > Available hadronic physics list: " << endl;
114  for(unsigned i=0; i<g4HadronicList.size(); i++)
115  cout << " - " << g4HadronicList[i] << endl;
116  cout << endl;
117 
118  cout << " > Available EM physics list: " << endl;
119  for(unsigned i=0; i<g4EMList.size(); i++)
120  cout << " - " << g4EMList[i] << endl;
121 
122  cout << " > Optica: optical" << endl;
123 }
124 
125 
126 
127 // check the ingredients consistency
129 {
130  unsigned isHadronicLegit = 0;
131  unsigned isEMLegit = 0;
132  unsigned isOpticalLegit = 0;
133  unsigned isHPLegit = 0;
134 
135  G4PhysListFactory factory;
136  for(unsigned i=0; i<physIngredients.size(); i++)
137  {
138  string ingredient = TrimSpaces(physIngredients[i]);
139 
140  if(factory.IsReferencePhysList(ingredient))
141  {
142  isHadronicLegit = 1;
143  hadronicPhys = ingredient;
144  }
145 
146  for(unsigned i=0; i<g4EMList.size(); i++)
147  if(ingredient == g4EMList[i])
148  {
149  isEMLegit = 1;
150  EMPhys = ingredient;
151  }
152 
153  if(ingredient == "Optical")
154  {
155  isOpticalLegit = 1;
156  opticalPhys = "yes";
157  }
158  if(ingredient == "HP")
159  {
160  HPPhys = "yes";
161  isHPLegit = 1;
162  }
163  }
164 
165  if(verbosity > 0)
166  {
167  cout << " >> Physics: " << ingredientsList << endl;
168  cout << " > Hadronic: " << hadronicPhys << endl;
169  cout << " > EM: " << EMPhys << endl;
170  cout << " > HP: " << HPPhys << endl;
171  cout << " > Optical: " << opticalPhys << endl << endl;
172  }
173 
174  if(physIngredients.size() == (isHadronicLegit + isEMLegit + isOpticalLegit + isHPLegit))
175  return TRUE;
176 
177  return FALSE;
178 }
179 
180 
181 
182 
184 {
185 
186  if (verbosity >0)
187  {
188  cout << "PhysicsList::SetCuts:";
189  cout << "CutLength : " << G4BestUnit(defaultCutValue, "Length") << endl;
190  }
191 
192  // set cut values for gamma at first and for e- second and next for e+,
193  // because some processes for e+/e- need cut values for gamma
194  SetCutValue(cutForGamma, "gamma");
195  SetCutValue(cutForElectron, "e-");
196  SetCutValue(cutForPositron, "e+");
197  SetCutValue(cutForProton, "proton");
198 
199  if (verbosity>0) DumpCutValuesTable();
200 }
201 
202 
204 {
205  cutForGamma = cut;
206  SetParticleCuts(cutForGamma, G4Gamma::Gamma());
207 }
208 
210 {
211  cutForElectron = cut;
212  SetParticleCuts(cutForElectron, G4Electron::Electron());
213 }
214 
216 {
217  cutForPositron = cut;
218  SetParticleCuts(cutForPositron, G4Positron::Positron());
219 }
220 
222 {
223  cutForProton = cut;
224  SetParticleCuts(cutForProton, G4Proton::Proton());
225 }
226 
227 
228 #include "FTFP_BERT.hh"
229 #include "FTFP_BERT_TRV.hh"
230 #include "FTFP_BERT_HP.hh"
231 #include "FTF_BIC.hh"
232 #include "LBE.hh"
233 #include "QBBC.hh"
234 #include "QGSP_BERT.hh"
235 #include "QGSP_BERT_HP.hh"
236 #include "QGSP_BIC.hh"
237 #include "QGSP_BIC_HP.hh"
238 #include "QGSP_FTFP_BERT.hh"
239 #include "QGS_BIC.hh"
240 #include "QGSP_INCLXX.hh"
241 #include "Shielding.hh"
242 #include "G4OpticalPhysics.hh"
243 
244 #include "G4StepLimiter.hh"
245 
246 void PhysicsList::cookPhysics()
247 {
248  // Particles
249  g4ParticleList = new G4DecayPhysics("decays");
250 
251  // EM Physics
252  if(g4EMPhysics) delete g4EMPhysics;
253  if(EMPhys == "STD") g4EMPhysics = new G4EmStandardPhysics();
254  else if(EMPhys == "EMV") g4EMPhysics = new G4EmStandardPhysics_option1();
255  else if(EMPhys == "EMX") g4EMPhysics = new G4EmStandardPhysics_option2();
256  else if(EMPhys == "EMY") g4EMPhysics = new G4EmStandardPhysics_option3();
257  else if(EMPhys == "EMZ") g4EMPhysics = new G4EmStandardPhysics_option4();
258  else if(EMPhys == "LIV") g4EMPhysics = new G4EmLivermorePhysics();
259  else if(EMPhys == "PEN") g4EMPhysics = new G4EmPenelopePhysics();
260  else
261  {
262  cout << " !! Wrong EMPhys " << EMPhys << endl << "Exiting." << endl;
263  exit(0);
264  }
265 
266  // Hadronic Physics
267  // always adding these
268  // this is a general version of
269  // Hadr01 example
270  // LBE and QBBC were removed
271 
272  // em extra physics always there
273  if(hadronicPhys != "none")
274  {
275  g4HadronicPhysics.push_back( new G4EmExtraPhysics(verbosity));
276 
277  if(HPPhys == "yes")
278  {
279  cout << " > Loading High Precision Cross Sections... this may take a while..." << endl;
280  g4HadronicPhysics.push_back( new G4HadronElasticPhysicsHP(verbosity) );
281  }
282  else
283  g4HadronicPhysics.push_back( new G4HadronElasticPhysics(verbosity) );
284 
285  // binary cascade, bertini models, or standard
286  // ion physics
287  if(hadronicPhys.find("BIC") != string::npos)
288  g4HadronicPhysics.push_back( new G4IonBinaryCascadePhysics(verbosity));
289  else if(hadronicPhys.find("BERT") != string::npos)
290  g4HadronicPhysics.push_back( new G4IonPhysics(verbosity));
291 
292 
293  g4HadronicPhysics.push_back( new G4NeutronTrackingCut(verbosity));
294  }
295  // adding the hadronic physics list
296  // I don't understand why there isn't a factory method for this
297  // had to hardcode the cases
298  // in any case they are in G4PhysListFactory
299 
300  if(hadronicPhys == "FTFP_BERT") {g4HadronicPhysics.push_back( new G4HadronPhysicsFTFP_BERT());}
301  else if(hadronicPhys == "FTFP_BERT_TRV") {g4HadronicPhysics.push_back( new G4HadronPhysicsFTFP_BERT_TRV());}
302  else if(hadronicPhys == "FTFP_BERT_HP") {g4HadronicPhysics.push_back( new G4HadronPhysicsFTFP_BERT_HP());}
303  else if(hadronicPhys == "FTF_BIC") {g4HadronicPhysics.push_back( new G4HadronPhysicsFTF_BIC());}
304  else if(hadronicPhys == "QGSP_BERT") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGSP_BERT());}
305  else if(hadronicPhys == "QGSP_BERT_HP") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGSP_BERT_HP());}
306  else if(hadronicPhys == "QGSP_BIC") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGSP_BIC());}
307  else if(hadronicPhys == "QGSP_BIC_HP") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGSP_BIC_HP());}
308  else if(hadronicPhys == "QGSP_FTFP_BERT") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGSP_FTFP_BERT());}
309  else if(hadronicPhys == "QGS_BIC") {g4HadronicPhysics.push_back( new G4HadronPhysicsQGS_BIC());}
310  else if(hadronicPhys == "none") {;}
311  //else if(hadronicPhys == "Shielding") {g4HadronicPhysics.push_back( new Shielding());}
312  else {cout << "Wrong hadronicPhys " << hadronicPhys << endl << "Exiting." << endl; exit(0);}
313 
314  // optical physics
315  // taken from example: optical/LXe
316  if(opticalPhys == "yes")
317  {
318  // verbosity is set to zero at the constructor level by default
319  // see G4OpticalPhysics.hh
320  G4OpticalPhysics* opticalPhysics = new G4OpticalPhysics();
321  opticalPhysics->SetWLSTimeProfile("delta");
322 
323  g4HadronicPhysics.push_back(opticalPhysics);
324  }
325 
326 }
327 
328 
329 void PhysicsList::ConstructParticle()
330 {
331  g4ParticleList->ConstructParticle();
332 }
333 
334 
335 void PhysicsList::ConstructProcess()
336 {
337  AddTransportation();
338  g4EMPhysics->ConstructProcess();
339  g4ParticleList->ConstructProcess();
340  for(size_t i=0; i<g4HadronicPhysics.size(); i++)
341  g4HadronicPhysics[i]->ConstructProcess();
342 
343 
344 
345  // PhysicsList contains theParticleIterator
346  theParticleIterator->reset();
347 
348  while( (*theParticleIterator)() )
349  {
350  G4ParticleDefinition* particle = theParticleIterator->value();
351  G4ProcessManager* pmanager = particle->GetProcessManager();
352  string pname = particle->GetParticleName();
353 
354  // Adding Step Limiter
355  if ((!particle->IsShortLived()) && (particle->GetPDGCharge() != 0.0) && (pname != "chargedgeantino"))
356  {
357  if(verbosity > 2)
358  cout << " > Adding Step Limiter for " << pname << endl;
359 
360  pmanager->AddProcess(new G4StepLimiter, -1,-1,3);
361  }
362 
363  }
364 
365 }
366 
367 
368 
369 
370 
371 
372 
373 
374 
375 
376 
vector< string > get_strings(string input)
returns a vector of strings from a stringstream, space is delimiter
STL namespace.
bool validateIngredients()
Definition: PhysicsList.cc:128
void SetCutForElectron(double)
Definition: PhysicsList.cc:209
map< string, aopt > optMap
Options map.
Definition: options.h:75
void SetCutForGamma(double)
Definition: PhysicsList.cc:203
vector< string > physIngredients
Definition: PhysicsList.h:31
void SetCuts()
Definition: PhysicsList.cc:183
void SetCutForProton(double)
Definition: PhysicsList.cc:221
string TrimSpaces(string in)
Removes leading and trailing spaces.
PhysicsList(goptions)
Definition: PhysicsList.cc:46
void SetCutForPositron(double)
Definition: PhysicsList.cc:215