ATLAS Offline Software
Loading...
Searching...
No Matches
PhysicsConfigurationHelper.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#include "G4ios.hh"
7#include "CLHEP/Units/PhysicalConstants.h"
8#include <iostream>
9#include <fstream>
10
11
13{
14 G4cout << "PhysicsConfigurationHelper constructor: start" << G4endl;
15
16 std::map<G4String,G4double> parameters;
17 ReadInPhysicsParameters(parameters);
18 if (parameters["Resonant"]!=0.) m_resonant=true;
19 m_ek_0 = parameters["ResonanceEnergy"]*CLHEP::GeV;
20 m_gamma = parameters["Gamma"]*CLHEP::GeV;
21 m_amplitude = parameters["Amplitude"]*CLHEP::millibarn;
22 m_xsecmultiplier = parameters["XsecMultiplier"];
23 m_suppressionfactor = parameters["ReggeSuppression"];
24 m_hadronlifetime = parameters["HadronLifeTime"];
25 m_mixing = parameters["Mixing"];
26 if (parameters["ReggeModel"]!=0.) m_reggemodel=true;
27 m_doDecays=parameters["DoDecays"];
28
29 G4cout<<"Read in physics parameters:"<<G4endl;
30 G4cout<<"Resonant = "<< m_resonant <<G4endl;
31 G4cout<<"ResonanceEnergy = "<<m_ek_0/CLHEP::GeV<<" GeV"<<G4endl;
32 G4cout<<"XsecMultiplier = "<<m_xsecmultiplier<<G4endl;
33 G4cout<<"Gamma = "<<m_gamma/CLHEP::GeV<<" GeV"<<G4endl;
34 G4cout<<"Amplitude = "<<m_amplitude/CLHEP::millibarn<<" millibarn"<<G4endl;
35 G4cout<<"ReggeSuppression = "<<100*m_suppressionfactor<<" %"<<G4endl;
36 G4cout<<"HadronLifeTime = "<<m_hadronlifetime;
37 if (m_doDecays) G4cout<<" ns"<<G4endl;
38 else G4cout<<" s"<<G4endl;
39 G4cout<<"ReggeModel = "<< m_reggemodel <<G4endl;
40 G4cout<<"Mixing = "<< m_mixing*100 <<" %"<<G4endl;
41 G4cout<<"DoDecays = "<< m_doDecays << G4endl;
42
43 if ((!m_doDecays && m_hadronlifetime>0.) ||
45 G4cout << "WARNING: Inconsistent treatment of R-Hadron properties! Lifetime of " << m_hadronlifetime
46 << " and doDecays= " << m_doDecays << G4endl;
47 }
48
49 return;
50}
51
52
58
59
60void PhysicsConfigurationHelper::ReadInPhysicsParameters(std::map<G4String,G4double>& parameters) const
61 {
62 parameters["Resonant"]=0.;
63 parameters["ResonanceEnergy"]=0.;
64 parameters["XsecMultiplier"]=1.;
65 parameters["Gamma"]=0.;
66 parameters["Amplitude"]=0.;
67 parameters["ReggeSuppression"]=0.;
68 parameters["HadronLifeTime"]=0.;
69 parameters["ReggeModel"]=0.;
70 parameters["Mixing"]=0.;
71 parameters["DoDecays"]=0;
72
73 std::ifstream physics_stream ("PhysicsConfiguration.txt");
74 G4String line;
75 char** endptr=0;
76 while (getline(physics_stream,line)) {
77 std::vector<G4String> tokens;
78 //Getting a line
79 ReadAndParse(line,tokens,"=");
80 G4String key = tokens[0];
81 G4double val = strtod(tokens[1],endptr);
82 parameters[key]=val;
83 }
84 physics_stream.close();
85 }
86
87
89 std::vector<G4String>& tokens,
90 const G4String& delimiters) const
91{
92 // Skip delimiters at beginning.
93 G4String::size_type lastPos = str.find_first_not_of(delimiters, 0);
94 if (lastPos==G4String::npos) return;
95
96 // Find first "non-delimiter".
97 G4String::size_type pos = str.find_first_of(delimiters, lastPos);
98
99 while (G4String::npos != pos || G4String::npos != lastPos)
100 {
101 //Skipping leading / trailing whitespaces
102 G4String temp = str.substr(lastPos, pos - lastPos);
103 while(temp.c_str()[0] == ' ') temp.erase(0,1);
104 while(temp[temp.size()-1] == ' ') temp.erase(temp.size()-1,1);
105
106 // Found a token, add it to the vector.
107 tokens.push_back(std::move(temp));
108
109 // Skip delimiters. Note the "not_of"
110 lastPos = str.find_first_not_of(delimiters, pos);
111 if (lastPos==G4String::npos) continue;
112
113 // Find next "non-delimiter"
114 pos = str.find_first_of(delimiters, lastPos);
115 }
116}
std::map< std::string, double > instance
void ReadAndParse(const G4String &str, std::vector< G4String > &tokens, const G4String &delimiters=" ") const
static const PhysicsConfigurationHelper * Instance()
void ReadInPhysicsParameters(std::map< G4String, G4double > &parameters) const