11 #include <boost/algorithm/string/classification.hpp> 12 #include <boost/algorithm/string/split.hpp> 96 skipEvents_(
params.getUntrackedParameter<unsigned
int>(
"skipEvents", 0)),
98 lheAlpgenUnwParHeader(
"AlpgenUnwParFile"),
99 extraHeaderFileName_(
params.getUntrackedParameter<
std::
string>(
"extraHeaderFileName",
"")),
100 extraHeaderName_(
params.getUntrackedParameter<
std::
string>(
"extraHeaderName",
"")),
101 writeAlpgenWgtFile(
params.getUntrackedParameter<
bool>(
"writeAlpgenWgtFile",
true)),
102 writeAlpgenParFile(
params.getUntrackedParameter<
bool>(
"writeAlpgenParFile",
true)),
103 writeExtraHeader(
params.getUntrackedParameter<
bool>(
"writeExtraHeader",
false)) {
104 std::vector<std::string> allFileNames =
fileNames(0);
107 if (allFileNames.size() != 1)
108 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource needs exactly one file specified " 116 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource only supports the file: scheme " 126 <<
"AlpgenSource was unable to open the file \"" <<
fileName_ <<
"_unw.par\"." << std::endl;
136 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource was unable to parse the Alpgen " 137 <<
"unweighted parameter file." << std::endl;
140 produces<LHERunInfoProduct, edm::Transition::BeginRun>();
141 produces<LHEEventProduct>();
147 std::ostringstream
ss;
149 << comment << std::endl;
160 heprup.
IDBMUP.first = 2212;
163 heprup.
IDBMUP.second = 2212;
166 heprup.
IDBMUP.second = -2212;
169 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource was unable to understand the ih2 " 170 <<
"parameter." << std::endl;
178 heprup.
PDFGUP.second = -1;
180 heprup.
PDFSUP.second = -1;
201 comments.
addLine(
"\tExtracted by AlpgenInterface\n");
206 slha.
addLine(
"\n# SLHA header containing masses from Alpgen\n");
207 slha.
addLine(
"Block MASS # Mass spectrum (kinematic masses)\n");
221 std::ifstream wgtascii((
fileName_ +
".wgt").c_str());
222 while (wgtascii.getline(
buffer, 512)) {
229 std::ifstream parascii((
fileName_ +
".par").c_str());
230 while (parascii.getline(
buffer, 512)) {
241 while (extraascii.getline(
buffer, 512)) {
251 runInfo->addHeader(lheAlpgenWgtHeader);
253 runInfo->addHeader(lheAlpgenParHeader);
256 runInfo->addHeader(extraHeader);
263 <<
"AlpgenSource was unable to open the file \"" <<
fileName_ <<
".unw\"." << std::endl;
266 template <
typename T>
273 "not found in Alpgen parameter file." 276 return T(
pos->second);
279 template <
typename T>
285 return T(
pos->second);
314 if (
ls.bad() || nPart < 1 || nPart > 1000)
326 for (
int i = 0;
i != 2; ++
i) {
346 hepeup.
PUP[
i][0] = 0.;
347 hepeup.
PUP[
i][1] = 0.;
348 hepeup.
PUP[
i][2] = zMomentum;
349 hepeup.
PUP[
i][3] = std::fabs(zMomentum);
350 hepeup.
PUP[
i][4] = 0.;
355 hepeup.
ICOLUP[
i].first = colour1;
356 hepeup.
ICOLUP[
i].second = colour2;
383 hepeup.
PUP[
i][2] = pz;
390 hepeup.
ICOLUP[
i].first = colour1;
391 hepeup.
ICOLUP[
i].second = colour2;
399 hepeup_ = std::make_unique<lhef::HEPEUP>();
410 <<
"AlpgenSource is not able read event no. " <<
nEvent_ << std::endl;
460 throw cms::Exception(
"Generator|AlpgenInterface") <<
"Unrecognized IHRD process code" << std::endl;
464 std::unique_ptr<LHEEventProduct> lheEvent(
new LHEEventProduct(hepeup));
std::string slhaMassLine(int pdgId, AlpgenHeader::Masses mass, const std::string &comment) const
AlpgenSource(const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc)
Constructor.
std::vector< std::pair< int, int > > ICOLUP
std::pair< double, double > EBMUP
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
T getParameter(AlpgenHeader::Parameter index) const
Function to get parameter by name from AlpgenHeader.
std::pair< int, int > IDBMUP
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
bool setRunAndEventInfo(edm::EventID &, edm::TimeValue_t &, edm::EventAuxiliary::ExperimentType &) override
unsigned long nEvent_
Number of events.
unsigned long skipEvents_
Number of events to skip.
std::pair< int, int > PDFGUP
bool writeAlpgenWgtFile
configuration flags
std::unique_ptr< lhef::HEPEUP > hepeup_
void fixEventWZ(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 1,2,3,4,10,14,15.
LHERunInfoProduct::Header lheAlpgenUnwParHeader
Alpgen _unw.par file as a LHE header.
void fixEventMultiBoson(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 5.
void fixEventHiggsTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 8.
std::string extraHeaderFileName_
Name of the extra header file.
std::vector< FiveVector > PUP
unsigned int processID() const
~AlpgenSource() override
Destructor.
std::vector< std::pair< int, int > > MOTHUP
unsigned long long TimeValue_t
void produce(edm::Event &event) override
std::vector< double > XERRUP
std::string fileName_
Name of the input file.
std::vector< double > XMAXUP
TString nPart(Int_t part, TString string, TString delimit=";", Bool_t removerest=true)
std::string extraHeaderName_
Name given to the extra header.
void fixEventSingleTop(lhef::HEPEUP &hepeup, double mb, int itopprc)
Fixes Event Record for ihrd = 13.
void beginRun(edm::Run &run) override
std::pair< int, int > PDFSUP
std::vector< std::string > fileNames(unsigned iCatalog) const
void fixEventTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 6.
std::vector< double > XSECUP
bool readAlpgenEvent(lhef::HEPEUP &hepeup)
Read an event and put it into the HEPEUP.