CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | Private Attributes
lhef::LHEReader Class Reference

#include <LHEReader.h>

Classes

class  FileSource
 
class  Source
 
class  StringSource
 
class  XMLHandler
 

Public Member Functions

 LHEReader (const edm::ParameterSet &params)
 
 LHEReader (const std::vector< std::string > &fileNames, unsigned int skip=0)
 
 LHEReader (const std::string &inputs, unsigned int skip=0)
 
boost::shared_ptr< LHEEventnext (bool *newFileOpened=nullptr)
 
 ~LHEReader ()
 

Private Attributes

std::auto_ptr< XMLDocumentcurDoc
 
unsigned int curIndex
 
boost::shared_ptr< LHERunInfocurRunInfo
 
std::auto_ptr< SourcecurSource
 
const std::vector< std::string > fileURLs
 
unsigned int firstEvent
 
std::auto_ptr< XMLHandlerhandler
 
int maxEvents
 
const std::string strName
 
std::vector< std::string > weightsinconfig
 

Detailed Description

Definition at line 18 of file LHEReader.h.

Constructor & Destructor Documentation

lhef::LHEReader::LHEReader ( const edm::ParameterSet params)

Definition at line 432 of file LHEReader.cc.

432  :
433  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
434  strName(""),
435  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
436  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
437  curIndex(0), handler(new XMLHandler())
438 {
439 }
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:45
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
unsigned int curIndex
Definition: LHEReader.h:39
lhef::LHEReader::LHEReader ( const std::vector< std::string > &  fileNames,
unsigned int  skip = 0 
)

Definition at line 441 of file LHEReader.cc.

442  :
444  curIndex(0), handler(new XMLHandler())
445 {
446 }
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:45
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
tuple fileNames
Definition: LaserDQM_cfg.py:34
unsigned int curIndex
Definition: LHEReader.h:39
lhef::LHEReader::LHEReader ( const std::string &  inputs,
unsigned int  skip = 0 
)

Definition at line 448 of file LHEReader.cc.

449  :
451  curIndex(0), handler(new XMLHandler())
452 {
453 }
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:45
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
unsigned int curIndex
Definition: LHEReader.h:39
lhef::LHEReader::~LHEReader ( )

Definition at line 455 of file LHEReader.cc.

456 {
457 }

Member Function Documentation

boost::shared_ptr< LHEEvent > lhef::LHEReader::next ( bool *  newFileOpened = nullptr)

Definition at line 459 of file LHEReader.cc.

References lhef::LHERunInfo::addHeader(), curDoc, curIndex, curRunInfo, curSource, data, event(), fileURLs, first, firstEvent, handler, i, info(), lhef::LHEReader::XMLHandler::kComment, lhef::LHEReader::XMLHandler::kEvent, lhef::LHEReader::XMLHandler::kHeader, lhef::LHEReader::XMLHandler::kInit, lhef::LHEReader::XMLHandler::kNone, lhef::logFileAction(), maxEvents, pileupDistInMC::num, edm::second(), and strName.

Referenced by BeautifulSoup.PageElement::_invert().

460  {
461  while(curDoc.get() || curIndex < fileURLs.size() || (fileURLs.size() == 0 && strName != "" ) ) {
462  if (!curDoc.get()) {
463  if ( fileURLs.size() > 0 ) {
464  logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]);
465  curSource.reset(new FileSource(fileURLs[curIndex]));
466  logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]);
467  if ( newFileOpened != nullptr ) *newFileOpened = true;
468  ++curIndex;
469  } else if ( strName != "" ) {
470  curSource.reset(new StringSource(strName));
471  }
472  handler->reset();
473  curDoc.reset(curSource->createReader(*handler));
474  curRunInfo.reset();
475  }
476 
477  XMLHandler::Object event = handler->gotObject;
478  handler->gotObject = XMLHandler::kNone;
479 
480  std::istringstream data;
481  if (event != XMLHandler::kNone) {
482  data.str(handler->buffer);
483  handler->buffer.clear();
484  }
485 
486  switch(event) {
487  case XMLHandler::kNone:
488  if (!curDoc->parse()) {
489  curDoc.reset();
490  logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]);
491  return boost::shared_ptr<LHEEvent>();
492  }
493  break;
494 
495  case XMLHandler::kHeader:
496  break;
497 
498  case XMLHandler::kInit:
499  curRunInfo.reset(new LHERunInfo(data));
500 
501  std::for_each(handler->headers.begin(),
502  handler->headers.end(),
503  boost::bind(&LHERunInfo::addHeader,
504  curRunInfo.get(), _1));
505  handler->headers.clear();
506  break;
507 
509  break;
510 
511  case XMLHandler::kEvent:
512  if (!curRunInfo.get())
513  throw cms::Exception("InvalidState")
514  << "Got LHE event without"
515  " initialization." << std::endl;
516 
517  if (firstEvent > 0) {
518  firstEvent--;
519  continue;
520  }
521 
522  if (maxEvents == 0)
523  return boost::shared_ptr<LHEEvent>();
524  else if (maxEvents > 0)
525  maxEvents--;
526 
527  boost::shared_ptr<LHEEvent> lheevent;
528  lheevent.reset(new LHEEvent(curRunInfo, data));
529  const XMLHandler::wgt_info& info = handler->weightsinevent;
530  for( size_t i=0; i< info.size(); ++i ) {
531  double num = -1.0;
532  sscanf(info[i].second.c_str(),"%le",&num);
533  lheevent->addWeight(gen::WeightsInfo(info[i].first,num));
534  }
535  lheevent->setNpLO(handler->npLO);
536  lheevent->setNpNLO(handler->npNLO);
537  //fill scales
538  if (handler->scales.size()>0) {
539  lheevent->setScales(handler->scales);
540  }
541  return lheevent;
542  }
543  }
544 
545  return boost::shared_ptr<LHEEvent>();
546  }
int i
Definition: DBlmapReader.cc:9
static const TGPicture * info(bool iBackgroundIsBlack)
static void logFileAction(char const *msg, std::string const &fileName)
Definition: LHEReader.cc:37
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
U second(std::pair< T, U > const &p)
boost::shared_ptr< LHERunInfo > curRunInfo
Definition: LHEReader.h:44
void addHeader(const Header &header)
Definition: LHERunInfo.h:63
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:45
const std::string strName
Definition: LHEReader.h:36
std::vector< std::pair< std::string, std::string > > wgt_info
Definition: LHEReader.cc:100
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
bool first
Definition: L1TdeRCT.cc:75
std::auto_ptr< XMLDocument > curDoc
Definition: LHEReader.h:43
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:82
unsigned int firstEvent
Definition: LHEReader.h:37
std::auto_ptr< Source > curSource
Definition: LHEReader.h:42
unsigned int curIndex
Definition: LHEReader.h:39

Member Data Documentation

std::auto_ptr<XMLDocument> lhef::LHEReader::curDoc
private

Definition at line 43 of file LHEReader.h.

Referenced by next().

unsigned int lhef::LHEReader::curIndex
private

Definition at line 39 of file LHEReader.h.

Referenced by next().

boost::shared_ptr<LHERunInfo> lhef::LHEReader::curRunInfo
private

Definition at line 44 of file LHEReader.h.

Referenced by next().

std::auto_ptr<Source> lhef::LHEReader::curSource
private

Definition at line 42 of file LHEReader.h.

Referenced by next().

const std::vector<std::string> lhef::LHEReader::fileURLs
private

Definition at line 33 of file LHEReader.h.

Referenced by next().

unsigned int lhef::LHEReader::firstEvent
private

Definition at line 37 of file LHEReader.h.

Referenced by looper.Looper::loop(), next(), and Printer.Printer::process().

std::auto_ptr<XMLHandler> lhef::LHEReader::handler
private

Definition at line 45 of file LHEReader.h.

Referenced by next().

int lhef::LHEReader::maxEvents
private

Definition at line 38 of file LHEReader.h.

Referenced by next().

const std::string lhef::LHEReader::strName
private

Definition at line 36 of file LHEReader.h.

Referenced by next().

std::vector<std::string> lhef::LHEReader::weightsinconfig
private

Definition at line 40 of file LHEReader.h.