Commit 7eb43254 authored by Stefan Hoeche's avatar Stefan Hoeche Committed by Frank Siegert

Enable process group separation for integration

parent 10350cea
#!/bin/bash
test -z "$1" && exit 1
zipinfo $1 | awk 'function mapped(file){
command = ("unzip -p '$1' "file" | head -n 1");
(command | getline result); close(command);
split(result,a); return a[1]!=a[2]; }
BEGIN{np=0}
{ if (match($NF,".map")>0 && match($NF,"__j")==0)
if (!mapped($NF)) { print np": "$NF; np+=1; } }'
......@@ -294,7 +294,8 @@ InitializeProcess(const PHASIC::Process_Info &pi, bool add)
newxs->Get<COMIX::Process_Base>()->SetModel(p_model);
newxs->Get<COMIX::Process_Base>()->SetCTS(p_cts);
newxs->Get<COMIX::Process_Base>()->SetGPath(pi.m_gpath);
if (!newxs->Get<Single_Process>()->Initialize(&pmap,&m_umprocs.back())) {
if (!newxs->Get<Single_Process>()->Initialize
(&pmap,&m_umprocs.back(),m_blocks,m_nproc)) {
My_In_File::CloseDB
(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Comix/",0);
msg_Debugging()<<METHOD<<"(): Init failed for '"
......
......@@ -39,7 +39,8 @@ COMIX::Process_Base::~Process_Base()
}
bool COMIX::Process_Base::Initialize(std::map<std::string,std::string> *const pmap,
std::vector<Single_Process*> *const procs)
std::vector<Single_Process*> *const procs,
const std::vector<int> &blocks,size_t &nproc)
{
p_pmap=pmap;
p_umprocs=procs;
......
......@@ -55,7 +55,8 @@ namespace COMIX {
// member functions
virtual bool Initialize(std::map<std::string,std::string> *const pmap,
std::vector<Single_Process*> *const procs);
std::vector<Single_Process*> *const procs,
const std::vector<int> &blocks,size_t &nproc);
virtual bool MapProcess() = 0;
virtual void InitPSGenerator(const size_t &ismode) = 0;
......
......@@ -19,10 +19,10 @@ using namespace PHASIC;
using namespace ATOOLS;
COMIX::Process_Group::Process_Group():
COMIX::Process_Base(this) {}
COMIX::Process_Base(this), m_nproc(0) {}
COMIX::Process_Group::Process_Group(MODEL::Model_Base *const model):
COMIX::Process_Base(this,model) {}
COMIX::Process_Base(this,model), m_nproc(0) {}
bool COMIX::Process_Group::Initialize(std::map<std::string,std::string> *const pmap,
std::vector<Single_Process*> *const procs)
......@@ -48,7 +48,7 @@ bool COMIX::Process_Group::Initialize(std::map<std::string,std::string> *const p
}
}
}
return COMIX::Process_Base::Initialize(pmap,procs);
return COMIX::Process_Base::Initialize(pmap,procs,m_blocks,m_nproc);
}
PHASIC::Process_Base *COMIX::Process_Group::GetProcess(const PHASIC::Process_Info &pi) const
......@@ -64,7 +64,7 @@ bool COMIX::Process_Group::Initialize(PHASIC::Process_Base *const proc)
cdxs->SetCTS(p_cts);
proc->Integrator()->SetHelicityScheme(p_int->HelicityScheme());
proc->SetParent((PHASIC::Process_Base*)this);
if (!cdxs->Initialize(p_pmap,p_umprocs)) return false;
if (!cdxs->Initialize(p_pmap,p_umprocs,m_blocks,m_nproc)) return false;
if (s_partcommit) My_In_File::CloseDB
(rpa->gen.Variable("SHERPA_CPP_PATH")+"/Process/Comix/",0);
if (!cdxs->MapProcess())
......
......@@ -12,6 +12,8 @@ namespace COMIX {
public PHASIC::Process_Group, public Process_Base {
protected:
size_t m_nproc;
void InitPSGenerator(const size_t &ismode);
public :
......
......@@ -59,11 +59,13 @@ COMIX::Single_Process::~Single_Process()
bool COMIX::Single_Process::Initialize
(std::map<std::string,std::string> *const pmap,
std::vector<Single_Process*> *const procs)
std::vector<Single_Process*> *const procs,
const std::vector<int> &blocks,size_t &nproc)
{
DEBUG_FUNC("");
m_p.resize(m_nin+m_nout);
if (!COMIX::Process_Base::Initialize(pmap,procs)) return false;
if (!COMIX::Process_Base::Initialize
(pmap,procs,blocks,nproc)) return false;
if (p_bg!=NULL) delete p_bg;
p_bg=NULL;
if (pmap->find(m_name)!=pmap->end()) {
......@@ -85,8 +87,25 @@ bool COMIX::Single_Process::Initialize
if (mapname!=m_name) {
msg_Debugging()<<METHOD<<"(): Map '"<<m_name
<<"' onto '"<<mapname<<"'\n";
if (Parent()->Name()==Name() && mapname=="x") return false;
if (blocks.size()) {
for (size_t i(0);i<procs->size();++i)
if ((*procs)[i]->Name()==mapname) {
msg_Debugging()<<"Keep "<<m_name<<"\n";
return true;
}
return false;
}
return true;
}
else {
++nproc;
if (blocks.size()) {
if (std::find(blocks.begin(),blocks.end(),nproc-1)
==blocks.end()) return false;
msg_Debugging()<<"Keep "<<nproc<<"\n";
}
}
}
}
msg_Debugging()<<"'"<<m_name<<"' not pre-mapped"<<std::endl;
......
......@@ -58,7 +58,8 @@ namespace COMIX {
// member functions
bool Initialize(std::map<std::string,std::string> *const pmap,
std::vector<Single_Process*> *const procs);
std::vector<Single_Process*> *const procs,
const std::vector<int> &blocks,size_t &nproc);
bool MapProcess();
int PerformTests();
......
......@@ -53,6 +53,7 @@ The following parameters are used to steer the process setup.
* PSI_ItMin:: Tag to set the number of points per optimization step.
* RS_PSI_ItMin:: Tag to set the number of points per optimization step
in real-minus-subtraction parts.
* Special Group:: Manual grouping of flavour processes for integration
* End process:: The process setup end tag.
@end menu
......@@ -547,6 +548,25 @@ Sets the number of points per optimization step, see @ref{PSI_ITMIN}.
Sets the number of points per optimization step in real-minus-subtraction
parts of fixed-order and MC@@NLO calculations, see @ref{PSI_ITMIN}.
@node Special Group
@subsection Special Group
Allows to split up individual flavour processes within a process group for
integrating them separately. This can help improve the integration/unweighting
efficiency. Note: Only works with Comix so far.
Example for usage:
@verbatim
Process 93 93 -> 11 -11 93
Special Group(0-1,4)
[...]
End process
Process 93 93 -> 11 -11 93
Special Group(2-3,5-7)
[...]
End process
@end verbatim
The numbers for each individual process can be found using a script in the
AddOns directory: @code{AddOns/ShowProcessIds.sh Process/Comix.zip}
@node End process
@subsection End process
Completes the setup of a process or a list of processes
......
......@@ -186,9 +186,9 @@ void Process_Integrator::InitWeightHistogram()
}
double av(dabs(TotalResult()));
if (!(av>0.)) {
msg_Error()<<"Process_Integrator::InitWeightHistogram(): "
<<"Average = "<<av<<" in "<<p_proc->Name()<<std::endl;
if (IsBad(av)) {
msg_Error()<<METHOD<<"(): Average = "<<av
<<" in "<<p_proc->ResultsName()<<std::endl;
return;
}
if (av<.3) av/=10.;
......@@ -201,7 +201,7 @@ void Process_Integrator::InitWeightHistogram()
bool Process_Integrator::ReadInXSecs(const std::string &path)
{
std::string fname(p_proc->Name());
std::string fname(p_proc->ResultsName());
size_t vn;
std::string name, dummy;
My_In_File from(path+"/"+fname);
......@@ -237,7 +237,7 @@ bool Process_Integrator::ReadInXSecs(const std::string &path)
void Process_Integrator::ReadInHistogram(std::string dir)
{
std::string filename = dir+"/"+p_proc->Name();
std::string filename = dir+"/"+p_proc->ResultsName();
if (!FileExists(filename)) return;
if (p_whisto) delete p_whisto;
p_whisto = new Histogram(filename);
......@@ -248,7 +248,7 @@ void Process_Integrator::ReadInHistogram(std::string dir)
void Process_Integrator::WriteOutXSecs(const std::string &path)
{
std::string fname(p_proc->Name());
std::string fname(p_proc->ResultsName());
My_Out_File outfile(path+"/"+fname);
if (outfile.Open()) m_writeout=1;
outfile->precision(16);
......@@ -268,7 +268,7 @@ void Process_Integrator::WriteOutXSecs(const std::string &path)
void Process_Integrator::WriteOutHistogram(std::string dir)
{
if (p_whisto) p_whisto->Output(dir+"/"+p_proc->Name());
if (p_whisto) p_whisto->Output(dir+"/"+p_proc->ResultsName());
if (p_proc->IsGroup())
for (size_t i(0);i<p_proc->Size();++i)
(*p_proc)[i]->Integrator()->WriteOutHistogram(dir);
......@@ -291,14 +291,14 @@ void Process_Integrator::SetTotal(const int mode)
m_totalerr=totalerr;
if (mode && m_totalxs!=0.0) {
if (p_proc->NIn()==1) {
msg_Info()<<om::bold<<p_proc->Name()<<om::reset<<" : "<<om::blue<<om::bold
msg_Info()<<om::bold<<p_proc->ResultsName()<<om::reset<<" : "<<om::blue<<om::bold
<<m_totalxs<<" GeV"<<om::reset<<" +- ( "<<om::red
<<m_totalerr<<" GeV = "<<dabs(m_totalerr/m_totalxs)*100.
<<" %"<<om::reset<<" ) "<<om::bold<<" exp. eff: "
<<om::red<<(100.*dabs(m_totalxs/m_max))<<" %"<<om::reset<<std::endl;
}
else {
msg_Info()<<om::bold<<p_proc->Name()<<om::reset<<" : "<<om::blue<<om::bold
msg_Info()<<om::bold<<p_proc->ResultsName()<<om::reset<<" : "<<om::blue<<om::bold
<<m_totalxs*rpa->Picobarn()<<" pb"<<om::reset<<" +- ( "<<om::red
<<m_totalerr*rpa->Picobarn()<<" pb = "<<dabs(m_totalerr/m_totalxs)*100.
<<" %"<<om::reset<<" ) "<<om::bold<<" exp. eff: "
......@@ -332,8 +332,9 @@ void Process_Integrator::SetUpEnhance(const int omode)
if (m_maxeps>0.0 && !p_proc->IsGroup()) {
double max(GetMaxEps(m_maxeps));
if (omode)
msg_Info()<<" reduce max for "<<p_proc->Name()<<" to "
<<max/Max()<<" ( eps = "<<m_maxeps<<" ) "<<std::endl;
msg_Info()<<" reduce max for "<<p_proc->ResultsName()<<" to "
<<max/Max()<<" ( eps = "<<m_maxeps<<" -> exp. eff "
<<dabs(m_totalxs/max)<<" ) "<<std::endl;
SetMax(max);
}
if (p_proc->IsGroup()) {
......@@ -345,8 +346,9 @@ void Process_Integrator::SetUpEnhance(const int omode)
}
if (omode || p_proc->Parent()==p_proc)
if (p_whisto)
msg_Info()<<" reduce max for "<<p_proc->Name()<<" to "
<<m_max/oldmax<<" ( eps = "<<m_maxeps<<" ) "<<std::endl;
msg_Info()<<" reduce max for "<<p_proc->ResultsName()<<" to "
<<m_max/oldmax<<" ( eps = "<<m_maxeps<<" -> exp. eff "
<<dabs(m_totalxs/m_max)<<" ) "<<std::endl;
}
}
......@@ -421,7 +423,7 @@ void Process_Integrator::SetMax(const double max)
if (!ATOOLS::IsEqual(sum,m_totalxs,1e-11)) {
msg_Error().precision(12);
msg_Error()<<METHOD<<"(): Summation does not agree for '"
<<p_proc->Name()<<".\n sum = "<<sum
<<p_proc->ResultsName()<<".\n sum = "<<sum
<<" vs. total = "<<m_totalxs<<" ("
<<((sum-m_totalxs)/m_totalxs)<<")"<<std::endl;
msg_Error().precision(6);
......@@ -590,7 +592,7 @@ void Process_Integrator::StoreResults(const int mode)
if (m_resultpath.length()==0) return;
if (m_totalxs!=0.0 && mode==0) return;
SetTotal(0);
std::string fname(p_proc->Name());
std::string fname(p_proc->ResultsName());
WriteOutXSecs(m_resultpath+"/"+p_proc->Generator()->Name()+"/XS_"+fname);
WriteOutHistogram(m_resultpath+"/"+p_proc->Generator()->Name()+"/WD_"+fname);
p_pshandler->WriteOut(m_resultpath+"/"+p_proc->Generator()->Name()+"/MC_"+fname);
......@@ -601,7 +603,7 @@ void Process_Integrator::StoreResults(const int mode)
void Process_Integrator::ReadResults()
{
if (m_resultpath.length()==0) return;
std::string fname(p_proc->Name());
std::string fname(p_proc->ResultsName());
if (!ReadInXSecs(m_resultpath+"/"+p_proc->Generator()->Name()+"/XS_"+fname)) return;
ReadInHistogram(m_resultpath+"/"+p_proc->Generator()->Name()+"/WD_"+fname);
p_pshandler->ReadIn(m_resultpath+"/"+p_proc->Generator()->Name()+"/MC_"+fname);
......
......@@ -326,6 +326,7 @@ void Process_Base::Init(const Process_Info &pi,
isrhandler->AllowSwap(m_flavs[0],m_flavs[1]))
m_symfac*=(m_issymfac=2.0);
m_name+=pi.m_addname;
m_resname=m_name;
}
std::string Process_Base::BaseName
......
......@@ -70,7 +70,7 @@ namespace PHASIC {
KFactor_Setter_Base *p_kfactor;
size_t m_nin, m_nout, m_mcmode, m_cmode;
std::string m_name;
std::string m_name, m_resname;
std::vector<double> m_maxcpl, m_mincpl;
......@@ -210,7 +210,8 @@ namespace PHASIC {
inline const ATOOLS::Flavour_Vector &Flavours() const { return m_flavs; }
inline void SetFlavours(const ATOOLS::Flavour_Vector& flavs) { m_flavs = flavs; }
inline const std::string &Name() const { return m_name; }
inline const std::string &Name() const { return m_name; }
inline const std::string &ResultsName() const { return m_resname; }
inline void SetMaxOrders(const std::vector<double> &o) { m_maxcpl=o; }
inline void SetMinOrders(const std::vector<double> &o) { m_mincpl=o; }
......
......@@ -191,7 +191,7 @@ bool Process_Group::CalculateTotalXSec(const std::string &resultpath,
namestring+=")";
}
msg_Info()<<METHOD<<"(): Calculate xs for '"
<<m_name<<"' "<<namestring<<std::endl;
<<m_resname<<"' "<<namestring<<std::endl;
double totalxs(psh->Integrate()/rpa->Picobarn());
if (!IsEqual(totalxs,p_int->TotalResult())) {
msg_Error()<<"Result of PS-Integrator and summation do not coincide!\n"
......@@ -338,6 +338,25 @@ bool Process_Group::ConstructProcesses()
+"/Process/Sherpa/"+m_name);
if (cpi.m_megenerator.length()) mapfile+="__"+cpi.m_megenerator;
mapfile+=".map";
size_t bpos(m_pinfo.m_special.find("Group("));
if (bpos!=std::string::npos) {
m_resname+="__Group(";
size_t epos(m_pinfo.m_special.find(")",bpos)), npos(epos);
for (bpos+=6;bpos<epos;bpos=npos+1) {
npos=std::min(epos,m_pinfo.m_special.find(',',bpos+1));
std::string cur(m_pinfo.m_special.substr(bpos,npos-bpos));
m_resname+=(m_blocks.size()?",":"")+cur;
size_t dpos(cur.find('-'));
if (dpos==std::string::npos) m_blocks.push_back(ToType<int>(cur));
else {
int start(ToType<int>(cur.substr(0,dpos)));
int end(ToType<int>(cur.substr(dpos+1)));
for (size_t i(start);i<=end;++i) m_blocks.push_back(i);
}
}
m_resname+=")";
msg_Debugging()<<"Group "<<m_blocks<<"\n";
}
msg_Debugging()<<"checking for '"<<mapfile<<"' ... "<<std::flush;
if (FileExists(mapfile)) {
msg_Debugging()<<"found"<<std::endl;
......@@ -350,8 +369,11 @@ bool Process_Group::ConstructProcesses()
SetFlavour(cpi.m_ii,cpi.m_fi,Flavour(std::abs(cfl),cfl<0),cnt);
*map>>cfl;
}
if (cnt!=m_nin+m_nout || cfl || !ConstructProcess(cpi))
THROW(fatal_error,"Corrupted map file '"+mapfile+"'");
int construct(ConstructProcess(cpi));
if (m_blocks.empty()) {
if (cnt!=m_nin+m_nout || cfl || !construct)
THROW(fatal_error,"Corrupted map file '"+mapfile+"'");
}
*map>>cfl;
}
return m_procs.size();
......
......@@ -12,6 +12,8 @@ namespace PHASIC {
std::vector<Process_Base*> m_procs;
std::map<std::string,Process_Base*> m_procmap;
std::vector<int> m_blocks;
Process_Base *GetProcess(const std::string &name);
bool CheckFlavours(const Subprocess_Info &ii,
......
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