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

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

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

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

416 {
417 }

Member Function Documentation

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

Definition at line 419 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, edm::second(), and strName.

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