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
 
- 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
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 25 of file RamdiskMonitor.cc.

Constructor & Destructor Documentation

◆ RamdiskMonitor()

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

Definition at line 61 of file RamdiskMonitor.cc.

References edm::ParameterSet::getUntrackedParameter().

62  : runNumber_{ps.getUntrackedParameter<unsigned int>("runNumber")},
64  streamLabels_{ps.getUntrackedParameter<std::vector<std::string>>("streamLabels")},
65  runPath_{fmt::sprintf("%s/run%06d", runInputDir_, runNumber_)}
66 
67  {}
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 ( )
override

Definition at line 69 of file RamdiskMonitor.cc.

69 {};

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 36 of file RamdiskMonitor.cc.

36 {};

◆ analyzeFile()

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

Definition at line 122 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().

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

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

71  {
72  for (const auto &stream : streamLabels_) {
73  edm::LogInfo("RamdiskMonitor") << "Booking: " << stream;
74 
75  ib.cd();
76  ib.setCurrentFolder(std::string("Info/RamdiskMonitor/") + stream + "/");
77 
78  StreamME m;
79 
80  m.eventsAccepted = ib.book1D("EventAccepted", "# of accepted events per lumi", 4, 0., 4.);
81  m.eventsProcessed = ib.book1D("EventProcessed", "# of processed events per lumi", 4, 0., 4.);
82  m.deliveryDelayMTime =
83  ib.book1D("DeliveryDelayMTime", "Observed delivery delay for the data file (mtime).", 4, 0., 4.);
84  m.deliveryDelayCTime =
85  ib.book1D("DeliveryDelayCTime", "Observed delivery delay for the data file (ctime).", 4, 0., 4.);
86 
87  m.eventsAccepted->getTH1F()->SetCanExtend(TH1::kXaxis);
88  m.eventsProcessed->getTH1F()->SetCanExtend(TH1::kXaxis);
89  m.deliveryDelayMTime->getTH1F()->SetCanExtend(TH1::kXaxis);
90  m.deliveryDelayCTime->getTH1F()->SetCanExtend(TH1::kXaxis);
91 
92  m.eventsAccepted->setAxisTitle("Luminosity Section", 1);
93  m.eventsProcessed->setAxisTitle("Luminosity Section", 1);
94  m.deliveryDelayMTime->setAxisTitle("Luminosity Section", 1);
95  m.deliveryDelayCTime->setAxisTitle("Luminosity Section", 1);
96 
97  m.eventsAccepted->setAxisTitle("Number of events", 2);
98  m.eventsProcessed->setAxisTitle("Number of events", 2);
99  m.deliveryDelayMTime->setAxisTitle("Delay (s.)", 2);
100  m.deliveryDelayCTime->setAxisTitle("Delay (s.)", 2);
101 
102  streams_[stream] = m;
103  }
104  };
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 225 of file RamdiskMonitor.cc.

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

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

◆ getRunTimestamp()

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

Definition at line 106 of file RamdiskMonitor.cc.

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

Referenced by analyzeFile().

106  {
107  if (global_start_ != 0)
108  return global_start_;
109 
110  std::string run_global = fmt::sprintf("%s/.run%06d.global", runInputDir_, runNumber_);
111  struct stat st;
112  if (::stat(run_global.c_str(), &st) != 0) {
113  edm::LogWarning("RamdiskMonitor") << "Stat failed: " << run_global;
114  return 0.;
115  }
116 
117  global_start_ = st.st_mtime;
118  edm::LogPrint("RamdiskMonitor") << "Run start timestamp: " << global_start_;
119  return global_start_;
120  };
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 173 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.

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

35 {}

Member Data Documentation

◆ filesSeen_

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

Definition at line 55 of file RamdiskMonitor.cc.

Referenced by globalBeginLuminosityBlock().

◆ global_start_

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

Definition at line 56 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

◆ LUMI

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

Definition at line 58 of file RamdiskMonitor.cc.

Referenced by analyzeFile().

◆ runInputDir_

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

Definition at line 42 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

◆ runNumber_

const unsigned int dqm::RamdiskMonitor::runNumber_
protected

Definition at line 41 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp(), and globalBeginLuminosityBlock().

◆ runPath_

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

Definition at line 44 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and globalBeginLuminosityBlock().

◆ streamLabels_

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

Definition at line 43 of file RamdiskMonitor.cc.

Referenced by bookHistograms().

◆ streams_

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

Definition at line 54 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and bookHistograms().