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 450 of file LHEReader.cc.

450  :
451  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
452  strName(""),
453  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
454  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
455  curIndex(0), handler(new XMLHandler())
456 {
457 }
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 459 of file LHEReader.cc.

460  :
462  curIndex(0), handler(new XMLHandler())
463 {
464 }
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 466 of file LHEReader.cc.

467  :
469  curIndex(0), handler(new XMLHandler())
470 {
471 }
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 473 of file LHEReader.cc.

474 {
475 }

Member Function Documentation

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

Definition at line 477 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().

478  {
479  while(curDoc.get() || curIndex < fileURLs.size() || (fileURLs.size() == 0 && strName != "" ) ) {
480  if (!curDoc.get()) {
481  if ( fileURLs.size() > 0 ) {
482  logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]);
483  curSource.reset(new FileSource(fileURLs[curIndex]));
484  logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]);
485  if ( newFileOpened != nullptr ) *newFileOpened = true;
486  ++curIndex;
487  } else if ( strName != "" ) {
488  curSource.reset(new StringSource(strName));
489  }
490  handler->reset();
491  curDoc.reset(curSource->createReader(*handler));
492  curRunInfo.reset();
493  }
494  handler->skipEvent = firstEvent > 0;
495 
496  XMLHandler::Object event = handler->gotObject;
497  handler->gotObject = XMLHandler::kNone;
498 
499 
500  switch(event) {
501  case XMLHandler::kNone:
502  if (!curDoc->parse()) {
503  curDoc.reset();
504  logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]);
505  return boost::shared_ptr<LHEEvent>();
506  }
507  break;
508 
509  case XMLHandler::kHeader:
510  break;
511 
512  case XMLHandler::kInit:
513  {
514  std::istringstream data;
515  data.str(handler->buffer);
516  handler->buffer.clear();
517 
518  curRunInfo.reset(new LHERunInfo(data));
519 
520  std::for_each(handler->headers.begin(),
521  handler->headers.end(),
522  boost::bind(&LHERunInfo::addHeader,
523  curRunInfo.get(), _1));
524  handler->headers.clear();
525  }
526  break;
527 
529  break;
530 
531  case XMLHandler::kEvent:
532  {
533  if (!curRunInfo.get())
534  throw cms::Exception("InvalidState")
535  << "Got LHE event without"
536  " initialization." << std::endl;
537 
538  if (firstEvent > 0) {
539  firstEvent--;
540  continue;
541  }
542 
543  if (maxEvents == 0)
544  return boost::shared_ptr<LHEEvent>();
545  else if (maxEvents > 0)
546  maxEvents--;
547 
548  std::istringstream data;
549  data.str(handler->buffer);
550  handler->buffer.clear();
551 
552  boost::shared_ptr<LHEEvent> lheevent;
553  lheevent.reset(new LHEEvent(curRunInfo, data));
554  const XMLHandler::wgt_info& info = handler->weightsinevent;
555  for( size_t i=0; i< info.size(); ++i ) {
556  double num = -1.0;
557  sscanf(info[i].second.c_str(),"%le",&num);
558  lheevent->addWeight(gen::WeightsInfo(info[i].first,num));
559  }
560  lheevent->setNpLO(handler->npLO);
561  lheevent->setNpNLO(handler->npNLO);
562  //fill scales
563  if (handler->scales.size()>0) {
564  lheevent->setScales(handler->scales);
565  }
566  return lheevent;
567  }
568  }
569  }
570 
571  return boost::shared_ptr<LHEEvent>();
572  }
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 next().

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.