Commit c9af1862 authored by Frank Siegert's avatar Frank Siegert

Converting Amegic to sqlite, i.e. files like .map, .col, ..., are now stored...

Converting Amegic to sqlite, i.e. files like .map, .col, ..., are now stored in Process/Amegic.db instead of as files in the system. The library source code files themselves are still stored as normal files and compiled as before with makelibs.
parent 68c0a67a
......@@ -291,10 +291,11 @@ void Amplitude_Handler::StoreAmplitudeConfiguration(std::string path)
IO_Handler ioh;
ioh.SetFileName(name);
ioh.Output("",int(graphs.size()));
std::ofstream cplfile((path+"/Couplings.dat").c_str());
My_Out_File cplfile(path+"/Couplings.dat");
cplfile.Open();
for (size_t i=0;i<graphs.size();i++) {
cplfile<<i<<" "<<graphs[i]->GetOrderQCD()
<<" "<<graphs[i]->GetOrderQED()<<"\n";
*cplfile<<i<<" "<<graphs[i]->GetOrderQCD()
<<" "<<graphs[i]->GetOrderQED()<<"\n";
int size=graphs[i]->Size();
int *nums= new int[size];
for (int j=0;j<size;j++) nums[j]=(*graphs[i])[j]->GetNumber();
......@@ -305,8 +306,8 @@ void Amplitude_Handler::StoreAmplitudeConfiguration(std::string path)
void Amplitude_Handler::RestoreAmplitudes(std::string path)
{
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+path+"/Cluster.dat";
std::ifstream cplfile((rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+path+"/Couplings.dat").c_str());
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+path+"/Cluster.dat";
My_In_File cplfile(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+path+"/Couplings.dat");
IO_Handler ioh;
ioh.SetFileNameRO(name);
size_t cg = ioh.Input<int>("");
......@@ -319,8 +320,8 @@ void Amplitude_Handler::RestoreAmplitudes(std::string path)
Amplitude_Base* ab;
for (size_t i=0;i<graphs.size();i++) {
int *nums, ci, oqcd, oqed;
if (cplfile.bad()) THROW(fatal_error,"Missing coupling data");
cplfile>>ci>>oqcd>>oqed;
if (!cplfile.Open()) THROW(fatal_error,"Missing coupling data");
*cplfile>>ci>>oqcd>>oqed;
if (ci!=(int)i) THROW(fatal_error,"Invalid coupling data");
nums=ioh.ArrayInput<int>("");
int size=ioh.Nx();
......@@ -341,11 +342,11 @@ void Amplitude_Handler::RestoreAmplitudes(std::string path)
void Amplitude_Handler::CompleteLibAmplitudes(int N,std::string pID,std::string lib,
char emit,char spect,Flavour* fl)
{
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+pID+".map";
ifstream from;
from.open(name.c_str());
shand->Get_Generator()->ReadCouplings(from);
from.close();
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+pID+".map";
My_In_File from(name);
from.Open();
shand->Get_Generator()->ReadCouplings(*from);
from.Close();
Single_Amplitude* n = firstgraph;
ngraph = 0;
......
......@@ -34,7 +34,7 @@ CFColor::CFColor(int N,Single_Amplitude* first,ATOOLS::Flavour * fl,char emit,ch
CSC.Init();
int ncol((int)CSC.Nc);
if (ncol!=3) pID+="_NC"+ToString(ncol);
std::string name=ATOOLS::rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+pID+".col";
std::string name=ATOOLS::rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+pID+".col";
IO_Handler ioh;
bool gc(ioh.SetFileNameRO(name)==0);
if (gc&&force) {
......@@ -624,7 +624,7 @@ string CFColor::MapFChain(vector<string> fstring_list)
void CFColor::Output(string & dirname) {
std::string name;
name=ATOOLS::rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/")+dirname+".col";
name=ATOOLS::rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+dirname+".col";
IO_Handler ioh;
ioh.SetFileName(name);
ioh.Output("",mcount); // no of ampls
......
......@@ -76,10 +76,10 @@ Basic_Sfuncs::Basic_Sfuncs(int _nmom,int _nvec, Flavour* flav,int* _b,string nam
IO_Handler ioh;
ioh.SetFileNameRO(name);
ioh.GetFstream()>>momcount;
ioh.GetIFstream()>>momcount;
for (int i=0;i<momcount;i++) {
Momfunc mf;
ioh.GetFstream()>>mf;
ioh.GetIFstream()>>mf;
Momlist.push_back(mf);
}
Initialize();
......@@ -92,11 +92,11 @@ Basic_Sfuncs::Basic_Sfuncs(int _nmom,int _nvec, Flavour* flav,int* _b,string nam
void Basic_Sfuncs::UpdateMasses(string name)
{
int cnt=0;
ifstream is;
is.open(name.c_str());
My_In_File is(name);
is.Open();
string str;
for (;is;) {
getline(is,str);
for (;*is;) {
getline(*is,str);
if (str.find(string("fl"))==0) {
int a=str.find("[");
int b=str.find("]");
......@@ -116,7 +116,7 @@ void Basic_Sfuncs::UpdateMasses(string name)
}
}
if (cnt!=momcount) THROW(critical_error,"Missing flavour in *.map");
is.close();
is.Close();
}
void Basic_Sfuncs::Output(string name)
......@@ -125,7 +125,7 @@ void Basic_Sfuncs::Output(string name)
IO_Handler ioh;
ioh.SetFileName(name);
ioh.Output("",momcount);
for (int i=0;i<momcount;i++) ioh.GetFstream()<<Momlist[i]<<endl;
for (int i=0;i<momcount;i++) ioh.GetOFstream()<<Momlist[i]<<endl;
ioh.MatrixOutput<int>("",calc_st,momcount,momcount);
}
......
......@@ -5,7 +5,6 @@
#include "ATOOLS/Org/Exception.H"
#include "ATOOLS/Org/Run_Parameter.H"
#include "ATOOLS/Org/MyStrStream.H"
#include <fstream.h>
#include <iostream.h>
#include "ATOOLS/Math/MathTools.H"
......@@ -241,10 +240,10 @@ void MomentumList::Print()
bool MomentumList::Get(const char* file)
{
std::string line;
ifstream dat(file);
if (dat==NULL)
My_In_File dat(file);
if (!dat.Open())
THROW(fatal_error,"Error in opening a data file");
while (getline(dat,line)) {
while (getline(*dat,line)) {
if (line.find("%")!=std::string::npos) line=line.substr(0,line.find("%"));
if (line.find("p_[")!=std::string::npos) {
size_t stpos(line.find("p_[")+2);
......@@ -297,7 +296,7 @@ bool MomentumList::Get(const char* file)
etha[1]= ToType<double>(line.substr(c1pos+1,endpos-c1pos-1));
}
}
dat.close();
*dat.close();
m_size=size();
if (size()>0) return 1;
return 0;
......
......@@ -67,7 +67,7 @@ int Single_LOProcess_External::InitAmplitude(Model_Base * model,Topology* top,
for (size_t i=m_nin;i<m_nin+m_nout;i++) if (m_flavs[i].Strong()) m_partonlist.push_back(i);
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......@@ -131,7 +131,7 @@ int Single_LOProcess_External::InitAmplitude(Model_Base * model,Topology* top,
model->GetCouplings(m_cpls);
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......
......@@ -76,7 +76,7 @@ int Single_LOProcess_MHV::InitAmplitude(Model_Base * model,Topology* top,
for (size_t i=m_nin;i<m_nin+m_nout;i++) if (m_flavs[i].Strong()) m_partonlist.push_back(i);
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......@@ -177,7 +177,7 @@ int Single_LOProcess_MHV::InitAmplitude(Model_Base * model,Topology* top,
model->GetCouplings(m_cpls);
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......
......@@ -91,6 +91,7 @@ Amegic::Amegic():
Amegic::~Amegic()
{
My_In_File::CloseDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
if (p_cluster) delete p_cluster;
}
......@@ -116,6 +117,11 @@ bool Amegic::Initialize(const std::string &path,const std::string &file,
int gauge(read.GetValue<int>("AMEGIC_DEFAULT_GAUGE",1));
AMEGIC::Process_Base::SetGauge(gauge);
if (gauge!=10) msg_Info()<<METHOD<<"(): Set gauge "<<gauge<<"."<<std::endl;
MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process",true);
My_In_File::OpenDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/");
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","begin");
return true;
}
......@@ -198,6 +204,8 @@ PHASIC::Process_Base *Amegic::InitializeProcess(const PHASIC::Process_Info &pi,
int Amegic::PerformTests()
{
My_In_File::ExecDB(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/","commit");
int tests(Process_Group::PerformTests());
if (NewLibs()) THROW(normal_exit,"New libraries created. Please compile.");
for (size_t i(0);i<m_rsprocs.size();++i)
......
......@@ -117,17 +117,17 @@ int AMEGIC::Process_Group::InitAmplitude(Model_Base * model,Topology * top)
m_oew=m_oqcd=0;
m_mfname = "P"+ToString(m_nin)+"_"+ToString(m_nout)+"/"+m_name+".map";
string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_mfname;
string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_mfname;
string buffer;
ifstream file;
file.open(name.c_str());
for (;file;) {
getline(file,buffer);
My_In_File file(name);
file.Open();
for (;*file;) {
getline(*file,buffer);
if (buffer.length()>0) {
m_whitelist.insert(buffer);
}
}
file.close();
file.Close();
if (m_whitelist.size()>0) m_mfname="";
return true;
......@@ -136,13 +136,18 @@ int AMEGIC::Process_Group::InitAmplitude(Model_Base * model,Topology * top)
void AMEGIC::Process_Group::WriteMappingFile()
{
if (m_mfname==string("")) return;
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_mfname;
fstream file;
file.open(name.c_str(),ios::out|ios::app);
for (size_t i=0;i<m_procs.size();i++) file<<m_procs[i]->Name()<<endl;
file.close();
std::string name = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_mfname;
std::string str, tmp;
My_In_File in(name);
if (in.Open())
for (getline(*in,tmp);in->good(); getline(*in,tmp)) str+=tmp+"\n";
in.Close();
My_Out_File out(name);
out.Open();
*out<<str;
for (size_t i=0;i<m_procs.size();i++) *out<<m_procs[i]->Name()<<"\n";
out.Close();
}
bool AMEGIC::Process_Group::SetUpIntegrator()
......
......@@ -57,25 +57,25 @@ void AMEGIC::Single_Process::PolarizationNorm() {
void AMEGIC::Single_Process::WriteAlternativeName(string aname)
{
if (aname==m_name) return;
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".alt";
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".alt";
if (FileExists(altname)) return;
std::ofstream to;
to.open(altname.c_str(),ios::out);
to<<aname<<" "<<m_sfactor<<endl;
My_Out_File to(altname);
to.Open();
*to<<aname<<" "<<m_sfactor<<endl;
for (map<string,ATOOLS::Flavour>::const_iterator fit=p_ampl->GetFlavourmap().begin();fit!=p_ampl->GetFlavourmap().end();fit++)
to<<fit->first<<" "<<(long int)fit->second<<endl;
to.close();
*to<<fit->first<<" "<<(long int)fit->second<<endl;
to.Close();
}
bool AMEGIC::Single_Process::CheckAlternatives(vector<Process_Base *>& links,string procname)
{
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+procname+".alt";
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+procname+".alt";
if (FileExists(altname)) {
double factor;
string name,dummy;
ifstream from;
from.open(altname.c_str(),ios::in);
from>>name>>factor;
My_In_File from(altname);
from.Open();
*from>>name>>factor;
m_sfactor *= factor;
for (size_t j=0;j<links.size();j++) {
if (links[j]->Name()==name) {
......@@ -86,10 +86,10 @@ bool AMEGIC::Single_Process::CheckAlternatives(vector<Process_Base *>& links,str
m_ntchanmin=p_partner->NTchanMin();
msg_Tracking()<<"Found Alternative process: "<<m_name<<" "<<name<<endl;
while (from) {
while (*from) {
string f1;
long int f2;
getline(from,dummy);
getline(*from,dummy);
if (dummy!="") {
MyStrStream str;
str<<dummy;
......@@ -97,12 +97,12 @@ bool AMEGIC::Single_Process::CheckAlternatives(vector<Process_Base *>& links,str
AddtoFlavmap(f1,Flavour(abs(f2),f2<0));
}
}
from.close();
from.Close();
InitFlavmap(p_partner);
return true;
}
}
from.close();
from.Close();
if (CheckAlternatives(links,name)) return true;
}
m_sfactor = 1.;
......@@ -124,7 +124,7 @@ int AMEGIC::Single_Process::InitAmplitude(Model_Base * model,Topology* top,
PolarizationNorm();
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......@@ -148,8 +148,8 @@ int AMEGIC::Single_Process::InitAmplitude(Model_Base * model,Topology* top,
}
if (directload) directload = FoundMappingFile(m_libname,m_pslibname);
if (directload) {
string hstr=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_libname;
string hstr2=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
string hstr=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_libname;
string hstr2=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
p_BS = new Basic_Sfuncs(m_nin+m_nout,m_nin+m_nout,&m_flavs.front(),p_b,hstr,hstr2);
}
else p_BS = new Basic_Sfuncs(m_nin+m_nout,m_nin+m_nout,&m_flavs.front(),p_b);
......@@ -173,15 +173,15 @@ int AMEGIC::Single_Process::InitAmplitude(Model_Base * model,Topology* top,
msg_Tracking()<<"AMEGIC::Single_Process::InitAmplitude : Found compatible process for "<<Name()<<" : "<<links[j]->Name()<<endl;
if (!FoundMappingFile(m_libname,m_pslibname)) {
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+Name();
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+Name();
if (FileExists(mlname+string(".map"))) {
if (m_sfactor==1.) Copy(mlname+".map",mnname+".map");
if (m_sfactor==1.) My_In_File::CopyInDB(mlname+".map",mnname+".map");
else {
UpdateMappingFile(mlname,cplmap);
CreateMappingFile((Single_Process*)links[j]);
}
Copy(mlname+".col",mnname+".col");
My_In_File::CopyInDB(mlname+".col",mnname+".col");
}
}
......@@ -401,7 +401,7 @@ int AMEGIC::Single_Process::Tests()
gauge_test = string_test = 0;
}
else {
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/")+m_ptypename+string("/")+testname+string("/V.H");
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/")+testname+string("/V.H");
if (FileExists(searchfilename)) {
msg_Error()<<"ERROR in AMEGIC::Single_Process::Tests()"<<std::endl
<<" No compiled & linked library found for process "<<testname<<std::endl
......@@ -548,7 +548,7 @@ int AMEGIC::Single_Process::CheckLibraries() {
shand1 = new String_Handler(p_shand->Get_Generator());
m_libnumb = 0;
string proc = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/")+m_ptypename+string("/V");
string proc = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/V");
string testname;
double M2s, helvalue;
......@@ -617,7 +617,7 @@ void AMEGIC::Single_Process::WriteLibrary()
{
if (m_gen_str<2) return;
string testname;
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/");
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/");
for (;;) {
testname = CreateLibName()+string("_")+ToString(m_libnumb);
if (!(FileExists(newpath+m_ptypename+string("/")+testname+string("/V.H")))) break;
......@@ -650,7 +650,7 @@ std::string AMEGIC::Single_Process::CreateLibName()
void AMEGIC::Single_Process::CreateMappingFile(Single_Process* partner) {
if (m_gen_str<2) return;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname)) {
string MEname,PSname;
FoundMappingFile(MEname,PSname);
......@@ -662,29 +662,29 @@ void AMEGIC::Single_Process::CreateMappingFile(Single_Process* partner) {
return;
}
std::ofstream to;
to.open(outname.c_str(),ios::out);
to<<"ME: "<<m_libname<<endl
My_Out_File to(outname);
to.Open();
*to<<"ME: "<<m_libname<<endl
<<"PS: "<<m_pslibname<<endl;
p_shand->Get_Generator()->WriteCouplings(to);
partner->WriteMomFlavs(to);
to.close();
p_shand->Get_Generator()->WriteCouplings(*to);
partner->WriteMomFlavs(*to);
to.Close();
}
bool AMEGIC::Single_Process::FoundMappingFile(std::string & MEname, std::string & PSname)
{
std::string buf;
int pos;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname)) {
ifstream from;
from.open(outname.c_str());
getline(from,buf);
My_In_File from(outname);
from.Open();
getline(*from,buf);
pos = buf.find(string("ME:"));
if (pos==-1) MEname = PSname = buf;
else {
MEname = buf.substr(pos+4);
getline(from,buf);
getline(*from,buf);
pos = buf.find(string("PS:"));
if (pos==-1) PSname = MEname;
else PSname = buf.substr(pos+4);
......@@ -700,21 +700,21 @@ void AMEGIC::Single_Process::UpdateMappingFile(std::string name, map<string,Comp
std::string buf;
int pos;
name+=".map";
ifstream from;
from.open(name.c_str());
getline(from,buf);
My_In_File from(name);
from.Open();
getline(*from,buf);
pos = buf.find(string("ME:"));
if (pos==-1) m_libname = m_pslibname = buf;
else {
m_libname = buf.substr(pos+4);
getline(from,buf);
getline(*from,buf);
pos = buf.find(string("PS:"));
if (pos==-1) m_pslibname = m_libname;
else m_pslibname = buf.substr(pos+4);
if (m_pslibname==string("")) m_pslibname = m_libname;
}
p_shand->Get_Generator()->ReadCouplings(from);
from.close();
p_shand->Get_Generator()->ReadCouplings(*from);
from.Close();
p_shand->Get_Generator()->UpdateCouplings(cmap);
}
......
......@@ -58,25 +58,25 @@ void AMEGIC::Single_Process_Combined::PolarizationNorm() {
void AMEGIC::Single_Process_Combined::WriteAlternativeName(string aname)
{
if (aname==m_name) return;
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".alt";
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".alt";
if (FileExists(altname)) return;
std::ofstream to;
to.open(altname.c_str(),ios::out);
to<<aname<<" "<<m_sfactor<<endl;
My_Out_File to(altname);
to.Open();
*to<<aname<<" "<<m_sfactor<<endl;
for (map<string,ATOOLS::Flavour>::const_iterator fit=p_ampl->GetFlavourmap().begin();fit!=p_ampl->GetFlavourmap().end();fit++)
to<<fit->first<<" "<<(long int)fit->second<<endl;
to.close();
*to<<fit->first<<" "<<(long int)fit->second<<endl;
to.Close();
}
bool AMEGIC::Single_Process_Combined::CheckAlternatives(vector<Process_Base *>& links,string procname)
{
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+procname+".alt";
std::string altname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+procname+".alt";
if (FileExists(altname)) {
double factor;
string name,dummy;
ifstream from;
from.open(altname.c_str(),ios::in);
from>>name>>factor;
My_In_File from(altname);
from.Open();
*from>>name>>factor;
m_sfactor *= factor;
for (size_t j=0;j<links.size();j++) {
if (links[j]->Name()==name) {
......@@ -87,10 +87,10 @@ bool AMEGIC::Single_Process_Combined::CheckAlternatives(vector<Process_Base *>&
m_ntchanmin=p_partner->NTchanMin();
msg_Tracking()<<"Found Alternative process: "<<m_name<<" "<<name<<endl;
while (from) {
while (*from) {
string f1;
long int f2;
getline(from,dummy);
getline(*from,dummy);
if (dummy!="") {
MyStrStream str;
str<<dummy;
......@@ -98,12 +98,12 @@ bool AMEGIC::Single_Process_Combined::CheckAlternatives(vector<Process_Base *>&
AddtoFlavmap(f1,Flavour(abs(f2),f2<0));
}
}
from.close();
from.Close();
InitFlavmap(p_partner);
return true;
}
}
from.close();
from.Close();
if (CheckAlternatives(links,name)) return true;
}
m_sfactor = 1.;
......@@ -129,7 +129,7 @@ int AMEGIC::Single_Process_Combined::InitAmplitude(Model_Base * model,Topology*
p_me2->SetCouplings(m_cpls);
if (m_gen_str>1) {
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename);
ATOOLS::MakeDir(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename);
}
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH");
ATOOLS::MakeDir(newpath);
......@@ -153,8 +153,8 @@ int AMEGIC::Single_Process_Combined::InitAmplitude(Model_Base * model,Topology*
}
if (directload) directload = FoundMappingFile(m_libname,m_pslibname);
if (directload) {
string hstr=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_libname;
string hstr2=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
string hstr=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_libname;
string hstr2=rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
p_BS = new Basic_Sfuncs(m_nin+m_nout,m_nin+m_nout,&m_flavs.front(),p_b,hstr,hstr2);
}
else p_BS = new Basic_Sfuncs(m_nin+m_nout,m_nin+m_nout,&m_flavs.front(),p_b);
......@@ -178,15 +178,15 @@ int AMEGIC::Single_Process_Combined::InitAmplitude(Model_Base * model,Topology*
msg_Tracking()<<"AMEGIC::Single_Process_Combined::InitAmplitude : Found compatible process for "<<Name()<<" : "<<links[j]->Name()<<endl;
if (!FoundMappingFile(m_libname,m_pslibname)) {
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+Name();
string mlname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+links[j]->Name();
string mnname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+Name();
if (FileExists(mlname+string(".map"))) {
if (m_sfactor==1.) Copy(mlname+".map",mnname+".map");
if (m_sfactor==1.) My_In_File::CopyInDB(mlname+".map",mnname+".map");
else {
UpdateMappingFile(mlname,cplmap);
CreateMappingFile((Single_Process_Combined*)links[j]);
}
Copy(mlname+".col",mnname+".col");
My_In_File::CopyInDB(mlname+".col",mnname+".col");
}
}
......@@ -401,7 +401,7 @@ int AMEGIC::Single_Process_Combined::Tests()
gauge_test = string_test = 0;
}
else {
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/")+m_ptypename+string("/")+testname+string("/V.H");
string searchfilename = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/")+testname+string("/V.H");
if (FileExists(searchfilename)) {
msg_Error()<<"ERROR in AMEGIC::Single_Process_Combined::Tests()"<<std::endl
<<" No compiled & linked library found for process "<<testname<<std::endl
......@@ -548,7 +548,7 @@ int AMEGIC::Single_Process_Combined::CheckLibraries() {
shand1 = new String_Handler(p_shand->Get_Generator());
m_libnumb = 0;
string proc = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/")+m_ptypename+string("/V");
string proc = rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/")+m_ptypename+string("/V");
string testname;
double M2s, helvalue;
......@@ -616,7 +616,7 @@ void AMEGIC::Single_Process_Combined::WriteLibrary()
{
if (m_gen_str<2) return;
string testname;
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/");
string newpath=rpa->gen.Variable("SHERPA_CPP_PATH")+string("/Process/Amegic/");
for (;;) {
testname = CreateLibName()+string("_")+ToString(m_libnumb);
if (!(FileExists(newpath+m_ptypename+string("/")+testname+string("/V.H")))) break;
......@@ -649,7 +649,7 @@ std::string AMEGIC::Single_Process_Combined::CreateLibName()
void AMEGIC::Single_Process_Combined::CreateMappingFile(Single_Process_Combined* partner) {
if (m_gen_str<2) return;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname)) {
string MEname,PSname;
FoundMappingFile(MEname,PSname);
......@@ -661,29 +661,29 @@ void AMEGIC::Single_Process_Combined::CreateMappingFile(Single_Process_Combined*
return;
}
std::ofstream to;
to.open(outname.c_str(),ios::out);
to<<"ME: "<<m_libname<<endl
My_Out_File to(outname);
to.Open();
*to<<"ME: "<<m_libname<<endl
<<"PS: "<<m_pslibname<<endl;
p_shand->Get_Generator()->WriteCouplings(to);
partner->WriteMomFlavs(to);
to.close();
p_shand->Get_Generator()->WriteCouplings(*to);
partner->WriteMomFlavs(*to);
to.Close();
}
bool AMEGIC::Single_Process_Combined::FoundMappingFile(std::string & MEname, std::string & PSname)
{
std::string buf;
int pos;
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/"+m_ptypename+"/"+m_name+".map";
std::string outname = rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Amegic/"+m_ptypename+"/"+m_name+".map";
if (FileExists(outname)) {
ifstream from;
from.open(outname.c_str());
getline(from,buf);
My_In_File from(outname);
from.Open();
getline(*from,buf);
pos = buf.find(string("ME:"));
if (pos==-1) MEname = PSname = buf;
else {
MEname = buf.substr(pos+4);
getline(from,buf);
getline(*from,buf);
pos = buf.find(string("PS:"));
if (pos==-1) PSname = MEname;
else PSname = buf.substr(pos+4);
......@@ -699,21 +699,21 @@ void AMEGIC::Single_Process_Combined::UpdateMappingFile(std::string name, map<st
std::string buf;
int pos;
name+=".map";
ifstream from;
from.open(name.c_str());
getline(from,buf);
My_In_File from(name);
from.Open();
getline(*from,buf);
pos = buf.find(string("ME:"));
if (pos==-1) m_libname = m_pslibname = buf;
else {
m_libname = buf.substr(pos+4);
getline(from,buf);
getline(*from,buf);
pos = buf.find(string("PS:"));
if (pos==-1) m_pslibname = m_libname;
else m_pslibname = buf.substr(pos+4);
if (m_pslibname==string("")) m_pslibname = m_libname;
}