9 #include <boost/algorithm/string/classification.hpp>
10 #include <boost/algorithm/string/split.hpp>
96 edm::ProducerSourceFromFiles(params, desc,
false),
97 skipEvents_(params.getUntrackedParameter<unsigned int>(
"skipEvents", 0)),
98 nEvent_(0), 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))
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::InRun>();
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;
396 hepeup.
PUP[
i][4] = mass;
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;
virtual ~AlpgenSource()
Destructor.
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.
virtual 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
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger but the state exists so we define the behavior If all triggers are the negative crieriion will lead to accepting the event(this again matches the behavior of"!*"before the partial wildcard feature was incorporated).The per-event"cost"of each negative criterion with multiple relevant triggers is about the same as!*was in the past
unsigned long long TimeValue_t
virtual 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.
virtual void beginRun(edm::Run &run) override
std::pair< int, int > PDFSUP
EventNumber_t event() const
T getParameter(AlpgenHeader::Parameter index) const
Function to get parameter by name from AlpgenHeader.
void put(std::auto_ptr< PROD > product)
Put a new product.
void fixEventTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 6.
volatile std::atomic< bool > shutdown_flag false
std::vector< double > XSECUP
int flavour(const Candidate &part)
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