File indexing completed on 2025-04-19 09:10:13
0001 #ifndef SHERPA_PerturbativePhysics_Matrix_Element_Handler_H
0002 #define SHERPA_PerturbativePhysics_Matrix_Element_Handler_H
0003
0004 #include "MODEL/Main/Model_Base.H"
0005 #include "BEAM/Main/Beam_Spectra_Handler.H"
0006 #include "PDF/Main/ISR_Handler.H"
0007 #include "YFS/Main/YFS_Handler.H"
0008 #include "REMNANTS/Main/Remnant_Handler.H"
0009 #include "PHASIC++/Main/Phase_Space_Handler.H"
0010 #include "PHASIC++/Process/Process_Base.H"
0011 #include "PHASIC++/Process/ME_Generators.H"
0012 #include "ATOOLS/Org/CXXFLAGS_PACKAGES.H"
0013 #include "ATOOLS/Org/CXXFLAGS.H"
0014 #include "ATOOLS/Phys/Weight_Info.H"
0015
0016 #include <map>
0017
0018 namespace ATOOLS {
0019 #ifdef USING__GZIP
0020 class igzstream;
0021 class ogzstream;
0022 #endif
0023 }
0024
0025 namespace BEAM { class Beam_Spectra_Handler; }
0026 namespace PDF {
0027 class ISR_Handler;
0028 class NLOMC_Base;
0029 }
0030
0031 namespace PHASIC {
0032 class Single_Process;
0033 class Selector_Key;
0034 }
0035
0036 namespace YFS { class YFS_Handler; }
0037
0038 namespace SHERPA {
0039
0040 class Shower_Handler;
0041
0042 class Matrix_Element_Handler {
0043 public:
0044
0045 typedef std::vector<PHASIC::NLOTypeStringProcessMap_Map*> ProcMap_Vector;
0046
0047 typedef std::map<std::string,std::pair<int,int> > MPIV_Map;
0048 typedef std::map<std::string,std::pair<int,double> > MPDV_Map;
0049 typedef std::map<std::string,std::pair<int,std::string> > MPSV_Map;
0050
0051 struct Processblock_Info {
0052 MPDV_Map m_vmaxerr, m_vmaxeps, m_vefac, m_vrsefac;
0053 MPSV_Map m_veobs, m_vefunc, m_vycut, m_vscale, m_vcoupl, m_vkfac,
0054 m_vnlomode, m_vnlopart, m_vnlocpl,
0055 m_vnlosubv, m_vasscontribs, m_vmegen, m_vrsmegen, m_vloopgen, m_vint,
0056 m_vrsint, m_vgpath, m_vcpl, m_vmaxcpl, m_vmincpl, m_vacpl,
0057 m_vmaxacpl, m_vminacpl, m_vaddname, m_vspecial;
0058 MPIV_Map m_vnmaxq, m_vnminq, m_vamegicmhv, m_vcls, m_vhls,
0059 m_vntchan, m_vmtchan, m_vitmin, m_vrsitmin;
0060 ATOOLS::Scoped_Settings m_selectors;
0061
0062 std::string m_gycut;
0063 int m_cutcore;
0064 size_t m_sort;
0065 inline Processblock_Info(): m_cutcore(0), m_sort(3) {}
0066 };
0067
0068 private :
0069
0070 PHASIC::ME_Generators m_gens;
0071 PHASIC::Process_Vector m_procs;
0072
0073 PHASIC::Process_Base *p_proc;
0074
0075 BEAM::Beam_Spectra_Handler *p_beam;
0076 PDF::ISR_Handler *p_isr;
0077 YFS::YFS_Handler *p_yfs;
0078 REMNANTS::Remnant_Handler *p_remnants;
0079 MODEL::Model_Base *p_model;
0080
0081 std::string m_respath;
0082 int m_eventmode, m_seedmode, m_hasnlo;
0083 bool m_pilotrunenabled;
0084 int m_nloadd, m_ewaddmode, m_qcdaddmode;
0085
0086 ATOOLS::Weight_Info m_evtinfo;
0087
0088 Shower_Handler *p_shower;
0089 PDF::NLOMC_Base *p_nlomc;
0090
0091 double m_sum, m_ovwth, m_weightfactor;
0092 size_t m_ranidx, m_fosettings;
0093 ATOOLS::nlo_mode::code m_nlomode;
0094
0095 #ifdef USING__GZIP
0096 ATOOLS::igzstream *p_ranin;
0097 ATOOLS::ogzstream *p_ranout;
0098 #else
0099 std::ifstream *p_ranin;
0100 std::ofstream *p_ranout;
0101 #endif
0102
0103 ProcMap_Vector m_pmaps;
0104
0105 void RegisterDefaults();
0106 void RegisterMainProcessDefaults(ATOOLS::Scoped_Settings&);
0107
0108 void LimitCouplings
0109 (MPSV_Map &pbi,const size_t &nfs,const std::string &pnid,
0110 std::vector<double> &mincpl,std::vector<double> &maxcpl,const int mode);
0111 void BuildDecays
0112 (PHASIC::Subprocess_Info &ACFS,const std::vector<std::string> &dectags);
0113
0114 struct Single_Process_List_Args {
0115 PHASIC::Process_Info pi;
0116 Processblock_Info pbi;
0117 std::string ini;
0118 std::string fin;
0119 std::vector<std::string> dectags;
0120 };
0121 void BuildSingleProcessList(Single_Process_List_Args&);
0122
0123 std::string MakeOrderString(ATOOLS::Scoped_Settings&&) const;
0124 std::string MakeString(const std::vector<std::string>&) const;
0125
0126 template <typename Type> Type ExtractMPvalue(const std::string& str);
0127 template <typename Type>
0128 void AddMPvalue(std::string lstr,std::string rstr,const Type &val,
0129 std::map<std::string,std::pair<int,Type> >& dv,
0130 const int nfs,const int &priority);
0131 template <typename Type>
0132 bool GetMPvalue(std::map<std::string,std::pair<int,Type> >& dv,
0133 const int nfs,const std::string &pnid,Type &rv);
0134 template <typename Type>
0135 void ExtractMPvalues(std::string str,
0136 std::pair<size_t, size_t> multirange,
0137 const int &priority,
0138 std::map<std::string,std::pair<int,Type> >&) const;
0139
0140 std::vector<PHASIC::Process_Base*> InitializeProcess(
0141 PHASIC::Process_Info, PHASIC::NLOTypeStringProcessMap_Map*&);
0142 std::vector<PHASIC::Process_Base*> InitializeSingleProcess
0143 (const PHASIC::Process_Info &pi,PHASIC::NLOTypeStringProcessMap_Map *&pmap);
0144 void CheckInitialStateOrdering(const PHASIC::Process_Info&);
0145
0146 void BuildProcesses();
0147 void ReadFinalStateMultiIndependentProcessSettings(
0148 const std::string& procname, ATOOLS::Scoped_Settings, Single_Process_List_Args&);
0149 void ReadFinalStateMultiSpecificProcessSettings(
0150 ATOOLS::Scoped_Settings,
0151 Single_Process_List_Args&,
0152 std::string range="-") const;
0153
0154 void InitNLOMC();
0155
0156
0157 void SetRandomSeed();
0158 bool GenerateOneTrialEvent();
0159
0160 public :
0161
0162 Matrix_Element_Handler(MODEL::Model_Base*);
0163
0164 ~Matrix_Element_Handler();
0165
0166 int InitializeProcesses(BEAM::Beam_Spectra_Handler*,
0167 PDF::ISR_Handler*,
0168 YFS::YFS_Handler*);
0169
0170 int InitializeTheReweighting(ATOOLS::Variations_Mode mode);
0171
0172
0173 bool CalculateTotalXSecs();
0174 bool GenerateOneEvent();
0175
0176
0177 inline PHASIC::Process_Base *Process() const { return p_proc; }
0178
0179 inline PHASIC::Process_Vector AllProcesses() const { return m_procs; }
0180
0181 inline PHASIC::ME_Generators *Generators() { return &m_gens; }
0182
0183 inline ProcMap_Vector ProcMaps() const { return m_pmaps;}
0184
0185 inline int EventGenerationMode() const { return m_eventmode; }
0186
0187 inline ATOOLS::Weight_Info WeightInfo() const { return m_evtinfo; }
0188
0189 inline void SetRemnantHandler(REMNANTS::Remnant_Handler *const rh) {
0190 p_remnants = rh;
0191 }
0192 inline void SetShowerHandler(Shower_Handler *const sh) {
0193 p_shower=sh;
0194 }
0195 inline BEAM::Beam_Spectra_Handler *GetBeam() const { return p_beam; }
0196 inline PDF::ISR_Handler *GetISR() const { return p_isr; }
0197 inline YFS::YFS_Handler *GetYFS() const { return p_yfs; }
0198 inline REMNANTS::Remnant_Handler *Remnants() const { return p_remnants; }
0199 inline Shower_Handler *Shower() const { return p_shower; }
0200
0201 inline double WeightFactor() const { return m_weightfactor; }
0202
0203 inline double Sum() const { return m_sum; }
0204
0205 inline int HasNLO() const { return m_hasnlo; }
0206
0207 double GetWeight(const ATOOLS::Cluster_Amplitude &l,
0208 const ATOOLS::nlo_type::code type,
0209 const int mode) const;
0210
0211 inline int SeedMode() const { return m_seedmode; }
0212
0213 static size_t ExtractFlavours(PHASIC::Subprocess_Info &infos,std::string buffer);
0214
0215 void CheckAssociatedContributionsSetup(
0216 const std::set<ATOOLS::asscontrib::type>& calculated_asscontribs) const;
0217 };
0218
0219 }
0220
0221 #endif
0222