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

391  :
392  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
393  strName(""),
394  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
395  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
396  curIndex(0), handler(new XMLHandler())
397 {
398 }
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 400 of file LHEReader.cc.

401  :
403  curIndex(0), handler(new XMLHandler())
404 {
405 }
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 407 of file LHEReader.cc.

408  :
410  curIndex(0), handler(new XMLHandler())
411 {
412 }
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 414 of file LHEReader.cc.

415 {
416 }

Member Function Documentation

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

Definition at line 418 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(), AlCaHLTBitMon_QueryRunRegistry::string, and strName.

Referenced by BeautifulSoup.PageElement::_invert().

419  {
420  while(curDoc.get() || curIndex < fileURLs.size() || (fileURLs.size() == 0 && strName != "" ) ) {
421  if (!curDoc.get()) {
422  if ( fileURLs.size() > 0 ) {
423  logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]);
424  curSource.reset(new FileSource(fileURLs[curIndex]));
425  logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]);
426  if ( newFileOpened != nullptr ) *newFileOpened = true;
427  ++curIndex;
428  } else if ( strName != "" ) {
429  curSource.reset(new StringSource(strName));
430  }
431  handler->reset();
432  curDoc.reset(curSource->createReader(*handler));
433  curRunInfo.reset();
434  }
435 
436  XMLHandler::Object event = handler->gotObject;
437  handler->gotObject = XMLHandler::kNone;
438 
439  std::istringstream data;
440  if (event != XMLHandler::kNone) {
441  data.str(handler->buffer);
442  handler->buffer.clear();
443  }
444 
445  switch(event) {
446  case XMLHandler::kNone:
447  if (!curDoc->parse()) {
448  curDoc.reset();
449  logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]);
450  }
451  break;
452 
453  case XMLHandler::kHeader:
454  break;
455 
456  case XMLHandler::kInit:
457  curRunInfo.reset(new LHERunInfo(data));
458 
459  std::for_each(handler->headers.begin(),
460  handler->headers.end(),
461  boost::bind(&LHERunInfo::addHeader,
462  curRunInfo.get(), _1));
463  handler->headers.clear();
464  break;
465 
467  break;
468 
469  case XMLHandler::kEvent:
470  if (!curRunInfo.get())
471  throw cms::Exception("InvalidState")
472  << "Got LHE event without"
473  " initialization." << std::endl;
474 
475  if (firstEvent > 0) {
476  firstEvent--;
477  continue;
478  }
479 
480  if (maxEvents == 0)
481  return boost::shared_ptr<LHEEvent>();
482  else if (maxEvents > 0)
483  maxEvents--;
484 
485  boost::shared_ptr<LHEEvent> lheevent;
486  lheevent.reset(new LHEEvent(curRunInfo, data));
487  const XMLHandler::wgt_info& info = handler->weightsinevent;
488  for( size_t i=0; i< info.size(); ++i ) {
489  std::string snum = info[i].second.substr(0,info[i].second.size()-1);
490  double num = -1.0;
491  sscanf(snum.c_str(),"%le",&num);
492  lheevent->addWeight(gen::WeightsInfo(info[i].first,num));
493  }
494  return lheevent;
495  }
496  }
497 
498  return boost::shared_ptr<LHEEvent>();
499  }
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:79
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.