CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | Static Protected Attributes
dqm::RamdiskMonitor Class Reference
Inheritance diagram for dqm::RamdiskMonitor:
DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > > edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... > edm::one::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Classes

struct  StreamME
 

Public Member Functions

 RamdiskMonitor (const edm::ParameterSet &ps)
 
 ~RamdiskMonitor () override=default
 
- Public Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >
void accumulate (edm::Event const &event, edm::EventSetup const &setup) override
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
 DQMOneEDAnalyzer ()
 
void endRun (edm::Run const &, edm::EventSetup const &) final
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) final
 
virtual bool getCanSaveByLumi ()
 
- Public Member Functions inherited from edm::one::EDProducer< edm::EndRunProducer, edm::one::WatchRuns, edm::Accumulator, Args... >
 EDProducer ()=default
 
 EDProducer (const EDProducer &)=delete
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginProcessBlocks () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndProcessBlocks () const final
 
bool hasAbilityToProduceInEndRuns () const final
 
const EDProduceroperator= (const EDProducer &)=delete
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () const final
 
bool wantsInputProcessBlocks () const final
 
bool wantsProcessBlocks () const final
 
- Public Member Functions inherited from edm::one::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
bool wantsStreamLuminosityBlocks () const
 
bool wantsStreamRuns () const
 
 ~EDProducerBase () override
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
std::vector< edm::ProductResolverIndex > const & indiciesForPutProducts (BranchType iBranchType) const
 
 ProducerBase ()
 
std::vector< edm::ProductResolverIndex > const & putTokenIndexToProductResolverIndex () const
 
std::vector< bool > const & recordProvenanceList () const
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription const &)> registrationCallback () const
 used by the fwk to register list of products More...
 
void resolvePutIndicies (BranchType iBranchType, ModuleToResolverIndicies const &iIndicies, std::string const &moduleLabel)
 
TypeLabelList const & typeLabelList () const
 used by the fwk to register the list of products of this module More...
 
 ~ProducerBase () noexcept(false) override
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
void convertCurrentProcessAlias (std::string const &processName)
 Convert "@currentProcess" in InputTag process names to the actual current process name. More...
 
 EDConsumerBase ()
 
 EDConsumerBase (EDConsumerBase const &)=delete
 
 EDConsumerBase (EDConsumerBase &&)=default
 
ESProxyIndex const * esGetTokenIndices (edm::Transition iTrans) const
 
std::vector< ESProxyIndex > const & esGetTokenIndicesVector (edm::Transition iTrans) const
 
std::vector< ESRecordIndex > const & esGetTokenRecordIndicesVector (edm::Transition iTrans) const
 
ProductResolverIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductResolverIndexAndSkipBit > &) const
 
std::vector< ProductResolverIndexAndSkipBit > const & itemsToGetFrom (BranchType iType) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesWhoseProductsAreConsumed (std::array< std::vector< ModuleDescription const *> *, NumBranchTypes > &modulesAll, std::vector< ModuleProcessName > &modulesInPreviousProcesses, ProductRegistry const &preg, std::map< std::string, ModuleDescription const *> const &labelsToDesc, std::string const &processName) const
 
EDConsumerBase const & operator= (EDConsumerBase const &)=delete
 
EDConsumerBaseoperator= (EDConsumerBase &&)=default
 
bool registeredToConsume (ProductResolverIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void selectInputProcessBlocks (ProductRegistry const &productRegistry, ProcessBlockHelperBase const &processBlockHelperBase)
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
void updateLookup (eventsetup::ESRecordsToProxyIndices const &)
 
virtual ~EDConsumerBase () noexcept(false)
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from edm::one::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

void analyze (edm::Event const &e, edm::EventSetup const &eSetup) override
 
void analyzeFile (std::string fn, unsigned int run, unsigned int lumi, std::string label) const
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
double getRunTimestamp () const
 
std::shared_ptr< rdm::EmptyglobalBeginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) const override
 
void globalEndLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) final
 
- Protected Member Functions inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
virtual void dqmEndRun (edm::Run const &, edm::EventSetup const &)
 
- Protected Member Functions inherited from edm::ProducerBase
template<Transition Tr = Transition::Event>
auto produces (std::string instanceName) noexcept
 declare what type of product will make and with which optional label More...
 
template<Transition B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<BranchType B>
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
BranchAliasSetter produces (const TypeID &id, std::string instanceName=std::string(), bool recordProvenance=true)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces ()
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , BranchType B>
BranchAliasSetterT< ProductType > produces ()
 
template<class ProductType >
BranchAliasSetterT< ProductType > produces (std::string instanceName)
 
template<typename ProductType , Transition B>
BranchAliasSetterT< ProductType > produces ()
 
template<Transition Tr = Transition::Event>
auto produces () noexcept
 
ProducesCollector producesCollector ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
template<BranchType B = InEvent>
EDConsumerBaseAdaptor< Bconsumes (edm::InputTag tag) noexcept
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
template<Transition Tr = Transition::Event>
constexpr auto esConsumes ()
 
template<Transition Tr = Transition::Event>
auto esConsumes (ESInputTag tag)
 
template<Transition Tr = Transition::Event>
ESGetTokenGeneric esConsumes (eventsetup::EventSetupRecordKey const &iRecord, eventsetup::DataKey const &iKey)
 Used with EventSetupRecord::doGet. More...
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
void resetItemsToGetFrom (BranchType iType)
 

Protected Attributes

std::set< std::string > filesSeen_
 
double global_start_ = 0.
 
const std::string runInputDir_
 
const unsigned int runNumber_
 
const std::string runPath_
 
const std::vector< std::string > streamLabels_
 
std::map< std::string, StreamMEstreams_
 
- Protected Attributes inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >
edm::EDPutTokenT< DQMTokenrunToken_
 

Static Protected Attributes

static constexpr double LUMI = 23.310893056
 

Additional Inherited Members

- Public Types inherited from DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >
typedef dqm::reco::DQMStore DQMStore
 
typedef dqm::reco::MonitorElement MonitorElement
 
- Public Types inherited from edm::one::EDProducerBase
typedef EDProducerBase ModuleType
 
- Public Types inherited from edm::ProducerBase
template<typename T >
using BranchAliasSetterT = ProductRegistryHelper::BranchAliasSetterT< T >
 
using ModuleToResolverIndicies = std::unordered_multimap< std::string, std::tuple< edm::TypeID const *, const char *, edm::ProductResolverIndex > >
 
typedef ProductRegistryHelper::TypeLabelList TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Detailed Description

Definition at line 31 of file RamdiskMonitor.cc.

Constructor & Destructor Documentation

◆ RamdiskMonitor()

dqm::RamdiskMonitor::RamdiskMonitor ( const edm::ParameterSet ps)

Definition at line 67 of file RamdiskMonitor.cc.

References edm::ParameterSet::getUntrackedParameter().

68  : runNumber_{ps.getUntrackedParameter<unsigned int>("runNumber")},
70  streamLabels_{ps.getUntrackedParameter<std::vector<std::string>>("streamLabels")},
71  runPath_{fmt::sprintf("%s/run%06d", runInputDir_, runNumber_)} {}
const std::string runPath_
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< std::string > streamLabels_
const std::string runInputDir_
const unsigned int runNumber_

◆ ~RamdiskMonitor()

dqm::RamdiskMonitor::~RamdiskMonitor ( )
overridedefault

Member Function Documentation

◆ analyze()

void dqm::RamdiskMonitor::analyze ( edm::Event const &  e,
edm::EventSetup const &  eSetup 
)
inlineoverrideprotectedvirtual

Reimplemented from DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >.

Definition at line 42 of file RamdiskMonitor.cc.

42 {}

◆ analyzeFile()

void dqm::RamdiskMonitor::analyzeFile ( std::string  fn,
unsigned int  run,
unsigned int  lumi,
std::string  label 
) const
protected

Definition at line 124 of file RamdiskMonitor.cc.

References personalPlayback::fn, getRunTimestamp(), label, LUMI, visualization-live-secondInstance_cfg::m, runPath_, edm_modernize_messagelogger::stat, and streams_.

Referenced by globalBeginLuminosityBlock().

124  {
125  using LumiEntry = dqmservices::DQMFileIterator::LumiEntry;
126 
127  // we are disabled, at least for this stream
128  if (streams_.empty())
129  return;
130 
131  auto itStream = streams_.find(label);
132  if (itStream == streams_.end()) {
133  edm::LogPrint("RamdiskMonitor") << "Stream not monitored [" << label << "]: " << fn;
134  return;
135  }
136 
137  StreamME m = itStream->second;
138 
139  // decode json and fill in some histograms
140  LumiEntry lumi_jsn = LumiEntry::load_json(runPath_, fn, lumi, -1);
141  m.eventsAccepted->setBinContent(lumi, lumi_jsn.n_events_accepted);
142  m.eventsProcessed->setBinContent(lumi, lumi_jsn.n_events_processed);
143 
144  // collect stat struct and calculate mtimes
145  struct stat st;
146  if (::stat(fn.c_str(), &st) != 0) {
147  edm::LogWarning("RamdiskMonitor") << "Stat failed: " << fn;
148  return;
149  }
150 
151  // get start offset (from .global)
152  // abort the calculation if it does not exist
153  double start_offset = getRunTimestamp();
154  if (start_offset <= 0)
155  return;
156 
157  // check fff_dqmtools (separate repository)
158  // for calculation details
159  double mtime = st.st_mtime;
160  double ctime = st.st_ctime;
161 
162  // timeout from the begging of the run
163  double start_offset_mtime = mtime - start_offset - LUMI;
164  double start_offset_ctime = ctime - start_offset - LUMI;
165  double lumi_offset = (lumi - 1) * LUMI;
166 
167  // timeout from the time we think this lumi happenned
168  double delay_mtime = start_offset_mtime - lumi_offset;
169  double delay_ctime = start_offset_ctime - lumi_offset;
170 
171  m.deliveryDelayMTime->setBinContent(lumi, delay_mtime);
172  m.deliveryDelayCTime->setBinContent(lumi, delay_ctime);
173  };
std::map< std::string, StreamME > streams_
const std::string runPath_
char const * label
Log< level::Warning, true > LogPrint
double getRunTimestamp() const
Log< level::Warning, false > LogWarning
static constexpr double LUMI

◆ bookHistograms()

void dqm::RamdiskMonitor::bookHistograms ( DQMStore::IBooker ib,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Implements DQMOneEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >.

Definition at line 73 of file RamdiskMonitor.cc.

References cuy::ib, visualization-live-secondInstance_cfg::m, cms::cuda::stream, streamLabels_, streams_, and AlCaHLTBitMon_QueryRunRegistry::string.

73  {
74  for (const auto &stream : streamLabels_) {
75  edm::LogInfo("RamdiskMonitor") << "Booking: " << stream;
76 
77  ib.cd();
78  ib.setCurrentFolder(std::string("Info/RamdiskMonitor/") + stream + "/");
79 
80  StreamME m;
81 
82  m.eventsAccepted = ib.book1D("EventAccepted", "# of accepted events per lumi", 4, 0., 4.);
83  m.eventsProcessed = ib.book1D("EventProcessed", "# of processed events per lumi", 4, 0., 4.);
84  m.deliveryDelayMTime =
85  ib.book1D("DeliveryDelayMTime", "Observed delivery delay for the data file (mtime).", 4, 0., 4.);
86  m.deliveryDelayCTime =
87  ib.book1D("DeliveryDelayCTime", "Observed delivery delay for the data file (ctime).", 4, 0., 4.);
88 
89  m.eventsAccepted->getTH1F()->SetCanExtend(TH1::kXaxis);
90  m.eventsProcessed->getTH1F()->SetCanExtend(TH1::kXaxis);
91  m.deliveryDelayMTime->getTH1F()->SetCanExtend(TH1::kXaxis);
92  m.deliveryDelayCTime->getTH1F()->SetCanExtend(TH1::kXaxis);
93 
94  m.eventsAccepted->setAxisTitle("Luminosity Section", 1);
95  m.eventsProcessed->setAxisTitle("Luminosity Section", 1);
96  m.deliveryDelayMTime->setAxisTitle("Luminosity Section", 1);
97  m.deliveryDelayCTime->setAxisTitle("Luminosity Section", 1);
98 
99  m.eventsAccepted->setAxisTitle("Number of events", 2);
100  m.eventsProcessed->setAxisTitle("Number of events", 2);
101  m.deliveryDelayMTime->setAxisTitle("Delay (s.)", 2);
102  m.deliveryDelayCTime->setAxisTitle("Delay (s.)", 2);
103 
104  streams_[stream] = m;
105  }
106  };
std::map< std::string, StreamME > streams_
uint32_t T const *__restrict__ uint32_t const *__restrict__ int32_t int Histo::index_type cudaStream_t stream
Log< level::Info, false > LogInfo
const std::vector< std::string > streamLabels_
ib
Definition: cuy.py:661

◆ fillDescriptions()

void dqm::RamdiskMonitor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 227 of file RamdiskMonitor.cc.

References ztail::d, submitPVResolutionJobs::desc, and AlCaHLTBitMon_QueryRunRegistry::string.

227  {
229 
230  desc.setComment(
231  "Analyses file timestams in the /fff/ramdisk and creates monitor "
232  "elements.");
233 
234  desc.addUntracked<std::vector<std::string>>("streamLabels")->setComment("List of streams to monitor.");
235 
236  desc.addUntracked<unsigned int>("runNumber")->setComment("Run number passed via configuration file.");
237 
238  desc.addUntracked<std::string>("runInputDir")->setComment("Directory where the DQM files will appear.");
239 
240  d.add("RamdiskMonitor", desc);
241  }
d
Definition: ztail.py:151

◆ getRunTimestamp()

double dqm::RamdiskMonitor::getRunTimestamp ( ) const
protected

Definition at line 108 of file RamdiskMonitor.cc.

References global_start_, runInputDir_, runNumber_, edm_modernize_messagelogger::stat, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyzeFile().

108  {
109  if (global_start_ != 0)
110  return global_start_;
111 
112  std::string run_global = fmt::sprintf("%s/.run%06d.global", runInputDir_, runNumber_);
113  struct stat st;
114  if (::stat(run_global.c_str(), &st) != 0) {
115  edm::LogWarning("RamdiskMonitor") << "Stat failed: " << run_global;
116  return 0.;
117  }
118 
119  global_start_ = st.st_mtime;
120  edm::LogPrint("RamdiskMonitor") << "Run start timestamp: " << global_start_;
121  return global_start_;
122  };
Log< level::Warning, true > LogPrint
const std::string runInputDir_
Log< level::Warning, false > LogWarning
const unsigned int runNumber_

◆ globalBeginLuminosityBlock()

std::shared_ptr< dqm::rdm::Empty > dqm::RamdiskMonitor::globalBeginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  eSetup 
) const
overrideprotected

Definition at line 175 of file RamdiskMonitor.cc.

References analyzeFile(), MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, corrVsCorr::filename, filesSeen_, personalPlayback::fn, label, mps_check::msg, mps_fire::result, writedatasetfile::run, runNumber_, runPath_, and AlCaHLTBitMon_QueryRunRegistry::string.

176  {
177  // search filesystem to find available lumi section files
178  using std::filesystem::directory_entry;
179  using std::filesystem::directory_iterator;
180 
181  directory_iterator dend;
182  for (directory_iterator di(runPath_); di != dend; ++di) {
183  const boost::regex fn_re("run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
184 
185  const std::string filename = di->path().filename().string();
186  const std::string fn = di->path().string();
187 
188  if (filesSeen_.find(filename) != filesSeen_.end()) {
189  continue;
190  }
191 
192  boost::smatch result;
193  if (boost::regex_match(filename, result, fn_re)) {
194  unsigned int run = std::stoi(result[1]);
195  unsigned int lumi = std::stoi(result[2]);
196  std::string label = result[3];
197 
198  filesSeen_.insert(filename);
199 
200  if (run != runNumber_)
201  continue;
202 
203  // check if this is EoR
204  if ((lumi == 0) && (label == "EoR")) {
205  // do not handle
206  continue;
207  }
208 
209  try {
210  this->analyzeFile(fn, run, lumi, label);
211  } catch (const std::exception &e) {
212  // it's likely we have read it too soon
213  filesSeen_.erase(filename);
214 
215  std::string msg("Found, tried to load the json, but failed (");
216  msg += e.what();
217  msg += "): ";
218  edm::LogWarning("RamdiskMonitor") << msg;
219  }
220  }
221  }
222 
223  // @TODO lookup info for the current lumi
224  return std::shared_ptr<dqm::rdm::Empty>();
225  }
void analyzeFile(std::string fn, unsigned int run, unsigned int lumi, std::string label) const
const std::string runPath_
char const * label
tuple msg
Definition: mps_check.py:286
Log< level::Warning, false > LogWarning
std::set< std::string > filesSeen_
const unsigned int runNumber_

◆ globalEndLuminosityBlock()

void dqm::RamdiskMonitor::globalEndLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  eSetup 
)
inlinefinalprotected

Definition at line 41 of file RamdiskMonitor.cc.

41 {}

Member Data Documentation

◆ filesSeen_

std::set<std::string> dqm::RamdiskMonitor::filesSeen_
mutableprotected

Definition at line 61 of file RamdiskMonitor.cc.

Referenced by globalBeginLuminosityBlock().

◆ global_start_

double dqm::RamdiskMonitor::global_start_ = 0.
mutableprotected

Definition at line 62 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

◆ LUMI

constexpr double dqm::RamdiskMonitor::LUMI = 23.310893056
staticprotected

Definition at line 64 of file RamdiskMonitor.cc.

Referenced by analyzeFile().

◆ runInputDir_

const std::string dqm::RamdiskMonitor::runInputDir_
protected

Definition at line 48 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

◆ runNumber_

const unsigned int dqm::RamdiskMonitor::runNumber_
protected

Definition at line 47 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp(), and globalBeginLuminosityBlock().

◆ runPath_

const std::string dqm::RamdiskMonitor::runPath_
protected

Definition at line 50 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and globalBeginLuminosityBlock().

◆ streamLabels_

const std::vector<std::string> dqm::RamdiskMonitor::streamLabels_
protected

Definition at line 49 of file RamdiskMonitor.cc.

Referenced by bookHistograms().

◆ streams_

std::map<std::string, StreamME> dqm::RamdiskMonitor::streams_
protected

Definition at line 60 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and bookHistograms().