CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Classes | Public Member Functions | 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)
 
void beginJob (void)
 BeginJob. More...
 
void beginRun (const edm::Run &run, const edm::EventSetup &c)
 BeginRun. More...
 
void endLuminosityBlock (const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
 
void endRun (const edm::Run &run, const edm::EventSetup &c)
 EndRun. More...
 
 HLTScalersClient (const edm::ParameterSet &ps)
 Constructors. More...
 
virtual ~HLTScalersClient ()
 Destructor. More...
 
- Public Member Functions inherited from edm::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 EDAnalyzer ()
 
ModuleDescription const & moduleDescription () const
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

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
 
- Static Public Member Functions inherited from edm::EDAnalyzer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description

Definition at line 57 of file HLTScalersClient.h.

Constructor & Destructor Documentation

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

Constructors.

Definition at line 67 of file HLTScalersClient.cc.

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

67  :
68  dbe_(0),
69  nLumi_(0),
70  currentRate_(0),
72  first_(true), missingPathNames_(true),
74  "HLT/HLScalers_EvF")),
75  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow",
76  3)),
77  processName_(ps.getParameter<std::string>("processName")),
78  ignores_(),
79  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
80  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
83 {
84  LogDebug("HLTScalersClient") << "constructor" ;
85  if ( debug_ ) {
86  textfile_.open("debug.txt");
87  if ( ! textfile_ ) {
88  std::cout << "constructor: can't open text file" << std::endl;
89  }
90  }
91  // get back-end interface
93  dbe_->setVerbose(1);
95 
96 
97  std::string rawdir(folderName_ + "/raw");
98  dbe_->setCurrentFolder(rawdir);
99  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS",
102  hltNormRate_ = dbe_->book1D("hltRateNorm",
103  "Overall HLT Accept rate vs LS, scaled",
105  hltCount_= dbe_->book1D("hltCount", "Overall HLT Counts vs LS",
107 // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
108 // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
109  mergeCount_= dbe_->book1D("mergeCount", "Number of merge counts vs LS",
111 
112 
113 
114  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
115  updates_->setBinLabel(1, "Good Updates");
116  updates_->setBinLabel(2, "Incomplete Updates");
117 
118 
119 } // end constructor
#define LogDebug(id)
std::ofstream textfile_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
MonitorElement * updates_
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:971
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)
std::string folderName_
std::string processName_
MonitorElement * hltRate_
std::deque< int > ignores_
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
void setVerbose(unsigned level)
Definition: DQMStore.cc:648
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
MonitorElement * hltCount_
CountLSFifo_t recentNormedOverallCountsPerLS_
#define MAX_LUMI_SEG_HLT
tuple cout
Definition: gather_cfg.py:121
MonitorElement * hltNormRate_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:684
virtual HLTScalersClient::~HLTScalersClient ( )
inlinevirtual

Destructor.

Definition at line 139 of file HLTScalersClient.h.

References debug_, and textfile_.

139  {
140  if ( debug_ ) {
141  textfile_.close();
142  }
143  };
std::ofstream textfile_

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 582 of file HLTScalersClient.cc.

583 {
584  // nothing to do here
585 }
void HLTScalersClient::beginJob ( void  )
virtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 123 of file HLTScalersClient.cc.

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

124 {
125  LogDebug("HLTScalersClient") << "beingJob" ;
126  if (dbe_) {
128  }
129  first_ = true;
130  missingPathNames_ = true;
131 }
#define LogDebug(id)
std::string folderName_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:684
void HLTScalersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

BeginRun.

beginRun

Reimplemented from edm::EDAnalyzer.

Definition at line 135 of file HLTScalersClient.cc.

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

136 {
137  missingPathNames_ = true;
138  first_ = true;
139  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
140 
141 } // beginRun
#define LogDebug(id)
RunID const & id() const
Definition: RunBase.h:41
void HLTScalersClient::endLuminosityBlock ( const edm::LuminosityBlock lumiSeg,
const edm::EventSetup c 
)
virtual

End LumiBlock DQM Client Diagnostic should be performed here

Reimplemented from edm::EDAnalyzer.

Definition at line 153 of file HLTScalersClient.cc.

References newFWLiteAna::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_, i, edm::LuminosityBlockBase::id(), edm::isNotFinite(), roll_playback::k, kPerHisto, kRateIntegWindow_, diffTwoXMLs::label, geometryCSVtoXML::line, LogDebug, edm::LuminosityBlockID::luminosityBlock(), MAX_LUMI_SEG_HLT, MAX_PATHS, maxFU_, relval_steps::merge(), mergeCount_, missingPathNames_, producerFileCleanner::msg, mergeVDriftHistosByStation::name, cscdqm::h::names, nLumi_, 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_.

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 144 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

145 {
146  missingPathNames_ = true;
147  first_ = true;
148 }
std::pair< double, double > HLTScalersClient::getSlope_ ( const CountLSFifo_t points)
private

Definition at line 591 of file HLTScalersClient.cc.

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

Referenced by endLuminosityBlock().

592 {
593  double slope, sigma_m;
594  if ( points.size() < points.targetSize() ) {
595  return std::pair<double,double>(-1,-1);
596  }
597  // just do a delta if we just want two bins
598  else if ( points.size() == 2 ) {
599  // just do diff and be done with it
600  double delta_ls = points.front().first - points.back().first;
601  double delta_cnt = points.front().second - points.back().second;
602  slope = delta_cnt / delta_ls ;
603  sigma_m = -1;
604  }
605  else { // do a fit
606  double xy = 0;
607  double x = 0;
608  double xsq = 0;
609  double y = 0;
610  double n = double(points.size());
611  for ( auto i(points.begin());
612  i != points.end(); ++i ) {
613  if ( debug_ )
614  std::cout << "x = " << i->first << ", y = " << i->second
615  << std::endl;
616  xy += i->first * i->second;
617  x += i->first;
618  xsq += i->first*i->first;
619  y += i->second;
620  }
621  slope = (n*xy - x*y)/(n*xsq - x*x);
622 
623  // now get the uncertainty on the slope. Need intercept for this.
624  double intercept = (xsq*y - xy*x)/(n*xsq-x*x);
625  double sigma_ysq = 0;
626  for ( auto i (points.begin());
627  i != points.end(); ++i ) {
628  sigma_ysq += pow(( i->second - slope * i->first - intercept),2.);
629  }
630 // if ( debug_ )
631 // std::cout << "chi^2 = " << sigma_ysq << std::endl;
632  sigma_ysq *= 1./(n-2.);
633 
634  sigma_m = sqrt( n*sigma_ysq/(n*xsq - x*x));
635  }
636 
637  // std::cout << "Slope is " << slope << std::endl;
638  slope /= SECS_PER_LUMI_SECTION;
639  if ( sigma_m >0 )
640  sigma_m /= SECS_PER_LUMI_SECTION;
641 // if ( debug_ ) {
642 // std::cout << "Slope = " << slope << " +- " << sigma_m
643 // << std::endl;
644 // std::cout << "intercept is " << intercept
645 // << std::endl;
646 // }
647 
648 
649  return std::pair<double,double>(slope, sigma_m);
650 }
int i
Definition: DBlmapReader.cc:9
static const double slope[3]
#define SECS_PER_LUMI_SECTION
T sqrt(T t)
Definition: SSEVec.h:48
tuple cout
Definition: gather_cfg.py:121
Definition: DDAxes.h:10
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 175 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentLumiBlockNumber_
private

Definition at line 173 of file HLTScalersClient.h.

MonitorElement* HLTScalersClient::currentNormRate_
private

Definition at line 186 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::currentRate_
private

Definition at line 172 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentRun_
private

Definition at line 170 of file HLTScalersClient.h.

DQMStore* HLTScalersClient::dbe_
private

Definition at line 166 of file HLTScalersClient.h.

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

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

Definition at line 190 of file HLTScalersClient.h.

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

std::string HLTScalersClient::folderName_
private

Definition at line 191 of file HLTScalersClient.h.

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

MonitorElement* HLTScalersClient::hltCount_
private

Definition at line 179 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 188 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 177 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::hltNormRate_
private

Definition at line 185 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::hltRate_
private

Definition at line 178 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 195 of file HLTScalersClient.h.

unsigned int HLTScalersClient::kRateIntegWindow_
private

Definition at line 192 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::maxFU_
private

Definition at line 199 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::mergeCount_
private

Definition at line 182 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

bool HLTScalersClient::missingPathNames_
private

Definition at line 190 of file HLTScalersClient.h.

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

int HLTScalersClient::nev_
private

Definition at line 168 of file HLTScalersClient.h.

int HLTScalersClient::nLumi_
private

Definition at line 169 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::string HLTScalersClient::processName_
private

Definition at line 193 of file HLTScalersClient.h.

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

Definition at line 174 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 187 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentNormedOverallCountsPerLS_
private

Definition at line 204 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 203 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentOverallCountsPerLS_
private

Definition at line 201 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 200 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::ofstream HLTScalersClient::textfile_
private

Definition at line 60 of file HLTScalersClient.h.

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

MonitorElement* HLTScalersClient::updates_
private

Definition at line 181 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().