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  XMLHandler
 

Public Member Functions

 LHEReader (const edm::ParameterSet &params)
 
 LHEReader (const std::vector< std::string > &fileNames, unsigned int skip=0)
 
boost::shared_ptr< LHEEventnext ()
 
 ~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
 

Detailed Description

Definition at line 18 of file LHEReader.h.

Constructor & Destructor Documentation

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

Definition at line 287 of file LHEReader.cc.

287  :
288  fileURLs(params.getUntrackedParameter< std::vector<std::string> >("fileNames")),
289  firstEvent(params.getUntrackedParameter<unsigned int>("skipEvents", 0)),
290  maxEvents(params.getUntrackedParameter<int>("limitEvents", -1)),
291  curIndex(0), handler(new XMLHandler())
292 {
293 }
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > fileURLs
Definition: LHEReader.h:30
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:40
unsigned int firstEvent
Definition: LHEReader.h:33
unsigned int curIndex
Definition: LHEReader.h:35
lhef::LHEReader::LHEReader ( const std::vector< std::string > &  fileNames,
unsigned int  skip = 0 
)

Definition at line 295 of file LHEReader.cc.

296  :
298  curIndex(0), handler(new XMLHandler())
299 {
300 }
tuple fileNames
Definition: align_tpl.py:17
const std::vector< std::string > fileURLs
Definition: LHEReader.h:30
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:40
unsigned int firstEvent
Definition: LHEReader.h:33
unsigned int curIndex
Definition: LHEReader.h:35
lhef::LHEReader::~LHEReader ( )

Definition at line 302 of file LHEReader.cc.

303 {
304 }

Member Function Documentation

boost::shared_ptr< LHEEvent > lhef::LHEReader::next ( void  )

Definition at line 306 of file LHEReader.cc.

References lhef::LHERunInfo::addHeader(), curDoc, curIndex, curRunInfo, curSource, runTheMatrix::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, and maxEvents.

307 {
308  while(curDoc.get() || curIndex < fileURLs.size()) {
309  if (!curDoc.get()) {
310  curSource.reset(new FileSource(fileURLs[curIndex++]));
311  handler->reset();
312  curDoc.reset(curSource->createReader(*handler));
313  curRunInfo.reset();
314  }
315 
316  XMLHandler::Object event = handler->gotObject;
317  handler->gotObject = XMLHandler::kNone;
318 
319  std::istringstream data;
320  if (event != XMLHandler::kNone) {
321  data.str(handler->buffer);
322  handler->buffer.clear();
323  }
324 
325  switch(event) {
326  case XMLHandler::kNone:
327  if (!curDoc->parse())
328  curDoc.reset();
329  break;
330 
331  case XMLHandler::kHeader:
332  break;
333 
334  case XMLHandler::kInit:
335  curRunInfo.reset(new LHERunInfo(data));
336 
337  std::for_each(handler->headers.begin(),
338  handler->headers.end(),
339  boost::bind(&LHERunInfo::addHeader,
340  curRunInfo.get(), _1));
341  handler->headers.clear();
342  break;
343 
345  break;
346 
347  case XMLHandler::kEvent:
348  if (!curRunInfo.get())
349  throw cms::Exception("InvalidState")
350  << "Got LHE event without"
351  " initialization." << std::endl;
352 
353  if (firstEvent > 0) {
354  firstEvent--;
355  continue;
356  }
357 
358  if (maxEvents == 0)
359  return boost::shared_ptr<LHEEvent>();
360  else if (maxEvents > 0)
361  maxEvents--;
362 
363  return boost::shared_ptr<LHEEvent>(
364  new LHEEvent(curRunInfo, data));
365  }
366  }
367 
368  return boost::shared_ptr<LHEEvent>();
369 }
const std::vector< std::string > fileURLs
Definition: LHEReader.h:30
boost::shared_ptr< LHERunInfo > curRunInfo
Definition: LHEReader.h:39
void addHeader(const Header &header)
Definition: LHERunInfo.h:63
std::auto_ptr< XMLHandler > handler
Definition: LHEReader.h:40
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:38
unsigned int firstEvent
Definition: LHEReader.h:33
std::auto_ptr< Source > curSource
Definition: LHEReader.h:37
unsigned int curIndex
Definition: LHEReader.h:35

Member Data Documentation

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

Definition at line 38 of file LHEReader.h.

Referenced by next().

unsigned int lhef::LHEReader::curIndex
private

Definition at line 35 of file LHEReader.h.

Referenced by next().

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

Definition at line 39 of file LHEReader.h.

Referenced by next().

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

Definition at line 37 of file LHEReader.h.

Referenced by next().

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

Definition at line 30 of file LHEReader.h.

Referenced by next().

unsigned int lhef::LHEReader::firstEvent
private

Definition at line 33 of file LHEReader.h.

Referenced by next().

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

Definition at line 40 of file LHEReader.h.

Referenced by next().

int lhef::LHEReader::maxEvents
private

Definition at line 34 of file LHEReader.h.

Referenced by next().