9 #include <boost/algorithm/string/classification.hpp> 10 #include <boost/algorithm/string/split.hpp> 97 skipEvents_(params.getUntrackedParameter<unsigned
int>(
"skipEvents", 0)),
105 std::vector<std::string> allFileNames =
fileNames();
108 if (allFileNames.size() != 1)
110 <<
"AlpgenSource needs exactly one file specified " 111 "for now." << std::endl;
117 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource only supports the file: scheme " 118 "for now." << std::endl;
126 <<
"AlpgenSource was unable to open the file \"" 127 <<
fileName_ <<
"_unw.par\"." << std::endl;
131 while(reader.getline(buffer,
sizeof buffer))
139 <<
"AlpgenSource was unable to parse the Alpgen " 140 <<
"unweighted parameter file." << std::endl;
143 produces<LHERunInfoProduct, edm::Transition::BeginRun>();
144 produces<LHEEventProduct>();
154 std::ostringstream ss;
155 ss << std::setw(9) << pdgId <<
" " << std::scientific
157 << comment << std::endl;
169 heprup.
IDBMUP.first = 2212;
172 heprup.
IDBMUP.second = 2212;
175 heprup.
IDBMUP.second = -2212;
179 <<
"AlpgenSource was unable to understand the ih2 " 180 <<
"parameter." << std::endl;
189 heprup.
PDFGUP.second = -1;
191 heprup.
PDFSUP.second = -1;
212 comments.
addLine(
"\tExtracted by AlpgenInterface\n");
217 slha.
addLine(
"\n# SLHA header containing masses from Alpgen\n");
218 slha.
addLine(
"Block MASS # Mass spectrum (kinematic masses)\n");
232 std::ifstream wgtascii((
fileName_+
".wgt").c_str());
233 while(wgtascii.getline(buffer,512)) {
240 std::ifstream parascii((
fileName_+
".par").c_str());
241 while(parascii.getline(buffer,512)) {
252 while(extraascii.getline(buffer,512)) {
259 runInfo->addHeader(comments);
262 runInfo->addHeader(lheAlpgenWgtHeader);
264 runInfo->addHeader(lheAlpgenParHeader);
265 runInfo->addHeader(slha);
267 runInfo->addHeader(extraHeader);
274 <<
"AlpgenSource was unable to open the file \"" 282 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
286 <<
"Requested Alpgen parameter \"" 288 "not found in Alpgen parameter file." << std::endl;
290 return T(pos->second);
295 const T &defValue)
const 297 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
302 return T(pos->second);
326 std::istringstream
ls(buffer);
329 ls >> dummy >> dummy;
332 ls >> nPart >> sWgtRes >> sQ;
334 if (ls.bad() || nPart < 1 || nPart > 1000)
346 for(
int i = 0;
i != 2; ++
i) {
348 std::istringstream
ls(buffer);
350 int colour1; ls >> colour1;
351 int colour2; ls >> colour2;
352 double zMomentum; ls >> zMomentum;
362 hepeup.
PUP[
i][0] = 0.;
363 hepeup.
PUP[
i][1] = 0.;
364 hepeup.
PUP[
i][2] = zMomentum;
365 hepeup.
PUP[
i][3] = std::fabs(zMomentum);
366 hepeup.
PUP[
i][4] = 0.;
367 if (colour1) colour1 += 500;
368 if (colour2) colour2 += 500;
369 hepeup.
ICOLUP[
i].first = colour1;
370 hepeup.
ICOLUP[
i].second = colour2;
376 std::istringstream
ls(buffer);
378 int colour1; ls >> colour1;
379 int colour2; ls >> colour2;
380 double px, py, pz,
mass;
381 ls >> px >> py >> pz >>
mass;
392 hepeup.
PUP[
i][0] = px;
393 hepeup.
PUP[
i][1] = py;
394 hepeup.
PUP[
i][2] = pz;
397 if (colour1) colour1 += 500;
398 if (colour2) colour2 += 500;
399 hepeup.
ICOLUP[
i].first = colour1;
400 hepeup.
ICOLUP[
i].second = colour2;
420 <<
"AlpgenSource is not able read event no. " 475 <<
"Unrecognized IHRD process code" << std::endl;
479 std::unique_ptr<LHEEventProduct> lheEvent(
new LHEEventProduct(hepeup));
AlpgenSource(const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc)
Constructor.
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.
std::vector< std::pair< int, int > > MOTHUP
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.
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.
std::vector< std::pair< int, int > > ICOLUP
unsigned int processID() const