CMS 3D CMS Logo

Public Member Functions | Protected Member Functions | Protected Attributes

MCatNLOSource Class Reference

#include <MCatNLOSource.h>

Inheritance diagram for MCatNLOSource:
edm::ExternalInputSource gen::Herwig6Instance edm::ConfigurableInputSource gen::FortranInstance edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

 MCatNLOSource (const edm::ParameterSet &params, const edm::InputSourceDescription &desc)
virtual ~MCatNLOSource ()

Protected Member Functions

virtual void beginRun (edm::Run &run)
virtual void endJob ()
virtual bool hwwarn (const std::string &fn, int code)
void nextEvent ()
virtual bool produce (edm::Event &event)

Protected Attributes

boost::shared_ptr< lhef::LHEEventevent
std::string fileName
 Name of the input file.
std::auto_ptr< std::ifstream > inputFile
 Pointer to the input file.
unsigned int nEvents
 Number of events.
int processCode
std::auto_ptr< std::ifstream > reader
boost::shared_ptr
< lhef::LHERunInfo
runInfo
unsigned int skipEvents
 Number of events to skip.

Detailed Description

Definition at line 43 of file MCatNLOSource.h.


Constructor & Destructor Documentation

MCatNLOSource::MCatNLOSource ( const edm::ParameterSet params,
const edm::InputSourceDescription desc 
) [explicit]

Definition at line 41 of file MCatNLOSource.cc.

References fileName, edm::ExternalInputSource::fileNames(), and reader.

                                                            :
        ExternalInputSource(params, desc, false),
        gen::Herwig6Instance(0),
        skipEvents(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
        nEvents(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.

{
}

Member Function Documentation

void MCatNLOSource::beginRun ( edm::Run run) [protected, virtual]

Reimplemented from edm::ConfigurableInputSource.

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  ) [protected, 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 
) [protected, virtual]

Reimplemented from gen::Herwig6Instance.

Definition at line 190 of file MCatNLOSource.cc.

{
  // dummy ignoring useless HERWIG warnings
  return true;
}
void MCatNLOSource::nextEvent ( ) [protected]

Definition at line 79 of file MCatNLOSource.cc.

{
  return;
}
bool MCatNLOSource::produce ( edm::Event event) [protected, virtual]

Implements edm::ConfigurableInputSource.

Definition at line 158 of file MCatNLOSource.cc.

References lhef::HEPEUP::IDPRUP, lhef::HEPRUP::LPRUP, makeConfigLine(), mcatnloupevnt_(), processCode, lhef::CommonBlocks::readHEPEUP(), lhef::CommonBlocks::readHEPRUP(), skipEvents, and wrapper.

{
  InstanceWrapper wrapper(this);

  int lastEventDone=0;
  int 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;

  // 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);

  return true;
}

Member Data Documentation

boost::shared_ptr<lhef::LHEEvent> MCatNLOSource::event [protected]

Definition at line 76 of file MCatNLOSource.h.

std::string MCatNLOSource::fileName [protected]

Name of the input file.

Definition at line 60 of file MCatNLOSource.h.

Referenced by beginRun(), and MCatNLOSource().

std::auto_ptr<std::ifstream> MCatNLOSource::inputFile [protected]

Pointer to the input file.

Definition at line 63 of file MCatNLOSource.h.

unsigned int MCatNLOSource::nEvents [protected]

Number of events.

Definition at line 69 of file MCatNLOSource.h.

int MCatNLOSource::processCode [protected]

Definition at line 71 of file MCatNLOSource.h.

Referenced by beginRun(), and produce().

std::auto_ptr<std::ifstream> MCatNLOSource::reader [protected]

Definition at line 73 of file MCatNLOSource.h.

Referenced by endJob(), and MCatNLOSource().

boost::shared_ptr<lhef::LHERunInfo> MCatNLOSource::runInfo [protected]

Definition at line 75 of file MCatNLOSource.h.

Referenced by beginRun().

unsigned int MCatNLOSource::skipEvents [protected]

Number of events to skip.

Definition at line 66 of file MCatNLOSource.h.

Referenced by produce().