Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
PhysicsConfigurationHelper.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 #include "CLHEP/Units/PhysicalConstants.h"
7 #include <iostream>
8 #include <fstream>
9 #include <stdexcept>
10 
12 
14 {
15  G4cout << "PhysicsConfigurationHelper constructor: start" << G4endl;
16 
17  std::map<G4String,G4double> parameters;
19  if (parameters["Resonant"]!=0.) m_resonant=true;
20  m_ek_0 = parameters["ResonanceEnergy"]*CLHEP::GeV;
21  m_gamma = parameters["Gamma"]*CLHEP::GeV;
23  m_xsecmultiplier = parameters["XsecMultiplier"];
24  m_suppressionfactor = parameters["ReggeSuppression"];
25  m_hadronlifetime = parameters["HadronLifeTime"];
26  m_mixing = parameters["Mixing"];
27  if (parameters["ReggeModel"]!=0.) m_reggemodel=true;
28  m_doDecays=parameters["DoDecays"];
29 
30  G4cout<<"Read in physics parameters:"<<G4endl;
31  G4cout<<"Resonant = "<< m_resonant <<G4endl;
32  G4cout<<"ResonanceEnergy = "<<m_ek_0/CLHEP::GeV<<" GeV"<<G4endl;
33  G4cout<<"XsecMultiplier = "<<m_xsecmultiplier<<G4endl;
34  G4cout<<"Gamma = "<<m_gamma/CLHEP::GeV<<" GeV"<<G4endl;
35  G4cout<<"Amplitude = "<<m_amplitude/CLHEP::millibarn<<" millibarn"<<G4endl;
36  G4cout<<"ReggeSuppression = "<<100*m_suppressionfactor<<" %"<<G4endl;
37  G4cout<<"HadronLifeTime = "<<m_hadronlifetime;
38  if (m_doDecays) G4cout<<" ns"<<G4endl;
39  else G4cout<<" s"<<G4endl;
40  G4cout<<"ReggeModel = "<< m_reggemodel <<G4endl;
41  G4cout<<"Mixing = "<< m_mixing*100 <<" %"<<G4endl;
42  G4cout<<"DoDecays = "<< m_doDecays << G4endl;
43 
44  if ((!m_doDecays && m_hadronlifetime>0.) ||
45  (m_doDecays && m_hadronlifetime<=0.) ){
46  G4cout << "WARNING: Inconsistent treatment of R-Hadron properties! Lifetime of " << m_hadronlifetime
47  << " and doDecays= " << m_doDecays << G4endl;
48  }
49 
50  return;
51 }
52 
53 
55 {
57  return &instance;
58 }
59 
60 
61 void PhysicsConfigurationHelper::ReadInPhysicsParameters(std::map<G4String,G4double>& parameters) const
62  {
63  parameters["Resonant"]=0.;
64  parameters["ResonanceEnergy"]=0.;
65  parameters["XsecMultiplier"]=1.;
66  parameters["Gamma"]=0.;
67  parameters["Amplitude"]=0.;
68  parameters["ReggeSuppression"]=0.;
69  parameters["HadronLifeTime"]=0.;
70  parameters["ReggeModel"]=0.;
71  parameters["Mixing"]=0.;
72  parameters["DoDecays"]=0;
73 
74  std::ifstream physics_stream ("PhysicsConfiguration.txt");
75  G4String line;
76  char** endptr=0;
77  while (getline(physics_stream,line)) {
78  std::vector<G4String> tokens;
79  //Getting a line
81  G4String key = tokens[0];
82  G4double val = strtod(tokens[1],endptr);
84  }
85  physics_stream.close();
86  }
87 
88 
90  std::vector<G4String>& tokens,
91  const G4String& delimiters) const
92 {
93  // Skip delimiters at beginning.
94  G4String::size_type lastPos = str.find_first_not_of(delimiters, 0);
95  if (lastPos==G4String::npos) return;
96 
97  // Find first "non-delimiter".
98  G4String::size_type pos = str.find_first_of(delimiters, lastPos);
99 
100  while (G4String::npos != pos || G4String::npos != lastPos)
101  {
102  //Skipping leading / trailing whitespaces
103  G4String temp = str.substr(lastPos, pos - lastPos);
104  while(temp.c_str()[0] == ' ') temp.erase(0,1);
105  while(temp[temp.size()-1] == ' ') temp.erase(temp.size()-1,1);
106 
107  // Found a token, add it to the vector.
108  tokens.push_back(temp);
109 
110  // Skip delimiters. Note the "not_of"
111  lastPos = str.find_first_not_of(delimiters, pos);
112  if (lastPos==G4String::npos) continue;
113 
114  // Find next "non-delimiter"
115  pos = str.find_first_of(delimiters, lastPos);
116  }
117 }
GeV
#define GeV
Definition: PhysicsAnalysis/TauID/TauAnalysisTools/Root/HelperFunctions.cxx:17
checkFileSG.line
line
Definition: checkFileSG.py:75
PhysicsConfigurationHelper::m_xsecmultiplier
double m_xsecmultiplier
Definition: PhysicsConfigurationHelper.h:47
python.SystemOfUnits.millibarn
int millibarn
Definition: SystemOfUnits.py:77
beamspotman.tokens
tokens
Definition: beamspotman.py:1284
PhysicsConfigurationHelper.h
instance
std::map< std::string, double > instance
Definition: Run_To_Get_Tags.h:8
PhysicsConfigurationHelper::ReadAndParse
void ReadAndParse(const G4String &str, std::vector< G4String > &tokens, const G4String &delimiters=" ") const
Definition: PhysicsConfigurationHelper.cxx:89
PhysicsConfigurationHelper::m_ek_0
double m_ek_0
Definition: PhysicsConfigurationHelper.h:44
PhysicsConfigurationHelper::m_reggemodel
bool m_reggemodel
Definition: PhysicsConfigurationHelper.h:43
PhysicsConfigurationHelper::m_mixing
double m_mixing
Definition: PhysicsConfigurationHelper.h:50
PhysicsConfigurationHelper::m_amplitude
double m_amplitude
Definition: PhysicsConfigurationHelper.h:46
PhysicsConfigurationHelper::m_gamma
double m_gamma
Definition: PhysicsConfigurationHelper.h:45
PhysicsConfigurationHelper::m_suppressionfactor
double m_suppressionfactor
Definition: PhysicsConfigurationHelper.h:48
PhysicsConfigurationHelper::m_doDecays
int m_doDecays
Definition: PhysicsConfigurationHelper.h:51
python.LumiBlobConversion.pos
pos
Definition: LumiBlobConversion.py:18
PhysicsConfigurationHelper::m_resonant
bool m_resonant
Definition: PhysicsConfigurationHelper.h:42
PhysicsConfigurationHelper::m_hadronlifetime
double m_hadronlifetime
Definition: PhysicsConfigurationHelper.h:49
Pythia8_RapidityOrderMPI.val
val
Definition: Pythia8_RapidityOrderMPI.py:14
PhysicsConfigurationHelper::PhysicsConfigurationHelper
PhysicsConfigurationHelper()
Definition: PhysicsConfigurationHelper.cxx:13
PhysicsConfigurationHelper::ReadInPhysicsParameters
void ReadInPhysicsParameters(std::map< G4String, G4double > &parameters) const
Definition: PhysicsConfigurationHelper.cxx:61
physics_parameters.parameters
parameters
Definition: physics_parameters.py:144
str
Definition: BTagTrackIpAccessor.cxx:11
checker_macros.h
Define macros for attributes used to control the static checker.
PhysicsConfigurationHelper::Instance
static const PhysicsConfigurationHelper * Instance()
Definition: PhysicsConfigurationHelper.cxx:54
PhysicsConfigurationHelper
Definition: PhysicsConfigurationHelper.h:13
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37