#include "METOOLS/Explicit/Vertex.H" #include "MODEL/Main/Single_Vertex.H" #include "MODEL/Main/Model_Base.H" #include "METOOLS/Explicit/Dipole_Kinematics.H" #include "ATOOLS/Org/Message.H" #include "ATOOLS/Org/Exception.H" #include "ATOOLS/Org/STL_Tools.H" #include "ATOOLS/Org/MyStrStream.H" #include "ATOOLS/Org/Shell_Tools.H" #include #include using namespace METOOLS; using namespace ATOOLS; namespace METOOLS { template std::string GetName(const Type &o,const int mode=0) { std::string id=Demangle(typeid(o).name()); size_t pos=id.find("METOOLS::"); if (pos'); if (epos Vertex::s_h; Vertex::Vertex(const Vertex_Key &key): p_v(key.p_mv), p_c(NULL), p_info(key.p_dinfo), p_kin(NULL), p_h(NULL), m_sign(false), m_fperm(0), m_stype(key.m_stype), m_icplfac(1.0) { if (key.p_mv==NULL) return; if (p_info) p_kin = new Dipole_Kinematics (p_info,key.m_j[0],key.m_j[1],key.p_k,key.p_c,key.p_kt); key.p_v=this; Vertex_Key ckey(key); for (ckey.m_n=0;ckey.m_nLorentz.size();++ckey.m_n) { std::string ctag(ToString(ckey.p_mv->Color[ckey.m_n].PID())); if (key.p_dinfo) { if (key.m_stype==2) ctag="S-D"; else if (abs(ckey.p_c->Flav().StrongCharge())==3) ctag="S-T"; else if (key.p_c->Flav().StrongCharge()==8) ctag="S-F"; else { for (size_t i(0);iMappedLorentzName(ckey.p_mv->Lorentz[ckey.m_n]); else lname+=ckey.p_mv->Lorentz[ckey.m_n]; m_lc.push_back(LC_Getter::GetObject(lname,ckey)); if (m_lc.back()==NULL) { msg_Out()<<*ckey.p_mv<DetachOut(this); if (p_kin) delete p_kin; } void Vertex::Evaluate() { SetZero(); if (p_kin && !p_kin->Trig()) return; for (Current_Vector::const_iterator jit(m_j.begin()); jit!=m_j.end();++jit) if ((*jit)->Zero()) return; if (p_kin) { for (LC_Vector::const_iterator lit(m_lc.begin()); lit!=m_lc.end();++lit) (*lit)->Evaluate(); if (!p_c->Zero()) { const CObject *c(p_kin->JK()->J().front().front()); p_kin->JKT()->ConstructJ(p_kin->JKT()->P(),0,(*c)(0),(*c)(1),0); } return; } #ifdef DEBUG__BG msg_Debugging()<J().size()), sh1(m_j[1]->J().size()); for (size_t h0(0);h0J()[h0]); if (hjj0->empty()) { hid+=sh1; continue; } for (size_t h1(0);h1J()[h1]); if (hjj1->empty()) { ++hid; continue; } for (size_t c0(0);c0size();++c0) { m_cjj[0]=(*hjj0)[c0]; for (size_t c1(0);c1size();++c1) { m_cjj[1]=(*hjj1)[c1]; for (size_t k(0);kEvaluate(m_cjj)) { CObject *j(m_lc[k]->Evaluate(m_cjj)); if (j==NULL) continue; j->Multiply(p_v->Coupling(k)*m_cc[k]->Coupling()); j->SetH(H(hid)); m_cc[k]->AddJ(j); SetZero(false); } } } ++hid; } } return; } size_t hid(0); Int_Vector m_cjc(m_j.size()), m_hjc(m_j.size(),0); std::vector m_hjj(m_j.size()); for (size_t j(0);jJ().front(); for (size_t hc(m_hjc.size()-1);m_hjc[0]J().size();) { if(m_hjc[hc]==m_j[hc]->J().size()){m_hjc[hc--]=0;++m_hjc[hc];continue;} m_hjj[hc]=&m_j[hc]->J()[m_hjc[hc]];if(hcempty()) {zero=true;break;} else m_cjj[i]=m_hjj[i]->front(); if (zero) {++m_hjc[hc];++hid;continue;} for (size_t cc(m_cjc.size()-1);m_cjc[0]size();) { if (m_cjc[cc]==m_hjj[cc]->size()){m_cjc[cc--]=0;++m_cjc[cc];continue;} m_cjj[cc]=(*m_hjj[cc])[m_cjc[cc]];if(ccEvaluate(m_cjj)) { CObject *j(m_lc[k]->Evaluate(m_cjj)); if (j==NULL) continue; j->Multiply(p_v->Coupling(k)*m_cc[k]->Coupling()); j->SetH(H(hid)); m_cc[k]->AddJ(j); SetZero(false); } ++m_cjc[cc]; } ++m_hjc[hc]; ++hid; } } void Vertex::FindPermutation() { m_fperm=0; #ifdef DEBUG__BG msg_Debugging()<Id()), fid(p_c->FId()); Int_Vector pid(m_j[0]->Id()), pfid(m_j[0]->FId()); for (size_t i(1);iId().begin(),m_j[i]->Id().end()); pfid.insert(pfid.end(),m_j[i]->FId().begin(),m_j[i]->FId().end()); } #ifdef DEBUG__BG msg_Debugging()<<" pid = "<i?k-1:k+1); m_fperm+=pfid[k]==1&&pfid[l]==1; #ifdef DEBUG__BG if (pfid[k]==1 && pfid[l]==1) msg_Debugging()<<" swap "<(pid[k],pid[l]); std::swap(pfid[k],pfid[l]); k=l; } break; } } m_sign=m_fperm%2==1; #ifdef DEBUG__BG msg_Debugging()<<"} => "<<*this<<"\n"; #endif } void Vertex::InitPols() { #ifdef DEBUG__BG msg_Debugging()<H().SpinID(); nmax=Max(nmax,m_j[i]->Id().back()); } static std::map s_imap; for (size_t i(0);i<=nmax;++i) for (size_t j(0);jId().begin(), m_j[j]->Id().end(),i)!= m_j[j]->Id().end()) { std::map::iterator iit(s_imap.find(j)); if (iit==s_imap.end()) iit=s_imap.insert(make_pair(j,ToString(j))).first; id+="_"+iit->second; break; } std::map::iterator hit(s_h.find(id)); if (hit!=s_h.end()) { p_h=&hit->second; #ifdef DEBUG__BG msg_Debugging()<<" "<second; #ifdef DEBUG__BG msg_Debugging()<<" "< hjj(m_j.size()); for (size_t i(0);iH()(0); for (size_t hc(m_hjc.size()-1);m_hjc[0]H().N();) { if(m_hjc[hc]==m_j[hc]->H().N()){m_hjc[hc--]=0;++m_hjc[hc];continue;} hjj[hc]=m_j[hc]->H()(m_hjc[hc]);if(hcId()); id.reserve(p_c->Id().size()); ch.reserve(p_c->Id().size()); for (size_t i(0);iId()[m]<*iit) break; id.insert(iit,m_j[i]->Id()[m]); ch.insert(cit,hjj[i][m]); } } #ifdef DEBUG__BG msg_Debugging()<<" ["<size()<<"]: j = "< id = "<H()(ch)<<"\n"; #endif p_h->push_back(p_c->H()(ch)); ++m_hjc[hc]; } #ifdef DEBUG__BG msg_Debugging()<<"}\n"; #endif } bool Vertex::Map(const Vertex &v) { #ifdef DEBUG__BG msg_Debugging()<<" "<<(m_cc.size()?GetName(*m_cc.front()):"") <<"|"<<(m_lc.size()?GetName(*m_lc.front()):"") <<" "<cpl[i].Value() != v.p_v->cpl[i].Value()) return false; } return VId()==v.VId(); } void Vertex::AddJ(const Current_Vector &j) { for (size_t i(0);iCId()); return estr+"_"+ToString(p_c->CId()); } std::string Vertex::CVLabel() const { std::string label(m_lc[0]->Label()); for (size_t i(1);iLabel(); return label; } std::string Vertex::VLabel() const { std::string label; if (s_vlmode&1) label+="\\scriptstyle\\blue F="+ToString(m_fperm); if (s_vlmode&2) { if (m_cc.empty() || m_lc.empty()) THROW(fatal_error,"Invalid call"); std::string id(GetName(*m_cc.front())+"_"+GetName(*m_lc.front(),1)); for (size_t pos;(pos=id.find("_"))!=std::string::npos && id[pos-1]!='\\';id.replace(pos,1,"\\_")); if (s_vlmode&16) { label+=std::string(label.length()>0?"\\\\":"")+ "\\scriptstyle\\green O="+id+"("+m_j[0]->Flav().TexName(); for (size_t i(1);iFlav().TexName(); label+=")"; } } if (s_vlmode&4) label+=std::string(label.length()>0?"\\\\":"")+ "\\scriptstyle\\red L="+CVLabel(); if (s_vlmode&8) { label+=std::string(label.length()>0?"\\\\":"")+ "\\scriptstyle\\green C={"+p_v->cpl.front().String(); for (size_t i(1);icpl.size();++i) label+=","+p_v->cpl[i].String(); label+="}"; } for (size_t pos(label.find(',')); pos!=std::string::npos;pos=label.find(',',pos+2)) label.replace(pos,1,",,"); return "decor.size=0ex,label=$\\begin{array}{c}"+label+"\\end{array}$"; } void Vertex::CollectGraphs(Graph_Node *graph) const { graph->push_back(" \\fmfv{"+VLabel()+"}{"+VId()+"}"); graph->push_back(" %% "+VId()); for (size_t i(0);iCollectGraphs(graph); } const std::vector &Vertex::Order() const { return p_v->order; } int Vertex::Order(const size_t &id) const { return p_v->order[id]; } std::ostream &METOOLS::operator<<(std::ostream &str,const Vertex &v) { for (size_t i(0);iType()<<','<Flav()<<'}'<Id(); if (v.J(i)->Sub()) str<<"S["<Sub()->Id() <Sub()->Sub()->Id()<<"]"; } if (v.JC()!=NULL) { str<<"-"; if (v.Color().size() && v.Lorentz().size()) { str<<"'"<{"<Type() <<','<Flav()<<'}'<Id(); } if (v.Kin()) str<<" D["<JK()->Id() <<","<Type()<<"]"; return str<<" {"<