CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

edm::StreamerFileReader Class Reference

#include <StreamerFileReader.h>

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

List of all members.

Public Member Functions

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

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)

Private Attributes

boost::shared_ptr
< EventSkipperByID
eventSkipperByID_
int numberOfEventsToSkip_
std::vector< std::string > streamerNames_
std::auto_ptr< StreamerInputFilestreamReader_

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 13 of file StreamerFileReader.cc.

References validate_alignment_devdb10_cfg::catalog, edm::StreamerInputSource::deserializeAndMergeWithRegistry(), eventSkipperByID_, Exception, edm::InputFileCatalog::fileNames(), edm::errors::FileReadError, getHeader(), edm::ParameterSet::getUntrackedParameter(), MultipleCompare::header, numberOfEventsToSkip_, streamerNames_, and streamReader_.

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

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

Definition at line 34 of file StreamerFileReader.cc.

                                          {
  }

Member Function Documentation

void edm::StreamerFileReader::fillDescriptions ( ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::InputSource.

Definition at line 82 of file StreamerFileReader.cc.

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

                                                                              {
    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 61 of file StreamerFileReader.cc.

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

Referenced by read(), and StreamerFileReader().

                                {

    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 74 of file StreamerFileReader.cc.

References streamReader_.

Referenced by read().

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

Definition at line 56 of file StreamerFileReader.cc.

References streamReader_.

Referenced by read().

                                {
    return streamReader_->newHeader();
  }
EventPrincipal * edm::StreamerFileReader::read ( ) [virtual]

Implements edm::StreamerInputSource.

Definition at line 38 of file StreamerFileReader.cc.

References edm::StreamerInputSource::deserializeAndMergeWithRegistry(), edm::StreamerInputSource::deserializeEvent(), getHeader(), getNextEvent(), MultipleCompare::header, 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 == 0) {
      return  0;
    }
    return(deserializeEvent(*eview));
  }

Member Data Documentation

Definition at line 36 of file StreamerFileReader.h.

Referenced by StreamerFileReader().

Definition at line 37 of file StreamerFileReader.h.

Referenced by StreamerFileReader().

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

Definition at line 34 of file StreamerFileReader.h.

Referenced by StreamerFileReader().

Definition at line 35 of file StreamerFileReader.h.

Referenced by getHeader(), getNextEvent(), newHeader(), and StreamerFileReader().