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) final
 
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
 
SerialTaskQueueglobalLuminosityBlocksQueue () final
 
SerialTaskQueueglobalRunsQueue () final
 
bool hasAbilityToProduceInBeginLumis () const final
 
bool hasAbilityToProduceInBeginRuns () const final
 
bool hasAbilityToProduceInEndLumis () const final
 
bool hasAbilityToProduceInEndRuns () 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
 
ESProxyIndex const * esGetTokenIndices (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::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)
 
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
ProducesCollector producesCollector ()
 
- 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 ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes ()
 
template<typename ESProduct , typename ESRecord , Transition Tr = Transition::Event>
auto esConsumes (ESInputTag const &tag)
 
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 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 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 28 of file RamdiskMonitor.cc.

Constructor & Destructor Documentation

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

Definition at line 64 of file RamdiskMonitor.cc.

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

65  : runNumber_{ps.getUntrackedParameter<unsigned int>("runNumber")},
67  streamLabels_{ps.getUntrackedParameter<std::vector<std::string>>("streamLabels")},
69 
70  {}
T getUntrackedParameter(std::string const &, T const &) const
const std::string runPath_
const std::vector< std::string > streamLabels_
const std::string runInputDir_
#define str(s)
const unsigned int runNumber_
dqm::RamdiskMonitor::~RamdiskMonitor ( )
override

Definition at line 72 of file RamdiskMonitor.cc.

72 {};

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 
) const
protected

Definition at line 125 of file RamdiskMonitor.cc.

References dqm::RamdiskMonitor::StreamME::deliveryDelayCTime, dqm::RamdiskMonitor::StreamME::deliveryDelayMTime, dqm::RamdiskMonitor::StreamME::eventsAccepted, dqm::RamdiskMonitor::StreamME::eventsProcessed, personalPlayback::fn, getRunTimestamp(), LUMI, visualization-live-secondInstance_cfg::m, runPath_, dqm::impl::MonitorElement::setBinContent(), hgcalPlots::stat, and streams_.

Referenced by globalBeginLuminosityBlock().

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

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

Definition at line 74 of file RamdiskMonitor.cc.

References dqm::dqmstoreimpl::DQMStore::IBooker::book1D(), dqm::dqmstoreimpl::DQMStore::IBooker::cd(), dqm::RamdiskMonitor::StreamME::deliveryDelayCTime, dqm::RamdiskMonitor::StreamME::deliveryDelayMTime, dqm::RamdiskMonitor::StreamME::eventsAccepted, dqm::RamdiskMonitor::StreamME::eventsProcessed, dqm::impl::MonitorElement::getTH1F(), visualization-live-secondInstance_cfg::m, dqm::impl::MonitorElement::setAxisTitle(), dqm::dqmstoreimpl::DQMStore::IBooker::setCurrentFolder(), streamLabels_, streams_, and AlCaHLTBitMon_QueryRunRegistry::string.

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

Definition at line 228 of file RamdiskMonitor.cc.

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

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

Definition at line 109 of file RamdiskMonitor.cc.

References dqm-mbProfile::format, global_start_, runInputDir_, runNumber_, hgcalPlots::stat, str, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by analyzeFile().

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

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

38 {}

Member Data Documentation

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

Definition at line 58 of file RamdiskMonitor.cc.

Referenced by globalBeginLuminosityBlock().

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

Definition at line 59 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp().

double dqm::RamdiskMonitor::LUMI = 23.310893056
staticprotected

Definition at line 61 of file RamdiskMonitor.cc.

Referenced by analyzeFile().

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

Definition at line 45 of file RamdiskMonitor.cc.

Referenced by getRunTimestamp(), and RamdiskMonitor().

const unsigned int dqm::RamdiskMonitor::runNumber_
protected

Definition at line 44 of file RamdiskMonitor.cc.

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

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

Definition at line 47 of file RamdiskMonitor.cc.

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

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

Definition at line 46 of file RamdiskMonitor.cc.

Referenced by bookHistograms(), and RamdiskMonitor().

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

Definition at line 57 of file RamdiskMonitor.cc.

Referenced by analyzeFile(), and bookHistograms().