LArSoft  v09_90_00
Liquid Argon Software toolkit - https://larsoft.org/
ConfigurablePhysicsList.icc
Go to the documentation of this file.
1 // Configurable Physics List Class
2 //
3 // Ben Jones, MIT, 24/06/09
4 //
5 // Based on the QGSP_BERT physics list supplied with geant 4, but with
6 // options to switch on and off different physics processed from the config
7 // file.
8 //
9 // To include a new physics process, create a new physics builder registering
10 // the relevant particles and interactions. Then add the builder to the
11 // GetPhysicsBuilders and GetDefaultSettings functions in this class,
12 // using the name by which the builder will be referenced in the config
13 // file. Physics builders to be enabled are specified in the LArG4 config.
14 //
15 
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
17 
18 #include "Geant4/G4ChargeExchangePhysics.hh"
19 #include "Geant4/G4EmExtraPhysics.hh"
20 #include "Geant4/G4ParticleDefinition.hh"
21 #include "Geant4/G4ParticleTable.hh"
22 #include "Geant4/G4ParticleTypes.hh"
23 #include "Geant4/G4ParticleWithCuts.hh"
24 #include "Geant4/G4ProcessManager.hh"
25 #include "Geant4/G4ProcessVector.hh"
26 #include "Geant4/globals.hh"
27 
28 #include "Geant4/G4Material.hh"
29 #include "Geant4/G4MaterialTable.hh"
30 #include "Geant4/G4MuonNuclearProcess.hh"
31 #include "Geant4/G4ios.hh"
32 #include <iomanip>
33 
34 #include "Geant4/G4Version.hh"
35 #if G4VERSION_NUMBER < 1060
36 #include "Geant4/G4DataQuestionaire.hh"
37 #else
38 // The G4DataQuestionaire.hh interface was removed in the 10.6, as described in the release notes:
39 // http://geant4-data.web.cern.ch/geant4-data/ReleaseNotes/ReleaseNotes4.10.6.html 8
40 // The class was header-only and only used internally by packaged physics lists to check dataset
41 // environment variables. These are checked anyway by processes that require them,
42 // so it should be possible to remove it from your application without an issue.
43 #endif
44 
45 #include "larsim/LegacyLArG4/CustomPhysicsTable.hh"
46 #include "larsim/LegacyLArG4/MuNuclearSplittingProcess.h"
47 #include "larsim/LegacyLArG4/MuNuclearSplittingProcessXSecBias.h"
48 #include "larsim/Simulation/LArG4Parameters.h"
49 
50 #include "cetlib_except/exception.h"
51 #include "messagefacility/MessageLogger/MessageLogger.h"
52 
53 namespace larg4 {
54 
55  template <class T>
56  TConfigurablePhysicsList<T>::TConfigurablePhysicsList(G4int const ver) : T()
57  {
58  mf::LogWarning logmsg{"ConfigurablePhysics"};
59  logmsg << "Setting up Configurable Physics List.\n";
60  // note - not sure exact purpose of these commands, but left in from QGSP_BERT list
61  this->defaultCutValue = 0.7 * CLHEP::mm;
62  this->SetVerboseLevel(ver);
63 #if G4VERSION_NUMBER < 1060
64  G4DataQuestionaire it(photon);
65 #endif
66  art::ServiceHandle<sim::LArG4Parameters> lgp;
67  if (lgp->UseCustomPhysics()) {
68  EnabledPhysics = lgp->EnabledPhysics();
69  logmsg << "Custom physics list enabled, contents:\n";
70  for (auto const& val : EnabledPhysics) {
71  logmsg << " " << val << '\n';
72  assert(TheCustomPhysicsTable);
73  if (!TheCustomPhysicsTable->IsPhysicsAvailable(val)) {
74  logmsg << "\nERROR: physics not available: " << val << '\n';
75  std::vector<std::string> availablePhysics(
76  TheCustomPhysicsTable->GetAvailablePhysicsList());
77  logmsg << "\n-- Available physics:\n";
78  for (auto const& nm : availablePhysics) {
79  if (TheCustomPhysicsTable->IsPhysicsAvailable(nm)) { logmsg << " " << nm << '\n'; }
80  }
81  logmsg << "--\n";
82  logmsg << "\nERROR: Throwing exception!\n";
83  throw cet::exception("ConfigurablePhysics") << "Physics not available: " << val;
84  }
85  }
86  }
87  else {
88  logmsg << "Custom physics list disabled, using default QGSP_BERT configuration.\n";
89  EnabledPhysics = GetDefaultSettings();
90  }
91  for (auto const& PhysicsName : EnabledPhysics) {
92  logmsg << "Registering physics: " << PhysicsName << '\n';
93  G4VPhysicsConstructor* g4v = TheCustomPhysicsTable->GetPhysicsConstructor(PhysicsName);
94  if (PhysicsName == "SynchrotronAndGN") {
95  logmsg << PhysicsName << ": Turning on GammaNuclear, Synchrotron.\n";
96  G4String on("on");
97  ((G4EmExtraPhysics*)g4v)->GammaNuclear(on);
98  ((G4EmExtraPhysics*)g4v)->Synch(on);
99  // We want MuonNuclear off, since we're gonna activate it
100  // within a Wrapped Process. This would double count these evts.
101  if (!lgp->K0Bias()) {
102  logmsg << PhysicsName << ": Turning on MuNuclear.\n";
103  ((G4EmExtraPhysics*)g4v)->MuonNuclear(on);
104  }
105  }
106  this->RegisterPhysics(g4v);
107  }
108  }
109 
110  template <class T>
111  TConfigurablePhysicsList<T>::~TConfigurablePhysicsList()
112  {}
113 
114  template <class T>
115  void TConfigurablePhysicsList<T>::SetCuts()
116  {
117 
118  art::ServiceHandle<sim::LArG4Parameters> lg4p;
119 
120  if (this->verboseLevel > 1) G4cout << "ConfigurablePhysicsList::SetCuts:";
121  this->SetCutsWithDefault();
122 
123  // Set Proton Cut to 0, particularly important when using High Precision Packages
124  // D.R. 02/25/19
125  bool ModifyProtonCut = lg4p->ModifyProtonCut();
126  if (ModifyProtonCut) {
127  double theProtonCut = (double)(lg4p->NewProtonCut());
128  this->SetCutValue(theProtonCut, "proton");
129  mf::LogInfo("ConfigurablePhysicsList::SetCuts:") << "Setting Proton cut to: " << theProtonCut;
130  }
131  }
132 
133  template <class T>
134  std::vector<std::string> TConfigurablePhysicsList<T>::GetDefaultSettings()
135  {
136  // Set default enabled physics processes (equivalent to QGSP_BERT physics list)
137  std::vector<std::string> TheVector;
138  TheVector.push_back("Em");
139  TheVector.push_back("SynchrotronAndGN");
140  TheVector.push_back("Decay");
141  TheVector.push_back("Hadron");
142  TheVector.push_back("HadronElastic");
143  TheVector.push_back("Stopping");
144  TheVector.push_back("Ion");
145  TheVector.push_back("NeutronTrackingCut");
146  return TheVector;
147  }
148 
149 }
150 
151 // Sept 2009 - Ben Jones, MIT