CMS 3D CMS Logo

List of all members | Classes | 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::streamer::StreamerInputSource edm::RawInputSource edm::InputSource

Classes

struct  OpenFile
 

Public Member Functions

 DQMStreamerReader (edm::ParameterSet const &pset, edm::InputSourceDescription const &desc)
 
bool newHeader ()
 
 ~DQMStreamerReader () override
 
- Public Member Functions inherited from edm::streamer::StreamerInputSource
void deserializeAndMergeWithRegistry (InitMsgView const &initView, bool subsequent=false)
 
void deserializeEvent (EventMsgView const &eventView)
 
void deserializeEventMetaData (EventMsgView const &eventView)
 
std::unique_ptr< SendJobHeaderdeserializeRegistry (InitMsgView const &initView)
 
uint32_t eventMetaDataChecksum (EventMsgView const &eventView) const
 
bool isBufferLZMA (unsigned char const *inputBuffer, unsigned int inputSize)
 
bool isBufferZSTD (unsigned char const *inputBuffer, unsigned int inputSize)
 
uint32_t presentEventMetaDataChecksum () const
 
 StreamerInputSource (ParameterSet const &pset, InputSourceDescription const &desc)
 
void updateEventMetaData ()
 
 ~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 const > branchIDListHelper () const
 Accessors for branchIDListHelper. More...
 
std::shared_ptr< BranchIDListHelper > & branchIDListHelper ()
 
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 (ParameterSet const &, InputSourceDescription const &)
 Constructor. More...
 
 InputSource (InputSource const &)=delete
 
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...
 
ItemTypeInfo 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 const > processBlockHelper () const
 Accessors for processBlockHelper. More...
 
std::shared_ptr< ProcessBlockHelper > & processBlockHelper ()
 
ProcessConfiguration const & processConfiguration () const
 Accessor for Process Configuration. More...
 
std::string const & processGUID () const
 Accessor for global process identifier. More...
 
ProcessHistoryRegistry const & processHistoryRegistry () const
 Accessors for process history registry. More...
 
ProcessHistoryRegistryprocessHistoryRegistry ()
 
ProcessingMode processingMode () const
 RunsLumisAndEvents (default), RunsAndLumis, or Runs. More...
 
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...
 
void readEvent (EventPrincipal &ep, StreamContext &)
 Read next event. More...
 
bool readEvent (EventPrincipal &ep, EventID const &, StreamContext &)
 Read a specific 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)
 
void switchTo (std::shared_ptr< ProductRegistry > iOther)
 switch to a different ProductRegistry. More...
 
std::shared_ptr< ThinnedAssociationsHelper const > thinnedAssociationsHelper () const
 Accessors for thinnedAssociationsHelper. More...
 
std::shared_ptr< ThinnedAssociationsHelper > & thinnedAssociationsHelper ()
 
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::streamer::StreamerInputSource
static void fillDescription (ParameterSetDescription &description)
 
static void mergeIntoRegistry (SendJobHeader const &header, ProductRegistry &, 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::streamer::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...
 
ItemTypeInfo state () const
 

Private Member Functions

bool acceptEvent (const edm::streamer::EventMsgView *)
 
void closeFileImp_ (const std::string &reason)
 
edm::streamer::EventMsgView const * getEventMsg ()
 
edm::streamer::InitMsgView const * getHeaderMsg ()
 
void openFileImp_ (const DQMFileIterator::LumiEntry &entry)
 
bool openNextFileImp_ ()
 
edm::streamer::EventMsgView const * prepareNextEvent ()
 
bool prepareNextFile ()
 
void reset_ () override
 
bool setAcceptAllEvt ()
 
bool setMatchTriggerSel (std::vector< std::string > const &tnames)
 
void setupMetaData (edm::streamer::InitMsgView const &msg, bool subsequent)
 

Private Attributes

bool acceptAllEvt_ = false
 
bool artificialFileBoundary_ = false
 
std::shared_ptr< edm::EventSkipperByIDeventSkipperByID_
 
struct dqmservices::DQMStreamerReader::OpenFile file_
 
DQMFileIterator fiterator_
 
bool const flagDeleteDatFiles_
 
bool const flagEndOfRunKills_
 
bool const flagSkipFirstLumis_
 
std::vector< std::string > const hltSel_
 
bool isFirstFile_ = true
 
bool matchTriggerSel_ = false
 
unsigned int const minEventsPerLs_
 
unsigned int processedEventPerLs_ = 0
 
std::shared_ptr< TriggerSelectortriggerSelector_
 

Additional Inherited Members

- Public Types inherited from edm::RawInputSource
enum  Next { Next::kEvent, Next::kFile, Next::kStop }
 
- Public Types inherited from edm::InputSource
enum  ItemPosition : char { ItemPosition::Invalid, ItemPosition::LastItemToBeMerged, ItemPosition::NotLastItemToBeMerged }
 
enum  ItemType : char {
  ItemType::IsInvalid, ItemType::IsStop, ItemType::IsFile, ItemType::IsRun,
  ItemType::IsLumi, ItemType::IsEvent, ItemType::IsRepeat, ItemType::IsSynchronize
}
 
enum  ProcessingMode { Runs, RunsAndLumis, RunsLumisAndEvents }
 
- 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::streamer::StreamerInputSource
static void buildClassCache (SendDescs const &descs)
 
static void declareStreamers (SendDescs const &descs)
 

Detailed Description

Definition at line 17 of file DQMStreamerReader.h.

Constructor & Destructor Documentation

◆ DQMStreamerReader()

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

Definition at line 23 of file DQMStreamerReader.cc.

References reset_(), and setAcceptAllEvt().

26  minEventsPerLs_(pset.getUntrackedParameter<int>("minEventsPerLumi")),
27  flagSkipFirstLumis_(pset.getUntrackedParameter<bool>("skipFirstLumis")),
28  flagEndOfRunKills_(pset.getUntrackedParameter<bool>("endOfRunKills")),
29  flagDeleteDatFiles_(pset.getUntrackedParameter<bool>("deleteDatFiles")),
30  hltSel_(pset.getUntrackedParameter<std::vector<std::string>>("SelectEvents")) {
32  reset_();
33  }
unsigned int const minEventsPerLs_
std::vector< std::string > const hltSel_
StreamerInputSource(ParameterSet const &pset, InputSourceDescription const &desc)

◆ ~DQMStreamerReader()

dqmservices::DQMStreamerReader::~DQMStreamerReader ( )
override

Definition at line 35 of file DQMStreamerReader.cc.

35  {
36  // Sometimes(?) the destructor called after service registry was already destructed
37  // and closeFile_ throws away no ServiceRegistry found exception...
38  //
39  // Normally, this file should be closed before this destructor is called.
40  //closeFileImp_("destructor");
41  }

Member Function Documentation

◆ acceptEvent()

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

Check the trigger path to accept event

Definition at line 404 of file DQMStreamerReader.cc.

References acceptAllEvt_, edm::streamer::EventMsgView::hltCount(), edm::streamer::EventMsgView::hltTriggerBits(), matchTriggerSel_, and triggerSelector_.

Referenced by prepareNextEvent().

404  {
405  if (acceptAllEvt_)
406  return true;
407  if (!matchTriggerSel_)
408  return false;
409 
410  std::vector<unsigned char> hltTriggerBits_;
411  int hltTriggerCount_ = evtmsg->hltCount();
412  if (hltTriggerCount_ > 0) {
413  hltTriggerBits_.resize(1 + (hltTriggerCount_ - 1) / 4);
414  }
415  evtmsg->hltTriggerBits(&hltTriggerBits_[0]);
416 
417  return (triggerSelector_->wantAll() || triggerSelector_->acceptEvent(&hltTriggerBits_[0], evtmsg->hltCount()));
418  }
std::shared_ptr< TriggerSelector > triggerSelector_
void hltTriggerBits(uint8 *put_here) const

◆ 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 337 of file DQMStreamerReader.cc.

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

337  {
338  try {
339  EventMsgView const* eview = prepareNextEvent();
340  if (eview == nullptr) {
341  if (artificialFileBoundary_ or (file_.streamFile_ and file_.streamFile_->newHeader())) {
342  return Next::kFile;
343  }
344  return Next::kStop;
345  }
346 
347  deserializeEvent(*eview);
348  } catch (const cms::Exception& e) {
349  // try to recover from corrupted files/events
350  fiterator_.logFileAction(std::string("Can't deserialize event or registry data: ") + e.what());
351  closeFileImp_("data file corrupted");
352 
353  // this is not optimal, but hopefully we won't catch this many times in a row
354  return checkNext();
355  }
356 
358 
359  return Next::kEvent;
360  }
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
void deserializeEvent(EventMsgView const &eventView)
void logFileAction(const std::string &msg, const std::string &fileName="") const
edm::streamer::EventMsgView const * prepareNextEvent()
std::unique_ptr< edm::streamer::StreamerInputFile > streamFile_
void closeFileImp_(const std::string &reason)
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ closeFileImp_()

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

◆ fillDescriptions()

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

Definition at line 436 of file DQMStreamerReader.cc.

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

436  {
438  desc.setComment("Reads events from streamer files.");
439 
440  desc.addUntracked<std::vector<std::string>>("SelectEvents")->setComment("HLT path to select events");
441 
442  desc.addUntracked<int>("minEventsPerLumi", 1)
443  ->setComment(
444  "Minimum number of events to process per lumisection, "
445  "before switching to a new input file. If the next file "
446  "does not yet exist, "
447  "the number of processed events will be bigger.");
448 
449  desc.addUntracked<bool>("skipFirstLumis", false)
450  ->setComment(
451  "Skip (and ignore the minEventsPerLumi parameter) for the files "
452  "which have been available at the begining of the processing. "
453  "If set to true, the reader will open last available file for "
454  "processing.");
455 
456  desc.addUntracked<bool>("deleteDatFiles", false)
457  ->setComment(
458  "Delete data files after they have been closed, in order to "
459  "save disk space.");
460 
461  desc.addUntracked<bool>("endOfRunKills", false)
462  ->setComment(
463  "Kill the processing as soon as the end-of-run file appears, even if "
464  "there are/will be unprocessed lumisections.");
465 
466  // desc.addUntracked<unsigned int>("skipEvents", 0U)
467  // ->setComment("Skip the first 'skipEvents' events that otherwise would "
468  // "have been processed.");
469 
470  // This next parameter is read in the base class, but its default value
471  // depends on the derived class, so it is set here.
472  desc.addUntracked<bool>("inputFileTransitionsEachEvent", false);
473 
477 
478  descriptions.add("source", desc);
479  }
static void fillDescription(ParameterSetDescription &description)
void add(std::string const &label, ParameterSetDescription const &psetDescription)
static void fillDescription(ParameterSetDescription &desc)
static void fillDescription(edm::ParameterSetDescription &d)

◆ genuineCloseFile()

void dqmservices::DQMStreamerReader::genuineCloseFile ( )
overrideprotectedvirtual

Reimplemented from edm::RawInputSource.

Definition at line 131 of file DQMStreamerReader.cc.

131 {}

◆ genuineReadFile()

void dqmservices::DQMStreamerReader::genuineReadFile ( )
overrideprotectedvirtual

Reimplemented from edm::RawInputSource.

Definition at line 142 of file DQMStreamerReader.cc.

References artificialFileBoundary_, getHeaderMsg(), RecoTauValidation_cfi::header, isFirstFile_, setupMetaData(), and edm::streamer::StreamerInputSource::updateEventMetaData().

142  {
143  if (isFirstFile_) {
144  //The file was already opened in the constructor
145  isFirstFile_ = false;
146  return;
147  }
148 
151  artificialFileBoundary_ = false;
152  return;
153  }
154  //Get header/init from reader
155  InitMsgView const* header = getHeaderMsg();
156  setupMetaData(*header, true);
157  }
edm::streamer::InitMsgView const * getHeaderMsg()
void setupMetaData(edm::streamer::InitMsgView const &msg, bool subsequent)

◆ getEventMsg()

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

Definition at line 196 of file DQMStreamerReader.cc.

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

Referenced by prepareNextEvent(), and setupMetaData().

196  {
197  auto next = file_.streamFile_->next();
199  return nullptr;
200  }
201 
203  return nullptr;
204  }
205 
206  EventMsgView const* msg = file_.streamFile_->currentRecord();
207 
208  // if (msg != nullptr) dumpEventView(msg);
209  return msg;
210  }
std::unique_ptr< edm::streamer::StreamerInputFile > streamFile_
tuple msg
Definition: mps_check.py:286
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ getHeaderMsg()

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

Definition at line 185 of file DQMStreamerReader.cc.

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

Referenced by genuineReadFile(), and openFileImp_().

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

◆ newHeader()

bool dqmservices::DQMStreamerReader::newHeader ( )

◆ openFileImp_()

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

Definition at line 95 of file DQMStreamerReader.cc.

References acceptAllEvt_, mps_splice::entry, file_, flagDeleteDatFiles_, getHeaderMsg(), RecoTauValidation_cfi::header, hltSel_, isFirstFile_, dqmservices::DQMStreamerReader::OpenFile::lumi_, castor_dqm_sourceclient_file_cfg::path, processedEventPerLs_, setMatchTriggerSel(), setupMetaData(), dqmservices::DQMStreamerReader::OpenFile::streamFile_, AlCaHLTBitMon_QueryRunRegistry::string, and triggerSelector_.

Referenced by openNextFileImp_().

95  {
97 
98  std::string path = entry.get_data_path();
99 
100  file_.lumi_ = entry;
101  file_.streamFile_ = std::make_unique<StreamerInputFile>(path);
102 
103  InitMsgView const* header = getHeaderMsg();
104  if (isFirstFile_) {
105  setupMetaData(*header, false);
106  }
107 
108  // dump the list of HLT trigger name from the header
109  // dumpInitHeader(header);
110 
111  // if specific trigger selection is requested, check if the requested triggers match with trigger paths in the header file
112  if (!acceptAllEvt_) {
113  std::vector<std::string> tnames;
114  header->hltTriggerNames(tnames);
115 
116  triggerSelector_.reset(new TriggerSelector(hltSel_, tnames));
117 
118  // check if any trigger path name requested matches with trigger name in the header file
119  setMatchTriggerSel(tnames);
120  }
121 
122  // our initialization
124 
125  if (flagDeleteDatFiles_) {
126  // unlink the file
127  unlink(path.c_str());
128  }
129  }
std::vector< std::string > const hltSel_
edm::streamer::InitMsgView const * getHeaderMsg()
std::shared_ptr< TriggerSelector > triggerSelector_
bool setMatchTriggerSel(std::vector< std::string > const &tnames)
void setupMetaData(edm::streamer::InitMsgView const &msg, bool subsequent)
std::unique_ptr< edm::streamer::StreamerInputFile > streamFile_
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ openNextFileImp_()

bool dqmservices::DQMStreamerReader::openNextFileImp_ ( )
private

Definition at line 159 of file DQMStreamerReader.cc.

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().

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

◆ prepareNextEvent()

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

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

Definition at line 279 of file DQMStreamerReader.cc.

References acceptEvent(), artificialFileBoundary_, cms::cuda::assert(), closeFileImp_(), dqmservices::DQMFileIterator::delay(), edm::streamer::StreamerInputSource::deserializeEventMetaData(), edm::streamer::StreamerInputSource::eventMetaDataChecksum(), file_, fiterator_, getEventMsg(), edm::streamer::EventMsgView::isEventMetaData(), GetRecoTauVFromDQM_MC_cff::next, dqmservices::DQMStreamerReader::OpenFile::open(), or, prepareNextFile(), and edm::streamer::StreamerInputSource::presentEventMetaDataChecksum().

Referenced by checkNext(), and skip().

279  {
280  EventMsgView const* eview = nullptr;
282 
283  // wait for the next event
284  for (;;) {
285  // edm::LogAbsolute("DQMStreamerReader")
286  // << "State loop.";
287  bool next = prepareNextFile();
288  if (!next)
289  return nullptr;
290 
291  // sleep
292  if (!file_.open()) {
293  // the reader does not exist
294  fiterator_.delay();
295  } else {
296  // our reader exists, try to read out an event
297  eview = getEventMsg();
298 
299  if (eview == nullptr) {
300  // read unsuccessful
301  // this means end of file, so close the file
302  closeFileImp_("eof");
303  } else {
304  //NOTE: at this point need to see if meta data checksum changed. If it did
305  // we need to issue a 'new File' transition
306  if (eview->isEventMetaData()) {
307  auto lastEventMetaData = presentEventMetaDataChecksum();
308  if (eventMetaDataChecksum(*eview) != lastEventMetaData) {
309  deserializeEventMetaData(*eview);
311  return nullptr;
312  } else {
313  //skipping
314  eview = getEventMsg();
315  assert((eview == nullptr) or (not eview->isEventMetaData()));
316  if (eview == nullptr) {
317  closeFileImp_("eof");
318  continue;
319  }
320  }
321  }
322 
323  if (!acceptEvent(eview)) {
324  continue;
325  } else {
326  return eview;
327  }
328  }
329  }
330  }
331  return eview;
332  }
void deserializeEventMetaData(EventMsgView const &eventView)
bool acceptEvent(const edm::streamer::EventMsgView *)
assert(be >=bs)
edm::streamer::EventMsgView const * getEventMsg()
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e< void, edm::EventID const &, edm::Timestamp const & > We also list in braces which AR_WATCH_USING_METHOD_ is used for those or
Definition: Activities.doc:12
uint32_t eventMetaDataChecksum(EventMsgView const &eventView) const
void closeFileImp_(const std::string &reason)
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ 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 222 of file DQMStreamerReader.cc.

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_().

222  {
224 
225  for (;;) {
227 
228  if (edm::shutdown_flag.load()) {
229  fiterator_.logFileAction("Shutdown flag was set, shutting down.");
230 
231  closeFileImp_("shutdown flag is set");
232  return false;
233  }
234 
235  // check for end of run file and force quit
236  if (flagEndOfRunKills_ && (fiterator_.state() != State::OPEN)) {
237  closeFileImp_("forced end-of-run");
238  return false;
239  }
240 
241  // check for end of run and quit if everything has been processed.
242  // this clean exit
243  if ((!file_.open()) && (!fiterator_.lumiReady()) && (fiterator_.state() == State::EOR)) {
244  return false;
245  }
246 
247  // if this is end of run and no more files to process
248  // close it
250  (fiterator_.state() == State::EOR)) {
251  closeFileImp_("graceful end-of-run");
252  return false;
253  }
254 
255  // skip to the next file if we have no files openned yet
256  if (!file_.open()) {
257  if (fiterator_.lumiReady()) {
259  // we might need to open once more (if .dat is missing)
260  continue;
261  }
262  }
263 
264  // or if there is a next file and enough eventshas been processed.
267  // we might need to open once more (if .dat is missing)
268  continue;
269  }
270 
271  return true;
272  }
273  }
unsigned int const minEventsPerLs_
volatile std::atomic< bool > shutdown_flag
void logFileAction(const std::string &msg, const std::string &fileName="") const
def load(fileName)
Definition: svgfig.py:547
void closeFileImp_(const std::string &reason)
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ reset_()

void dqmservices::DQMStreamerReader::reset_ ( )
overrideprivatevirtual

Reimplemented from edm::RawInputSource.

Definition at line 43 of file DQMStreamerReader.cc.

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

Referenced by DQMStreamerReader().

43  {
44  // We have to load at least a single header,
45  // so the ProductRegistry gets initialized.
46  //
47  // This must happen here (inside the constructor),
48  // as ProductRegistry gets frozen after we initialize:
49  // https://cmssdt.cern.ch/SDT/lxr/source/FWCore/Framework/src/Schedule.cc#441
50 
51  fiterator_.logFileAction("Waiting for the first lumi in order to initialize.");
52 
54 
55  // Fast-forward to the last open file.
56  if (flagSkipFirstLumis_) {
57  unsigned int l = fiterator_.lastLumiFound();
58  if (l > 1) {
59  fiterator_.advanceToLumi(l, "skipped: fast-forward to the latest lumi");
60  }
61  }
62 
63  for (;;) {
64  bool next = prepareNextFile();
65 
66  // check for end of run
67  if (!next) {
68  fiterator_.logFileAction("End of run reached before DQMStreamerReader was initialised.");
69  return;
70  }
71 
72  // check if we have a file openned
73  if (file_.open()) {
74  // we are now initialised
75  break;
76  }
77 
78  // wait
79  fiterator_.delay();
80  }
81 
82  fiterator_.logFileAction("DQMStreamerReader initialised.");
83  }
void logFileAction(const std::string &msg, const std::string &fileName="") const
void advanceToLumi(unsigned int lumi, std::string reason)
struct dqmservices::DQMStreamerReader::OpenFile file_

◆ setAcceptAllEvt()

bool dqmservices::DQMStreamerReader::setAcceptAllEvt ( )
private

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

Definition at line 366 of file DQMStreamerReader.cc.

References acceptAllEvt_, HltBtagPostValidation_cff::c, TriggerAnalyzer::hltPath, and hltSel_.

Referenced by DQMStreamerReader().

366  {
367  acceptAllEvt_ = false;
368  for (auto hltPath : hltSel_) {
369  hltPath.erase(std::remove_if(hltPath.begin(), hltPath.end(), [](unsigned char c) { return std::isspace(c); }),
370  hltPath.end());
371  if (hltPath == "*") {
372  acceptAllEvt_ = true;
373  break;
374  }
375  }
376  return acceptAllEvt_;
377  }
std::vector< std::string > const hltSel_

◆ setMatchTriggerSel()

bool dqmservices::DQMStreamerReader::setMatchTriggerSel ( std::vector< std::string > const &  tnames)
private

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

Definition at line 382 of file DQMStreamerReader.cc.

References HltBtagPostValidation_cff::c, TriggerAnalyzer::hltPath, hltSel_, oniaPATMuonsWithTrigger_cff::matches, matchTriggerSel_, and edm::regexMatch().

Referenced by openFileImp_().

382  {
383  matchTriggerSel_ = false;
384  for (auto hltPath : hltSel_) {
385  hltPath.erase(std::remove_if(hltPath.begin(), hltPath.end(), [](unsigned char c) { return std::isspace(c); }),
386  hltPath.end());
387  auto const matches = edm::regexMatch(tnames, hltPath);
388  if (not matches.empty()) {
389  matchTriggerSel_ = true;
390  break;
391  }
392  }
393 
394  if (not matchTriggerSel_) {
395  edm::LogWarning("DQMStreamerReader") << "Trigger selection does not match any trigger path!!!";
396  }
397 
398  return matchTriggerSel_;
399  }
std::vector< std::string > const hltSel_
std::vector< std::vector< std::string >::const_iterator > regexMatch(std::vector< std::string > const &strings, std::regex const &regexp)
Definition: RegexMatch.cc:26
Log< level::Warning, false > LogWarning

◆ setupMetaData()

void dqmservices::DQMStreamerReader::setupMetaData ( edm::streamer::InitMsgView const &  msg,
bool  subsequent 
)
private

Definition at line 85 of file DQMStreamerReader.cc.

References cms::cuda::assert(), edm::streamer::StreamerInputSource::deserializeAndMergeWithRegistry(), edm::streamer::StreamerInputSource::deserializeEventMetaData(), getEventMsg(), mps_check::msg, and edm::streamer::StreamerInputSource::updateEventMetaData().

Referenced by genuineReadFile(), and openFileImp_().

85  {
87  auto event = getEventMsg();
88  //file might be empty
89  if (not event)
90  return;
91  assert(event->isEventMetaData());
94  }
void deserializeEventMetaData(EventMsgView const &eventView)
assert(be >=bs)
edm::streamer::EventMsgView const * getEventMsg()
void deserializeAndMergeWithRegistry(InitMsgView const &initView, bool subsequent=false)
tuple msg
Definition: mps_check.py:286
Definition: event.py:1

◆ skip()

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

Reimplemented from edm::InputSource.

Definition at line 420 of file DQMStreamerReader.cc.

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

420  {
421  try {
422  for (int i = 0; i != toSkip; ++i) {
423  EventMsgView const* evMsg = prepareNextEvent();
424 
425  if (evMsg == nullptr) {
426  return;
427  }
428  }
429  } catch (const cms::Exception& e) {
430  // try to recover from corrupted files/events
431  fiterator_.logFileAction(std::string("Can't deserialize event data: ") + e.what());
432  closeFileImp_("data file corrupted");
433  }
434  }
void logFileAction(const std::string &msg, const std::string &fileName="") const
edm::streamer::EventMsgView const * prepareNextEvent()
void closeFileImp_(const std::string &reason)

Member Data Documentation

◆ acceptAllEvt_

bool dqmservices::DQMStreamerReader::acceptAllEvt_ = false
private

Definition at line 61 of file DQMStreamerReader.h.

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

◆ artificialFileBoundary_

bool dqmservices::DQMStreamerReader::artificialFileBoundary_ = false
private

Definition at line 69 of file DQMStreamerReader.h.

Referenced by checkNext(), genuineReadFile(), and prepareNextEvent().

◆ eventSkipperByID_

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

Definition at line 78 of file DQMStreamerReader.h.

◆ file_

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

◆ fiterator_

DQMFileIterator dqmservices::DQMStreamerReader::fiterator_
private

◆ flagDeleteDatFiles_

bool const dqmservices::DQMStreamerReader::flagDeleteDatFiles_
private

Definition at line 58 of file DQMStreamerReader.h.

Referenced by openFileImp_().

◆ flagEndOfRunKills_

bool const dqmservices::DQMStreamerReader::flagEndOfRunKills_
private

Definition at line 57 of file DQMStreamerReader.h.

Referenced by prepareNextFile().

◆ flagSkipFirstLumis_

bool const dqmservices::DQMStreamerReader::flagSkipFirstLumis_
private

Definition at line 56 of file DQMStreamerReader.h.

Referenced by reset_().

◆ hltSel_

std::vector<std::string> const dqmservices::DQMStreamerReader::hltSel_
private

Definition at line 59 of file DQMStreamerReader.h.

Referenced by openFileImp_(), setAcceptAllEvt(), and setMatchTriggerSel().

◆ isFirstFile_

bool dqmservices::DQMStreamerReader::isFirstFile_ = true
private

Definition at line 48 of file DQMStreamerReader.h.

Referenced by genuineReadFile(), and openFileImp_().

◆ matchTriggerSel_

bool dqmservices::DQMStreamerReader::matchTriggerSel_ = false
private

Definition at line 64 of file DQMStreamerReader.h.

Referenced by acceptEvent(), and setMatchTriggerSel().

◆ minEventsPerLs_

unsigned int const dqmservices::DQMStreamerReader::minEventsPerLs_
private

Definition at line 55 of file DQMStreamerReader.h.

Referenced by prepareNextFile().

◆ processedEventPerLs_

unsigned int dqmservices::DQMStreamerReader::processedEventPerLs_ = 0
private

Definition at line 53 of file DQMStreamerReader.h.

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

◆ triggerSelector_

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

Definition at line 79 of file DQMStreamerReader.h.

Referenced by acceptEvent(), and openFileImp_().