#include <MCatNLOSource.h>
Public Member Functions | |
MCatNLOSource (const edm::ParameterSet ¶ms, const edm::InputSourceDescription &desc) | |
virtual | ~MCatNLOSource () |
Private Member Functions | |
virtual void | beginRun (edm::Run &run) |
virtual void | endJob () |
virtual bool | hwwarn (const std::string &fn, int code) |
void | nextEvent () |
virtual void | produce (edm::Event &event) |
virtual bool | setRunAndEventInfo (edm::EventID &, edm::TimeValue_t &) |
Private Attributes | |
boost::shared_ptr< lhef::LHEEvent > | event |
std::string | fileName |
Name of the input file. | |
int | ihpro |
std::unique_ptr< std::ifstream > | inputFile |
Pointer to the input file. | |
unsigned int | nEvents |
Number of events. | |
int | processCode |
std::unique_ptr< std::ifstream > | reader |
boost::shared_ptr < lhef::LHERunInfo > | runInfo |
unsigned int | skipEvents |
Number of events to skip. |
Definition at line 43 of file MCatNLOSource.h.
MCatNLOSource::MCatNLOSource | ( | const edm::ParameterSet & | params, |
const edm::InputSourceDescription & | desc | ||
) | [explicit] |
Definition at line 40 of file MCatNLOSource.cc.
References fileName, edm::ProducerSourceFromFiles::fileNames(), and reader.
: ProducerSourceFromFiles(params, desc, false), gen::Herwig6Instance(0), skipEvents(params.getUntrackedParameter<unsigned int>("skipEvents", 0)), nEvents(0), ihpro(0), processCode(params.getParameter<int>("processCode")) { std::vector<std::string> allFileNames = fileNames(); // Only one filename if (allFileNames.size() != 1) throw cms::Exception("Generator|MCatNLOInterface") << "MCatNLOSource needs exactly one file specified. " <<std::endl; fileName = allFileNames[0]; // Strip the "file:" prefix if (fileName.find("file:") != 0) throw cms::Exception("Generator|MCatNLOInterface") << "MCatNLOSource only supports the file: scheme. "<<std::endl; fileName.erase(0, 5); // open input file reader.reset(new std::ifstream(fileName.c_str())); produces<LHEEventProduct>(); produces<LHERunInfoProduct, edm::InRun>(); }
MCatNLOSource::~MCatNLOSource | ( | ) | [virtual] |
Definition at line 70 of file MCatNLOSource.cc.
{ }
void MCatNLOSource::beginRun | ( | edm::Run & | run | ) | [private, virtual] |
Reimplemented from edm::ProducerSourceBase.
Definition at line 100 of file MCatNLOSource.cc.
References abs, LHERunInfoProduct::Header::addLine(), MCPARS_::emmax, MCPARS_::emmaxs, MCPARS_::emmin, MCPARS_::emmins, fileName, MCPARS_::gammax, MCPARS_::gammaxs, MCPARS_::gamw, MCPARS_::gamws, MCPARS_::gamz, MCPARS_::gamzs, i, makeConfigLine(), mcatnloupinit_(), mcpars_, processCode, edm::Run::put(), lhef::CommonBlocks::readHEPRUP(), MCPARS_::rmass, MCPARS_::rmasss, runInfo, and wrapper.
{ InstanceWrapper wrapper(this); // call UPINIT privided by MC@NLO (v3.4) mcatnloupinit_(&processCode, fileName.c_str(), fileName.length()); // fill HEPRUP common block and store in edm::Run lhef::HEPRUP heprup; lhef::CommonBlocks::readHEPRUP(&heprup); // make sure we write a valid LHE header, Herwig6Hadronizer // will interpret it correctly and set up LHAPDF heprup.PDFGUP.first = 0; heprup.PDFGUP.second = 0; std::auto_ptr<LHERunInfoProduct> runInfo(new LHERunInfoProduct(heprup)); LHERunInfoProduct::Header hw6header("herwig6header"); hw6header.addLine("\n"); hw6header.addLine("# Herwig6 parameters\n"); hw6header.addLine(makeConfigLine("IPROC", processCode)); // add lines for parameter that have been touched by UPINIT if(mcpars_.emmins) hw6header.addLine(makeConfigLine("EMMIN", mcpars_.emmin)); if(mcpars_.emmaxs) hw6header.addLine(makeConfigLine("EMMAX", mcpars_.emmax)); if(mcpars_.gammaxs) hw6header.addLine(makeConfigLine("GAMMAX",mcpars_.gammax)); if(mcpars_.gamzs) hw6header.addLine(makeConfigLine("GAMZ",mcpars_.gamz)); if(mcpars_.gamws) hw6header.addLine(makeConfigLine("GAMW",mcpars_.gamw)); for(unsigned int i=0; i<1000; ++i) { if(mcpars_.rmasss[i]) hw6header.addLine(makeConfigLine("RMASS",i+1,mcpars_.rmass[i])); } // other needed MC@NLO defaults (from mcatnlo_hwdriver.f v3.4) hw6header.addLine(makeConfigLine("SOFTME", false)); hw6header.addLine(makeConfigLine("NOWGT", false)); hw6header.addLine(makeConfigLine("NEGWTS", true)); if(abs(processCode)==1705 || abs(processCode)==11705) hw6header.addLine(makeConfigLine("PSPLT",2,0.5)); double wgtmax_=1.000001; hw6header.addLine(makeConfigLine("WGTMAX", wgtmax_)); hw6header.addLine(makeConfigLine("AVABW", wgtmax_)); hw6header.addLine(makeConfigLine("RLTIM",6, 1.0E-23)); hw6header.addLine(makeConfigLine("RLTIM",12, 1.0E-23)); runInfo->addHeader(hw6header); run.put(runInfo); return; }
void MCatNLOSource::endJob | ( | void | ) | [private, virtual] |
Reimplemented from edm::InputSource.
Definition at line 74 of file MCatNLOSource.cc.
References reader.
{ reader.reset(); }
bool MCatNLOSource::hwwarn | ( | const std::string & | fn, |
int | code | ||
) | [private, virtual] |
Reimplemented from gen::Herwig6Instance.
Definition at line 194 of file MCatNLOSource.cc.
{ // dummy ignoring useless HERWIG warnings return true; }
void MCatNLOSource::nextEvent | ( | ) | [private] |
Definition at line 79 of file MCatNLOSource.cc.
{
return;
}
void MCatNLOSource::produce | ( | edm::Event & | event | ) | [private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 179 of file MCatNLOSource.cc.
References lhef::HEPEUP::IDPRUP, ihpro, lhef::HEPRUP::LPRUP, makeConfigLine(), lhef::CommonBlocks::readHEPEUP(), lhef::CommonBlocks::readHEPRUP(), and wrapper.
{ InstanceWrapper wrapper(this); // fill HEPRUP common block and store in edm::Run lhef::HEPRUP heprup; lhef::HEPEUP hepeup; lhef::CommonBlocks::readHEPRUP(&heprup); lhef::CommonBlocks::readHEPEUP(&hepeup); hepeup.IDPRUP = heprup.LPRUP[0]; std::auto_ptr<LHEEventProduct> lhEvent(new LHEEventProduct(hepeup)); lhEvent->addComment(makeConfigLine("#IHPRO", ihpro)); event.put(lhEvent); }
bool MCatNLOSource::setRunAndEventInfo | ( | edm::EventID & | , |
edm::TimeValue_t & | |||
) | [private, virtual] |
Implements edm::ProducerSourceBase.
Definition at line 158 of file MCatNLOSource.cc.
References ihpro, mcatnloupevnt_(), processCode, skipEvents, and wrapper.
{ InstanceWrapper wrapper(this); int lastEventDone=0; ihpro=0; // skip events if asked to... while(skipEvents>0) { skipEvents--; mcatnloupevnt_(&processCode,&lastEventDone,&ihpro); if(lastEventDone) return false; } // call UPINIT privided by MC@NLO (v3.4) mcatnloupevnt_(&processCode,&lastEventDone,&ihpro); if(lastEventDone) return false; return true; }
boost::shared_ptr<lhef::LHEEvent> MCatNLOSource::event [private] |
Definition at line 79 of file MCatNLOSource.h.
std::string MCatNLOSource::fileName [private] |
Name of the input file.
Definition at line 61 of file MCatNLOSource.h.
Referenced by beginRun(), and MCatNLOSource().
int MCatNLOSource::ihpro [private] |
Definition at line 72 of file MCatNLOSource.h.
Referenced by produce(), and setRunAndEventInfo().
std::unique_ptr<std::ifstream> MCatNLOSource::inputFile [private] |
Pointer to the input file.
Definition at line 64 of file MCatNLOSource.h.
unsigned int MCatNLOSource::nEvents [private] |
Number of events.
Definition at line 70 of file MCatNLOSource.h.
int MCatNLOSource::processCode [private] |
Definition at line 74 of file MCatNLOSource.h.
Referenced by beginRun(), and setRunAndEventInfo().
std::unique_ptr<std::ifstream> MCatNLOSource::reader [private] |
Definition at line 76 of file MCatNLOSource.h.
Referenced by endJob(), and MCatNLOSource().
boost::shared_ptr<lhef::LHERunInfo> MCatNLOSource::runInfo [private] |
Definition at line 78 of file MCatNLOSource.h.
Referenced by beginRun().
unsigned int MCatNLOSource::skipEvents [private] |
Number of events to skip.
Definition at line 67 of file MCatNLOSource.h.
Referenced by setRunAndEventInfo().