Commit a6fa5ff9 authored by Frank Siegert's avatar Frank Siegert

Improvements for new HADRONS infrastructure:

- tidy up decay channel file read-in code
- actually make write-out work
parent 99e982da
......@@ -26,7 +26,17 @@ namespace ATOOLS {
}
return result;
}
std::string SubString(const std::string& original,
const std::string& begin, const std::string& end)
{
size_t ibegin = original.find(begin);
if (ibegin == std::string::npos) return "";
ibegin += begin.length();
size_t iend = original.find(end);
return original.substr(ibegin, iend-ibegin);
}
std::string ReplaceUnits(std::string v)
{
std::string f("");
......
......@@ -98,6 +98,10 @@ namespace ATOOLS {
std::string StringReplace(const std::string &original,
const std::string &from, const std::string &to);
std::string SubString(const std::string& original,
const std::string& begin, const std::string& end);
std::string ReplaceUnits(std::string v);
}// end of namespace ATOOLS;
......
This diff is collapsed.
......@@ -48,65 +48,47 @@ namespace HADRONS {
/**
* Gets relevant section between begin and end from a decay channel
* file and rescans it.
* file.
*
* @param content Content of decay channel file
* @param begin Begin of needed section
* @param end End of needed section
* @param reader The DataReader dealing with the decay channel file
*/
bool Process(std::string content, std::string begin,
std::string end,
ATOOLS::Data_Reader & reader);
std::vector<std::vector<std::string> > Process(const std::string& content,
const std::string& begin,
const std::string& end);
/**
* Process <Options> section in decay channel file.
*
* @param helpsvv Contents of <Options> section
* @param content of DC file
*/
void ProcessOptions(std::vector<std::vector<std::string> > helpsvv);
void ProcessOptions(const std::string& content);
/**
* Process <Phasespace> section in decay channel file.
*
* @param ps_svv Contents of <Phasespace> section
* @param reader The DataReader dealing with the decay channel file
* @param content of DC file
* @param model Global hadron decay parameters
*/
void ProcessPhasespace(std::vector<std::vector<std::string> > ps_svv,
ATOOLS::Data_Reader & reader,
GeneralModel const & model );
void ProcessPhasespace(const std::string& content,
const GeneralModel& model );
/**
* Process <ME> section in decay channel file.
*
* @param me_svv Contents of <ME> section
* @param reader The DataReader dealing with the decay channel file, which
* is needed for reading the options for each extracted
* matrix element.
* @param content of DC file
* @param model Global hadron decay parameters
*/
void ProcessME( std::vector<std::vector<std::string> > me_svv,
ATOOLS::Data_Reader & reader,
GeneralModel & model_for_ps );
void ProcessME(const std::string& content,
GeneralModel& model_for_ps );
/**
* Process <Result> section in decay channel file.
*
* @param result_svv Contents of <Result> section
* @param content of DC file
*/
void ProcessResult(std::vector<std::vector<std::string> > result_svv);
/**
* Helper function to create a GeneralModel from parameter = value pairs
*
* @param helpsvv vector of lines of parameter = value pairs
* @param md additional model to be filled at the same time
*
* @return New model filled from helpsvv
*/
GeneralModel Parameters2Model(std::vector<std::vector<std::string> >helpsvv,
GeneralModel& md);
void ProcessResult(const std::string& content);
/**
* Writes out to a decay channel file.
......
......@@ -2,6 +2,7 @@
#include "ATOOLS/Org/Message.H"
#include "ATOOLS/Org/MyStrStream.H"
#include "ATOOLS/Org/Run_Parameter.H"
#include "ATOOLS/Org/Data_Reader.H"
#include "ATOOLS/Math/Algebra_Interpreter.H"
#include <vector>
......@@ -12,6 +13,7 @@
using namespace HADRONS;
using namespace ATOOLS;
using namespace std;
PHASIC::Decay_Table * Tools::partonic_b =
new PHASIC::Decay_Table(Flavour(kf_b),NULL);
......@@ -188,3 +190,45 @@ void Tools::ExtractBRInfo( std::string entry, double & br,
if (dbr==-1.0) dbr = br;
}
void GeneralModel::AddParameters(const std::string& params)
{
Data_Reader reader(" ",";","!");
reader.SetAddCommandLine(false);
reader.AddComment("#");
reader.AddComment("//");
reader.SetMatrixType(mtc::transposed);
reader.AddLineSeparator("\n");
if (params!="") reader.RescanFileContent(params,true);
vector<vector<string> > helpsvv;
reader.MatrixFromString(helpsvv,"");
Algebra_Interpreter ip;
for (size_t i=0;i<helpsvv.size();i++) {
if ( helpsvv[i][1] == string("=")) {
if( helpsvv[i].size() == 3 ) { // <name> = <real value>
double real = ToType<double> (ip.Interprete(helpsvv[i][2]) );
(*this)[helpsvv[i][0]] = real;
}
if( helpsvv[i].size() == 4 ) { // <name> = <complex value>
double abs = ToType<double>(ip.Interprete(helpsvv[i][2]) );
double phase = ToType<double>( ip.Interprete(helpsvv[i][3]) );
(*this)[helpsvv[i][0]+string("_abs")] = abs;
(*this)[helpsvv[i][0]+string("_phase")] = phase;
}
}
if ( helpsvv[i][2] == string("=")) {
if( helpsvv[i].size() == 4 ) { // <name> <index> = <real value>
double real = ToType<double>( ip.Interprete(helpsvv[i][3]) );
(*this)[helpsvv[i][0]+string("_")+helpsvv[i][1]] = real;
}
if( helpsvv[i].size() == 5 ) { // <name> <index> = <complex value>
double abs = ToType<double> ( ip.Interprete(helpsvv[i][3]) );
double phase = ToType<double> ( ip.Interprete(helpsvv[i][4]) );
(*this)[helpsvv[i][0]+"_"+helpsvv[i][1]+"_abs"] = abs;
(*this)[helpsvv[i][0]+"_"+helpsvv[i][1]+"_phase"] = phase;
}
}
}
}
......@@ -49,6 +49,14 @@ namespace HADRONS
std::map<std::string,double>::const_iterator fit(find(tag));
return fit!=end()?fit->second:def;
}
/**
* Helper function to create a GeneralModel from parameter = value pairs
*
* @param parameters string containing parameter = value lines
*
*/
void AddParameters(const std::string& parameters);
};
/**
......
......@@ -41,6 +41,7 @@ namespace HADRONS {
void EndOptimize() { p_vegas->EndOptimize(); }
void WriteOut(std::string pId) { p_vegas->WriteOut(pId); }
void ReadIn(std::string pId) { p_vegas->ReadIn(pId); }
void MPISync() {};
}; // end of class
class IsotropicSpectator : public PHASIC::Single_Channel {
......@@ -55,6 +56,7 @@ namespace HADRONS {
double * _ran=NULL);
void GenerateWeight(ATOOLS::Vec4D * p,PHASIC::Cut_Data * =NULL);
std::string ChID() { return std::string("IsotropicSpectator");}
void MPISync() {};
}; // end of class
/*!
......
......@@ -26,6 +26,7 @@ namespace HADRONS {
int ChNumber() { return m_chnumber; }
void SetChNumber(int _chnumber) { m_chnumber = _chnumber; }
std::string ChID() { return name;}
void MPISync() {};
}; // end of class
/*!
......
......@@ -15,6 +15,7 @@ namespace HADRONS {
int ChNumber() { return m_chnumber; }
void SetChNumber(int _chnumber) { m_chnumber = _chnumber; }
std::string ChID() { return std::string("Iso2");}
void MPISync() {};
}; // end of class
class Iso1Channel : public PHASIC::Single_Channel {
......@@ -27,6 +28,7 @@ namespace HADRONS {
int ChNumber() { return m_chnumber; }
void SetChNumber(int _chnumber) { m_chnumber = _chnumber; }
std::string ChID() { return std::string("Iso1");}
void MPISync() {};
}; // end of class
......
......@@ -45,6 +45,8 @@ Hadron_Decay_Handler::Hadron_Decay_Handler(string path, string fragfile) :
string tmp=reader.Get<string>("DECAYPATH",rpa->gen.Variable("SHERPA_SHARE_PATH")+"/");
if (tmp[tmp.length()-1]!='/') tmp+="/";
string decaydatazip=reader.Get<string>("DECAYDATA",tmp+"Decaydata.zip");
msg_Info()<<METHOD<<": Opening Decaydata from "<<decaydatazip<<endl;
// @todo this is obsolete, decaydata == decaydatazip after this?!?
string decaydata=decaydatazip.replace(decaydatazip.length()-4,4,"/");
string decayfile=reader.Get<string>("DECAYFILE",string("HadronDecays.dat"));
string decayconstfile=reader.Get<string>("DECAYCONSTFILE",
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment