1 // Configurable Physics List Class
3 // Ben Jones, MIT, 24/06/09
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
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.
16 #include "art/Framework/Services/Registry/ServiceHandle.h"
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"
28 #include "Geant4/G4Material.hh"
29 #include "Geant4/G4MaterialTable.hh"
30 #include "Geant4/G4MuonNuclearProcess.hh"
31 #include "Geant4/G4ios.hh"
34 #include "Geant4/G4Version.hh"
35 #if G4VERSION_NUMBER < 1060
36 #include "Geant4/G4DataQuestionaire.hh"
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.
45 #include "larsim/LegacyLArG4/CustomPhysicsTable.hh"
46 #include "larsim/LegacyLArG4/MuNuclearSplittingProcess.h"
47 #include "larsim/LegacyLArG4/MuNuclearSplittingProcessXSecBias.h"
48 #include "larsim/Simulation/LArG4Parameters.h"
50 #include "cetlib_except/exception.h"
51 #include "messagefacility/MessageLogger/MessageLogger.h"
56 TConfigurablePhysicsList<T>::TConfigurablePhysicsList(G4int const ver) : T()
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);
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'; }
82 logmsg << "\nERROR: Throwing exception!\n";
83 throw cet::exception("ConfigurablePhysics") << "Physics not available: " << val;
88 logmsg << "Custom physics list disabled, using default QGSP_BERT configuration.\n";
89 EnabledPhysics = GetDefaultSettings();
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";
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);
106 this->RegisterPhysics(g4v);
111 TConfigurablePhysicsList<T>::~TConfigurablePhysicsList()
115 void TConfigurablePhysicsList<T>::SetCuts()
118 art::ServiceHandle<sim::LArG4Parameters> lg4p;
120 if (this->verboseLevel > 1) G4cout << "ConfigurablePhysicsList::SetCuts:";
121 this->SetCutsWithDefault();
123 // Set Proton Cut to 0, particularly important when using High Precision Packages
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;
134 std::vector<std::string> TConfigurablePhysicsList<T>::GetDefaultSettings()
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");
151 // Sept 2009 - Ben Jones, MIT