test
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::unique_ptr< XMLDocumentcurDoc
 
unsigned int curIndex
 
boost::shared_ptr< LHERunInfocurRunInfo
 
std::unique_ptr< SourcecurSource
 
const std::vector< std::string > fileURLs
 
unsigned int firstEvent
 
std::unique_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 451 of file LHEReader.cc.

451  :
452  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
453  strName(""),
454  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
455  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
456  curIndex(0), handler(new XMLHandler())
457 {
458 }
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
std::unique_ptr< XMLHandler > handler
Definition: LHEReader.h:45
unsigned int curIndex
Definition: LHEReader.h:39
lhef::LHEReader::LHEReader ( const std::vector< std::string > &  fileNames,
unsigned int  skip = 0 
)

Definition at line 460 of file LHEReader.cc.

461  :
463  curIndex(0), handler(new XMLHandler())
464 {
465 }
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
std::unique_ptr< XMLHandler > handler
Definition: LHEReader.h:45
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 467 of file LHEReader.cc.

468  :
470  curIndex(0), handler(new XMLHandler())
471 {
472 }
const std::string strName
Definition: LHEReader.h:36
unsigned int firstEvent
Definition: LHEReader.h:37
std::unique_ptr< XMLHandler > handler
Definition: LHEReader.h:45
unsigned int curIndex
Definition: LHEReader.h:39
lhef::LHEReader::~LHEReader ( )

Definition at line 474 of file LHEReader.cc.

References curDoc, curSource, and handler.

475 {
476  // Explicitly release "orphaned" resources
477  // that were created through DOM implementation
478  // createXXXX factory method *before* last
479  // XMLPlatformUtils::Terminate is called.
480  handler.release();
481  curDoc.release();
482  curSource.release();
483 }
std::unique_ptr< XMLDocument > curDoc
Definition: LHEReader.h:43
std::unique_ptr< Source > curSource
Definition: LHEReader.h:42
std::unique_ptr< XMLHandler > handler
Definition: LHEReader.h:45

Member Function Documentation

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

Definition at line 485 of file LHEReader.cc.

References lhef::LHERunInfo::addHeader(), curDoc, curIndex, curRunInfo, curSource, data, event(), fileURLs, plotBeamSpotDB::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().

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

Member Data Documentation

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

Definition at line 43 of file LHEReader.h.

Referenced by next(), and ~LHEReader().

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::unique_ptr<Source> lhef::LHEReader::curSource
private

Definition at line 42 of file LHEReader.h.

Referenced by next(), and ~LHEReader().

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::unique_ptr<XMLHandler> lhef::LHEReader::handler
private

Definition at line 45 of file LHEReader.h.

Referenced by next(), and ~LHEReader().

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.