9 #include <boost/algorithm/string/classification.hpp>
10 #include <boost/algorithm/string/split.hpp>
52 const std::string &
comment)
const;
93 edm::ExternalInputSource(params, desc,
false),
94 skipEvents_(params.getUntrackedParameter<unsigned int>(
"skipEvents", 0)),
95 nEvent_(0), lheAlpgenUnwParHeader(
"AlpgenUnwParFile"),
96 extraHeaderFileName_(params.getUntrackedParameter<std::string>(
"extraHeaderFileName",
"")),
97 extraHeaderName_(params.getUntrackedParameter<std::string>(
"extraHeaderName",
"")),
98 writeAlpgenWgtFile(params.getUntrackedParameter<bool>(
"writeAlpgenWgtFile",
true)),
99 writeAlpgenParFile(params.getUntrackedParameter<bool>(
"writeAlpgenParFile",
true)),
100 writeExtraHeader(params.getUntrackedParameter<bool>(
"writeExtraHeader",
false))
102 std::vector<std::string> allFileNames =
fileNames();
105 if (allFileNames.size() != 1)
107 <<
"AlpgenSource needs exactly one file specified "
108 "for now." << std::endl;
114 throw cms::Exception(
"Generator|AlpgenInterface") <<
"AlpgenSource only supports the file: scheme "
115 "for now." << std::endl;
123 <<
"AlpgenSource was unable to open the file \""
124 <<
fileName_ <<
"_unw.par\"." << std::endl;
128 while(reader.getline(buffer,
sizeof buffer))
136 <<
"AlpgenSource was unable to parse the Alpgen "
137 <<
"unweighted parameter file." << std::endl;
140 produces<LHERunInfoProduct, edm::InRun>();
141 produces<LHEEventProduct>();
149 const std::string &
comment)
const
151 std::ostringstream ss;
152 ss << std::setw(9) << pdgId <<
" " << std::scientific
154 << comment << std::endl;
166 heprup.
IDBMUP.first = 2212;
169 heprup.
IDBMUP.second = 2212;
172 heprup.
IDBMUP.second = -2212;
176 <<
"AlpgenSource was unable to understand the ih2 "
177 <<
"parameter." << std::endl;
186 heprup.
PDFGUP.second = -1;
188 heprup.
PDFSUP.second = -1;
209 comments.
addLine(
"\tExtracted by AlpgenInterface\n");
214 slha.
addLine(
"\n# SLHA header containing masses from Alpgen\n");
215 slha.
addLine(
"Block MASS # Mass spectrum (kinematic masses)\n");
229 std::ifstream wgtascii((
fileName_+
".wgt").c_str());
230 while(wgtascii.getline(buffer,512)) {
231 lheAlpgenWgtHeader.
addLine(std::string(buffer) +
"\n");
237 std::ifstream parascii((
fileName_+
".par").c_str());
238 while(parascii.getline(buffer,512)) {
239 lheAlpgenParHeader.
addLine(std::string(buffer) +
"\n");
249 while(extraascii.getline(buffer,512)) {
250 extraHeader.
addLine(std::string(buffer) +
"\n");
256 runInfo->addHeader(comments);
259 runInfo->addHeader(lheAlpgenWgtHeader);
261 runInfo->addHeader(lheAlpgenParHeader);
262 runInfo->addHeader(slha);
264 runInfo->addHeader(extraHeader);
271 <<
"AlpgenSource was unable to open the file \""
279 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
283 <<
"Requested Alpgen parameter \""
285 "not found in Alpgen parameter file." << std::endl;
287 return T(pos->second);
292 const T &defValue)
const
294 std::map<AlpgenHeader::Parameter, double>::const_iterator
pos =
299 return T(pos->second);
323 std::istringstream
ls(buffer);
326 ls >> dummy >> dummy;
329 ls >> nPart >> sWgtRes >> sQ;
331 if (ls.bad() || nPart < 1 || nPart > 1000)
343 for(
int i = 0;
i != 2; ++
i) {
345 std::istringstream
ls(buffer);
347 int colour1; ls >> colour1;
348 int colour2; ls >> colour2;
349 double zMomentum; ls >> zMomentum;
359 hepeup.
PUP[
i][0] = 0.;
360 hepeup.
PUP[
i][1] = 0.;
361 hepeup.
PUP[
i][2] = zMomentum;
362 hepeup.
PUP[
i][3] = std::fabs(zMomentum);
363 hepeup.
PUP[
i][4] = 0.;
364 if (colour1) colour1 += 500;
365 if (colour2) colour2 += 500;
366 hepeup.
ICOLUP[
i].first = colour1;
367 hepeup.
ICOLUP[
i].second = colour2;
373 std::istringstream
ls(buffer);
375 int colour1; ls >> colour1;
376 int colour2; ls >> colour2;
377 double px, py, pz,
mass;
378 ls >> px >> py >> pz >>
mass;
389 hepeup.
PUP[
i][0] = px;
390 hepeup.
PUP[
i][1] = py;
391 hepeup.
PUP[
i][2] = pz;
394 if (colour1) colour1 += 500;
395 if (colour2) colour2 += 500;
396 hepeup.
ICOLUP[
i].first = colour1;
397 hepeup.
ICOLUP[
i].second = colour2;
415 <<
"AlpgenSource is not able read event no. "
464 <<
"Unrecognized IHRD process code" << std::endl;
virtual ~AlpgenSource()
Destructor.
AlpgenSource(const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc)
Constructor.
virtual void beginRun(edm::Run &run)
std::pair< double, double > EBMUP
AlpgenHeader header
Alpgen _unw.par file as an AlpgenHeader.
std::pair< int, int > IDBMUP
virtual bool produce(edm::Event &event)
unsigned long nEvent_
Number of events.
unsigned long skipEvents_
Number of events to skip.
std::pair< int, int > PDFGUP
bool writeAlpgenWgtFile
configuration flags
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
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.
std::pair< int, int > PDFSUP
T getParameter(AlpgenHeader::Parameter index) const
Function to get parameter by name from AlpgenHeader.
std::auto_ptr< std::ifstream > inputFile_
Pointer to the input file.
void put(std::auto_ptr< PROD > product)
Put a new product.
void fixEventTTbar(lhef::HEPEUP &hepeup)
Fixes Event Record for ihrd = 6.
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