Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-11 04:37:14

0001 #include "GeneratorInterface/Pythia8Interface/plugins/JetMatchingHook.h"
0002 #include "GeneratorInterface/PartonShowerVeto/interface/JetMatchingMadgraph.h"
0003 #include "GeneratorInterface/PartonShowerVeto/interface/JetMatchingMGFastJet.h"
0004 
0005 #include "FWCore/Utilities/interface/Exception.h"
0006 
0007 //#include "HepMC/HEPEVT_Wrapper.h"
0008 #include <cassert>
0009 
0010 #include "GeneratorInterface/Pythia8Interface/plugins/Py8toJetInput.h"
0011 
0012 extern "C" {
0013 // this is patchup for Py6 common block because
0014 // several elements of the VINT array are used in the matching process
0015 
0016 extern struct {
0017   int mint[400];
0018   double vint[400];
0019 } pyint1_;
0020 }
0021 
0022 using namespace gen;
0023 using namespace Pythia8;
0024 
0025 JetMatchingHook::JetMatchingHook(const edm::ParameterSet& ps, const Info* info)
0026     : UserHooks(),
0027       fRunBlock(nullptr),
0028       fEventBlock(nullptr),
0029       fEventNumber(0),
0030       //      fInfoPtr(info),
0031       fJetMatching(nullptr),
0032       fJetInputFill(nullptr),
0033       fIsInitialized(false) {
0034   //  assert(fInfoPtr);
0035 
0036   std::string scheme = ps.getParameter<std::string>("scheme");
0037 
0038   if (scheme == "Madgraph") {
0039     fJetMatching = new JetMatchingMadgraph(ps);
0040     fJetInputFill = new Py8toJetInputHEPEVT();
0041   } else if (scheme == "MadgraphFastJet") {
0042     fJetMatching = new JetMatchingMGFastJet(ps);
0043     fJetInputFill = new Py8toJetInput();
0044   } else if (scheme == "MLM" || scheme == "Alpgen") {
0045     throw cms::Exception("JetMatching") << "Port of " << scheme << "scheme \""
0046                                         << "\""
0047                                            " for parton-shower matching is still in progress."
0048                                         << std::endl;
0049   } else
0050     throw cms::Exception("InvalidJetMatching") << "Unknown scheme \"" << scheme
0051                                                << "\""
0052                                                   " specified for parton-shower matching."
0053                                                << std::endl;
0054 }
0055 
0056 JetMatchingHook::~JetMatchingHook() {
0057   if (fJetMatching)
0058     delete fJetMatching;
0059 }
0060 
0061 void JetMatchingHook::init(lhef::LHERunInfo* runInfo) {
0062   setLHERunInfo(runInfo);
0063   if (!fRunBlock) {
0064     throw cms::Exception("JetMatching") << "Invalid RunInfo" << std::endl;
0065   }
0066   fJetMatching->init(runInfo);
0067   double etaMax = fJetMatching->getJetEtaMax();
0068   fJetInputFill->setJetEtaMax(etaMax);
0069   return;
0070 }
0071 
0072 void JetMatchingHook::beforeHadronization(lhef::LHEEvent* lhee) {
0073   setLHEEvent(lhee);
0074   fJetMatching->beforeHadronisation(lhee);
0075 
0076   // here we'll have to adjust, if needed, for "massless" particles
0077   // from earlier Madgraph version(s)
0078   // also, we'll have to setup elements of the Py6 fortran array
0079   // VINT(357), VINT(358), VINT(360) and VINT(390)
0080   // if ( fJetMatching->getMatchingScheme() == "Madgraph" )
0081   // {
0082   //
0083   // }
0084 
0085   fJetMatching->beforeHadronisationExec();
0086 
0087   return;
0088 }
0089 
0090 bool JetMatchingHook::doVetoPartonLevel(const Event& event)
0091 // JetMatchingHook::doVetoPartonLevelEarly( const Event& event )
0092 {
0093   // event.list();
0094 
0095   // extract "hardest" event - the output will go into workEvent,
0096   // which is a data mamber of base class UserHooks
0097   //
0098   subEvent(event, true);
0099 
0100   if (!hepeup_.nup || fJetMatching->isMatchingDone()) {
0101     return true;
0102   }
0103 
0104   //
0105   // bool jmtch = fJetMatching->match( 0, 0, true ); // true if veto-ed, false if accepted (not veto-ed)
0106   std::vector<fastjet::PseudoJet> jetInput =
0107       fJetInputFill->fillJetAlgoInput(event, workEvent, fEventBlock, fJetMatching->getPartonList());
0108   bool jmtch = fJetMatching->match(fEventBlock, &jetInput);
0109   if (jmtch) {
0110     return true;
0111   }
0112 
0113   // Do not veto events that got this far
0114   //
0115   return false;
0116 }