File indexing completed on 2024-04-06 12:13:56
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
0008 #include <cassert>
0009
0010 #include "GeneratorInterface/Pythia8Interface/plugins/Py8toJetInput.h"
0011
0012 extern "C" {
0013
0014
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
0031 fJetMatching(nullptr),
0032 fJetInputFill(nullptr),
0033 fIsInitialized(false) {
0034
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
0077
0078
0079
0080
0081
0082
0083
0084
0085 fJetMatching->beforeHadronisationExec();
0086
0087 return;
0088 }
0089
0090 bool JetMatchingHook::doVetoPartonLevel(const Event& event)
0091
0092 {
0093
0094
0095
0096
0097
0098 subEvent(event, true);
0099
0100 if (!hepeup_.nup || fJetMatching->isMatchingDone()) {
0101 return true;
0102 }
0103
0104
0105
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
0114
0115 return false;
0116 }