9 #include <boost/algorithm/string/classification.hpp> 10 #include <boost/algorithm/string/split.hpp> 94 skipEvents_(params.getUntrackedParameter<unsigned
int>(
"skipEvents", 0)),
102 std::vector<std::string> allFileNames =
fileNames();
105 if (allFileNames.size() != 1)
106 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource needs exactly one file specified " 114 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource only supports the file: scheme " 124 <<
"AlpgenSource was unable to open the file \"" <<
fileName_ <<
"_unw.par\"." << std::endl;
128 while (reader.getline(buffer,
sizeof buffer))
134 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource was unable to parse the Alpgen " 135 <<
"unweighted parameter file." << std::endl;
138 produces<LHERunInfoProduct, edm::Transition::BeginRun>();
139 produces<LHEEventProduct>();
145 std::ostringstream
ss;
146 ss << std::setw(9) << pdgId <<
" " << std::scientific << std::setprecision(9) <<
header.
masses[
mass] <<
" # " 147 << comment << std::endl;
158 heprup.
IDBMUP.first = 2212;
161 heprup.
IDBMUP.second = 2212;
164 heprup.
IDBMUP.second = -2212;
167 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource was unable to understand the ih2 " 168 <<
"parameter." << std::endl;
176 heprup.
PDFGUP.second = -1;
178 heprup.
PDFSUP.second = -1;
199 comments.
addLine(
"\tExtracted by AlpgenInterface\n");
204 slha.
addLine(
"\n# SLHA header containing masses from Alpgen\n");
205 slha.
addLine(
"Block MASS # Mass spectrum (kinematic masses)\n");
219 std::ifstream wgtascii((
fileName_ +
".wgt").c_str());
220 while (wgtascii.getline(buffer, 512)) {
227 std::ifstream parascii((
fileName_ +
".par").c_str());
228 while (parascii.getline(buffer, 512)) {
239 while (extraascii.getline(buffer, 512)) {
246 runInfo->addHeader(comments);
249 runInfo->addHeader(lheAlpgenWgtHeader);
251 runInfo->addHeader(lheAlpgenParHeader);
252 runInfo->addHeader(slha);
254 runInfo->addHeader(extraHeader);
261 <<
"AlpgenSource was unable to open the file \"" <<
fileName_ <<
".unw\"." << std::endl;
264 template <
typename T>
266 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
header.
params.find(index);
271 "not found in Alpgen parameter file." 274 return T(pos->second);
277 template <
typename T>
279 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
header.
params.find(index);
283 return T(pos->second);
304 std::istringstream
ls(buffer);
307 ls >> dummy >> dummy;
310 ls >> nPart >> sWgtRes >> sQ;
312 if (ls.bad() || nPart < 1 || nPart > 1000)
324 for (
int i = 0;
i != 2; ++
i) {
326 std::istringstream
ls(buffer);
344 hepeup.
PUP[
i][0] = 0.;
345 hepeup.
PUP[
i][1] = 0.;
346 hepeup.
PUP[
i][2] = zMomentum;
347 hepeup.
PUP[
i][3] = std::fabs(zMomentum);
348 hepeup.
PUP[
i][4] = 0.;
353 hepeup.
ICOLUP[
i].first = colour1;
354 hepeup.
ICOLUP[
i].second = colour2;
360 std::istringstream
ls(buffer);
368 ls >> px >> py >> pz >>
mass;
381 hepeup.
PUP[
i][2] = pz;
388 hepeup.
ICOLUP[
i].first = colour1;
389 hepeup.
ICOLUP[
i].second = colour2;
408 <<
"AlpgenSource is not able read event no. " <<
nEvent_ << std::endl;
458 throw cms::Exception(
"Generator|AlpgenInterface") <<
"Unrecognized IHRD process code" << std::endl;
462 std::unique_ptr<LHEEventProduct> lheEvent(
new LHEEventProduct(hepeup));
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.
std::pair< int, int > IDBMUP
std::unique_ptr< std::ifstream > inputFile_
Pointer to the input file.
ProducerSourceFromFiles(ParameterSet const &pset, InputSourceDescription const &desc, bool realData)
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::vector< std::string > const & fileNames() const
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
~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 slhaMassLine(int pdgId, AlpgenHeader::Masses mass, const std::string &comment) const
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
void put(std::unique_ptr< PROD > product)
Put a new product.
std::pair< int, int > PDFSUP
T getParameter(AlpgenHeader::Parameter index) const
Function to get parameter by name from AlpgenHeader.
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.
unsigned int processID() const