CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes

edm::StreamerFileReader Class Reference

#include <StreamerFileReader.h>

Inheritance diagram for edm::StreamerFileReader:
edm::StreamerInputSource edm::RawInputSource edm::InputSource edm::ProductRegistryHelper

List of all members.

Public Member Functions

InitMsgView const * getHeader ()
EventMsgView const * getNextEvent ()
bool newHeader ()
 StreamerFileReader (ParameterSet const &pset, InputSourceDescription const &desc)
virtual ~StreamerFileReader ()

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)

Private Member Functions

virtual bool checkNextEvent ()
virtual void closeFile_ ()
virtual void reset_ ()
virtual void skip (int toSkip)

Private Attributes

boost::shared_ptr
< EventSkipperByID
eventSkipperByID_
int initialNumberOfEventsToSkip_
std::vector< std::string > streamerNames_
std::unique_ptr
< StreamerInputFile
streamReader_

Detailed Description

Definition at line 22 of file StreamerFileReader.h.


Constructor & Destructor Documentation

edm::StreamerFileReader::StreamerFileReader ( ParameterSet const &  pset,
InputSourceDescription const &  desc 
)

Definition at line 14 of file StreamerFileReader.cc.

References validate_alignment_devdb10_cfg::catalog, edm::InputFileCatalog::fileNames(), edm::ParameterSet::getUntrackedParameter(), reset_(), streamerNames_, and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                                                     :
      StreamerInputSource(pset, desc),
      streamerNames_(pset.getUntrackedParameter<std::vector<std::string> >("fileNames")),
      streamReader_(),
      eventSkipperByID_(EventSkipperByID::create(pset).release()),
      initialNumberOfEventsToSkip_(pset.getUntrackedParameter<unsigned int>("skipEvents")) {
    InputFileCatalog catalog(pset.getUntrackedParameter<std::vector<std::string> >("fileNames"), pset.getUntrackedParameter<std::string>("overrideCatalog"));
    streamerNames_ = catalog.fileNames();
    reset_();

  }
edm::StreamerFileReader::~StreamerFileReader ( ) [virtual]

Definition at line 26 of file StreamerFileReader.cc.

                                          {
  }

Member Function Documentation

bool edm::StreamerFileReader::checkNextEvent ( ) [private, virtual]

Implements edm::RawInputSource.

Definition at line 47 of file StreamerFileReader.cc.

References edm::StreamerInputSource::deserializeAndMergeWithRegistry(), edm::StreamerInputSource::deserializeEvent(), getHeader(), getNextEvent(), and newHeader().

                                          {
    EventMsgView const* eview = getNextEvent();

    if (newHeader()) {
      // FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl;
      // A new file has been opened and we must compare Heraders here !!
      //Get header/init from reader
      InitMsgView const* header = getHeader();
      deserializeAndMergeWithRegistry(*header, true);
    }
    if (eview == nullptr) {
      return  false;
    }
    deserializeEvent(*eview);
    return true;
  }
void edm::StreamerFileReader::closeFile_ ( ) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 79 of file StreamerFileReader.cc.

References streamReader_.

                                 {
    if(streamReader_.get() != nullptr) streamReader_->closeStreamerFile();
  }
void edm::StreamerFileReader::fillDescriptions ( ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::InputSource.

Definition at line 110 of file StreamerFileReader.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::StreamerInputSource::fillDescription(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

                                                                              {
    ParameterSetDescription desc;
    desc.setComment("Reads events from streamer files.");
    desc.addUntracked<std::vector<std::string> >("fileNames")
        ->setComment("Names of files to be processed.");
    desc.addUntracked<unsigned int>("skipEvents", 0U)
        ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
    desc.addUntracked<std::string>("overrideCatalog", std::string());
    //This next parameter is read in the base class, but its default value depends on the derived class, so it is set here.
    desc.addUntracked<bool>("inputFileTransitionsEachEvent", false);
    StreamerInputSource::fillDescription(desc);
    EventSkipperByID::fillDescription(desc);
    descriptions.add("source", desc);
  }
InitMsgView const * edm::StreamerFileReader::getHeader ( )

Definition at line 89 of file StreamerFileReader.cc.

References InitMsgView::code(), Exception, edm::errors::FileReadError, Header::INIT, and streamReader_.

Referenced by checkNextEvent(), and reset_().

                                {

    InitMsgView const* header = streamReader_->startMessage();

    if(header->code() != Header::INIT) { //INIT Msg
      throw Exception(errors::FileReadError, "StreamerFileReader::readHeader")
        << "received wrong message type: expected INIT, got "
        << header->code() << "\n";
    }
    return header;
  }
EventMsgView const * edm::StreamerFileReader::getNextEvent ( )

Definition at line 102 of file StreamerFileReader.cc.

References streamReader_.

Referenced by checkNextEvent(), and skip().

                                   {
    if (!streamReader_->next()) {
      return nullptr;
    }
    return streamReader_->currentRecord();
  }
bool edm::StreamerFileReader::newHeader ( )

Definition at line 84 of file StreamerFileReader.cc.

References streamReader_.

Referenced by checkNextEvent().

                                {
    return streamReader_->newHeader();
  }
void edm::StreamerFileReader::reset_ ( ) [private, virtual]

Reimplemented from edm::RawInputSource.

Definition at line 30 of file StreamerFileReader.cc.

References edm::StreamerInputSource::deserializeAndMergeWithRegistry(), eventSkipperByID_, Exception, edm::errors::FileReadError, getHeader(), initialNumberOfEventsToSkip_, skip(), streamerNames_, and streamReader_.

Referenced by StreamerFileReader().

                             {
    if (streamerNames_.size() > 1) {
      streamReader_ = std::unique_ptr<StreamerInputFile>(new StreamerInputFile(streamerNames_, eventSkipperByID_));
    } else if (streamerNames_.size() == 1) {
      streamReader_ = std::unique_ptr<StreamerInputFile>(new StreamerInputFile(streamerNames_.at(0), eventSkipperByID_));
    } else {
      throw Exception(errors::FileReadError, "StreamerFileReader::StreamerFileReader")
         << "No fileNames were specified\n";
    }
    InitMsgView const* header = getHeader();
    deserializeAndMergeWithRegistry(*header, false);
    if(initialNumberOfEventsToSkip_) {
      skip(initialNumberOfEventsToSkip_);
    }
  }
void edm::StreamerFileReader::skip ( int  toSkip) [private, virtual]

Reimplemented from edm::InputSource.

Definition at line 65 of file StreamerFileReader.cc.

References EventMsgView::event(), eventSkipperByID_, getNextEvent(), i, EventMsgView::lumi(), and EventMsgView::run().

Referenced by reset_().

                                     {
    for(int i = 0; i != toSkip; ++i) {
      EventMsgView const* evMsg = getNextEvent();
      if(evMsg == nullptr)  {
        return;
      }
      // If the event would have been skipped anyway, don't count it as a skipped event.
      if(eventSkipperByID_ && eventSkipperByID_->skipIt(evMsg->run(), evMsg->lumi(), evMsg->event())) {
        --i;
      }
    }
  }

Member Data Documentation

Definition at line 40 of file StreamerFileReader.h.

Referenced by reset_(), and skip().

Definition at line 41 of file StreamerFileReader.h.

Referenced by reset_().

std::vector<std::string> edm::StreamerFileReader::streamerNames_ [private]

Definition at line 38 of file StreamerFileReader.h.

Referenced by reset_(), and StreamerFileReader().

Definition at line 39 of file StreamerFileReader.h.

Referenced by closeFile_(), getHeader(), getNextEvent(), newHeader(), and reset_().