#ifndef PHASIC_Channels_VHAAG_Threshold_h #define PHASIC_Channels_VHAAG_Threshold_h #include "PHASIC++/Channels/Single_Channel.H" #include "PHASIC++/Channels/Vegas.H" #include "ATOOLS/Org/My_MPI.H" #include "ATOOLS/Org/Scoped_Settings.H" #include namespace PHASIC { class VHAAG_Threshold : public Single_Channel { int n_p1,m_type,n_d1,n_d2,n_b,n_ap; int *p_perm; double m_s0, m_thmass; ATOOLS::Vec4D* m_q; double* p_s; Vegas* p_vegas; bool m_ownvegas, m_first; std::map* p_sharedvegaslist; double PiFunc(double a1,double a2, double s1b,double s2b,double c); void Split(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2,int,int,double *ran); void Split0(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2,int,int,double *ran); void SingleSplit(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2,double,double *ran); void SingleSplitF(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2,double,double *ran); void SingleSplitF0(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2,double,double *ran); double SplitWeight(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D p1,ATOOLS::Vec4D p2,int,int,double *ran); double Split0Weight(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D p1,ATOOLS::Vec4D p2,int,int,double *ran); double SingleSplitWeight(ATOOLS::Vec4D q1,ATOOLS::Vec4D& Q, ATOOLS::Vec4D p1,ATOOLS::Vec4D p2,double,double *ran); double SingleSplitFWeight(ATOOLS::Vec4D q1,ATOOLS::Vec4D& Q, ATOOLS::Vec4D p1,ATOOLS::Vec4D p2,double,double *ran); double SingleSplitF0Weight(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D p1,ATOOLS::Vec4D p2,double,double *ran); void GenerateBosonMass(ATOOLS::Vec4D *p,double *ran); double BosonWeight(ATOOLS::Vec4D *p,double *ran); void GenerateBranch(ATOOLS::Vec4D q1,ATOOLS::Vec4D Q, ATOOLS::Vec4D* q,double*,int n,double *ran); double BranchWeight(ATOOLS::Vec4D q1,ATOOLS::Vec4D &Q, ATOOLS::Vec4D* q,double*,int n,double *ran); void ConstructMomenta(double a1,double a2, double s1,double s2,double s, ATOOLS::Vec4D q1,ATOOLS::Vec4D q2, ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2); void ConstructMomenta(double a1,double phi, double s1,double s2,double s, ATOOLS::Vec4D q1,ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2); void CalculateS0(Cut_Data *); void Initialize(std::vector perm, VHAAG_Threshold* ovl); public: VHAAG_Threshold(int _nin,int _nout,int pn,int d1,int d2,double th,VHAAG_Threshold* ovl); ~VHAAG_Threshold(); void AddPoint(double Value); void GenerateWeight(ATOOLS::Vec4D *,Cut_Data *); void GeneratePoint(ATOOLS::Vec4D *,Cut_Data *,double *); std::string Name() {return name;} void MPISync() { p_vegas->MPISync(); } void Optimize() { p_vegas->Optimize(); } void EndOptimize() { p_vegas->EndOptimize(); } void WriteOut(std::string pId) { if (m_ownvegas) p_vegas->WriteOut(pId); } void ReadIn(std::string pId) { if (m_ownvegas) p_vegas->ReadIn(pId); } int RTH() { return m_thmass; } int RD1() { return n_d1; } int RD2() { return n_d2; } int Type() { return m_type; } int OType(); std::map* GetSharedVegasList() { return p_sharedvegaslist; } bool OptimizationFinished() { return p_vegas->Finished(); } void ISRInfo(std::vector &ts,std::vector &ms, std::vector &ws) const; }; } #endif #include "ATOOLS/Org/Run_Parameter.H" #include "ATOOLS/Org/Message.H" #include "ATOOLS/Org/Data_Reader.H" #include "ATOOLS/Math/Random.H" #include "ATOOLS/Math/Permutation.H" #include "ATOOLS/Math/Poincare.H" #include "PHASIC++/Channels/Channel_Elements.H" #include "PHASIC++/Channels/Channel_Generator.H" #include "PHASIC++/Process/Process_Base.H" #include "PHASIC++/Channels/Multi_Channel.H" #include using namespace PHASIC; using namespace ATOOLS; const double a1_s =1.5; const double s_s =.3; const double a1_sp =1.; const double s_sp1 =1.; const double s_sp2 =.5; const double a1_i =1.; const double a2_i =1.; const double s_i =1.; const double a1_iF =1.; const double a2_iF =.0; const double s_xx =.5; VHAAG_Threshold::VHAAG_Threshold(int _nin,int _nout,int pn,int d1,int d2,double th,VHAAG_Threshold* ovl) { m_first=!ovl; nin=_nin; nout=_nout;n_ap=nin+nout-1; if (n_ap<5) { msg_Error()<<"Minimum number of final state particles for VHAAG_Threshold integrator is 4!"<RTH(); n_d1 = ovl->RD1(); n_d2 = ovl->RD2(); } Permutation pp(n_ap-2); int bp=pn%2; pn/=2; int* tp=pp.Get(pn); int i; for (i=0;i=n_d1) tp[i]+=2; std::vector perm(n_ap); perm[0] = 0; if (bp==0) { for (i=1;tp[i-1]!=1;i++) perm[i] = tp[i-1]; n_b=i;perm[i]=n_d1; for (;i perm, VHAAG_Threshold* ovl) { p_perm = new int[n_ap]; p_perm[0] = 0; p_s = new double[n_ap]; for (int i=0;iGetSharedVegasList(); else p_sharedvegaslist = NULL; if (p_sharedvegaslist==NULL) { p_sharedvegaslist = new std::map; } m_type=Min(n_p1-1,n_ap-(n_p1+1))+1; if (n_p1-1>=n_ap-(n_p1+1) && n_b>n_p1) m_type=-m_type; if (n_p1-1Get()<0.5) eps=-eps; Vec3D pv = a*e1+b*e2+eps*ee; p1 = Vec4D(sqrt(ps+s1),pv); p2 = Vec4D(sqrt(ps+s2),-1.*pv); } void VHAAG_Threshold::ConstructMomenta(double a1,double phi, double s1,double s2,double s, ATOOLS::Vec4D q1,ATOOLS::Vec4D& p1,ATOOLS::Vec4D& p2) { double ps = 0.25*(sqr(s-s1-s2)-4.*s1*s2)/s; if (q1.PPerp()!=0.||!IsZero(q1.Abs2()/Max(1.,sqr(q1[0])),1.0e-6)) { msg_Error()<<" Error in"<2;i--) { SingleSplit(r1,rQ,q[n-i],rQ,ms,ran); ran+=3; r1 = q[n-i]; ms-= s[n-i+1]; } SingleSplitF(r1,rQ,q[n-2],q[n-1],ms,ran); } double VHAAG_Threshold::BranchWeight(ATOOLS::Vec4D q1,ATOOLS::Vec4D &Q, ATOOLS::Vec4D* q,double* s,int n,double *ran) { double wt=1.; ran+= 3*(n-2); double ms(s[n-1]); wt*=SingleSplitFWeight(q[n-3],Q,q[n-2],q[n-1],ms,ran); for (int i=3;i<=n;i++) { ran-= 3; ms+= s[n-i+1]; wt*=SingleSplitWeight(q[n-i-1],Q,q[n-i],Q,ms,ran); } return wt; } void VHAAG_Threshold::GenerateWeight(ATOOLS::Vec4D *p,Cut_Data *cuts) { CalculateS0(cuts); double wt=1.; if (n_ap==4) { Vec4D Q(p[0]+p[1]); wt=SingleSplitF0Weight(p[0],Q,p[2],p[3],p_s[3],rans); weight = p_vegas->GenerateWeight(rans)/wt/pow(2.*M_PI,2); return; } for (int i=0;iGenerateWeight(rans); weight = vw/wt/pow(2.*M_PI,nout*3.-4.); } void VHAAG_Threshold::GeneratePoint(ATOOLS::Vec4D *p,Cut_Data *cuts,double *ran) { CalculateS0(cuts); double *vran = p_vegas->GeneratePoint(ran); for(int i=0;i &ts,std::vector &ms,std::vector &ws) const { if (!m_first) return; ts.push_back(2); ms.push_back(m_thmass); ws.push_back(0.0); } namespace PHASIC { class VHAAG_Threshold_Channel_Generator: public Channel_Generator { private: int m_d1, m_d2; double m_th; public: VHAAG_Threshold_Channel_Generator(const Channel_Generator_Key &key): Channel_Generator(key), m_d1(2), m_d2(3), m_th(40.0) { size_t bpos(key.m_key.find('[')), epos(key.m_key.rfind(']')); if (bpos==std::string::npos || epos==std::string::npos) { Scoped_Settings s{ Settings::GetMainSettings()["VHAAG"] }; m_th=s["TH"].SetDefault(40.0).Get(); m_d1=s["D1"].SetDefault(2).Get(); m_d2=s["D2"].SetDefault(3).Get(); return; } Data_Reader read(":",",","#","="); read.SetString(key.m_key.substr(bpos+1,epos-bpos-1)); if (!read.ReadFromString(m_d1,"I")) m_d1=2; if (!read.ReadFromString(m_d2,"J")) m_d2=3; if (!read.ReadFromString(m_th,"T")) m_th=40.0; } int GenerateChannels() { int m_nin=p_proc->NIn(), m_nout=p_proc->NOut(); VHAAG_Threshold *firsthaag=NULL,*hlp=NULL; Permutation pp(m_nin+m_nout-3); for (int j=0;jAdd(hlp=new VHAAG_Threshold(m_nin,m_nout,2*j,m_d1,m_d2,m_th,firsthaag)); if (!firsthaag) firsthaag=hlp; p_mc->Add(hlp=new VHAAG_Threshold(m_nin,m_nout,2*j+1,m_d1,m_d2,m_th,firsthaag)); if (!firsthaag) firsthaag=hlp; } return 0; } };// end of class VHAAG_Threshold_Channel_Generator }// end of namespace PHASIC DECLARE_GETTER(VHAAG_Threshold_Channel_Generator,"VHAAG_Threshold", Channel_Generator,Channel_Generator_Key); Channel_Generator *ATOOLS::Getter :: operator()(const Channel_Generator_Key &args) const { return new VHAAG_Threshold_Channel_Generator(args); } void ATOOLS::Getter:: PrintInfo(std::ostream &str,const size_t width) const { str<<"Vegas-improved HAAG integrator for resonance + jets"; }