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:
one::DQMEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > > one::dqmimplementation::DQMBaseClass< T... >

Classes

struct  StreamME
 

Public Member Functions

 RamdiskMonitor (const edm::ParameterSet &ps)
 
 ~RamdiskMonitor () override
 
- Public Member Functions inherited from one::DQMEDAnalyzer< edm::LuminosityBlockCache< rdm::Empty > >
 DQMEDAnalyzer ()=default
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > const &)=delete
 
 DQMEDAnalyzer (DQMEDAnalyzer< T... > &&)=delete
 
 ~DQMEDAnalyzer () override=default
 

Static Public Member Functions

static void fillDescriptions (edm::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 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_
 

Static Protected Attributes

static double LUMI = 23.310893056
 

Detailed Description

Definition at line 27 of file RamdiskMonitor.cc.

Constructor & Destructor Documentation

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

Definition at line 68 of file RamdiskMonitor.cc.

References cmsPerfStripChart::format, edm::ParameterSet::getUntrackedParameter(), runInputDir_, runNumber_, runPath_, str, streamLabels_, and AlCaHLTBitMon_QueryRunRegistry::string.

68  :
69  runNumber_{ps.getUntrackedParameter<unsigned int>("runNumber")},
72  ps.getUntrackedParameter<std::vector<std::string> >("streamLabels")},
73  runPath_{ str(boost::format("%s/run%06d") % runInputDir_ % runNumber_) }
74 
75 {
76 }
T getUntrackedParameter(std::string const &, T const &) const
const std::string runPath_
format
Some error handling for the usage.
const std::vector< std::string > streamLabels_
const std::string runInputDir_
#define str(s)
const unsigned int runNumber_
dqm::RamdiskMonitor::~RamdiskMonitor ( )
override

Definition at line 78 of file RamdiskMonitor.cc.

78 {};

Member Function Documentation

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

Definition at line 41 of file RamdiskMonitor.cc.

References label, findQualityFiles::run, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 137 of file RamdiskMonitor.cc.

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

Referenced by globalBeginLuminosityBlock().

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

Definition at line 80 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, MonitorElement::getTH1F(), funct::m, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), streamLabels_, streams_, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 241 of file RamdiskMonitor.cc.

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

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

Definition at line 121 of file RamdiskMonitor.cc.

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

Referenced by analyzeFile().

121  {
122  if (global_start_ != 0) return global_start_;
123 
124  std::string run_global =
125  str(boost::format("%s/.run%06d.global") % runInputDir_ % runNumber_);
126  struct stat st;
127  if (::stat(run_global.c_str(), &st) != 0) {
128  edm::LogWarning("RamdiskMonitor") << "Stat failed: " << run_global;
129  return 0.;
130  }
131 
132  global_start_ = st.st_mtime;
133  edm::LogPrint("RamdiskMonitor") << "Run start timestamp: " << global_start_;
134  return global_start_;
135 };
format
Some error handling for the usage.
const std::string runInputDir_
#define str(s)
const unsigned int runNumber_
std::shared_ptr< dqm::rdm::Empty > dqm::RamdiskMonitor::globalBeginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  eSetup 
) const
overrideprotected

Definition at line 189 of file RamdiskMonitor.cc.

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

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

Definition at line 39 of file RamdiskMonitor.cc.

40  {}

Member Data Documentation

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

Definition at line 62 of file RamdiskMonitor.cc.

Referenced by globalBeginLuminosityBlock().

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

Definition at line 63 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

double dqm::RamdiskMonitor::LUMI = 23.310893056
staticprotected

Definition at line 65 of file RamdiskMonitor.cc.

Referenced by analyzeFile().

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

Definition at line 49 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp(), and RamdiskMonitor().

const unsigned int dqm::RamdiskMonitor::runNumber_
protected

Definition at line 48 of file RamdiskMonitor.cc.

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

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

Definition at line 51 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), globalBeginLuminosityBlock(), and RamdiskMonitor().

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

Definition at line 50 of file RamdiskMonitor.cc.

Referenced by bookHistograms(), and RamdiskMonitor().

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

Definition at line 61 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and bookHistograms().