File indexing completed on 2025-04-19 09:10:00
0001 #ifndef COMIX_Amplitude_Amplitude_H
0002 #define COMIX_Amplitude_Amplitude_H
0003
0004 #include "PHASIC++/Process/Subprocess_Info.H"
0005 #include "PHASIC++/Process/Virtual_ME2_Base.H"
0006 #include "PHASIC++/Selectors/Combined_Selector.H"
0007 #include "METOOLS/Main/Spin_Structure.H"
0008 #include "METOOLS/Explicit/Vertex.H"
0009 #include "MODEL/Main/Coupling_Data.H"
0010 #include "ATOOLS/Phys/NLO_Subevt.H"
0011 #include "ATOOLS/Phys/NLO_Types.H"
0012 #include "ATOOLS/Phys/Weight_Info.H"
0013 #include "ATOOLS/Org/CXXFLAGS.H"
0014
0015 #ifdef USING__Threading
0016 #include <pthread.h>
0017 #endif
0018
0019 namespace PHASIC {
0020 class Color_Integrator;
0021 class Helicity_Integrator;
0022 }
0023
0024 namespace METOOLS {
0025 class Dipole_Info;
0026 class Spin_Amplitudes;
0027 }
0028
0029 namespace PDF {
0030 class NLOMC_Base;
0031 }
0032
0033 using namespace METOOLS;
0034
0035 namespace COMIX {
0036
0037 struct Coupling_Info {
0038 METOOLS::Vertex *p_v;
0039 size_t m_oqcd, m_oew;
0040 MODEL::Coupling_Data *p_aqcd, *p_aqed;
0041 inline Coupling_Info(METOOLS::Vertex *const v,
0042 const size_t &oqcd,const size_t &oew,
0043 MODEL::Coupling_Data *const aqcd,
0044 MODEL::Coupling_Data *const aqed):
0045 p_v(v), m_oqcd(oqcd), m_oew(oew), p_aqcd(aqcd), p_aqed(aqed) {}
0046 };
0047
0048 typedef std::vector<Coupling_Info> CouplingInfo_Vector;
0049
0050 typedef std::vector<Current_Vector> Current_Matrix;
0051
0052 typedef std::vector<long unsigned int> LongInt_Vector;
0053
0054 typedef std::set<std::pair<size_t,size_t> > Combination_Set;
0055 typedef std::map<size_t,ATOOLS::Flavour_Vector> CFlavVector_Map;
0056
0057 typedef std::map<size_t,size_t> SizeT_Map;
0058
0059 #ifdef USING__Threading
0060 class Amplitude;
0061
0062 struct CDBG_ME_TID {
0063 pthread_t m_id;
0064 Amplitude *p_ampl;
0065 size_t m_s, m_n, m_b, m_e, m_i;
0066 pthread_mutex_t m_s_mtx, m_t_mtx;
0067 pthread_cond_t m_s_cnd, m_t_cnd;
0068 CDBG_ME_TID(): p_ampl(NULL), m_s(2), m_b(0), m_e(0) {}
0069 };
0070
0071 typedef std::vector<CDBG_ME_TID*> CDBG_ME_TID_Vector;
0072 #endif
0073
0074 class Amplitude {
0075 public:
0076
0077 typedef std::complex<double> DComplex;
0078
0079 typedef std::vector<DComplex> DComplex_Vector;
0080
0081 private:
0082
0083 MODEL::Model_Base *p_model;
0084
0085 ATOOLS::Flavour_Vector m_fl, m_ndc;
0086 ATOOLS::Vec4D_Vector m_p;
0087
0088 ATOOLS::DecayInfo_Vector m_decid;
0089
0090 CouplingInfo_Vector m_cpls;
0091
0092 Int_Vector m_ch, m_dirs, m_sid, m_cchirs;
0093 Int_Matrix m_cl;
0094
0095 size_t m_nin, m_nout, m_dec;
0096 size_t m_n, m_wfmode, m_pgmode, m_ngpl;
0097 bool m_sccmur, m_murcoeffvirt;
0098 size_t m_minntc, m_maxntc, m_stype;
0099 char m_pmode;
0100
0101 std::vector<int> m_maxcpl, m_mincpl, m_maxacpl, m_minacpl;
0102
0103 std::vector<Spin_Structure<DComplex> > m_ress, m_cress;
0104 std::vector<std::pair<size_t,size_t> > m_on, m_son;
0105
0106 std::vector<std::vector<double> > m_dsij;
0107 std::map<size_t,std::pair<int,int> > m_dsm;
0108
0109 std::vector<std::pair<size_t,double> > m_dsf;
0110
0111 double m_res, m_born, m_cmur[2];
0112 double m_smth, m_smpow;
0113
0114 Current_Matrix m_cur;
0115 Current_Vector m_scur;
0116
0117 METOOLS::Dipole_Info *p_dinfo;
0118
0119 PHASIC::Color_Integrator *p_colint;
0120 PHASIC::Helicity_Integrator *p_helint;
0121
0122 double m_sf, m_fsf;
0123 bool m_trig;
0124
0125 ATOOLS::NLO_subevtlist m_subs;
0126 PHASIC::Virtual_ME2_Base *p_loop;
0127
0128 std::vector<std::map<size_t,std::vector<long int> > > m_affm;
0129
0130 ATOOLS::NLO_subevt *p_sub;
0131
0132 size_t BornID(const size_t &id,const NLO_subevt *sub) const;
0133
0134 #ifdef USING__Threading
0135 CDBG_ME_TID_Vector *p_cts;
0136 #endif
0137
0138 void CleanUp();
0139 void Prune();
0140 void ConstructNLOEvents();
0141 void ConstructDSijMap();
0142
0143 int CheckDecay(const ATOOLS::Flavour &fl,const Int_Vector &ids) const;
0144 bool MatchDecay(const Vertex_Key &vkey) const;
0145 Vertex *AddCurrent(const Current_Key &ckey,Vertex_Key &vkey,
0146 const size_t &n,const int dec,
0147 std::vector<int> &maxcpl,std::vector<int> &mincpl,
0148 std::map<std::string,Current*> &curs);
0149 void AddCurrent(const Int_Vector &ids,const size_t &n,
0150 const ATOOLS::Flavour &fl,const int dir);
0151
0152 Current *CopyCurrent(Current *const c);
0153 bool AddRSDipole(Current *const c,Current *const sc,
0154 Current_Vector &scur,int stype);
0155 bool AddRSDipoles();
0156 bool AddVIDipole(Current *const c,Current *const sc,Current_Vector &scur);
0157 bool AddVIDipoles();
0158
0159 bool Construct(ATOOLS::Flavour_Vector &fls,
0160 Int_Vector ids,const size_t &n);
0161 bool Construct(const ATOOLS::Flavour_Vector &flavs);
0162 bool Construct(const Int_Vector &incs,
0163 const ATOOLS::Flavour_Vector &flavs,
0164 MODEL::Model_Base *const model,
0165 MODEL::Coupling_Map *const cpls);
0166
0167 bool ConstructCouplings(MODEL::Coupling_Map *const cpls);
0168 bool CheckOrders();
0169 bool ConstructChirs();
0170
0171 void SetGauge(const size_t &n);
0172
0173 void CalcJL();
0174
0175 void SetCouplings() const;
0176
0177 double EpsSchemeFactor(const ATOOLS::Vec4D_Vector &mom) const;
0178
0179 void WriteOutGraph(std::ostream &str,Graph_Node *graph,
0180 size_t &ng,std::set<std::string> &cvs) const;
0181
0182 public:
0183
0184
0185 Amplitude();
0186
0187
0188 ~Amplitude();
0189
0190
0191 bool Initialize(const size_t &nin,const size_t &nout,
0192 const std::vector<ATOOLS::Flavour> &flavs,
0193 const double &isf,const double &fsf,
0194 My_In_File &file,
0195 MODEL::Model_Base *const model,
0196 MODEL::Coupling_Map *const cpls,
0197 const int stype,const int smode,
0198 const ATOOLS::cs_itype::type itype,
0199 const std::vector<int> &maxcpl,
0200 const std::vector<int> &mincpl,
0201 const std::vector<int> &maxacpl,
0202 const std::vector<int> &minacpl,
0203 const size_t &minntc,const size_t &maxntc,
0204 const std::string &name);
0205
0206 void ResetJ();
0207 void ResetZero();
0208
0209 bool Evaluate(const Int_Vector &chirs);
0210 bool EvaluateAll(const bool &mode=false);
0211
0212 double Differential(NLO_subevt *const sub=NULL);
0213 double Differential(const Int_Vector &ci,const Int_Vector &cj,
0214 const int set=0);
0215
0216 bool Map(const Amplitude &l,ATOOLS::Flavour_Map &flmap);
0217 bool GaugeTest(const ATOOLS::Vec4D_Vector &moms,const int mode=0);
0218
0219 bool SetMomenta(const ATOOLS::Vec4D_Vector &moms);
0220 void SetColors(const Int_Vector &rc,
0221 const Int_Vector &ac,const int set=0);
0222
0223 bool RSTrigger(PHASIC::Combined_Selector *const sel,const int mode);
0224
0225 void FillCombinations(Combination_Set &combs,CFlavVector_Map &flavs,
0226 SizeT_Map *brs=NULL,const NLO_subevt *sub=NULL) const;
0227 void FillAmplitudes(std::vector<METOOLS::Spin_Amplitudes> &s,
0228 std::vector<std::vector<Complex> > &cols);
0229
0230 void WriteOutGraphs(const std::string &file) const;
0231
0232 void WriteOutAmpFile(const std::string &name);
0233 bool ReadInAmpFile(const std::string &name,My_In_File &file);
0234
0235 void PrintStatistics(std::ostream &str,const int mode=0) const;
0236
0237 double Coupling(const int mode) const;
0238 void FillMEWeights(ATOOLS::ME_Weight_Info &wgtinfo) const;
0239
0240 double KT2Trigger(ATOOLS::NLO_subevt *const sub,const int mode);
0241 void SetNLOMC(PDF::NLOMC_Base *const mc);
0242
0243 void SetCTS(void *const cts);
0244
0245 #ifdef USING__Threading
0246 static void *TCalcJL(void *arg);
0247 #endif
0248
0249
0250 inline void SetColorIntegrator(PHASIC::Color_Integrator *const cint)
0251 { p_colint=cint; }
0252 inline void SetHelicityIntegrator(PHASIC::Helicity_Integrator *const hint)
0253 { p_helint=hint; }
0254
0255 inline PHASIC::Color_Integrator *ColorIntegrator() const
0256 { return p_colint; }
0257 inline PHASIC::Helicity_Integrator *HelicityIntegrator() const
0258 { return p_helint; }
0259
0260 inline double FSSymmetryFactor() const { return m_fsf; }
0261 inline double ISSymmetryFactor() const { return m_sf/m_fsf; }
0262
0263 inline const std::vector<int> &MaxCpl() const { return m_maxcpl; }
0264 inline const std::vector<int> &MinCpl() const { return m_mincpl; }
0265
0266 inline void SetMinNTChannel(const size_t &ntc) { m_minntc=ntc; }
0267
0268 inline const ATOOLS::Vec4D_Vector &Momenta() const { return m_p; }
0269 inline const ATOOLS::Flavour_Vector &Flavours() const { return m_fl; }
0270
0271 inline const Current_Matrix &Currents() const { return m_cur; }
0272
0273 inline void SetDecayInfos(const ATOOLS::DecayInfo_Vector &id)
0274 { m_decid=id; m_dec=m_decid.size(); }
0275 inline const ATOOLS::DecayInfo_Vector &DecayInfos() const
0276 { return m_decid; }
0277
0278 inline void SetNoDecays(const ATOOLS::Flavour_Vector &id) { m_ndc=id; }
0279
0280 inline char PMode() const { return m_pmode; }
0281
0282 inline ATOOLS::NLO_subevtlist &SubEvts() { return m_subs; }
0283
0284 inline void SetLoopME(PHASIC::Virtual_ME2_Base *const me) { p_loop=me; }
0285
0286 inline METOOLS::Dipole_Info *DInfo() const { return p_dinfo; }
0287
0288 inline const std::vector<std::vector<double> > &DSij() const
0289 { return m_dsij; }
0290
0291 inline double Born() const { return m_born; }
0292
0293 };
0294
0295 }
0296
0297 #endif