CMS 3D CMS Logo

List of all members | Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes
dqm::RamdiskMonitor Class Reference
Inheritance diagram for dqm::RamdiskMonitor:
DQMEDAnalyzer edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns > 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 DQMEDAnalyzer
void accumulate (edm::Event const &ev, edm::EventSetup const &es) final
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &setup) override
 
void beginRun (edm::Run const &run, edm::EventSetup const &setup) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer ()
 
 DQMEDAnalyzer (DQMEDAnalyzer const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer &&)=delete
 
void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override
 
void endLuminosityBlockProduce (edm::LuminosityBlock &lumi, edm::EventSetup const &setup) final
 
void endRun (edm::Run const &run, edm::EventSetup const &setup) override
 
void endRunProduce (edm::Run &run, edm::EventSetup const &setup) override
 
 ~DQMEDAnalyzer () override=default
 
- Public Member Functions inherited from edm::one::EDProducer< edm::Accumulator, edm::EndLuminosityBlockProducer, edm::EndRunProducer, edm::one::WatchLuminosityBlocks, edm::one::WatchRuns >
 EDProducer ()=default
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInLumis () const final
 
bool hasAbilityToProduceInRuns () const final
 
bool wantsGlobalLuminosityBlocks () const final
 
bool wantsGlobalRuns () 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
 
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)
 
 ~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
 
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::vector< ModuleDescription const * > &modules, 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
 
ProductResolverIndexAndSkipBit uncheckedIndexFrom (EDGetToken) const
 
void updateLookup (BranchType iBranchType, ProductResolverIndexHelper const &, bool iPrefetchMayGet)
 
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)
 
void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
 
void bookHistograms (DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
 
double getRunTimestamp ()
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
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 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)
 

Protected Attributes

std::set< std::string > filesSeen_
 
double global_start_ = 0.
 
const double LUMI = 23.310893056
 
std::string runInputDir_
 
unsigned int runNumber_
 
std::string runPath_
 
std::chrono::high_resolution_clock::time_point runPathLastCollect_
 
std::vector< std::string > streamLabels_
 
std::map< std::string, StreamMEstreams_
 
- Protected Attributes inherited from DQMEDAnalyzer
edm::EDPutTokenT< DQMTokenlumiToken_
 
edm::EDPutTokenT< DQMTokenrunToken_
 

Additional Inherited Members

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

Constructor & Destructor Documentation

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

Definition at line 66 of file RamdiskMonitor.cc.

References edm::ParameterSet::getUntrackedParameter(), runInputDir_, runNumber_, streamLabels_, and AlCaHLTBitMon_QueryRunRegistry::string.

66  {
67  runNumber_ = ps.getUntrackedParameter<unsigned int>("runNumber");
68  runInputDir_ = ps.getUntrackedParameter<std::string>("runInputDir");
70  ps.getUntrackedParameter<std::vector<std::string> >("streamLabels");
71 };
T getUntrackedParameter(std::string const &, T const &) const
std::vector< std::string > streamLabels_
std::string runInputDir_
unsigned int runNumber_
dqm::RamdiskMonitor::~RamdiskMonitor ( )
override

Definition at line 73 of file RamdiskMonitor.cc.

73 {};

Member Function Documentation

void dqm::RamdiskMonitor::analyze ( edm::Event const &  e,
edm::EventSetup const &  eSetup 
)
inlineoverrideprotectedvirtual
void dqm::RamdiskMonitor::analyzeFile ( std::string  fn,
unsigned int  run,
unsigned int  lumi,
std::string  label 
)
protected

Definition at line 133 of file RamdiskMonitor.cc.

References dqm::RamdiskMonitor::StreamME::deliveryDelayCTime, dqm::RamdiskMonitor::StreamME::deliveryDelayMTime, dqm::RamdiskMonitor::StreamME::eventsAccepted, dqm::RamdiskMonitor::StreamME::eventsProcessed, getRunTimestamp(), diffTwoXMLs::label, LUMI, funct::m, runPath_, MonitorElement::setBinContent(), trackingPlots::stat, and streams_.

Referenced by analyze(), and beginLuminosityBlock().

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

Definition at line 183 of file RamdiskMonitor.cc.

References analyzeFile(), MillePedeFileConverter_cfg::e, cppFunctionSkipper::exception, corrVsCorr::filename, filesSeen_, diffTwoXMLs::label, mps_check::msg, cmsPerfSuiteHarvest::now, mps_fire::result, findQualityFiles::run, runNumber_, runPath_, runPathLastCollect_, and AlCaHLTBitMon_QueryRunRegistry::string.

184  {
185  // search filesystem to find available lumi section files
188 
189  using boost::filesystem::directory_iterator;
190  using boost::filesystem::directory_entry;
191 
192  directory_iterator dend;
193  for (directory_iterator di(runPath_); di != dend; ++di) {
194  const boost::regex fn_re("run(\\d+)_ls(\\d+)_([a-zA-Z0-9]+)(_.*)?\\.jsn");
195 
196  const std::string filename = di->path().filename().string();
197  const std::string fn = di->path().string();
198 
199  if (filesSeen_.find(filename) != filesSeen_.end()) {
200  continue;
201  }
202 
203  boost::smatch result;
204  if (boost::regex_match(filename, result, fn_re)) {
205  unsigned int run = std::stoi(result[1]);
206  unsigned int lumi = std::stoi(result[2]);
207  std::string label = result[3];
208 
209  filesSeen_.insert(filename);
210 
211  if (run != runNumber_) continue;
212 
213  // check if this is EoR
214  if ((lumi == 0) && (label == "EoR")) {
215  // do not handle
216  continue;
217  }
218 
219  try {
220  this->analyzeFile(fn, run, lumi, label);
221  } catch (const std::exception &e) {
222  // it's likely we have read it too soon
223  filesSeen_.erase(filename);
224 
225  std::string msg("Found, tried to load the json, but failed (");
226  msg += e.what();
227  msg += "): ";
228  edm::LogWarning("RamdiskMonitor") << msg;
229  }
230  }
231  }
232 
233  // @TODO lookup info for the current lumi
234 };
std::chrono::high_resolution_clock::time_point runPathLastCollect_
void analyzeFile(std::string fn, unsigned int run, unsigned int lumi, std::string label)
tuple msg
Definition: mps_check.py:277
std::set< std::string > filesSeen_
unsigned int runNumber_
void dqm::RamdiskMonitor::bookHistograms ( DQMStore::IBooker ib,
edm::Run const &  ,
edm::EventSetup const &   
)
overrideprotectedvirtual

Implements DQMEDAnalyzer.

Definition at line 75 of file RamdiskMonitor.cc.

References DQMStore::IBooker::book1D(), DQMStore::IBooker::cd(), dqm::RamdiskMonitor::StreamME::deliveryDelayCTime, dqm::RamdiskMonitor::StreamME::deliveryDelayMTime, dqm::RamdiskMonitor::StreamME::eventsAccepted, dqm::RamdiskMonitor::StreamME::eventsProcessed, cmsPerfStripChart::format, MonitorElement::getTH1F(), funct::m, runInputDir_, runNumber_, runPath_, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), str, streamLabels_, streams_, and AlCaHLTBitMon_QueryRunRegistry::string.

76  {
77  runPath_ = str(boost::format("%s/run%06d") % runInputDir_ % runNumber_);
78 
79  for (auto stream : streamLabels_) {
80  edm::LogInfo("RamdiskMonitor") << "Booking: " << stream;
81 
82  ib.cd();
83  ib.setCurrentFolder(std::string("Info/RamdiskMonitor/") + stream + "/");
84 
85  StreamME m;
86 
87  m.eventsAccepted =
88  ib.book1D("EventAccepted", "# of accepted events per lumi", 4, 0., 4.);
89  m.eventsProcessed = ib.book1D("EventProcessed",
90  "# of processed events per lumi", 4, 0., 4.);
91  m.deliveryDelayMTime = ib.book1D(
92  "DeliveryDelayMTime",
93  "Observed delivery delay for the data file (mtime).", 4, 0., 4.);
94  m.deliveryDelayCTime = ib.book1D(
95  "DeliveryDelayCTime",
96  "Observed delivery delay for the data file (ctime).", 4, 0., 4.);
97 
98  m.eventsAccepted->getTH1F()->SetCanExtend(TH1::kXaxis);
99  m.eventsProcessed->getTH1F()->SetCanExtend(TH1::kXaxis);
100  m.deliveryDelayMTime->getTH1F()->SetCanExtend(TH1::kXaxis);
101  m.deliveryDelayCTime->getTH1F()->SetCanExtend(TH1::kXaxis);
102 
103  m.eventsAccepted->setAxisTitle("Luminosity Section", 1);
104  m.eventsProcessed->setAxisTitle("Luminosity Section", 1);
105  m.deliveryDelayMTime->setAxisTitle("Luminosity Section", 1);
106  m.deliveryDelayCTime->setAxisTitle("Luminosity Section", 1);
107 
108  m.eventsAccepted->setAxisTitle("Number of events", 2);
109  m.eventsProcessed->setAxisTitle("Number of events", 2);
110  m.deliveryDelayMTime->setAxisTitle("Delay (s.)", 2);
111  m.deliveryDelayCTime->setAxisTitle("Delay (s.)", 2);
112 
113  streams_[stream] = m;
114  }
115 };
std::map< std::string, StreamME > streams_
std::vector< std::string > streamLabels_
TH1F * getTH1F() const
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:118
std::string runInputDir_
format
Some error handling for the usage.
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
#define str(s)
unsigned int runNumber_
void dqm::RamdiskMonitor::fillDescriptions ( edm::ConfigurationDescriptions descriptions)
static

Definition at line 236 of file RamdiskMonitor.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addUntracked(), edm::ParameterSetDescription::setComment(), and AlCaHLTBitMon_QueryRunRegistry::string.

236  {
238 
239  desc.setComment(
240  "Analyses file timestams in the /fff/ramdisk and creates monitor "
241  "elements.");
242 
243  desc.addUntracked<std::vector<std::string> >("streamLabels")
244  ->setComment("List of streams to monitor.");
245 
246  desc.addUntracked<unsigned int>("runNumber")
247  ->setComment("Run number passed via configuration file.");
248 
249  desc.addUntracked<std::string>("runInputDir")
250  ->setComment("Directory where the DQM files will appear.");
251 
252  d.add("RamdiskMonitor", desc);
253 }
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
void setComment(std::string const &value)
double dqm::RamdiskMonitor::getRunTimestamp ( )
protected

Definition at line 117 of file RamdiskMonitor.cc.

References cmsPerfStripChart::format, global_start_, runInputDir_, runNumber_, trackingPlots::stat, str, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyze(), and analyzeFile().

117  {
118  if (global_start_ != 0) return global_start_;
119 
120  std::string run_global =
121  str(boost::format("%s/.run%06d.global") % runInputDir_ % runNumber_);
122  struct stat st;
123  if (::stat(run_global.c_str(), &st) != 0) {
124  edm::LogWarning("RamdiskMonitor") << "Stat failed: " << run_global;
125  return 0.;
126  }
127 
128  global_start_ = st.st_mtime;
129  edm::LogPrint("RamdiskMonitor") << "Run start timestamp: " << global_start_;
130  return global_start_;
131 };
std::string runInputDir_
format
Some error handling for the usage.
#define str(s)
unsigned int runNumber_

Member Data Documentation

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

Definition at line 59 of file RamdiskMonitor.cc.

Referenced by beginLuminosityBlock().

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

Definition at line 61 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

const double dqm::RamdiskMonitor::LUMI = 23.310893056
protected

Definition at line 63 of file RamdiskMonitor.cc.

Referenced by analyzeFile().

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

Definition at line 46 of file RamdiskMonitor.cc.

Referenced by bookHistograms(), getRunTimestamp(), and RamdiskMonitor().

unsigned int dqm::RamdiskMonitor::runNumber_
protected
std::string dqm::RamdiskMonitor::runPath_
protected

Definition at line 48 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), beginLuminosityBlock(), and bookHistograms().

std::chrono::high_resolution_clock::time_point dqm::RamdiskMonitor::runPathLastCollect_
protected

Definition at line 60 of file RamdiskMonitor.cc.

Referenced by beginLuminosityBlock().

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

Definition at line 47 of file RamdiskMonitor.cc.

Referenced by bookHistograms(), and RamdiskMonitor().

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

Definition at line 58 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and bookHistograms().