CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > > edm::stream::EDAnalyzerBase edm::EDConsumerBase

Classes

struct  StreamME
 

Public Member Functions

 RamdiskMonitor (const edm::ParameterSet &ps)
 
virtual ~RamdiskMonitor ()
 
- Public Member Functions inherited from DQMEDAnalyzer
virtual void beginRun (edm::Run const &, edm::EventSetup const &) final
 
virtual void beginStream (edm::StreamID id) final
 
virtual void dqmBeginRun (edm::Run const &, edm::EventSetup const &)
 
 DQMEDAnalyzer (void)
 
virtual void endLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
virtual void endRunSummary (edm::Run const &, edm::EventSetup const &, dqmDetails::NoCache *) const final
 
uint32_t streamId () const
 
- Public Member Functions inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
 EDAnalyzer ()=default
 
- Public Member Functions inherited from edm::stream::EDAnalyzerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDAnalyzerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (std::string const &iProcessName, std::string const &iModuleLabel, bool iPrint, std::vector< char const * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Static Public Member Functions

static void fillDescriptions (edm::ConfigurationDescriptions &descriptions)
 
- Static Public Member Functions inherited from DQMEDAnalyzer
static std::shared_ptr
< dqmDetails::NoCache
globalBeginLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *)
 
static std::shared_ptr
< dqmDetails::NoCache
globalBeginRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *)
 
static void globalEndLuminosityBlockSummary (edm::LuminosityBlock const &, edm::EventSetup const &, LuminosityBlockContext const *, dqmDetails::NoCache *)
 
static void globalEndRunSummary (edm::Run const &, edm::EventSetup const &, RunContext const *, dqmDetails::NoCache *)
 
- Static Public Member Functions inherited from edm::stream::EDAnalyzerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 

Protected Member Functions

virtual 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)
 
virtual void beginLuminosityBlock (edm::LuminosityBlock const &lumi, edm::EventSetup const &eSetup) override
 
virtual 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_
 

Additional Inherited Members

- Public Types inherited from edm::stream::EDAnalyzer< edm::RunSummaryCache< dqmDetails::NoCache >, edm::LuminosityBlockSummaryCache< dqmDetails::NoCache > >
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDAnalyzerBase
typedef EDAnalyzerAdaptorBase ModuleType
 
- 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 ( )
virtual

Definition at line 73 of file RamdiskMonitor.cc.

73 {};

Member Function Documentation

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

Implements edm::stream::EDAnalyzerBase.

Definition at line 38 of file RamdiskMonitor.cc.

39  {};
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, personalPlayback::fn, getRunTimestamp(), diffTwoXMLs::label, LUMI, visualization-live-secondInstance_cfg::m, runPath_, MonitorElement::setBinContent(), and streams_.

Referenced by beginLuminosityBlock().

134  {
135  using LumiEntry = dqmservices::DQMFileIterator::LumiEntry;
136 
137  // we are disabled, at least for this stream
138  if (streams_.size() == 0) 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_
tuple lumi
Definition: fjr2json.py:35
void dqm::RamdiskMonitor::beginLuminosityBlock ( edm::LuminosityBlock const &  lumi,
edm::EventSetup const &  eSetup 
)
overrideprotectedvirtual

Reimplemented from edm::stream::EDAnalyzerBase.

Definition at line 183 of file RamdiskMonitor.cc.

References analyzeFile(), alignCSCRings::e, cppFunctionSkipper::exception, lut2db_cfg::filename, filesSeen_, personalPlayback::fn, diffTwoXMLs::label, visualization-live-secondInstance_cfg::msg, fileCollector::now, mps_fire::result, DTTTrigCorrFirst::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_
tuple lumi
Definition: fjr2json.py:35
tuple result
Definition: mps_fire.py:95
void analyzeFile(std::string fn, unsigned int run, unsigned int lumi, std::string label)
tuple filename
Definition: lut2db_cfg.py:20
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(), visualization-live-secondInstance_cfg::m, runInputDir_, runNumber_, runPath_, MonitorElement::setAxisTitle(), DQMStore::IBooker::setCurrentFolder(), 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_
void cd(void)
Definition: DQMStore.cc:268
string format
Some error handling for the usage.
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
std::string runInputDir_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:276
TH1F * getTH1F(void) const
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)
tuple d
Definition: ztail.py:151
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_, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by 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 };
string format
Some error handling for the usage.
std::string runInputDir_
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().