CMS 3D CMS Logo

StreamerFileReader.cc
Go to the documentation of this file.
12 
13 namespace edm {
14 
16  : StreamerInputSource(pset, desc),
17  streamReader_(),
18  eventSkipperByID_(EventSkipperByID::create(pset).release()),
19  initialNumberOfEventsToSkip_(pset.getUntrackedParameter<unsigned int>("skipEvents")) {
20  InputFileCatalog catalog(pset.getUntrackedParameter<std::vector<std::string> >("fileNames"),
21  pset.getUntrackedParameter<std::string>("overrideCatalog"));
22  streamerNames_ = catalog.fileCatalogItems();
23  reset_();
24  }
25 
27 
29  if (streamerNames_.size() > 1) {
30  streamReader_ = std::make_unique<StreamerInputFile>(streamerNames_, eventSkipperByID());
31  } else if (streamerNames_.size() == 1) {
32  streamReader_ = std::make_unique<StreamerInputFile>(
33  streamerNames_.at(0).fileNames()[0], streamerNames_.at(0).logicalFileName(), eventSkipperByID());
34  } else {
35  throw Exception(errors::FileReadError, "StreamerFileReader::StreamerFileReader")
36  << "No fileNames were specified\n";
37  }
38  isFirstFile_ = true;
39  InitMsgView const* header = getHeader();
43  }
44  }
45 
47  EventMsgView const* eview = getNextEvent();
48 
49  if (eview == nullptr) {
50  if (newHeader()) {
51  return Next::kFile;
52  }
53  return Next::kStop;
54  }
55  deserializeEvent(*eview);
56  return Next::kEvent;
57  }
58 
59  void StreamerFileReader::skip(int toSkip) {
60  for (int i = 0; i != toSkip; ++i) {
61  EventMsgView const* evMsg = getNextEvent();
62  if (evMsg == nullptr) {
63  return;
64  }
65  // If the event would have been skipped anyway, don't count it as a skipped event.
66  if (eventSkipperByID_ && eventSkipperByID_->skipIt(evMsg->run(), evMsg->lumi(), evMsg->event())) {
67  --i;
68  }
69  }
70  }
71 
73  if (streamReader_.get() != nullptr)
74  streamReader_->closeStreamerFile();
75  }
76 
78  if (isFirstFile_) {
79  //The file was already opened in the constructor
80  isFirstFile_ = false;
81  return;
82  }
83  streamReader_->openNextFile();
84  // FDEBUG(6) << "A new file has been opened and we must compare Headers here !!" << std::endl;
85  // A new file has been opened and we must compare Heraders here !!
86  //Get header/init from reader
87  InitMsgView const* header = getHeader();
89  }
90 
91  bool StreamerFileReader::newHeader() { return streamReader_->newHeader(); }
92 
94  InitMsgView const* header = streamReader_->startMessage();
95 
96  if (header->code() != Header::INIT) { //INIT Msg
97  throw Exception(errors::FileReadError, "StreamerFileReader::readHeader")
98  << "received wrong message type: expected INIT, got " << header->code() << "\n";
99  }
100  return header;
101  }
102 
105  return nullptr;
106  }
107  return streamReader_->currentRecord();
108  }
109 
112  desc.setComment("Reads events from streamer files.");
113  desc.addUntracked<std::vector<std::string> >("fileNames")->setComment("Names of files to be processed.");
114  desc.addUntracked<unsigned int>("skipEvents", 0U)
115  ->setComment("Skip the first 'skipEvents' events that otherwise would have been processed.");
116  desc.addUntracked<std::string>("overrideCatalog", std::string());
117  //This next parameter is read in the base class, but its default value depends on the derived class, so it is set here.
118  desc.addUntracked<bool>("inputFileTransitionsEachEvent", false);
121  descriptions.add("source", desc);
122  }
123 } // namespace edm
ConfigurationDescriptions.h
mps_fire.i
i
Definition: mps_fire.py:355
getEcalConditions_orcoffint2r_cff.catalog
catalog
Definition: getEcalConditions_orcoffint2r_cff.py:40
edm::StreamerInputSource::deserializeEvent
void deserializeEvent(EventMsgView const &eventView)
Definition: StreamerInputSource.cc:185
edm
HLT enums.
Definition: AlignableModifier.h:19
edm::StreamerInputSource
Definition: StreamerInputSource.h:31
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::StreamerInputSource::fillDescription
static void fillDescription(ParameterSetDescription &description)
Definition: StreamerInputSource.cc:502
edm::InputSourceDescription
Definition: InputSourceDescription.h:20
edm::InputFileCatalog
Definition: InputFileCatalog.h:32
edm::StreamerInputFile::Next::kEvent
InputFileCatalog.h
beamerCreator.create
def create(alignables, pedeDump, additionalData, outputFile, config)
Definition: beamerCreator.py:44
Header::INIT
Definition: MsgHeader.h:15
edm::StreamerFileReader::getNextEvent
EventMsgView const * getNextEvent()
Definition: StreamerFileReader.cc:103
edm::StreamerFileReader::reset_
void reset_() override
Definition: StreamerFileReader.cc:28
EventMsgView
Definition: EventMessage.h:72
edm::StreamerFileReader::~StreamerFileReader
~StreamerFileReader() override
Definition: StreamerFileReader.cc:26
EventSkipperByID.h
edm::StreamerInputSource::deserializeAndMergeWithRegistry
void deserializeAndMergeWithRegistry(InitMsgView const &initView, bool subsequent=false)
Definition: StreamerInputSource.cc:167
edm::StreamerFileReader::newHeader
bool newHeader()
Definition: StreamerFileReader.cc:91
EDMException.h
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
edm::StreamerFileReader::skip
void skip(int toSkip) override
Definition: StreamerFileReader.cc:59
StreamerInputFile.h
EventMsgView::run
uint32 run() const
Definition: EventMessage.cc:71
edm::EventSkipperByID
Definition: EventSkipperByID.h:17
edm::StreamerFileReader::streamReader_
edm::propagate_const< std::unique_ptr< StreamerInputFile > > streamReader_
Definition: StreamerFileReader.h:44
ParameterSetDescription.h
edm::StreamerFileReader::StreamerFileReader
StreamerFileReader(ParameterSet const &pset, InputSourceDescription const &desc)
Definition: StreamerFileReader.cc:15
edm::StreamerFileReader::fillDescriptions
static void fillDescriptions(ConfigurationDescriptions &descriptions)
Definition: StreamerFileReader.cc:110
mitigatedMETSequence_cff.U
U
Definition: mitigatedMETSequence_cff.py:36
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSetDescription::addUntracked
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:100
edm::RawInputSource::Next::kFile
edm::StreamerFileReader::checkNext
Next checkNext() override
Definition: StreamerFileReader.cc:46
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ParameterSetDescription::setComment
void setComment(std::string const &value)
Definition: ParameterSetDescription.cc:33
fetchall_from_DQM_v2.release
release
Definition: fetchall_from_DQM_v2.py:92
edm::StreamerFileReader::genuineReadFile
void genuineReadFile() override
Definition: StreamerFileReader.cc:77
EventMsgView::event
uint64 event() const
Definition: EventMessage.cc:76
createfilelist.int
int
Definition: createfilelist.py:10
edm::RawInputSource::Next::kStop
MsgTools.h
edm::StreamerFileReader::getHeader
InitMsgView const * getHeader()
Definition: StreamerFileReader.cc:93
FileBlock.h
edm::RawInputSource::Next
Next
Definition: RawInputSource.h:24
edm::StreamerFileReader::eventSkipperByID_
edm::propagate_const< std::shared_ptr< EventSkipperByID > > eventSkipperByID_
Definition: StreamerFileReader.h:45
edm::StreamerFileReader::eventSkipperByID
std::shared_ptr< EventSkipperByID const > eventSkipperByID() const
Definition: StreamerFileReader.h:40
Exception
Definition: hltDiff.cc:246
edm::StreamerFileReader::streamerNames_
std::vector< FileCatalogItem > streamerNames_
Definition: StreamerFileReader.h:43
edm::EventSkipperByID::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition: EventSkipperByID.cc:116
Exception.h
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:292
edm::StreamerFileReader::initialNumberOfEventsToSkip_
int initialNumberOfEventsToSkip_
Definition: StreamerFileReader.h:46
edm::StreamerFileReader::isFirstFile_
bool isFirstFile_
Definition: StreamerFileReader.h:47
EventMsgView::lumi
uint32 lumi() const
Definition: EventMessage.cc:81
ParameterSet.h
edm::RawInputSource::Next::kEvent
edm::errors::FileReadError
Definition: EDMException.h:50
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
InitMsgView
Definition: InitMessage.h:61
edm::StreamerFileReader::genuineCloseFile
void genuineCloseFile() override
Definition: StreamerFileReader.cc:72
StreamerFileReader.h