CMS 3D CMS Logo

List of all members | Classes | Public Types | Public Member Functions | Private Member Functions | Private Attributes
HLTScalersClient Class Reference

#include <HLTScalersClient.h>

Inheritance diagram for HLTScalersClient:
edm::EDAnalyzer edm::EDConsumerBase

Classes

class  CountLS_t
 
class  CountLSFifo_t
 

Public Types

typedef dqm::legacy::DQMStore DQMStore
 
typedef dqm::legacy::MonitorElement MonitorElement
 
- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

void analyze (const edm::Event &e, const edm::EventSetup &c) override
 
void beginJob (void) override
 BeginJob. More...
 
void beginRun (const edm::Run &run, const edm::EventSetup &c) override
 BeginRun. More...
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
 
void endRun (const edm::Run &run, const edm::EventSetup &c) override
 EndRun. More...
 
 HLTScalersClient (const edm::ParameterSet &ps)
 Constructors. More...
 
 ~HLTScalersClient () override
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
SerialTaskQueueglobalLuminosityBlocksQueue ()
 
SerialTaskQueueglobalRunsQueue ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
 ~EDAnalyzer () 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)
 

Private Member Functions

std::pair< double, double > getSlope_ (const CountLSFifo_t &points)
 

Private Attributes

std::vector< MonitorElement * > countHistories_
 
int currentLumiBlockNumber_
 
MonitorElementcurrentNormRate_
 
MonitorElementcurrentRate_
 
int currentRun_
 
DQMStoredbe_
 
bool debug_
 
bool first_
 
std::string folderName_
 
MonitorElementhltCount_
 
std::vector< MonitorElement * > hltCurrentNormRate_
 
std::vector< MonitorElement * > hltCurrentRate_
 
MonitorElementhltNormRate_
 
MonitorElementhltRate_
 
std::deque< int > ignores_
 
unsigned int kRateIntegWindow_
 
int maxFU_
 
MonitorElementmergeCount_
 
bool missingPathNames_
 
int nev_
 
int nLumi_
 
std::string processName_
 
std::vector< MonitorElement * > rateHistories_
 
std::vector< MonitorElement * > rateNormHistories_
 
CountLSFifo_t recentNormedOverallCountsPerLS_
 
std::vector< CountLSFifo_trecentNormedPathCountsPerLS_
 
CountLSFifo_t recentOverallCountsPerLS_
 
std::vector< CountLSFifo_trecentPathCountsPerLS_
 
std::ofstream textfile_
 
MonitorElementupdates_
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
static bool wantsGlobalLuminosityBlocks ()
 
static bool wantsGlobalRuns ()
 
static bool wantsStreamLuminosityBlocks ()
 
static bool wantsStreamRuns ()
 
- 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)
 

Detailed Description

Definition at line 56 of file HLTScalersClient.h.

Member Typedef Documentation

Definition at line 62 of file HLTScalersClient.h.

Definition at line 61 of file HLTScalersClient.h.

Constructor & Destructor Documentation

HLTScalersClient::HLTScalersClient ( const edm::ParameterSet ps)

Constructors.

Definition at line 61 of file HLTScalersClient.cc.

References dqm::dqmstoreimpl::DQMStore::book1D(), gather_cfg::cout, dbe_, debug_, folderName_, hltCount_, hltNormRate_, hltRate_, LogDebug, MAX_LUMI_SEG_HLT, mergeCount_, Utilities::operator, dqm::impl::MonitorElement::setBinLabel(), dqm::dqmstoreimpl::DQMStore::setCurrentFolder(), AlCaHLTBitMon_QueryRunRegistry::string, textfile_, and updates_.

Referenced by HLTScalersClient::CountLSFifo_t::trim_().

62  : dbe_(nullptr),
63  nLumi_(0),
64  currentRate_(nullptr),
66  first_(true),
67  missingPathNames_(true),
68  folderName_(ps.getUntrackedParameter<std::string>("dqmFolder", "HLT/HLScalers_EvF")),
69  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow", 3)),
70  processName_(ps.getParameter<std::string>("processName")),
71  ignores_(),
72  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
73  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
76  LogDebug("HLTScalersClient") << "constructor";
77  if (debug_) {
78  textfile_.open("debug.txt");
79  if (!textfile_) {
80  std::cout << "constructor: can't open text file" << std::endl;
81  }
82  }
83  // get back-end interface
86 
87  std::string rawdir(folderName_ + "/raw");
88  dbe_->setCurrentFolder(rawdir);
89  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
92  "hltRateNorm", "Overall HLT Accept rate vs LS, scaled", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
93  hltCount_ = dbe_->book1D("hltCount", "Overall HLT Counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
94  // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
95  // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
96  mergeCount_ =
97  dbe_->book1D("mergeCount", "Number of merge counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
98 
99  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
100  updates_->setBinLabel(1, "Good Updates");
101  updates_->setBinLabel(2, "Incomplete Updates");
102 
103 } // end constructor
#define LogDebug(id)
std::ofstream textfile_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * updates_
std::string folderName_
std::string processName_
MonitorElement * hltRate_
std::deque< int > ignores_
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
MonitorElement * hltCount_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1121
MonitorElement * hltNormRate_
HLTScalersClient::~HLTScalersClient ( )
inlineoverride

Destructor.

Definition at line 119 of file HLTScalersClient.h.

References analyze(), beginJob(), beginRun(), HltBtagPostValidation_cff::c, debug_, MillePedeFileConverter_cfg::e, endLuminosityBlock(), endRun(), and writedatasetfile::run.

119  {
120  if (debug_) {
121  textfile_.close();
122  }
123  };
std::ofstream textfile_

Member Function Documentation

void HLTScalersClient::analyze ( const edm::Event e,
const edm::EventSetup c 
)
override

Definition at line 522 of file HLTScalersClient.cc.

Referenced by ~HLTScalersClient().

522  {
523  // nothing to do here
524 }
void HLTScalersClient::beginJob ( void  )
overridevirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 106 of file HLTScalersClient.cc.

References dbe_, first_, folderName_, LogDebug, missingPathNames_, and dqm::dqmstoreimpl::DQMStore::setCurrentFolder().

Referenced by ~HLTScalersClient().

106  {
107  LogDebug("HLTScalersClient") << "beingJob";
108  if (dbe_) {
110  }
111  first_ = true;
112  missingPathNames_ = true;
113 }
#define LogDebug(id)
std::string folderName_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
void HLTScalersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
override

BeginRun.

beginRun

Definition at line 116 of file HLTScalersClient.cc.

References first_, edm::RunBase::id(), LogDebug, and missingPathNames_.

Referenced by ~HLTScalersClient().

116  {
117  missingPathNames_ = true;
118  first_ = true;
119  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
120 
121 } // beginRun
#define LogDebug(id)
RunID const & id() const
Definition: RunBase.h:39
void HLTScalersClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
override

End LumiBlock DQM Client Diagnostic should be performed here

Definition at line 131 of file HLTScalersClient.cc.

References newFWLiteAna::bin, dqm::dqmstoreimpl::DQMStore::book1D(), countHistories_, gather_cfg::cout, currentNormRate_, currentRate_, dbe_, debug_, relativeConstraints::empty, dqm::impl::MonitorElement::Fill(), first_, SiStripCommissioningSource_FromRAW_cfg::fnames, folderName_, dqm::dqmstoreimpl::DQMStore::get(), dqm::impl::MonitorElement::getBinContent(), HLTScalersClient::CountLSFifo_t::getCount(), dqm::impl::MonitorElement::getIntValue(), dqm::impl::MonitorElement::getNbinsX(), getSlope_(), dqm::legacy::MonitorElement::getTH1(), hltCount_, hltCurrentNormRate_, hltCurrentRate_, hltNormRate_, hltRate_, mps_fire::i, edm::LuminosityBlockBase::id(), createfilelist::int, edm::isNotFinite(), dqmdumpme::k, kPerHisto, kRateIntegWindow_, label, mps_splice::line, LogDebug, edm::LuminosityBlockID::luminosityBlock(), MAX_LUMI_SEG_HLT, MAX_PATHS, maxFU_, mergeCount_, missingPathNames_, mps_check::msg, Skims_PA_cff::name, names, nLumi_, unpackData-CaloStage2::pname, rateHistories_, rateNormHistories_, recentNormedOverallCountsPerLS_, recentNormedPathCountsPerLS_, recentOverallCountsPerLS_, recentPathCountsPerLS_, LumiMonitor_cff::scalers, SECS_PER_LUMI_SECTION, dqm::impl::MonitorElement::setBinContent(), dqm::impl::MonitorElement::setBinError(), dqm::impl::MonitorElement::setBinLabel(), dqm::dqmstoreimpl::DQMStore::setCurrentFolder(), dqm::dqmstoreimpl::DQMStore::showDirStructure(), slope, mathSSE::sqrt(), AlCaHLTBitMon_QueryRunRegistry::string, textfile_, HLTScalersClient::CountLSFifo_t::update(), and updates_.

Referenced by ~HLTScalersClient().

131  {
132  nLumi_ = lumiSeg.id().luminosityBlock();
133  // PWDEBUG
134  if (first_ && debug_)
136  // PWDEBUG END
137 
138  // get raw data
139  std::string scalHisto = folderName_ + "/raw/hltScalers";
140  MonitorElement *scalers = dbe_->get(scalHisto);
141  if (scalers == nullptr) {
142  LogDebug("HLTScalersClient") << "cannot get hlt scalers histogram, "
143  << "bailing out.";
144  if (debug_)
145  std::cout << "No scalers ? Looking for " << scalHisto << std::endl;
146  return;
147  }
148 
149  int npaths = scalers->getNbinsX();
150  if (npaths > MAX_PATHS)
151  npaths = MAX_PATHS; // HARD CODE FOR NOW
152  LogDebug("HLTScalersClient") << "I see " << npaths << " paths. ";
153 
154  // set the bin labels on the first go-through
155  // I need to do this here because we don't have the paths yet
156  // on begin-run. I should do this in a less ugly way (see FV?)
157  if (first_) {
158  std::string rawdir(folderName_ + "/raw");
159 
160  LogDebug("HLTScalersClient") << "Setting up paths on first endLumiBlock " << npaths;
161  dbe_->setCurrentFolder(rawdir);
162  currentRate_ = dbe_->book1D("cur_rate", "current lumi section rate per path", npaths, -0.5, npaths - 0.5);
164  dbe_->book1D("cur_rate_norm", "current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
165  recentPathCountsPerLS_.reserve(npaths);
166  recentNormedPathCountsPerLS_.reserve(npaths);
167  char rates_subfolder[256];
168  snprintf(rates_subfolder, 256, "%s/RateHistory", folderName_.c_str());
169  char counts_subfolder[256];
170  snprintf(counts_subfolder, 256, "%s/CountHistory", folderName_.c_str());
171 
172  hltCurrentRate_.reserve(npaths);
173  rateHistories_.reserve(npaths);
174  countHistories_.reserve(npaths);
175  hltCurrentNormRate_.reserve(npaths);
176  rateNormHistories_.reserve(npaths);
177 
178  dbe_->setCurrentFolder(folderName_); // these belong in top-level
179  for (int i = 0; i < npaths; ++i) {
180  dbe_->setCurrentFolder(std::string(rates_subfolder) + "/raw");
181 
182  char name[256];
183  snprintf(name, 256, "raw_rate_p%03d", i);
184  // LogDebug("HLTScalersClient") << "name " << i << " is " << name ;
185  rateHistories_.push_back(dbe_->book1D(name, name, MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5));
186  snprintf(name, 256, "norm_rate_p%03d", i);
187  dbe_->setCurrentFolder(rates_subfolder);
188  rateNormHistories_.push_back(dbe_->book1D(name, name, MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5));
189  dbe_->setCurrentFolder(counts_subfolder);
190  snprintf(name, 256, "counts_p%03d", i);
191  countHistories_.push_back(dbe_->book1D(name, name, MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5));
192  // prefill the data structures
193  recentPathCountsPerLS_.push_back(CountLSFifo_t(kRateIntegWindow_));
194  recentNormedPathCountsPerLS_.push_back(CountLSFifo_t(2));
195  }
197 
198  // split hlt scalers up into groups of 20
199  const int maxlen = 64;
200  char metitle[maxlen]; // histo name
201  char mename[maxlen]; // ME name
202  int numHistos = int(npaths / kPerHisto); // this hasta be w/o remainders
203 
204  int remainder = npaths % kPerHisto;
205  if (remainder)
206  numHistos += 1;
207 
208  for (int k = 0; k < numHistos; k++) {
209  int npath_low = kPerHisto * k;
210  int npath_high = kPerHisto * (k + 1) - 1;
211  snprintf(mename, maxlen, "hltScalers_%0d", k);
212  snprintf(metitle, maxlen, "HLT scalers - Paths %d to %d", npath_low, npath_high);
213  dbe_->setCurrentFolder(rawdir);
214  hltCurrentRate_.push_back(dbe_->book1D(mename, metitle, kPerHisto, -0.5 + npath_low, npath_high + 0.5));
215  dbe_->setCurrentFolder(folderName_); // these belong in top-level
216  snprintf(mename, maxlen, "hltScalersNorm_%0d", k);
217  snprintf(metitle, maxlen, "HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
218  hltCurrentNormRate_.push_back(dbe_->book1D(mename, metitle, kPerHisto, -0.5 + npath_low, npath_high + 0.5));
219  }
220 
221  first_ = false;
222  }
223 
224  if (missingPathNames_) {
225  // first try the scalers histogram and see if the bin names are set
226  for (int i = 0; i < npaths; ++i) {
227  // needs to be i+1 since root bins start at 1
228  const char *name = scalers->getTH1()->GetXaxis()->GetBinLabel(i + 1);
229  if (name && (strlen(name) > 0)) {
230  if (debug_) {
231  std::cout << "path " << i << " name is " << name << std::endl;
232  }
233  int whichHisto = i / kPerHisto;
234  int whichBin = i % kPerHisto + 1;
235  char pname[256];
236  hltCurrentRate_[whichHisto]->setBinLabel(whichBin, name);
237  hltCurrentNormRate_[whichHisto]->setBinLabel(whichBin, name);
238  snprintf(pname, 256, "Rate - path %s (Path # %03d)", name, i);
239  rateHistories_[i]->setTitle(pname);
240  rateNormHistories_[i]->setTitle(pname);
241  snprintf(pname, 256, "Counts - path %s (Path # %03d)", name, i);
242  countHistories_[i]->setTitle(pname);
243 
244  currentRate_->setBinLabel(i + 1, name);
245  currentNormRate_->setBinLabel(i + 1, name);
246 
247  missingPathNames_ = false;
248  }
249  }
250  }
251  // MEGA-HACK
252  if (missingPathNames_) {
253  // if that didn't work we load 'em from a text file. damn straight.
254  int ipath = 1;
255  std::ifstream names("names.dat");
256  if (!names) {
257  if (debug_) {
258  std::ostringstream msg;
259  msg << "open of "
260  << "names.dat";
261  perror(msg.str().c_str());
262  }
263  } else { // open succeeded
264  missingPathNames_ = false;
266  while (!names.eof()) {
267  getline(names, line);
268  std::istringstream fnames(line);
270  int bin;
271  if (fnames.str().find("#") == 0) // skip comment lines
272  continue;
273  if (fnames >> bin >> label) {
274  if (debug_) {
275  std::cout << bin << "--" << label << "(" << ipath << ")" << std::endl;
276  }
277  currentRate_->setBinLabel(ipath, label);
278  currentNormRate_->setBinLabel(ipath, label);
279  countHistories_[ipath - 1]->setTitle(label);
280  rateHistories_[ipath - 1]->setTitle(label);
281  rateNormHistories_[ipath - 1]->setTitle(label);
282  int whichHisto = (ipath - 1) / kPerHisto;
283  int whichBin = (ipath - 1) % kPerHisto + 1;
284  hltCurrentRate_[whichHisto]->setBinLabel(whichBin, label);
285  hltCurrentNormRate_[whichHisto]->setBinLabel(whichBin, label);
286  ++ipath;
287  if (ipath > npaths)
288  break;
289  } //
290  } // loop lines
291  } // open ok
292  }
293 
294  // END SETUP
295 
296  std::string nLumiHisto(folderName_ + "/nLumiBlock");
297  MonitorElement *nLumi = dbe_->get(nLumiHisto);
298  if (nLumi == nullptr) {
299  nLumiHisto = folderName_ + "/raw/nLumiBlock";
300  nLumi = dbe_->get(nLumiHisto);
301  }
302  int testval = (nLumi != nullptr ? nLumi->getIntValue() : -1);
303  LogDebug("HLTScalersClient") << "Lumi Block from DQM: " << testval << ", local is " << nLumi_;
304  int nL = (nLumi != nullptr ? nLumi->getIntValue() : nLumi_);
305  if (nL > MAX_LUMI_SEG_HLT) {
306  LogDebug("HLTScalersClient") << "Too many Lumi segments, " << nL << " is greater than MAX_LUMI_SEG_HLT,"
307  << " wrapping to " << (nL % MAX_LUMI_SEG_HLT);
308  // nL = MAX_LUMI_SEG_HLT;
309  nL = nL % MAX_LUMI_SEG_HLT;
310  }
311 
312  // merging counts
313  double num_fu = -1.0;
314  std::string mergeName(folderName_ + "/raw/hltMerge");
315  MonitorElement *merge = dbe_->get(mergeName);
316  if (merge != nullptr) {
317  num_fu = merge->getBinContent(1);
318  if (debug_) {
319  std::cout << "Number of received entries: " << num_fu << std::endl;
320  }
321  mergeCount_->Fill(nL, num_fu);
322  }
323  // end
324 
325  // evaluate the data
326  // loop over current counts
327 
328  // this gets filled for all times. Mainly for debugging.
329  for (int i = 1; i <= npaths; ++i) { // bins start at 1
330  double current_count = scalers->getBinContent(i);
331  // nb that this will now _overwrite_ some settings
332  countHistories_[i - 1]->setBinContent(nL, current_count); // good or bad
333  }
334 
335  std::string overallScalerName(folderName_ + "/raw/hltOverallScaler");
336  MonitorElement *hltScaler = dbe_->get(overallScalerName);
337  if (hltScaler != nullptr) {
338  double current_count = hltScaler->getBinContent(1);
339  hltCount_->setBinContent(nL, current_count);
340  recentOverallCountsPerLS_.update(CountLS_t(nL, current_count));
341  std::pair<double, double> sl = getSlope_(recentOverallCountsPerLS_);
342  double slope = sl.first;
343  double slope_err = sl.second;
344  if (slope > 0) {
345  hltRate_->setBinContent(nL, slope);
346  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
347  hltRate_->setBinError(nL, slope_err);
348  }
349  } // found histo
350 
351  if (num_fu >= 0.95 * maxFU_) {
352  if (num_fu > maxFU_) {
353  maxFU_ = num_fu;
354  if (debug_)
355  std::cout << "maxFU is now " << maxFU_ << std::endl;
356  }
357  // good data
358  for (int i = 1; i <= npaths; ++i) { // bins start at 1
359  double current_count = scalers->getBinContent(i);
360  // DEBUG
361  if (!recentPathCountsPerLS_[i - 1].empty() && debug_)
362  std::cout << i << "\t-> good one: new => cnt, ls = " << current_count << ", " << nL
363  << ", old = " << recentPathCountsPerLS_[i - 1].back().second << "\t"
364  << recentPathCountsPerLS_[i - 1].back().first << std::endl;
365  // END DEBUG
366  recentPathCountsPerLS_[i - 1].update(CountLS_t(nL, current_count));
367 
368  // NB: we do not fill a new entry in the rate histo if we can't
369  // calculate it
370  std::pair<double, double> sl = getSlope_(recentPathCountsPerLS_[i - 1]);
371  double slope = sl.first;
372  double slope_err = sl.second;
373  // rateHistories_[i-1]->Fill(nL,slope);
374  if (slope > 0) {
375  rateHistories_[i - 1]->setBinContent(nL, slope);
376  // set the current rate(s)
377  hltCurrentRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
378  currentRate_->setBinContent(i, slope);
379  if (!edm::isNotFinite(slope_err) && (slope_err >= 0)) {
380  currentRate_->setBinError(i, slope_err);
381  hltCurrentRate_[(i - 1) / kPerHisto]->setBinError(i % kPerHisto, slope_err);
382  rateHistories_[i - 1]->setBinError(nL, slope_err);
383  }
384  }
387 
388  } // loop over paths
389 
390  // ---------------------------- overall rate, absolute counts
391  std::string overallScalerName(folderName_ + "/raw/hltOverallScaler");
392  MonitorElement *hltScaler = dbe_->get(overallScalerName);
393  if (hltScaler != nullptr) {
394  double current_count = hltScaler->getBinContent(1);
395  hltCount_->setBinContent(nL, current_count);
396  recentOverallCountsPerLS_.update(CountLS_t(nL, current_count));
397  std::pair<double, double> sl = getSlope_(recentOverallCountsPerLS_);
398  double slope = sl.first;
399  double slope_err = sl.second;
400  if (slope >= 0) {
401  hltRate_->setBinContent(nL, slope);
402  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
403  hltRate_->setBinError(nL, slope_err);
404  }
405  } // found histo
406  updates_->Fill(0); // good
407  } // check on number of FU's - good data
408  else {
409  updates_->Fill(1); // missing updates
410  }
411 
412  // PW DEBUG
413  if (debug_) {
414  textfile_ << nL << "\t" << npaths << "\t";
415  for (int i = 0; i < npaths; ++i) {
416  textfile_ << scalers->getBinContent(i) << " ";
417  }
418  textfile_ << std::endl;
419  }
420  // end DEBUG
421 
422 #ifdef LATER
423  // ------ overall rate normalized - all data
424  overallScalerName = std::string(folderName_ + "/raw/hltOverallScalerN");
425  hltScaler = dbe_->get(overallScalerName);
426  if (hltScaler != 0) {
427  double cnt = hltScaler->getBinContent(1);
428  // hltCountN_->setBinContent(nL,cnt);
429  if (debug_) {
430  std::cout << "Overall Norm: new => cnt, ls = " << cnt << ", " << nL << ", num_fu = " << num_fu << std::endl;
431  }
432  recentNormedOverallCountsPerLS_.update(CountLS_t(nL, cnt / num_fu));
433  cnt = recentNormedOverallCountsPerLS_.getCount(nL); // for dupes/partials
434  double slope = cnt / num_fu / SECS_PER_LUMI_SECTION;
435  if (debug_) {
436  std::cout << "Normalized slope = " << slope << std::endl;
437  }
438  if (slope > 0)
439  hltNormRate_->setBinContent(nL, slope);
440  }
441  //
442  std::string scalHistoNorm = folderName_ + "/raw/hltScalersN";
443  MonitorElement *scalersN = dbe_->get(scalHistoNorm);
444  if (scalersN) {
445  for (int i = 0; i < npaths; ++i) {
446  double cnt = scalersN->getBinContent(i);
447  double slope = cnt / num_fu / SECS_PER_LUMI_SECTION;
448  if (slope > 0) {
449  rateNormHistories_[i - 1]->setBinContent(nL, slope);
450  // set the current rate(s)
451  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
453  }
454  }
455  }
456 #else // NOT LATER
457  // ------ overall rate normalized - all data
458  overallScalerName = std::string(folderName_ + "/raw/hltOverallScaler");
459  hltScaler = dbe_->get(overallScalerName);
460  if (hltScaler != nullptr) {
461  double cnt = hltScaler->getBinContent(1);
462  // hltCountN_->setBinContent(nL,cnt);
463  float sf = num_fu / maxFU_;
464  if (debug_) {
465  std::cout << "Overall Norm: new => cnt, ls = " << cnt << ", " << nL << ", num_fu = " << num_fu << ", sf = " << sf
466  << std::endl;
467  }
468  recentNormedOverallCountsPerLS_.update(CountLS_t(nL, cnt / sf));
469  cnt = recentNormedOverallCountsPerLS_.getCount(nL); // for dupes/partials
470  std::pair<double, double> sl = getSlope_(recentNormedOverallCountsPerLS_);
471  double slope = sl.first;
472  double slope_err = sl.second;
473  if (debug_) {
474  std::cout << "Normalized slope = " << slope << std::endl;
475  }
476  if (slope > 0) {
477  hltNormRate_->setBinContent(nL, slope);
478  if (cnt > 0)
479  slope_err = slope * sqrt(2. / num_fu + 2. / cnt);
480  if (!edm::isNotFinite(slope_err) && (slope_err >= 0))
481  hltNormRate_->setBinError(nL, slope_err);
482  }
483  }
484  //
485  std::string scalHistoNorm = folderName_ + "/raw/hltScalers";
486  MonitorElement *scalersN = dbe_->get(scalHistoNorm);
487  if (scalersN) {
488  double sf = num_fu / maxFU_;
489  for (int i = 1; i <= npaths; ++i) {
490  double cnt = scalersN->getBinContent(i);
491  recentNormedPathCountsPerLS_[i - 1].update(CountLS_t(nL, cnt / sf));
492  std::pair<double, double> sl = getSlope_(recentNormedPathCountsPerLS_[i - 1]);
493  double slope = sl.first;
494  double slope_err = sl.second;
495  if (slope >= 0) {
496  rateNormHistories_[i - 1]->setBinContent(nL, slope);
497  // set the current rate(s)
498  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinContent(i % kPerHisto, slope);
500  if (slope_err <= 0 && cnt > 0) {
501  // ignores error on prev point, so scale by sqrt(2)
502  slope_err = slope * sqrt(2. / num_fu + 2. / cnt);
503  if (debug_) {
504  std::cout << "Slope err " << i << " = " << slope_err << std::endl;
505  }
506  }
507  if (!edm::isNotFinite(slope_err) && (slope_err >= 0)) {
508  rateNormHistories_[i - 1]->setBinError(nL, slope_err);
509  // set the current rate(s)
510  hltCurrentNormRate_[(i - 1) / kPerHisto]->setBinError(i % kPerHisto, slope_err);
511  currentNormRate_->setBinError(i, slope_err);
512  }
513  }
514  }
515  }
516 
517 #endif // LATER
518  //
519 }
#define LogDebug(id)
LuminosityBlockID id() const
std::ofstream textfile_
Definition: merge.py:1
MonitorElement * updates_
constexpr bool isNotFinite(T x)
Definition: isFinite.h:9
static const double slope[3]
MonitorElement * currentNormRate_
virtual int64_t getIntValue() const
std::vector< CountLSFifo_t > recentNormedPathCountsPerLS_
const std::string names[nVars_]
std::vector< MonitorElement * > hltCurrentNormRate_
void Fill(long long x)
char const * label
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
Definition: DQMStore.cc:1509
virtual int getNbinsX() const
get # of bins in X-axis
std::string folderName_
#define SECS_PER_LUMI_SECTION
MonitorElement * hltRate_
T sqrt(T t)
Definition: SSEVec.h:19
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
std::vector< MonitorElement * > countHistories_
virtual void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
virtual double getBinContent(int binx) const
get content of bin (1-D)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
std::vector< MonitorElement * > hltCurrentRate_
void update(const CountLS_t &T)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
std::vector< MonitorElement * > rateHistories_
LuminosityBlockNumber_t luminosityBlock() const
tuple msg
Definition: mps_check.py:285
MonitorElement * hltCount_
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:639
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
const int kPerHisto
void showDirStructure() const
Definition: DQMStore.cc:2926
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
Definition: DQMStore.cc:1121
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * hltNormRate_
#define MAX_PATHS
virtual TH1 * getTH1() const
void HLTScalersClient::endRun ( const edm::Run run,
const edm::EventSetup c 
)
override

EndRun.

Definition at line 124 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

Referenced by ~HLTScalersClient().

124  {
125  missingPathNames_ = true;
126  first_ = true;
127 }
std::pair< double, double > HLTScalersClient::getSlope_ ( const CountLSFifo_t points)
private

Definition at line 529 of file HLTScalersClient.cc.

References gather_cfg::cout, debug_, mps_fire::i, dqmiodumpmetadata::n, funct::pow(), SECS_PER_LUMI_SECTION, slope, mathSSE::sqrt(), HLTScalersClient::CountLSFifo_t::targetSize(), x, geometryCSVtoXML::xy, and y.

Referenced by endLuminosityBlock().

529  {
530  double slope, sigma_m;
531  if (points.size() < points.targetSize()) {
532  return std::pair<double, double>(-1, -1);
533  }
534  // just do a delta if we just want two bins
535  else if (points.size() == 2) {
536  // just do diff and be done with it
537  double delta_ls = points.front().first - points.back().first;
538  double delta_cnt = points.front().second - points.back().second;
539  slope = delta_cnt / delta_ls;
540  sigma_m = -1;
541  } else { // do a fit
542  double xy = 0;
543  double x = 0;
544  double xsq = 0;
545  double y = 0;
546  double n = double(points.size());
547  for (auto i(points.begin()); i != points.end(); ++i) {
548  if (debug_)
549  std::cout << "x = " << i->first << ", y = " << i->second << std::endl;
550  xy += i->first * i->second;
551  x += i->first;
552  xsq += i->first * i->first;
553  y += i->second;
554  }
555  slope = (n * xy - x * y) / (n * xsq - x * x);
556 
557  // now get the uncertainty on the slope. Need intercept for this.
558  double intercept = (xsq * y - xy * x) / (n * xsq - x * x);
559  double sigma_ysq = 0;
560  for (auto i(points.begin()); i != points.end(); ++i) {
561  sigma_ysq += pow((i->second - slope * i->first - intercept), 2.);
562  }
563  // if ( debug_ )
564  // std::cout << "chi^2 = " << sigma_ysq << std::endl;
565  sigma_ysq *= 1. / (n - 2.);
566 
567  sigma_m = sqrt(n * sigma_ysq / (n * xsq - x * x));
568  }
569 
570  // std::cout << "Slope is " << slope << std::endl;
571  slope /= SECS_PER_LUMI_SECTION;
572  if (sigma_m > 0)
573  sigma_m /= SECS_PER_LUMI_SECTION;
574  // if ( debug_ ) {
575  // std::cout << "Slope = " << slope << " +- " << sigma_m
576  // << std::endl;
577  // std::cout << "intercept is " << intercept
578  // << std::endl;
579  // }
580 
581  return std::pair<double, double>(slope, sigma_m);
582 }
static const double slope[3]
#define SECS_PER_LUMI_SECTION
T sqrt(T t)
Definition: SSEVec.h:19
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:30

Member Data Documentation

std::vector<MonitorElement *> HLTScalersClient::countHistories_
private

Definition at line 151 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentLumiBlockNumber_
private

Definition at line 149 of file HLTScalersClient.h.

MonitorElement* HLTScalersClient::currentNormRate_
private

Definition at line 162 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::currentRate_
private

Definition at line 148 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentRun_
private

Definition at line 146 of file HLTScalersClient.h.

DQMStore* HLTScalersClient::dbe_
private

Definition at line 142 of file HLTScalersClient.h.

Referenced by beginJob(), endLuminosityBlock(), and HLTScalersClient().

bool HLTScalersClient::debug_
private
bool HLTScalersClient::first_
private

Definition at line 166 of file HLTScalersClient.h.

Referenced by beginJob(), beginRun(), endLuminosityBlock(), and endRun().

std::string HLTScalersClient::folderName_
private

Definition at line 167 of file HLTScalersClient.h.

Referenced by beginJob(), endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::hltCount_
private

Definition at line 155 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

std::vector<MonitorElement *> HLTScalersClient::hltCurrentNormRate_
private

Definition at line 164 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::vector<MonitorElement *> HLTScalersClient::hltCurrentRate_
private

Definition at line 153 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::hltNormRate_
private

Definition at line 161 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::hltRate_
private

Definition at line 154 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

std::deque<int> HLTScalersClient::ignores_
private

Definition at line 171 of file HLTScalersClient.h.

unsigned int HLTScalersClient::kRateIntegWindow_
private

Definition at line 168 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::maxFU_
private

Definition at line 176 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::mergeCount_
private

Definition at line 158 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

bool HLTScalersClient::missingPathNames_
private

Definition at line 166 of file HLTScalersClient.h.

Referenced by beginJob(), beginRun(), endLuminosityBlock(), and endRun().

int HLTScalersClient::nev_
private

Definition at line 144 of file HLTScalersClient.h.

int HLTScalersClient::nLumi_
private

Definition at line 145 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::string HLTScalersClient::processName_
private

Definition at line 169 of file HLTScalersClient.h.

std::vector<MonitorElement *> HLTScalersClient::rateHistories_
private

Definition at line 150 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::vector<MonitorElement *> HLTScalersClient::rateNormHistories_
private

Definition at line 163 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentNormedOverallCountsPerLS_
private

Definition at line 181 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::vector<CountLSFifo_t> HLTScalersClient::recentNormedPathCountsPerLS_
private

Definition at line 180 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentOverallCountsPerLS_
private

Definition at line 178 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::vector<CountLSFifo_t> HLTScalersClient::recentPathCountsPerLS_
private

Definition at line 177 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::ofstream HLTScalersClient::textfile_
private

Definition at line 58 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::updates_
private

Definition at line 157 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().