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
 

Detailed Description

Definition at line 18 of file LHEReader.h.

Constructor & Destructor Documentation

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

Definition at line 318 of file LHEReader.cc.

318  :
319  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
320  strName(""),
321  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
322  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
323  curIndex(0), handler(new XMLHandler())
324 {
325 }
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:44
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 327 of file LHEReader.cc.

328  :
330  curIndex(0), handler(new XMLHandler())
331 {
332 }
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:44
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 334 of file LHEReader.cc.

335  :
337  curIndex(0), handler(new XMLHandler())
338 {
339 }
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:44
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 341 of file LHEReader.cc.

342 {
343 }

Member Function Documentation

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

Definition at line 345 of file LHEReader.cc.

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

346  {
347 
348  while(curDoc.get() || curIndex < fileURLs.size() || (fileURLs.size() == 0 && strName != "" ) ) {
349  if (!curDoc.get()) {
350  if ( fileURLs.size() > 0 ) {
351  logFileAction(" Initiating request to open LHE file ", fileURLs[curIndex]);
352  curSource.reset(new FileSource(fileURLs[curIndex]));
353  logFileAction(" Successfully opened LHE file ", fileURLs[curIndex]);
354  if ( newFileOpened != nullptr ) *newFileOpened = true;
355  ++curIndex;
356  } else if ( strName != "" ) {
357  curSource.reset(new StringSource(strName));
358  }
359  handler->reset();
360  curDoc.reset(curSource->createReader(*handler));
361  curRunInfo.reset();
362  }
363 
364  XMLHandler::Object event = handler->gotObject;
365  handler->gotObject = XMLHandler::kNone;
366 
367  std::istringstream data;
368  if (event != XMLHandler::kNone) {
369  data.str(handler->buffer);
370  handler->buffer.clear();
371  }
372 
373  switch(event) {
374  case XMLHandler::kNone:
375  if (!curDoc->parse()) {
376  curDoc.reset();
377  logFileAction(" Closed LHE file ", fileURLs[curIndex - 1]);
378  }
379  break;
380 
381  case XMLHandler::kHeader:
382  break;
383 
384  case XMLHandler::kInit:
385  curRunInfo.reset(new LHERunInfo(data));
386 
387  std::for_each(handler->headers.begin(),
388  handler->headers.end(),
389  boost::bind(&LHERunInfo::addHeader,
390  curRunInfo.get(), _1));
391  handler->headers.clear();
392  break;
393 
395  break;
396 
397  case XMLHandler::kEvent:
398  if (!curRunInfo.get())
399  throw cms::Exception("InvalidState")
400  << "Got LHE event without"
401  " initialization." << std::endl;
402 
403  if (firstEvent > 0) {
404  firstEvent--;
405  continue;
406  }
407 
408  if (maxEvents == 0)
409  return boost::shared_ptr<LHEEvent>();
410  else if (maxEvents > 0)
411  maxEvents--;
412 
413  return boost::shared_ptr<LHEEvent>(
414  new LHEEvent(curRunInfo, data));
415  }
416  }
417 
418  return boost::shared_ptr<LHEEvent>();
419  }
static void logFileAction(char const *msg, std::string const &fileName)
Definition: LHEReader.cc:34
const std::vector< std::string > fileURLs
Definition: LHEReader.h:33
boost::shared_ptr< LHERunInfo > curRunInfo
Definition: LHEReader.h:43
void addHeader(const Header &header)
Definition: LHERunInfo.h:63
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:44
const std::string strName
Definition: LHEReader.h:36
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::auto_ptr< XMLDocument > curDoc
Definition: LHEReader.h:42
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:41
unsigned int curIndex
Definition: LHEReader.h:39

Member Data Documentation

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

Definition at line 42 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 43 of file LHEReader.h.

Referenced by next().

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

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