Go to the documentation of this file.00001 #include <iostream>
00002 #include <cstring>
00003 #include <vector>
00004 #include <memory>
00005 #include <string>
00006
00007 #include <HepMC/GenEvent.h>
00008
00009 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00010 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00011
00012 #include "GeneratorInterface/LHEInterface/interface/LHERunInfo.h"
00013 #include "GeneratorInterface/LHEInterface/interface/LHEEvent.h"
00014 #include "GeneratorInterface/PartonShowerVeto/interface/JetMatchingAlpgen.h"
00015
00016 namespace gen {
00017
00018 extern "C" {
00019
00020
00021
00022 extern void alsetp_();
00023
00024 extern void alveto_(int *ipveto);
00025
00026 extern void dbpart_();
00027 extern void pyupre_();
00028
00029 void alshcd_(char csho[3]);
00030 void alshen_();
00031 }
00032
00033
00034 JetMatchingAlpgen::JetMatchingAlpgen(const edm::ParameterSet ¶ms) :
00035 JetMatching(params),
00036 applyMatching(params.getParameter<bool>("applyMatching")),
00037 runInitialized(false)
00038 {
00039 ahopts_.etclus = params.getParameter<double>("etMin");
00040 ahopts_.rclus = params.getParameter<double>("drMin");
00041 ahopts_.iexc = params.getParameter<bool>("exclusive");
00042 }
00043
00044
00045 JetMatchingAlpgen::~JetMatchingAlpgen()
00046 {
00047 }
00048
00049 std::set<std::string> JetMatchingAlpgen::capabilities() const
00050 {
00051 std::set<std::string> result;
00052 result.insert("psFinalState");
00053 result.insert("hepevt");
00054 result.insert("pythia6");
00055 return result;
00056 }
00057
00058
00059
00060 void JetMatchingAlpgen::init(const lhef::LHERunInfo* runInfo)
00061 {
00062
00063
00064 std::vector<std::string> headerLines = runInfo->findHeader("AlpgenUnwParFile");
00065 if (headerLines.empty())
00066 throw cms::Exception("Generator|PartonShowerVeto")
00067 << "In order to use Alpgen jet matching, "
00068 "the input file has to contain the corresponding "
00069 "Alpgen headers." << std::endl;
00070
00071
00072 header.parse(headerLines.begin(), headerLines.end());
00073
00074
00075
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087
00088
00089
00090
00091
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101
00102 std::copy(header.masses, header.masses + AlpgenHeader::MASS_MAX, ahppara_.masses);
00103 ahppara_.ihrd = header.ihrd;
00104 ahppara_.ebeam = header.ebeam;
00105
00106 for(std::map<AlpgenHeader::Parameter, double>::const_iterator iter =
00107 header.params.begin(); iter != header.params.end(); ++iter) {
00108 if (iter->first <= 0 || iter->first >= (int)AHPARS::nparam - 1)
00109 continue;
00110 ahpars_.parval[(int)iter->first - 1] = iter->second;
00111 }
00112
00113
00114 alsetp_();
00115
00116
00117 runInitialized = true;
00118 }
00119
00120 void JetMatchingAlpgen::beforeHadronisation(const lhef::LHEEvent* event)
00121 {
00122
00123 if (!runInitialized)
00124 throw cms::Exception("Generator|PartonShowerVeto")
00125 << "Run not initialized in JetMatchingAlpgen"
00126 << std::endl;
00127
00128
00129
00130
00131
00132
00133
00134
00135 eventInitialized = true;
00136 }
00137
00138 int JetMatchingAlpgen::match(const HepMC::GenEvent *partonLevel,
00139 const HepMC::GenEvent *finalState,
00140 bool showeredFinalState)
00141 {
00142 if (!showeredFinalState)
00143 throw cms::Exception("Generator|PartonShowerVeto")
00144 << "Alpgen matching expected parton shower "
00145 "final state." << std::endl;
00146
00147 if (!runInitialized)
00148 throw cms::Exception("Generator|PartonShowerVeto")
00149 << "Run not initialized in JetMatchingAlpgen"
00150 << std::endl;
00151
00152 if (!eventInitialized)
00153 throw cms::Exception("Generator|PartonShowerVeto")
00154 << "Event not initialized in JetMatchingAlpgen"
00155 << std::endl;
00156
00157
00158
00159 if(!applyMatching) return 0;
00160
00161
00162 int veto = 0;
00163 alveto_(&veto);
00164
00165 eventInitialized = false;
00166
00167
00168
00169
00170
00171 return veto ? 1 : 0;
00172 }
00173
00174 void alshcd_(char csho[3])
00175 {
00176 std::strncpy(csho, "PYT", 3);
00177 }
00178
00179 void alshen_()
00180 {
00181 }
00182
00183 }