Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 10:06:36

0001 // CombineMatchingInput.h is a part of the PYTHIA event generator.
0002 // Copyright (C) 2024 Torbjorn Sjostrand.
0003 // PYTHIA is licenced under the GNU GPL v2 or later, see COPYING for details.
0004 // Please respect the MCnet Guidelines, see GUIDELINES for details.
0005 
0006 // This file contains the following classes:
0007 // JetMatchingAlpgenInputAlpgen: combines Alpgen-style MLM matching
0008 //   with Alpgen native format event input.
0009 // JetMatchingMadgraphInputAlpgen: combines Madgraph-style MLM matching
0010 //   with Alpgen native format event input.
0011 // CombineMatchingInput: invokes Alpgen- or Madgraphs-style MLM matching
0012 //   for Madgraph LHEF or Alpgen native format event input.
0013 
0014 #ifndef Pythia8_CombineMatchingInput_H
0015 #define Pythia8_CombineMatchingInput_H
0016 
0017 // Includes and namespace
0018 #include "Pythia8/Pythia.h"
0019 #include "Pythia8Plugins/GeneratorInput.h"
0020 #include "Pythia8Plugins/JetMatching.h"
0021 
0022 namespace Pythia8 {
0023 
0024 //==========================================================================
0025 
0026 // JetMatchingAlpgenInputAlpgen:
0027 // A small UserHooks class that gives the functionality of both AlpgenHooks
0028 // and JetMatchingAlpgen. These classes have one overlapping function,
0029 // 'initAfterBeams()', which is overridden here such that both are called.
0030 
0031 class JetMatchingAlpgenInputAlpgen : public AlpgenHooks,
0032   public JetMatchingAlpgen {
0033 
0034 public:
0035 
0036   // Constructor and destructor.
0037   JetMatchingAlpgenInputAlpgen(Pythia& pythia) : AlpgenHooks(pythia),
0038     JetMatchingAlpgen() { }
0039   ~JetMatchingAlpgenInputAlpgen() {}
0040 
0041   // Initialisation.
0042   virtual bool initAfterBeams() {
0043     if (!AlpgenHooks::initAfterBeams()) return false;
0044     if (!JetMatchingAlpgen::initAfterBeams()) return false;
0045     return true;
0046   }
0047 
0048   // Process level vetos.
0049   virtual bool canVetoProcessLevel() {
0050     return JetMatchingAlpgen::canVetoProcessLevel();
0051   }
0052   virtual bool doVetoProcessLevel(Event & proc) {
0053     return JetMatchingAlpgen::doVetoProcessLevel(proc);
0054   }
0055 
0056   // Parton level vetos (before beam remnants and resonance decays).
0057   virtual bool canVetoPartonLevelEarly() {
0058     return JetMatchingAlpgen::canVetoPartonLevelEarly();
0059   }
0060   virtual bool doVetoPartonLevelEarly(const Event &proc) {
0061     return JetMatchingAlpgen::doVetoPartonLevelEarly(proc);
0062   }
0063 
0064 };
0065 
0066 //==========================================================================
0067 
0068 // JetMatchingMadgraphInputAlpgen:
0069 // A small UserHooks class that gives the functionality of both AlpgenHooks
0070 // and JetMatchingMadgraph. These classes have one overlapping function,
0071 // 'initAfterBeams()', which is overridden here such that both are called.
0072 
0073 class JetMatchingMadgraphInputAlpgen : public AlpgenHooks,
0074   public JetMatchingMadgraph {
0075 
0076 public:
0077 
0078   // Constructor and destructor.
0079   JetMatchingMadgraphInputAlpgen(Pythia& pythia) : AlpgenHooks(pythia),
0080     JetMatchingMadgraph() {}
0081   ~JetMatchingMadgraphInputAlpgen() {}
0082 
0083   // Initialisation.
0084   virtual bool initAfterBeams() {
0085     // Madgraph matching parameters should not be set from Alpgen file.
0086     settingsPtr->flag("JetMatching:setMad",false);
0087     if (!AlpgenHooks::initAfterBeams()) return false;
0088     if (!JetMatchingMadgraph::initAfterBeams()) return false;
0089     return true;
0090   }
0091 
0092   // Process level vetos.
0093   virtual bool canVetoProcessLevel() {
0094     return JetMatchingMadgraph::canVetoProcessLevel();
0095   }
0096   virtual bool doVetoProcessLevel(Event& proc) {
0097     return JetMatchingMadgraph::doVetoProcessLevel(proc);
0098   }
0099 
0100   // Parton level vetos (before beam remnants and resonance decays).
0101   virtual bool canVetoPartonLevelEarly() {
0102     return JetMatchingMadgraph::canVetoPartonLevelEarly();
0103   }
0104   virtual bool doVetoPartonLevelEarly(const Event& proc) {
0105     return JetMatchingMadgraph::doVetoPartonLevelEarly(proc);
0106   }
0107 
0108 };
0109 
0110 //==========================================================================
0111 
0112 class CombineMatchingInput {
0113 
0114 public:
0115 
0116   // Constructor and destructor.
0117   CombineMatchingInput() {}
0118   ~CombineMatchingInput() {}
0119 
0120   // Return a hook relevant for combination of input and matching.
0121   void setHook(Pythia& pythia) {
0122 
0123     // Find input source and matching scheme.
0124     bool isAlpgenFile = ( pythia.word("Alpgen:file") != "void" );
0125     int  scheme = pythia.mode("JetMatching:scheme");
0126 
0127     // Return relevant UserHooks.
0128     if (isAlpgenFile) {
0129       if (scheme == 2)
0130         hook = make_shared<JetMatchingAlpgenInputAlpgen>(pythia);
0131       if (scheme == 1)
0132         hook = make_shared<JetMatchingMadgraphInputAlpgen>(pythia);
0133     } else {
0134       if (scheme == 2)
0135         hook = make_shared<JetMatchingAlpgen>();
0136       if (scheme == 1)
0137         hook = make_shared<JetMatchingMadgraph>();
0138     }
0139 
0140     pythia.setUserHooksPtr(hook);
0141 
0142     return;
0143   }
0144 
0145   shared_ptr<UserHooks> hook;
0146 
0147 };
0148 
0149 //==========================================================================
0150 
0151 } // end namespace Pythia8
0152 
0153 #endif // Pythia8_CombineMatchingInput_H