Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-19 09:10:14

0001 #ifndef SHERPA_Tools_HepMC3_Interface_H
0002 #define SHERPA_Tools_HepMC3_Interface_H
0003 #include "ATOOLS/Org/CXXFLAGS_PACKAGES.H"
0004 
0005 #ifdef USING__HEPMC3
0006 
0007 #include "ATOOLS/Org/CXXFLAGS.H"
0008 #include "ATOOLS/Org/Message.H"
0009 #include "ATOOLS/Phys/Blob.H"
0010 #include "ATOOLS/Phys/NLO_Types.H"
0011 #include "ATOOLS/Phys/NLO_Subevt.H"
0012 #include "ATOOLS/Phys/Weight_Info.H"
0013 #include "PHASIC++/Process/Subprocess_Info.H"
0014 #include "ATOOLS/Phys/Variations.H"
0015 
0016 #include <map>
0017 #include <set>
0018 #include <memory>
0019 
0020 namespace HepMC3 {
0021   class GenEvent;
0022   class GenVertex;
0023   class GenRunInfo;
0024   class GenParticle;
0025   class GenCrossSection;
0026 
0027 using GenVertexPtr = std::shared_ptr<GenVertex>;
0028 using GenParticlePtr = std::shared_ptr<GenParticle>;
0029 
0030 }
0031 
0032 namespace ATOOLS {
0033   class Blob_List;
0034   class Particle;
0035   class ME_Weight_Info;
0036   class NLO_subevtlist;
0037   class PDF_Info;
0038 }
0039 
0040 namespace SHERPA {
0041 
0042   class EventInfo3 {
0043   private:
0044     ATOOLS::Blob * p_sp;
0045     bool m_usenamedweights, m_extendedweights;
0046     std::vector<ATOOLS::Variations_Source> m_variationsources;
0047     std::vector<double> m_orders;
0048     double m_wgt, m_mewgt, m_wgtnorm, m_ntrials, m_pswgt, m_pwgt;
0049     double m_mur2, m_muf12, m_muf22;
0050     double m_alphas, m_alpha;
0051     bool m_userhook;
0052     double m_userweight;
0053     ATOOLS::nlo_type::code m_type;
0054     ATOOLS::ME_Weight_Info * p_wgtinfo;
0055     ATOOLS::PDF_Info * p_pdfinfo;
0056     ATOOLS::NLO_subevtlist * p_subevtlist;
0057     ATOOLS::Weights_Map m_wgtmap;
0058 
0059     void ReadIn(ATOOLS::Blob_Data_Base * &db, std::string name, bool abort);
0060 
0061   public:
0062     EventInfo3(ATOOLS::Blob * sp, const double &wgt,
0063               bool namedweights,
0064               bool extendedweights,
0065               bool includemeonlyweights);
0066     EventInfo3(const EventInfo3 &evtinfo);
0067     ~EventInfo3() {}
0068     bool WriteTo(HepMC3::GenEvent &evt, const int& idx=-1);
0069     inline const ATOOLS::NLO_subevtlist * SubEvtList() { return p_subevtlist; }
0070     inline void SetWeight(const double &wgt)          { m_wgt=wgt; }
0071     inline void SetMEWeight(const double &mewgt)      { m_mewgt=mewgt; }
0072     inline void SetPartonicWeight(const double& pwgt) { m_pwgt=pwgt; }
0073     inline void SetMuR2(const double &mur2)           { m_mur2=mur2; }
0074     inline void SetMuF12(const double &muf12)         { m_muf12=muf12; }
0075     inline void SetMuF22(const double &muf22)         { m_muf22=muf22; }
0076     void SetAlphaS();
0077     void SetAlpha();
0078   };
0079 
0080   class HepMC3_Interface {
0081   private :
0082     bool m_usenamedweights, m_extendedweights, m_includemeonlyweights;
0083     bool m_hepmctree;
0084 
0085     std::map<ATOOLS::Blob*,HepMC3::GenVertexPtr > m_blob2genvertex;
0086     std::map<ATOOLS::Particle*,HepMC3::GenParticlePtr> m_particle2genparticle;
0087     std::set<ATOOLS::btp::code> m_ignoreblobs;
0088 
0089     HepMC3::GenEvent *p_event;
0090     std::shared_ptr<HepMC3::GenRunInfo> m_runinfo;
0091     std::vector<HepMC3::GenEvent*> m_subeventlist;
0092 
0093     std::shared_ptr<HepMC3::GenParticle> MakeGenParticle(const ATOOLS::Vec4D&,
0094                                                          const ATOOLS::Flavour&,
0095                                                          bool incoming);
0096 
0097   public:
0098     // constructor
0099     HepMC3_Interface();
0100 
0101     // destructor
0102     ~HepMC3_Interface();
0103 
0104     // member functions
0105     bool Sherpa2HepMC(ATOOLS::Blob_List *const blobs, HepMC3::GenEvent& event);
0106     bool Sherpa2HepMC(ATOOLS::Blob_List *const blobs, std::shared_ptr<HepMC3::GenRunInfo> run= std::shared_ptr<HepMC3::GenRunInfo>());
0107     bool Sherpa2HepMCBlobtoGenVertex(ATOOLS::Blob *, HepMC3::GenVertexPtr &, HepMC3::GenEvent& event ); 
0108     bool Sherpa2HepMC(ATOOLS::Particle *, HepMC3::GenParticlePtr &);
0109 
0110     bool Sherpa2ShortHepMC(ATOOLS::Blob_List *const blobs, HepMC3::GenEvent& event);
0111     bool Sherpa2ShortHepMC(ATOOLS::Blob_List *const blobs, std::shared_ptr<HepMC3::GenRunInfo> run= std::shared_ptr<HepMC3::GenRunInfo>());
0112     bool SubEvtList2ShortHepMC(EventInfo3 &evtinfo, std::shared_ptr<HepMC3::GenRunInfo> run);
0113 
0114     void AddCrossSection(HepMC3::GenEvent& event,
0115                          const ATOOLS::Weights_Map& xs,
0116                          const ATOOLS::Weights_Map& err);
0117 
0118     // inline functions
0119     inline HepMC3::GenEvent* GenEvent() { return p_event; }
0120     // For RivetInterface to enable ME/shower only analysis of fully hadronised event
0121     inline void Ignore(ATOOLS::btp::code type) { m_ignoreblobs.insert(type); }
0122 
0123     inline HepMC3::GenEvent* GenSubEvent(size_t i)
0124     { if (i<m_subeventlist.size()) return m_subeventlist[i]; return NULL; }
0125     inline std::vector<HepMC3::GenEvent*> GenSubEventList()
0126     { return m_subeventlist; }
0127 
0128     inline void SetHepMCNamedWeights(bool x)   { m_usenamedweights=x; }
0129     inline bool HepMCNamedWeights()            { return m_usenamedweights; }
0130     inline void SetHepMCExtendedWeights(bool x){ m_extendedweights=x; }
0131     inline bool HepMCExtendedWeights()         { return m_extendedweights; }
0132     inline void SetHepMCTreeLike(bool x)       { m_hepmctree=x; }
0133     inline bool HepMCTreeLike()                { return m_hepmctree; }
0134     inline void SetHepMCIncludeMEOnlyVariations(bool x)
0135     { m_includemeonlyweights=x; }
0136 
0137     void DeleteGenSubEventList();
0138 
0139   };// end of class HepMC3_Interface
0140 
0141 }// end of namespace SHERPA
0142 
0143 #endif
0144 #endif