CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
dqmservices::DQMStreamerReader Class Reference

#include <DQMStreamerReader.h>

Inheritance diagram for dqmservices::DQMStreamerReader:
edm::StreamerInputSource edm::RawInputSource edm::InputSource

Classes

struct  OpenFile
 

Public Types

typedef std::vector< std::string > Strings
 
- Public Types inherited from edm::RawInputSource
enum  Next { Next::kEvent, Next::kFile, Next::kStop }
 
- Public Types inherited from edm::InputSource
enum  ItemType {
  IsInvalid, IsStop, IsFile, IsRun,
  IsLumi, IsEvent, IsRepeat, IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 

Public Member Functions

 DQMStreamerReader (edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)
 
bool newHeader ()
 
 ~DQMStreamerReader () override
 
- Public Member Functions inherited from edm::StreamerInputSource
void deserializeAndMergeWithRegistry (InitMsgView const &initView, bool subsequent=false)
 
void deserializeEvent (EventMsgView const &eventView)
 
std::unique_ptr< SendJobHeaderdeserializeRegistry (InitMsgView const &initView)
 
bool isBufferLZMA (unsigned char const *inputBuffer, unsigned int inputSize)
 
bool isBufferZSTD (unsigned char const *inputBuffer, unsigned int inputSize)
 
 StreamerInputSource (ParameterSet const &pset, InputSourceDescription const &desc)
 
 ~StreamerInputSource () override
 
- Public Member Functions inherited from edm::RawInputSource
 RawInputSource (ParameterSet const &pset, InputSourceDescription const &desc)
 
 ~RawInputSource () override
 
- Public Member Functions inherited from edm::InputSource
std::shared_ptr< ActivityRegistryactReg () const
 Accessor for Activity Registry. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
std::shared_ptr< BranchIDListHelper const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
void closeFile (FileBlock *, bool cleaningUpAfterException)
 close current file More...
 
void doBeginJob ()
 Called by framework at beginning of job. More...
 
virtual void doBeginLumi (LuminosityBlockPrincipal &lbp, ProcessContext const *)
 Called by framework at beginning of lumi block. More...
 
virtual void doBeginRun (RunPrincipal &rp, ProcessContext const *)
 Called by framework at beginning of run. More...
 
void doEndJob ()
 Called by framework at end of job. More...
 
void fillProcessBlockHelper ()
 Fill the ProcessBlockHelper with info for the current file. More...
 
ProcessingController::ForwardState forwardState () const
 
bool goToEvent (EventID const &eventID)
 
 InputSource (InputSource const &)=delete
 
 InputSource (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
void issueReports (EventID const &eventID, StreamID streamID)
 issue an event report More...
 
LuminosityBlockNumber_t luminosityBlock () const
 Accessor for current luminosity block number. More...
 
std::shared_ptr< LuminosityBlockAuxiliaryluminosityBlockAuxiliary () const
 Called by the framework to merge or insert lumi in principal cache. More...
 
int maxEvents () const
 
int maxLuminosityBlocks () const
 
ModuleDescription const & moduleDescription () const
 Accessor for 'module' description. More...
 
ItemType nextItemType ()
 Advances the source to the next item. More...
 
bool nextProcessBlock (ProcessBlockPrincipal &)
 Next process block, return false if there is none, sets the processName in the principal. More...
 
InputSourceoperator= (InputSource const &)=delete
 
std::shared_ptr< ProcessBlockHelper > & processBlockHelper ()
 
std::shared_ptr< ProcessBlockHelper const > processBlockHelper () const
 Accessors for processBlockHelper. More...
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
std::shared_ptr< ProductRegistry > & productRegistry ()
 
std::shared_ptr< ProductRegistry const > productRegistry () const
 Accessors for product registry. More...
 
bool randomAccess () const
 
void readAndMergeLumi (LuminosityBlockPrincipal &lbp)
 Read next luminosity block (same as a prior lumi) More...
 
void readAndMergeRun (RunPrincipal &rp)
 Read next run (same as a prior run) More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific event. More...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
std::shared_ptr< FileBlockreadFile ()
 Read next file. More...
 
void readLuminosityBlock (LuminosityBlockPrincipal &lumiPrincipal, HistoryAppender &historyAppender)
 Read next luminosity block (new lumi) More...
 
std::shared_ptr< LuminosityBlockAuxiliaryreadLuminosityBlockAuxiliary ()
 Read next luminosity block Auxilary. More...
 
void readProcessBlock (ProcessBlockPrincipal &)
 Read next process block. More...
 
void readRun (RunPrincipal &runPrincipal, HistoryAppender &historyAppender)
 Read next run (new run) More...
 
std::shared_ptr< RunAuxiliaryreadRunAuxiliary ()
 Read next run Auxiliary. More...
 
ProcessHistoryID const & reducedProcessHistoryID () const
 
virtual void registerProducts ()
 Register any produced products. More...
 
int remainingEvents () const
 
int remainingLuminosityBlocks () const
 
void repeat ()
 Reset the remaining number of events/lumis to the maximum number. More...
 
std::pair< SharedResourcesAcquirer *, std::recursive_mutex * > resourceSharedWithDelayedReader ()
 Returns nullptr if no resource shared between the Source and a DelayedReader. More...
 
ProcessingController::ReverseState reverseState () const
 
void rewind ()
 Begin again at the first event. More...
 
RunNumber_t run () const
 Accessor for current run number. More...
 
std::shared_ptr< RunAuxiliaryrunAuxiliary () const
 Called by the framework to merge or insert run in principal cache. More...
 
void setLuminosityBlockNumber_t (LuminosityBlockNumber_t lb)
 Set the luminosity block ID. More...
 
void setRunNumber (RunNumber_t r)
 Set the run number. More...
 
void skipEvents (int offset)
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
Timestamp const & timestamp () const
 Accessor for the current time, as seen by the input source. More...
 
virtual ~InputSource () noexcept(false)
 Destructor. More...
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::StreamerInputSource
static void fillDescription (ParameterSetDescription &description)
 
static void mergeIntoRegistry (SendJobHeader const &header, ProductRegistry &, BranchIDListHelper &, ThinnedAssociationsHelper &, bool subsequent)
 
static unsigned int uncompressBuffer (unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize)
 
static unsigned int uncompressBufferLZMA (unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize, bool hasHeader=true)
 
static unsigned int uncompressBufferZSTD (unsigned char *inputBuffer, unsigned int inputSize, std::vector< unsigned char > &outputBuffer, unsigned int expectedFullSize, bool hasHeader=true)
 
- Static Public Member Functions inherited from edm::RawInputSource
static void fillDescription (ParameterSetDescription &description)
 
- Static Public Member Functions inherited from edm::InputSource
static const std::string & baseType ()
 
static void fillDescription (ParameterSetDescription &desc)
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 

Protected Member Functions

Next checkNext () override
 
void genuineCloseFile () override
 
void genuineReadFile () override
 
void skip (int toSkip) override
 
- Protected Member Functions inherited from edm::StreamerInputSource
void resetAfterEndRun ()
 
- Protected Member Functions inherited from edm::RawInputSource
void makeEvent (EventPrincipal &eventPrincipal, EventAuxiliary const &eventAuxiliary)
 
void setInputFileTransitionsEachEvent ()
 
- Protected Member Functions inherited from edm::InputSource
virtual void beginJob ()
 Begin protected makes it easier to do template programming. More...
 
void decreaseRemainingEventsBy (int iSkipped)
 
bool eventCached () const
 
bool newLumi () const
 
bool newRun () const
 
ProcessHistoryRegistryprocessHistoryRegistryForUpdate ()
 
ProductRegistryproductRegistryUpdate ()
 
void reset () const
 
void resetEventCached ()
 
void resetLuminosityBlockAuxiliary (bool isNewLumi=true) const
 
void resetNewLumi ()
 
void resetNewRun ()
 
void resetRunAuxiliary (bool isNewRun=true) const
 
void setEventCached ()
 Called by the framework to merge or ached() const {return eventCached_;}. More...
 
void setLuminosityBlockAuxiliary (LuminosityBlockAuxiliary *lbp)
 
void setNewLumi ()
 
void setNewRun ()
 
void setRunAuxiliary (RunAuxiliary *rp)
 
void setTimestamp (Timestamp const &theTime)
 To set the current time, as seen by the input source. More...
 
ItemType state () const
 

Private Member Functions

bool acceptEvent (const EventMsgView *)
 
void closeFileImp_ (const std::string &reason)
 
EventMsgView const * getEventMsg ()
 
InitMsgView const * getHeaderMsg ()
 
bool matchTriggerSel (Strings const &tnames)
 
void openFileImp_ (const DQMFileIterator::LumiEntry &entry)
 
bool openNextFileImp_ ()
 
EventMsgView const * prepareNextEvent ()
 
bool prepareNextFile ()
 
void reset_ () override
 
bool triggerSel ()
 

Private Attributes

bool acceptAllEvt_
 
std::shared_ptr< TriggerSelectoreventSelector_
 
std::shared_ptr< edm::EventSkipperByIDeventSkipperByID_
 
struct dqmservices::DQMStreamerReader::OpenFile file_
 
DQMFileIterator fiterator_
 
bool flagDeleteDatFiles_
 
bool flagEndOfRunKills_
 
bool flagSkipFirstLumis_
 
Strings hltSel_
 
bool isFirstFile_ = true
 
bool matchTriggerSel_
 
unsigned int minEventsPerLs_
 
edm::Service< DQMMonitoringServicemon_
 
unsigned int processedEventPerLs_
 
std::string runInputDir_
 
unsigned int runNumber_
 
std::string streamLabel_
 

Additional Inherited Members

- Public Attributes inherited from edm::InputSource
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> postEventReadFromSourceSignal_
 
signalslot::Signal< void(StreamContext const &, ModuleCallingContext const &)> preEventReadFromSourceSignal_
 
- Static Protected Member Functions inherited from edm::StreamerInputSource
static void buildClassCache (SendDescs const &descs)
 
static void declareStreamers (SendDescs const &descs)
 

Detailed Description

Definition at line 24 of file DQMStreamerReader.h.

Member Typedef Documentation

◆ Strings

typedef std::vector<std::string> dqmservices::DQMStreamerReader::Strings

Definition at line 32 of file DQMStreamerReader.h.

Constructor & Destructor Documentation

◆ DQMStreamerReader()

dqmservices::DQMStreamerReader::DQMStreamerReader ( edm::ParameterSet const &  pset,
edm::InputSourceDescription const &  desc 
)

Definition at line 29 of file DQMStreamerReader.cc.

31  runNumber_ = pset.getUntrackedParameter<unsigned int>("runNumber");
32  runInputDir_ = pset.getUntrackedParameter<std::string>("runInputDir");
33  hltSel_ = pset.getUntrackedParameter<std::vector<std::string> >("SelectEvents");
34 
35  minEventsPerLs_ = pset.getUntrackedParameter<int>("minEventsPerLumi");
36  flagSkipFirstLumis_ = pset.getUntrackedParameter<bool>("skipFirstLumis");
37  flagEndOfRunKills_ = pset.getUntrackedParameter<bool>("endOfRunKills");
38  flagDeleteDatFiles_ = pset.getUntrackedParameter<bool>("deleteDatFiles");
39 
40  triggerSel();
41 
42  reset_();
43  }

References flagDeleteDatFiles_, flagEndOfRunKills_, flagSkipFirstLumis_, hltSel_, minEventsPerLs_, muonDTDigis_cfi::pset, reset_(), runInputDir_, runNumber_, AlCaHLTBitMon_QueryRunRegistry::string, and triggerSel().

◆ ~DQMStreamerReader()

dqmservices::DQMStreamerReader::~DQMStreamerReader ( )
override

Definition at line 45 of file DQMStreamerReader.cc.

45  {
46  // Sometimes(?) the destructor called after service registry was already destructed
47  // and closeFile_ throws away no ServiceRegistry found exception...
48  //
49  // Normally, this file should be closed before this destructor is called.
50  //closeFileImp_("destructor");
51  }

Member Function Documentation

◆ acceptEvent()

bool dqmservices::DQMStreamerReader::acceptEvent ( const EventMsgView evtmsg)
private

Check the trigger path to accept event

Definition at line 381 of file DQMStreamerReader.cc.

381  {
382  if (acceptAllEvt_)
383  return true;
384  if (!matchTriggerSel_)
385  return false;
386 
387  std::vector<unsigned char> hltTriggerBits_;
388  int hltTriggerCount_ = evtmsg->hltCount();
389  if (hltTriggerCount_ > 0) {
390  hltTriggerBits_.resize(1 + (hltTriggerCount_ - 1) / 4);
391  }
392  evtmsg->hltTriggerBits(&hltTriggerBits_[0]);
393 
394  if (eventSelector_->wantAll() || eventSelector_->acceptEvent(&hltTriggerBits_[0], evtmsg->hltCount())) {
395  return true;
396  } else {
397  return false;
398  }
399  }

References acceptAllEvt_, eventSelector_, EventMsgView::hltCount(), EventMsgView::hltTriggerBits(), and matchTriggerSel_.

Referenced by prepareNextEvent().

◆ checkNext()

edm::RawInputSource::Next dqmservices::DQMStreamerReader::checkNext ( )
overrideprotectedvirtual

This is the actual code for checking the new event and/or deserializing it.

Implements edm::RawInputSource.

Definition at line 317 of file DQMStreamerReader.cc.

317  {
318  try {
319  EventMsgView const* eview = prepareNextEvent();
320  if (eview == nullptr) {
321  if (file_.streamFile_ and file_.streamFile_->newHeader()) {
322  return Next::kFile;
323  }
324  return Next::kStop;
325  }
326 
327  deserializeEvent(*eview);
328  } catch (const cms::Exception& e) {
329  // try to recover from corrupted files/events
330  fiterator_.logFileAction(std::string("Can't deserialize event or registry data: ") + e.what());
331  closeFileImp_("data file corrupted");
332 
333  // this is not optimal, but hopefully we won't catch this many times in a row
334  return checkNext();
335  }
336 
338 
339  return Next::kEvent;
340  }

References closeFileImp_(), edm::StreamerInputSource::deserializeEvent(), MillePedeFileConverter_cfg::e, file_, fiterator_, edm::RawInputSource::kEvent, edm::RawInputSource::kFile, edm::RawInputSource::kStop, dqmservices::DQMFileIterator::logFileAction(), prepareNextEvent(), processedEventPerLs_, dqmservices::DQMStreamerReader::OpenFile::streamFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ closeFileImp_()

void dqmservices::DQMStreamerReader::closeFileImp_ ( const std::string &  reason)
private

◆ fillDescriptions()

void dqmservices::DQMStreamerReader::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 417 of file DQMStreamerReader.cc.

417  {
419  desc.setComment("Reads events from streamer files.");
420 
421  desc.addUntracked<std::vector<std::string> >("SelectEvents")->setComment("HLT path to select events ");
422 
423  desc.addUntracked<int>("minEventsPerLumi", 1)
424  ->setComment(
425  "Minimum number of events to process per lumisection, "
426  "before switching to a new input file. If the next file "
427  "does not yet exist, "
428  "the number of processed events will be bigger.");
429 
430  desc.addUntracked<bool>("skipFirstLumis", false)
431  ->setComment(
432  "Skip (and ignore the minEventsPerLumi parameter) for the files "
433  "which have been available at the begining of the processing. "
434  "If set to true, the reader will open last available file for "
435  "processing.");
436 
437  desc.addUntracked<bool>("deleteDatFiles", false)
438  ->setComment(
439  "Delete data files after they have been closed, in order to "
440  "save disk space.");
441 
442  desc.addUntracked<bool>("endOfRunKills", false)
443  ->setComment(
444  "Kill the processing as soon as the end-of-run file appears, even if "
445  "there are/will be unprocessed lumisections.");
446 
447  // desc.addUntracked<unsigned int>("skipEvents", 0U)
448  // ->setComment("Skip the first 'skipEvents' events that otherwise would "
449  // "have been processed.");
450 
451  // This next parameter is read in the base class, but its default value
452  // depends on the derived class, so it is set here.
453  desc.addUntracked<bool>("inputFileTransitionsEachEvent", false);
454 
458 
459  descriptions.add("source", desc);
460  }

References edm::ConfigurationDescriptions::add(), submitPVResolutionJobs::desc, edm::EventSkipperByID::fillDescription(), edm::StreamerInputSource::fillDescription(), and dqmservices::DQMFileIterator::fillDescription().

◆ genuineCloseFile()

void dqmservices::DQMStreamerReader::genuineCloseFile ( )
overrideprotectedvirtual

Reimplemented from edm::RawInputSource.

Definition at line 135 of file DQMStreamerReader.cc.

135 {}

◆ genuineReadFile()

void dqmservices::DQMStreamerReader::genuineReadFile ( )
overrideprotectedvirtual

Reimplemented from edm::RawInputSource.

Definition at line 146 of file DQMStreamerReader.cc.

146  {
147  if (isFirstFile_) {
148  //The file was already opened in the constructor
149  isFirstFile_ = false;
150  return;
151  }
152 
153  //Get header/init from reader
154  InitMsgView const* header = getHeaderMsg();
156  }

References edm::StreamerInputSource::deserializeAndMergeWithRegistry(), getHeaderMsg(), RecoTauValidation_cfi::header, and isFirstFile_.

◆ getEventMsg()

EventMsgView const * dqmservices::DQMStreamerReader::getEventMsg ( )
private

Definition at line 195 of file DQMStreamerReader.cc.

195  {
196  auto next = file_.streamFile_->next();
198  return nullptr;
199  }
200 
202  return nullptr;
203  }
204 
205  EventMsgView const* msg = file_.streamFile_->currentRecord();
206 
207  // if (msg != nullptr) dumpEventView(msg);
208  return msg;
209  }

References file_, edm::RawInputSource::kFile, edm::RawInputSource::kStop, mps_check::msg, GetRecoTauVFromDQM_MC_cff::next, and dqmservices::DQMStreamerReader::OpenFile::streamFile_.

Referenced by prepareNextEvent().

◆ getHeaderMsg()

InitMsgView const * dqmservices::DQMStreamerReader::getHeaderMsg ( )
private

Definition at line 184 of file DQMStreamerReader.cc.

184  {
185  InitMsgView const* header = file_.streamFile_->startMessage();
186 
187  if (header->code() != Header::INIT) { // INIT Msg
188  throw edm::Exception(edm::errors::FileReadError, "DQMStreamerReader::readHeader")
189  << "received wrong message type: expected INIT, got " << header->code() << "\n";
190  }
191 
192  return header;
193  }

References Exception, file_, edm::errors::FileReadError, RecoTauValidation_cfi::header, Header::INIT, and dqmservices::DQMStreamerReader::OpenFile::streamFile_.

Referenced by genuineReadFile(), and openFileImp_().

◆ matchTriggerSel()

bool dqmservices::DQMStreamerReader::matchTriggerSel ( Strings const &  tnames)
private

Check if hlt selection matches any trigger name taken from the header file

Definition at line 360 of file DQMStreamerReader.cc.

360  {
361  matchTriggerSel_ = false;
362  for (Strings::const_iterator i(hltSel_.begin()), end(hltSel_.end()); i != end; ++i) {
364  boost::erase_all(hltPath, " \t");
365  std::vector<Strings::const_iterator> matches = edm::regexMatch(tnames, hltPath);
366  if (!matches.empty()) {
367  matchTriggerSel_ = true;
368  }
369  }
370 
371  if (!matchTriggerSel_) {
372  edm::LogWarning("Trigger selection does not match any trigger path!!!") << std::endl;
373  }
374 
375  return matchTriggerSel_;
376  }

References mps_fire::end, TriggerAnalyzer::hltPath, hltSel_, mps_fire::i, oniaPATMuonsWithTrigger_cff::matches, matchTriggerSel_, edm::regexMatch(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by openFileImp_().

◆ newHeader()

bool dqmservices::DQMStreamerReader::newHeader ( )

◆ openFileImp_()

void dqmservices::DQMStreamerReader::openFileImp_ ( const DQMFileIterator::LumiEntry entry)
private

Definition at line 95 of file DQMStreamerReader.cc.

95  {
98 
99  std::string path = entry.get_data_path();
100 
101  file_.lumi_ = entry;
102  file_.streamFile_ = std::make_unique<edm::StreamerInputFile>(path);
103 
104  InitMsgView const* header = getHeaderMsg();
105  if (isFirstFile_) {
107  }
108 
109  // dump the list of HLT trigger name from the header
110  // dumpInitHeader(header);
111 
112  // if specific trigger selection is requested, check if the requested triggers
113  // match with trigger paths in the header file
114  if (!acceptAllEvt_) {
115  Strings tnames;
116  header->hltTriggerNames(tnames);
117 
118  pset.addParameter<Strings>("SelectEvents", hltSel_);
119  eventSelector_.reset(new TriggerSelector(pset, tnames));
120 
121  // check if any trigger path name requested matches with trigger name in the
122  // header file
123  matchTriggerSel(tnames);
124  }
125 
126  // our initialization
128 
129  if (flagDeleteDatFiles_) {
130  // unlink the file
131  unlink(path.c_str());
132  }
133  }

References acceptAllEvt_, edm::StreamerInputSource::deserializeAndMergeWithRegistry(), mps_splice::entry, eventSelector_, file_, flagDeleteDatFiles_, getHeaderMsg(), RecoTauValidation_cfi::header, hltSel_, isFirstFile_, dqmservices::DQMStreamerReader::OpenFile::lumi_, matchTriggerSel(), castor_dqm_sourceclient_file_cfg::path, processedEventPerLs_, muonDTDigis_cfi::pset, dqmservices::DQMStreamerReader::OpenFile::streamFile_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by openNextFileImp_().

◆ openNextFileImp_()

bool dqmservices::DQMStreamerReader::openNextFileImp_ ( )
private

Definition at line 158 of file DQMStreamerReader.cc.

158  {
159  closeFileImp_("skipping to another file");
160 
161  DQMFileIterator::LumiEntry currentLumi = fiterator_.open();
162  std::string p = currentLumi.get_data_path();
163 
164  if (std::filesystem::exists(p)) {
165  try {
166  openFileImp_(currentLumi);
167  return true;
168  } catch (const cms::Exception& e) {
169  fiterator_.logFileAction(std::string("Can't deserialize registry data (in open file): ") + e.what(), p);
170  fiterator_.logLumiState(currentLumi, "error: data file corrupted");
171 
172  closeFileImp_("data file corrupted");
173  return false;
174  }
175  } else {
176  /* dat file missing */
177  fiterator_.logFileAction("Data file (specified in json) is missing:", p);
178  fiterator_.logLumiState(currentLumi, "error: data file missing");
179 
180  return false;
181  }
182  }

References closeFileImp_(), MillePedeFileConverter_cfg::e, fiterator_, dqmservices::DQMFileIterator::LumiEntry::get_data_path(), dqmservices::DQMFileIterator::logFileAction(), dqmservices::DQMFileIterator::logLumiState(), dqmservices::DQMFileIterator::open(), openFileImp_(), AlCaHLTBitMon_ParallelJobs::p, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by prepareNextFile().

◆ prepareNextEvent()

EventMsgView const * dqmservices::DQMStreamerReader::prepareNextEvent ( )
private

Waits and reads the event header. If end-of-run nullptr is returned.

Definition at line 278 of file DQMStreamerReader.cc.

278  {
279  EventMsgView const* eview = nullptr;
281 
282  // wait for the next event
283  for (;;) {
284  // edm::LogAbsolute("DQMStreamerReader")
285  // << "State loop.";
286  bool next = prepareNextFile();
287  if (!next)
288  return nullptr;
289 
290  // sleep
291  if (!file_.open()) {
292  // the reader does not exist
293  fiterator_.delay();
294  } else {
295  // our reader exists, try to read out an event
296  eview = getEventMsg();
297 
298  if (eview == nullptr) {
299  // read unsuccessful
300  // this means end of file, so close the file
301  closeFileImp_("eof");
302  } else {
303  if (!acceptEvent(eview)) {
304  continue;
305  } else {
306  return eview;
307  }
308  }
309  }
310  }
311  return eview;
312  }

References acceptEvent(), closeFileImp_(), dqmservices::DQMFileIterator::delay(), file_, fiterator_, getEventMsg(), GetRecoTauVFromDQM_MC_cff::next, dqmservices::DQMStreamerReader::OpenFile::open(), and prepareNextFile().

Referenced by checkNext(), and skip().

◆ prepareNextFile()

bool dqmservices::DQMStreamerReader::prepareNextFile ( )
private

Prepare (open) the next file for reading. It is used by prepareNextEvent and in the constructor.

Does not block/wait.

Return false if this is end of run and/or no more file are available. However, return of "true" does not imply the file has been openned, but we need to wait until some future file becomes available.

Definition at line 221 of file DQMStreamerReader.cc.

221  {
223 
224  for (;;) {
226 
227  if (edm::shutdown_flag.load()) {
228  fiterator_.logFileAction("Shutdown flag was set, shutting down.");
229 
230  closeFileImp_("shutdown flag is set");
231  return false;
232  }
233 
234  // check for end of run file and force quit
235  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
236  closeFileImp_("forced end-of-run");
237  return false;
238  }
239 
240  // check for end of run and quit if everything has been processed.
241  // this clean exit
242  if ((!file_.open()) && (!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
243  return false;
244  }
245 
246  // if this is end of run and no more files to process
247  // close it
249  (fiterator_.state() == State::EOR)) {
250  closeFileImp_("graceful end-of-run");
251  return false;
252  }
253 
254  // skip to the next file if we have no files openned yet
255  if (!file_.open()) {
256  if (fiterator_.lumiReady()) {
258  // we might need to open once more (if .dat is missing)
259  continue;
260  }
261  }
262 
263  // or if there is a next file and enough eventshas been processed.
266  // we might need to open once more (if .dat is missing)
267  continue;
268  }
269 
270  return true;
271  }
272  }

References closeFileImp_(), file_, fiterator_, flagEndOfRunKills_, svgfig::load(), dqmservices::DQMFileIterator::logFileAction(), dqmservices::DQMFileIterator::lumiReady(), minEventsPerLs_, dqmservices::DQMStreamerReader::OpenFile::open(), openNextFileImp_(), processedEventPerLs_, edm::shutdown_flag, dqmservices::DQMFileIterator::state(), and dqmservices::DQMFileIterator::update_state().

Referenced by prepareNextEvent(), and reset_().

◆ reset_()

void dqmservices::DQMStreamerReader::reset_ ( )
overrideprivatevirtual

Reimplemented from edm::RawInputSource.

Definition at line 53 of file DQMStreamerReader.cc.

53  {
54  // We have to load at least a single header,
55  // so the ProductRegistry gets initialized.
56  //
57  // This must happen here (inside the constructor),
58  // as ProductRegistry gets frozen after we initialize:
59  // https://cmssdt.cern.ch/SDT/lxr/source/FWCore/Framework/src/Schedule.cc#441
60 
61  fiterator_.logFileAction("Waiting for the first lumi in order to initialize.");
62 
64 
65  // Fast-forward to the last open file.
66  if (flagSkipFirstLumis_) {
67  unsigned int l = fiterator_.lastLumiFound();
68  if (l > 1) {
69  fiterator_.advanceToLumi(l, "skipped: fast-forward to the latest lumi");
70  }
71  }
72 
73  for (;;) {
74  bool next = prepareNextFile();
75 
76  // check for end of run
77  if (!next) {
78  fiterator_.logFileAction("End of run reached before DQMStreamerReader was initialised.");
79  return;
80  }
81 
82  // check if we have a file openned
83  if (file_.open()) {
84  // we are now initialised
85  break;
86  }
87 
88  // wait
89  fiterator_.delay();
90  }
91 
92  fiterator_.logFileAction("DQMStreamerReader initialised.");
93  }

References dqmservices::DQMFileIterator::advanceToLumi(), dqmservices::DQMFileIterator::delay(), file_, fiterator_, flagSkipFirstLumis_, cmsLHEtoEOSManager::l, dqmservices::DQMFileIterator::lastLumiFound(), dqmservices::DQMFileIterator::logFileAction(), GetRecoTauVFromDQM_MC_cff::next, dqmservices::DQMStreamerReader::OpenFile::open(), prepareNextFile(), and dqmservices::DQMFileIterator::update_state().

Referenced by DQMStreamerReader().

◆ skip()

void dqmservices::DQMStreamerReader::skip ( int  toSkip)
overrideprotectedvirtual

Reimplemented from edm::InputSource.

Definition at line 401 of file DQMStreamerReader.cc.

401  {
402  try {
403  for (int i = 0; i != toSkip; ++i) {
404  EventMsgView const* evMsg = prepareNextEvent();
405 
406  if (evMsg == nullptr) {
407  return;
408  }
409  }
410  } catch (const cms::Exception& e) {
411  // try to recover from corrupted files/events
412  fiterator_.logFileAction(std::string("Can't deserialize event data: ") + e.what());
413  closeFileImp_("data file corrupted");
414  }
415  }

References closeFileImp_(), MillePedeFileConverter_cfg::e, fiterator_, mps_fire::i, dqmservices::DQMFileIterator::logFileAction(), prepareNextEvent(), and AlCaHLTBitMon_QueryRunRegistry::string.

◆ triggerSel()

bool dqmservices::DQMStreamerReader::triggerSel ( )
private

If hlt trigger selection is '*', return a boolean variable to accept all events

Definition at line 346 of file DQMStreamerReader.cc.

346  {
347  acceptAllEvt_ = false;
348  for (Strings::const_iterator i(hltSel_.begin()), end(hltSel_.end()); i != end; ++i) {
350  boost::erase_all(hltPath, " \t");
351  if (hltPath == "*")
352  acceptAllEvt_ = true;
353  }
354  return acceptAllEvt_;
355  }

References acceptAllEvt_, mps_fire::end, TriggerAnalyzer::hltPath, hltSel_, mps_fire::i, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by DQMStreamerReader().

Member Data Documentation

◆ acceptAllEvt_

bool dqmservices::DQMStreamerReader::acceptAllEvt_
private

Definition at line 59 of file DQMStreamerReader.h.

Referenced by acceptEvent(), openFileImp_(), and triggerSel().

◆ eventSelector_

std::shared_ptr<TriggerSelector> dqmservices::DQMStreamerReader::eventSelector_
private

Definition at line 86 of file DQMStreamerReader.h.

Referenced by acceptEvent(), and openFileImp_().

◆ eventSkipperByID_

std::shared_ptr<edm::EventSkipperByID> dqmservices::DQMStreamerReader::eventSkipperByID_
private

Definition at line 85 of file DQMStreamerReader.h.

◆ file_

struct dqmservices::DQMStreamerReader::OpenFile dqmservices::DQMStreamerReader::file_
private

◆ fiterator_

DQMFileIterator dqmservices::DQMStreamerReader::fiterator_
private

◆ flagDeleteDatFiles_

bool dqmservices::DQMStreamerReader::flagDeleteDatFiles_
private

Definition at line 73 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader(), and openFileImp_().

◆ flagEndOfRunKills_

bool dqmservices::DQMStreamerReader::flagEndOfRunKills_
private

Definition at line 72 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader(), and prepareNextFile().

◆ flagSkipFirstLumis_

bool dqmservices::DQMStreamerReader::flagSkipFirstLumis_
private

Definition at line 71 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader(), and reset_().

◆ hltSel_

Strings dqmservices::DQMStreamerReader::hltSel_
private

Definition at line 66 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader(), matchTriggerSel(), openFileImp_(), and triggerSel().

◆ isFirstFile_

bool dqmservices::DQMStreamerReader::isFirstFile_ = true
private

Definition at line 61 of file DQMStreamerReader.h.

Referenced by genuineReadFile(), and openFileImp_().

◆ matchTriggerSel_

bool dqmservices::DQMStreamerReader::matchTriggerSel_
private

Definition at line 60 of file DQMStreamerReader.h.

Referenced by acceptEvent(), and matchTriggerSel().

◆ minEventsPerLs_

unsigned int dqmservices::DQMStreamerReader::minEventsPerLs_
private

Definition at line 69 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader(), and prepareNextFile().

◆ mon_

edm::Service<DQMMonitoringService> dqmservices::DQMStreamerReader::mon_
private

Definition at line 89 of file DQMStreamerReader.h.

◆ processedEventPerLs_

unsigned int dqmservices::DQMStreamerReader::processedEventPerLs_
private

Definition at line 68 of file DQMStreamerReader.h.

Referenced by checkNext(), openFileImp_(), and prepareNextFile().

◆ runInputDir_

std::string dqmservices::DQMStreamerReader::runInputDir_
private

Definition at line 64 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader().

◆ runNumber_

unsigned int dqmservices::DQMStreamerReader::runNumber_
private

Definition at line 63 of file DQMStreamerReader.h.

Referenced by DQMStreamerReader().

◆ streamLabel_

std::string dqmservices::DQMStreamerReader::streamLabel_
private

Definition at line 65 of file DQMStreamerReader.h.

mps_fire.i
i
Definition: mps_fire.py:428
dqmservices::DQMStreamerReader::reset_
void reset_() override
Definition: DQMStreamerReader.cc:53
dqmservices::DQMFileIterator::logFileAction
void logFileAction(const std::string &msg, const std::string &fileName="") const
Definition: DQMFileIterator.cc:375
dqmservices::DQMStreamerReader::triggerSel
bool triggerSel()
Definition: DQMStreamerReader.cc:346
dqmservices::DQMStreamerReader::acceptAllEvt_
bool acceptAllEvt_
Definition: DQMStreamerReader.h:59
hcaldqm::flag::State
State
Definition: Flag.h:13
edm::StreamerInputSource::deserializeEvent
void deserializeEvent(EventMsgView const &eventView)
Definition: StreamerInputSource.cc:185
dqmservices::DQMStreamerReader::acceptEvent
bool acceptEvent(const EventMsgView *)
Definition: DQMStreamerReader.cc:381
edm::regexMatch
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const &regexp)
Definition: RegexMatch.cc:26
mps_splice.entry
entry
Definition: mps_splice.py:68
TriggerAnalyzer.hltPath
hltPath
Definition: TriggerAnalyzer.py:62
oniaPATMuonsWithTrigger_cff.matches
matches
Definition: oniaPATMuonsWithTrigger_cff.py:77
dqmservices::DQMStreamerReader::openFileImp_
void openFileImp_(const DQMFileIterator::LumiEntry &entry)
Definition: DQMStreamerReader.cc:95
dqmservices::DQMStreamerReader::OpenFile::streamFile_
std::unique_ptr< edm::StreamerInputFile > streamFile_
Definition: DQMStreamerReader.h:78
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::StreamerInputSource::fillDescription
static void fillDescription(ParameterSetDescription &description)
Definition: StreamerInputSource.cc:513
dqmservices::DQMFileIterator::open
LumiEntry open()
Definition: DQMFileIterator.cc:123
dqmservices::DQMStreamerReader::closeFileImp_
void closeFileImp_(const std::string &reason)
Definition: DQMStreamerReader.cc:137
mps_check.msg
tuple msg
Definition: mps_check.py:285
dqmservices::DQMStreamerReader::isFirstFile_
bool isFirstFile_
Definition: DQMStreamerReader.h:61
dqmservices::DQMStreamerReader::runInputDir_
std::string runInputDir_
Definition: DQMStreamerReader.h:64
dqmservices::DQMStreamerReader::openNextFileImp_
bool openNextFileImp_()
Definition: DQMStreamerReader.cc:158
dqmservices::DQMFileIterator::delay
void delay()
Definition: DQMFileIterator.cc:390
Strings
std::vector< std::string > Strings
Definition: MsgTools.h:18
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
dqmservices::DQMStreamerReader::minEventsPerLs_
unsigned int minEventsPerLs_
Definition: DQMStreamerReader.h:69
Header::INIT
Definition: MsgHeader.h:15
EventMsgView
Definition: EventMessage.h:72
dqmservices::DQMStreamerReader::flagEndOfRunKills_
bool flagEndOfRunKills_
Definition: DQMStreamerReader.h:72
dqmservices::DQMFileIterator::fillDescription
static void fillDescription(edm::ParameterSetDescription &d)
Definition: DQMFileIterator.cc:397
edm::StreamerInputSource::deserializeAndMergeWithRegistry
void deserializeAndMergeWithRegistry(InitMsgView const &initView, bool subsequent=false)
Definition: StreamerInputSource.cc:167
dqmservices::DQMStreamerReader::checkNext
Next checkNext() override
Definition: DQMStreamerReader.cc:317
dqmservices::DQMStreamerReader::flagDeleteDatFiles_
bool flagDeleteDatFiles_
Definition: DQMStreamerReader.h:73
EventMsgView::hltCount
uint32 hltCount() const
Definition: EventMessage.h:94
dqmservices::DQMStreamerReader::matchTriggerSel_
bool matchTriggerSel_
Definition: DQMStreamerReader.h:60
dqmservices::DQMStreamerReader::prepareNextFile
bool prepareNextFile()
Definition: DQMStreamerReader.cc:221
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
dqmservices::DQMStreamerReader::file_
struct dqmservices::DQMStreamerReader::OpenFile file_
mps_fire.end
end
Definition: mps_fire.py:242
EventMsgView::hltTriggerBits
void hltTriggerBits(uint8 *put_here) const
Definition: EventMessage.cc:110
svgfig.load
def load(fileName)
Definition: svgfig.py:547
dqmservices::DQMStreamerReader::prepareNextEvent
EventMsgView const * prepareNextEvent()
Definition: DQMStreamerReader.cc:278
edm::RawInputSource::Next::kFile
edm::ParameterSet
Definition: ParameterSet.h:47
dqmservices::DQMFileIterator::state
State state()
Definition: DQMFileIterator.cc:121
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
edm::shutdown_flag
volatile std::atomic< bool > shutdown_flag
Definition: UnixSignalHandlers.cc:22
edm::RawInputSource::Next::kStop
dqmservices::DQMStreamerReader::OpenFile::lumi_
DQMFileIterator::LumiEntry lumi_
Definition: DQMStreamerReader.h:79
dqmservices::DQMFileIterator::lumiReady
bool lumiReady()
Definition: DQMFileIterator.cc:129
dqmservices::DQMStreamerReader::processedEventPerLs_
unsigned int processedEventPerLs_
Definition: DQMStreamerReader.h:68
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
cmsLHEtoEOSManager.l
l
Definition: cmsLHEtoEOSManager.py:204
PixelMapPlotter.reason
reason
Definition: PixelMapPlotter.py:509
dqmservices::DQMFileIterator::advanceToLumi
void advanceToLumi(unsigned int lumi, std::string reason)
Definition: DQMFileIterator.cc:147
dqmservices::DQMStreamerReader::flagSkipFirstLumis_
bool flagSkipFirstLumis_
Definition: DQMStreamerReader.h:71
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
dqmservices::DQMStreamerReader::getHeaderMsg
InitMsgView const * getHeaderMsg()
Definition: DQMStreamerReader.cc:184
dqmservices::DQMStreamerReader::fiterator_
DQMFileIterator fiterator_
Definition: DQMStreamerReader.h:75
dqmservices::DQMStreamerReader::matchTriggerSel
bool matchTriggerSel(Strings const &tnames)
Definition: DQMStreamerReader.cc:360
Exception
Definition: hltDiff.cc:245
edm::EventSkipperByID::fillDescription
static void fillDescription(ParameterSetDescription &desc)
Definition: EventSkipperByID.cc:116
dqmservices::DQMFileIterator::update_state
void update_state()
Definition: DQMFileIterator.cc:316
edm::StreamerInputSource::StreamerInputSource
StreamerInputSource(ParameterSet const &pset, InputSourceDescription const &desc)
Definition: StreamerInputSource.cc:45
RecoTauValidation_cfi.header
header
Definition: RecoTauValidation_cfi.py:291
cms::Exception
Definition: Exception.h:70
castor_dqm_sourceclient_file_cfg.path
path
Definition: castor_dqm_sourceclient_file_cfg.py:37
dqmservices::DQMStreamerReader::getEventMsg
EventMsgView const * getEventMsg()
Definition: DQMStreamerReader.cc:195
edm::RawInputSource::Next::kEvent
dqmservices::DQMFileIterator::logLumiState
void logLumiState(const LumiEntry &lumi, const std::string &msg)
Definition: DQMFileIterator.cc:380
edm::errors::FileReadError
Definition: EDMException.h:50
dqmservices::DQMFileIterator::lastLumiFound
unsigned int lastLumiFound()
Definition: DQMFileIterator.cc:139
dqmservices::DQMFileIterator::State
State
Definition: DQMFileIterator.h:50
dqmservices::DQMStreamerReader::runNumber_
unsigned int runNumber_
Definition: DQMStreamerReader.h:63
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27
dqmservices::DQMStreamerReader::eventSelector_
std::shared_ptr< TriggerSelector > eventSelector_
Definition: DQMStreamerReader.h:86
dqmservices::DQMStreamerReader::OpenFile::open
bool open()
Definition: DQMStreamerReader.h:81
GetRecoTauVFromDQM_MC_cff.next
next
Definition: GetRecoTauVFromDQM_MC_cff.py:31
InitMsgView
Definition: InitMessage.h:61
MillePedeFileConverter_cfg.e
e
Definition: MillePedeFileConverter_cfg.py:37
dqmservices::DQMStreamerReader::hltSel_
Strings hltSel_
Definition: DQMStreamerReader.h:66