19#include "TRestGeant4PhysicsLists.h"
21#include <TRestTools.h>
27TRestGeant4PhysicsLists::TRestGeant4PhysicsLists() :
TRestMetadata() { Initialize(); }
29TRestGeant4PhysicsLists::TRestGeant4PhysicsLists(
const char* configFilename,
string name)
32 LoadConfigFromFile(fConfigFileName, name);
35TRestGeant4PhysicsLists::~TRestGeant4PhysicsLists() =
default;
47 fCutForGamma = GetDblParameterWithUnits(
"cutForGamma", 0.01);
48 fCutForElectron = GetDblParameterWithUnits(
"cutForElectron", 1);
49 fCutForPositron = GetDblParameterWithUnits(
"cutForPositron", 1);
50 fCutForMuon = GetDblParameterWithUnits(
"cutForMuon", 1);
51 fCutForNeutron = GetDblParameterWithUnits(
"cutForNeutron", 1);
52 fMinEnergyRangeProductionCuts = GetDblParameterWithUnits(
"minEnergyRangeProductionCuts", 1);
53 fMaxEnergyRangeProductionCuts = GetDblParameterWithUnits(
"maxEnergyRangeProductionCuts", 1e6);
55 TiXmlElement* physicsListDefinition =
GetElement(
"physicsList");
56 while (physicsListDefinition) {
58 TString physicsListName =
GetFieldValue(
"name", physicsListDefinition);
60 if (!PhysicsListExists(physicsListName)) {
61 cerr <<
"TRestPhysicsList: Physics list: '" << physicsListName
62 <<
"' not found among valid options" << endl;
66 TString optionString =
"";
67 TiXmlElement* optionDefinition =
GetElement(
"option", physicsListDefinition);
68 while (optionDefinition) {
70 TString optionValue =
GetFieldValue(
"value", optionDefinition);
72 if (optionString !=
"") {
75 optionString += optionName +
":" + optionValue;
80 fPhysicsLists.push_back(physicsListName);
81 fPhysicsListOptions.push_back(optionString);
86Int_t TRestGeant4PhysicsLists::FindPhysicsList(
const TString& physicsListName)
const {
87 if (!PhysicsListExists(physicsListName))
return -1;
89 for (
unsigned int n = 0; n < fPhysicsLists.size(); n++) {
90 if (fPhysicsLists[n] == physicsListName) {
98TString TRestGeant4PhysicsLists::GetPhysicsListOptionString(
const TString& physicsListName)
const {
99 Int_t index = FindPhysicsList(physicsListName);
105 return fPhysicsListOptions[index];
108TString TRestGeant4PhysicsLists::GetPhysicsListOptionValue(
const TString& physicsListName,
109 const TString& option,
110 const TString& defaultValue)
const {
113 for (
unsigned int n = 0; n < optList.size(); n = n + 2) {
114 if (optList[n] == option) {
115 return optList[n + 1];
122Bool_t TRestGeant4PhysicsLists::PhysicsListExists(
const TString& physicsListName)
const {
123 const set<TString> validPhysicsLists = {
"G4DecayPhysics",
124 "G4RadioactiveDecayPhysics",
125 "G4RadioactiveDecay",
126 "G4RadioactiveDecayBase",
128 "G4EmLivermorePhysics",
129 "G4EmPenelopePhysics",
130 "G4EmStandardPhysics_option3",
131 "G4EmStandardPhysics_option4",
132 "G4HadronElasticPhysicsHP",
133 "G4IonBinaryCascadePhysics",
134 "G4HadronPhysicsQGSP_BIC_HP",
135 "G4NeutronTrackingCut",
138 return validPhysicsLists.count(physicsListName) > 0;
144 RESTMetadata <<
"Cut for electrons : " << fCutForElectron <<
" mm" <<
RESTendl;
145 RESTMetadata <<
"Cut for positrons : " << fCutForPositron <<
" mm" <<
RESTendl;
146 RESTMetadata <<
"Cut for gammas : " << fCutForGamma <<
" mm" <<
RESTendl;
147 RESTMetadata <<
"Cut for muons : " << fCutForMuon <<
" mm" <<
RESTendl;
148 RESTMetadata <<
"Cut for neutrons : " << fCutForNeutron <<
" mm" <<
RESTendl;
149 RESTMetadata <<
"Min Energy for particle production: " << fMinEnergyRangeProductionCuts <<
" keV"
151 RESTMetadata <<
"Max Energy for particle production: " << fMaxEnergyRangeProductionCuts <<
" keV"
153 RESTMetadata <<
"---------------------------------------" <<
RESTendl;
154 for (
unsigned int n = 0; n < fPhysicsLists.size(); n++) {
155 RESTMetadata <<
"Physics list " << n <<
" : " << fPhysicsLists[n] <<
RESTendl;
157 for (
unsigned int m = 0; m < optList.size(); m = m + 2)
158 RESTMetadata <<
" - Option " << m / 2 <<
" : " << optList[m] <<
" = " << optList[m + 1]
161 if (!fIonLimitStepList.empty()) {
162 RESTMetadata <<
"List of ions affected by step limit" <<
RESTendl;
163 for (
const auto& ion : fIonLimitStepList) {
164 RESTMetadata <<
" - " << ion <<
RESTendl;
168 RESTMetadata <<
"******************************************" <<
RESTendl;
void InitFromConfigFile() override
To make settings from rml file. This method must be implemented in the derived class.
void PrintMetadata() override
Implemented it in the derived metadata class to print out specific metadata information.
void Initialize() override
Making default settings.
std::vector< std::string > Split(std::string in, std::string separator, bool allowBlankString=false, bool removeWhiteSpaces=false, int startPos=-1)
Split the input string according to the given separator. Returning a vector of fragments.