CMS 3D CMS Logo

List of all members | Classes | 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 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

- Public Types inherited from edm::EDAnalyzer
typedef EDAnalyzer ModuleType
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 
- 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 57 of file HLTScalersClient.h.

Constructor & Destructor Documentation

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

Constructors.

Definition at line 62 of file HLTScalersClient.cc.

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

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

63  : dbe_(nullptr),
64  nLumi_(0),
65  currentRate_(nullptr),
67  first_(true),
68  missingPathNames_(true),
69  folderName_(ps.getUntrackedParameter<std::string>("dqmFolder", "HLT/HLScalers_EvF")),
70  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow", 3)),
71  processName_(ps.getParameter<std::string>("processName")),
72  ignores_(),
73  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
74  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
77  LogDebug("HLTScalersClient") << "constructor";
78  if (debug_) {
79  textfile_.open("debug.txt");
80  if (!textfile_) {
81  std::cout << "constructor: can't open text file" << std::endl;
82  }
83  }
84  // get back-end interface
86  dbe_->setVerbose(1);
88 
89  std::string rawdir(folderName_ + "/raw");
90  dbe_->setCurrentFolder(rawdir);
91  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
94  "hltRateNorm", "Overall HLT Accept rate vs LS, scaled", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
95  hltCount_ = dbe_->book1D("hltCount", "Overall HLT Counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
96  // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
97  // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
98  mergeCount_ =
99  dbe_->book1D("mergeCount", "Number of merge counts vs LS", MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT - 0.5);
100 
101  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
102  updates_->setBinLabel(1, "Good Updates");
103  updates_->setBinLabel(2, "Incomplete Updates");
104 
105 } // end constructor
#define LogDebug(id)
std::ofstream textfile_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * updates_
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)
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:1098
std::string folderName_
std::string processName_
MonitorElement * hltRate_
std::deque< int > ignores_
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
void setVerbose(unsigned level)
Definition: DQMStore.cc:531
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:571
MonitorElement * hltCount_
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
MonitorElement * hltNormRate_
HLTScalersClient::~HLTScalersClient ( )
inlineoverride

Destructor.

Definition at line 118 of file HLTScalersClient.h.

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

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

Member Function Documentation

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

Definition at line 524 of file HLTScalersClient.cc.

Referenced by ~HLTScalersClient().

524  {
525  // nothing to do here
526 }
void HLTScalersClient::beginJob ( void  )
overridevirtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 108 of file HLTScalersClient.cc.

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

Referenced by ~HLTScalersClient().

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

BeginRun.

beginRun

Definition at line 118 of file HLTScalersClient.cc.

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

Referenced by ~HLTScalersClient().

118  {
119  missingPathNames_ = true;
120  first_ = true;
121  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
122 
123 } // 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 133 of file HLTScalersClient.cc.

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

Referenced by ~HLTScalersClient().

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

EndRun.

Definition at line 126 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

Referenced by ~HLTScalersClient().

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

Definition at line 531 of file HLTScalersClient.cc.

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

Referenced by endLuminosityBlock().

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

Member Data Documentation

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

Definition at line 150 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentLumiBlockNumber_
private

Definition at line 148 of file HLTScalersClient.h.

MonitorElement* HLTScalersClient::currentNormRate_
private

Definition at line 161 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::currentRate_
private

Definition at line 147 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentRun_
private

Definition at line 145 of file HLTScalersClient.h.

DQMStore* HLTScalersClient::dbe_
private

Definition at line 141 of file HLTScalersClient.h.

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

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

Definition at line 165 of file HLTScalersClient.h.

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

std::string HLTScalersClient::folderName_
private

Definition at line 166 of file HLTScalersClient.h.

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

MonitorElement* HLTScalersClient::hltCount_
private

Definition at line 154 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 163 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 152 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::hltNormRate_
private

Definition at line 160 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::hltRate_
private

Definition at line 153 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 170 of file HLTScalersClient.h.

unsigned int HLTScalersClient::kRateIntegWindow_
private

Definition at line 167 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::maxFU_
private

Definition at line 175 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::mergeCount_
private

Definition at line 157 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

bool HLTScalersClient::missingPathNames_
private

Definition at line 165 of file HLTScalersClient.h.

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

int HLTScalersClient::nev_
private

Definition at line 143 of file HLTScalersClient.h.

int HLTScalersClient::nLumi_
private

Definition at line 144 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::string HLTScalersClient::processName_
private

Definition at line 168 of file HLTScalersClient.h.

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

Definition at line 149 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 162 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentNormedOverallCountsPerLS_
private

Definition at line 180 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 179 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentOverallCountsPerLS_
private

Definition at line 177 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 176 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::ofstream HLTScalersClient::textfile_
private

Definition at line 59 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::updates_
private

Definition at line 156 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().