Commit eb96f45c authored by Enrico Bothmann's avatar Enrico Bothmann

Rewrite settings input using YAML

This commit closes #10.

- Replace custom configuration parsing and format with a YAML-based
  solution
- Improve implementation of settings handling to enable features such
  as:
  - Generally only specify defaults once in the code, not scattered
    throughout with possibly different values
  - Print comprehensive report of values used for each setting at the
    end of a run
  - Warn when a setting is specified that is not used during a run (this
    is foreseen and now possible, but not implemented yet)

NOTE: This is a squashed commit to keep the commit history of master
simple. The full history of the development branch will be retained as
10-rewrite-settings-input+commit-history in case it is needed, e.g. to
find a (small) changeset that introduced a bug using git-bisect.

A good example for new syntax is:
Examples/V_plus_Jets/LHC_WJets/Sherpa.yaml

The command line can process words using the YAML syntax, but also
supports the old legacy syntax, at least for scalar settings.

In the code, setting default settings and getting the resolved value
for a setting can be done e.g. as follows:

```
auto hds = Settings::GetMainSettings()["HARD_DECAYS"];
const auto apply_br
  = hds["Apply_Branching_Ratios"].SetDefault(true).Get<bool>();
```

Note also that Sherpa can now process several configuration files:
`Sherpa "RUNDATA: [1.yaml, 2.yaml, ...]"`, with settings in files to the
right taking precedence over settings in files to the left. This can be
useful for specifying base set-ups and then deriving specialisations.

A more detailed discussion of the new settings architecture is given
in
https://gitlab.com/sherpa-team/sherpa/wikis/The-new-Settings-implementation
(accessing this link might require developer access to the repository).

Lastly, note that physics results are guaranteed to stay the same after
this commit. If you find that to be not true, please contact me. When
soft physics is used, numerics sometimes causes the statistics not to be
the same after this commit. However, I've got some patches to mitigate
this to some degree. So in any case, contact me if you find differences
between results generated with this commit and the preceding one.
parent 8172f68a
......@@ -70,11 +70,11 @@ test-LO_Z:
script:
- mkdir test-LO_Z
- cd test-LO_Z
- ../build/install/bin/Sherpa -f ../Examples/CI/LO_Z/Run.dat
- ../build/install/bin/Sherpa -f ../Examples/CI/LO_Z/Sherpa.yaml
test-clang-strict-LO_Z:
<<: *test
script:
- mkdir test-clang-strict-LO_Z
- cd test-clang-strict-LO_Z
- ../build-clang-strict/install/bin/Sherpa -f ../Examples/CI/LO_Z/Run.dat
- ../build-clang-strict/install/bin/Sherpa -f ../Examples/CI/LO_Z/Sherpa.yaml
......@@ -4,6 +4,8 @@
#include "ATOOLS/Org/Message.H"
#include "ATOOLS/Org/Run_Parameter.H"
#include <algorithm>
using namespace AHADIC;
using namespace ATOOLS;
using namespace std;
......
......@@ -5,7 +5,7 @@
#include "AHADIC++/Tools/Cluster.H"
#include "ATOOLS/Org/Message.H"
#include "ATOOLS/Org/Run_Parameter.H"
#include "ATOOLS/Org/Data_Reader.H"
#include "ATOOLS/Org/Settings.H"
#include "ATOOLS/Org/Shell_Tools.H"
using namespace AHADIC;
......@@ -13,7 +13,7 @@ using namespace ATOOLS;
using namespace std;
Ahadic::Ahadic(string path, string file,string shower) :
Ahadic::Ahadic(string shower) :
m_softclusters(Soft_Cluster_Handler(&m_hadron_list)),
m_beamparticles(Beam_Particles_Shifter(&m_singlet_list, &m_softclusters)),
m_sformer(Singlet_Former(&m_singlet_list)),
......@@ -22,7 +22,7 @@ Ahadic::Ahadic(string path, string file,string shower) :
m_clusterdecayer(Cluster_Decayer(&m_cluster_list, &m_softclusters))
{
hadpars = new Hadronisation_Parameters();
hadpars->Init(path,file,shower);
hadpars->Init(shower);
m_beamparticles.Init();
m_softclusters.Init();
......
......@@ -27,9 +27,9 @@ namespace AHADIC {
Singlet_Checker m_singletchecker;
Gluon_Decayer m_gluondecayer;
Cluster_Decayer m_clusterdecayer;
ATOOLS::Vec4D m_totmom;
bool ExtractSinglets(ATOOLS::Blob * blob);
bool ShiftBeamParticles();
bool CheckSinglets();
......@@ -43,9 +43,7 @@ namespace AHADIC {
bool SanityCheck(ATOOLS::Blob * blob,double norm2);
void CleanUp(ATOOLS::Blob * blob);
public:
Ahadic(std::string path=std::string("./"),
std::string file=std::string("Cluster.dat"),
std::string shower="Dire");
Ahadic(std::string shower="Dire");
~Ahadic();
ATOOLS::Return_Value::code Hadronize(ATOOLS::Blob_List *);
......
This diff is collapsed.
#ifndef AHADIC_Tools_Hadron_Init_H
#define AHADIC_Tools_Hadron_Init_H
#include "ATOOLS/Org/Data_Reader.H"
#include "ATOOLS/Phys/KF_Table.H"
#include <unordered_set>
namespace AHADIC {
class Hadron_Init {
class Hadron_Init {
public:
Hadron_Init() {}
void Init();
void OverWriteProperties(ATOOLS::Data_Reader& overwrite);
private:
void InitHadron(const kf_code&,
const bool checkinitialised,
const double &mass,
const double &width,
const int icharge,
const int spin,
const bool majorana,
const bool on,
const int stable,
const std::string& idname,
const std::string& texname);
void InitHadron(const kf_code&,
const double &mass,
const double &width,
const int icharge,
const int strong,
const int spin,
const bool majorana,
const bool on,
const int stable,
const bool massive,
const std::string& idname,
const std::string& antiname,
const std::string& texname,
const std::string& antitexname);
void OverrideProperties();
std::unordered_set<kf_code> m_addedhadrons;
};
}
......
This diff is collapsed.
......@@ -5,7 +5,6 @@
#include "AHADIC++/Tools/Double_Transitions.H"
#include "AHADIC++/Tools/Single_Transitions.H"
#include "ATOOLS/Math/Vector.H"
#include "ATOOLS/Org/Data_Reader.H"
#include <map>
#include <string>
......@@ -36,19 +35,19 @@ namespace AHADIC {
SDiter m_piter;
bool m_ana;
void ReadParameters(std::string,std::string);
void ReadGeneralSwitches(ATOOLS::Data_Reader & dataread);
void ReadMassParameters(ATOOLS::Data_Reader & dataread);
void ReadPoppingParameters(ATOOLS::Data_Reader & dataread);
void ReadMesonWeights(ATOOLS::Data_Reader & dataread);
void ReadGluonSplittingParameters(ATOOLS::Data_Reader & dataread);
void ReadClusterDecayParameters(ATOOLS::Data_Reader & dataread);
void ReadClusterToMesonPSParameters(ATOOLS::Data_Reader & dataread);
void ReadParameters();
void ReadGeneralSwitches();
void ReadMassParameters();
void ReadPoppingParameters();
void ReadMesonWeights();
void ReadGluonSplittingParameters();
void ReadClusterDecayParameters();
void ReadClusterToMesonPSParameters();
public:
Hadronisation_Parameters();
~Hadronisation_Parameters();
void Init(std::string,std::string,std::string);
void Init(std::string);
double Get(std::string keyword);
const bool & AnaOn() const { return m_ana; }
......
#include "AHADIC++/Tools/Multiplet_Constructor.H"
#include "AHADIC++/Tools/Hadronisation_Parameters.H"
#include "ATOOLS/Org/Message.H"
#include "ATOOLS/Org/MyStrStream.H"
#include "ATOOLS/Org/Settings.H"
#include "ATOOLS/Phys/KF_Table.H"
#include <stdio.h>
using namespace AHADIC;
......
......@@ -17,24 +17,24 @@ namespace AHADIC {
const ATOOLS::Vec4D & mom=ATOOLS::Vec4D(0.,0.,0.,0.),
bool leading=false,bool beam=false);
~Proto_Particle();
ATOOLS::Vec4D Momentum() const { return m_momentum; }
ATOOLS::Flavour Flavour() const { return m_flav; }
bool IsLeading() const { return m_isleading; }
bool IsBeam() const { return m_isbeam; }
void SetMomentum(const ATOOLS::Vec4D & mom) { m_momentum = mom; }
void SetFlavour(const ATOOLS::Flavour & flav) { m_flav = flav; }
void SetLeading(const bool & lead) { m_isleading = lead; }
void SetBeam(const bool & beam) { m_isbeam = beam; }
static std::set<Proto_Particle *> s_protos;
static void Reset();
ATOOLS::Particle * operator()();
};
std::ostream & operator<<(std::ostream &,const Proto_Particle &);
}
#endif
......@@ -44,7 +44,7 @@ CFColor::CFColor(int N, Single_Amplitude* first, ATOOLS::Flavour * fl,
bool gc(ioh.SetFileNameRO(name)==0);
if (gc&&force) {
msg_Error()<<"Color matrix for process "<<pID<<" not found!"<<endl
<<" Rerun with option 'AMEGIC_ME_LIBCHECK=1'."<<endl;
<<" Rerun with option 'ME_LIBCHECK: true'."<<endl;
THROW(critical_error,"Failed to load color matrix.");
}
if (!gc) {
......
......@@ -84,12 +84,6 @@ void Zfunc_Generator::MarkCut(Point* p,int notcut,bool fromfermion,bool cutvecto
// spin 2 particles must be cutted
if (p->fl.IsTensor() && p->number>99) p->m = 1;
// "new gauge test" cut all massless propagators
if (p->fl.IsVector() && p->number>99 && rpa->gen.CutScheme()==1) {
if(p->fl.Mass()==0.0) {
p->m=1;
}
}
MarkCut(p->right,notcut,p->fl.IsFermion(),p->Lorentz->CutVectors());
MarkCut(p->left,notcut,p->fl.IsFermion(),p->Lorentz->CutVectors());
MarkCut(p->middle,notcut,p->fl.IsFermion(),p->Lorentz->CutVectors());
......
......@@ -404,9 +404,9 @@ int Basic_Sfuncs::BuildPolarisations(int momindex, Flavour fl)
momcount++;
Momlist.push_back(Mom);
}
if(Mass==0.0){
if (GetPolNumber(momindex,mt::p_si,0,1)==-1 && rpa->gen.CutScheme()!=1 ) {
if (GetPolNumber(momindex,mt::p_si,0,1)==-1) {
Mom.arg[0] = momcount;
Mom.type=mt::p_si;
momcount++;
......
......@@ -6,6 +6,7 @@
#include "ATOOLS/Org/Message.H"
#include "ATOOLS/Org/Shell_Tools.H"
#include "ATOOLS/Org/MyStrStream.H"
#include "ATOOLS/Org/Scoped_Settings.H"
#include <typeinfo>
......@@ -32,18 +33,19 @@ DipoleSplitting_Base::DipoleSplitting_Base(sbt::subtype st,
p_cpl(NULL)
{
p_nlomc=NULL;
m_subtype=ToType<int>(rpa->gen.Variable("NLO_SUBTRACTION_SCHEME"));
Settings& s = Settings::GetMainSettings();
m_subtype = s["NLO_SUBTRACTION_SCHEME"].Get<int>();
m_name=ToString(m_dtype)+"["+ToString(m_ftype)
+"("+ToString(m_i)+","+ToString(m_j)+")("+ToString(m_k)+")]"
+"("+ToString(m_stype)+")";
DEBUG_FUNC(m_name);
m_amin=ToType<double>(rpa->gen.Variable("DIPOLE_AMIN"));
m_kappa=ToType<double>(rpa->gen.Variable("DIPOLE_KAPPA"));
m_amin=s["DIPOLES"]["AMIN"].Get<double>();
m_kappa=s["DIPOLES"]["KAPPA"].Get<double>();
if (m_stype==sbt::qed) m_collVFF=false;
m_collVFF=ToType<int>(rpa->gen.Variable("DIPOLE_COLLINEAR_VFF_SPLITTINGS"));
m_Vsubmode=ToType<int>(rpa->gen.Variable("DIPOLE_V_SUBTRACTION_MODE"));
m_collVFF=s["DIPOLES"]["COLLINEAR_VFF_SPLITTINGS"].Get<int>();
m_Vsubmode=s["DIPOLES"]["V_SUBTRACTION_MODE"].Get<int>();
if (m_Vsubmode<0 || m_Vsubmode>2) THROW(fatal_error,"Unknown mode.");
std::string vsm("");
if (m_Vsubmode==0) vsm="scalar";
......@@ -57,9 +59,9 @@ DipoleSplitting_Base::DipoleSplitting_Base(sbt::subtype st,
}