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
 EDAnalyzer ()
 
std::string workerType () const
 
virtual ~EDAnalyzer ()
 
- Public Member Functions inherited from edm::EDConsumerBase
 EDConsumerBase ()
 
ProductHolderIndex indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndex > &) const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Member Functions

std::pair< double, double > getSlope_ (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
 
typedef WorkerT< EDAnalyzerWorkerType
 
- 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::EDAnalyzer
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
CurrentProcessingContext const * currentContext () const
 
- 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 62 of file HLTScalersClient.h.

Constructor & Destructor Documentation

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

Constructors.

Definition at line 74 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_.

74  :
75  dbe_(0),
76  nLumi_(0),
77  currentRate_(0),
79  first_(true), missingPathNames_(true),
81  "HLT/HLScalers_EvF")),
82  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow",
83  3)),
84  processName_(ps.getParameter<std::string>("processName")),
85  ignores_(),
86  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
87  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
90 {
91  LogDebug("HLTScalersClient") << "constructor" ;
92  if ( debug_ ) {
93  textfile_.open("debug.txt");
94  if ( ! textfile_ ) {
95  std::cout << "constructor: can't open text file" << std::endl;
96  }
97  }
98  // get back-end interface
100  dbe_->setVerbose(1);
102 
103 
104  std::string rawdir(folderName_ + "/raw");
105  dbe_->setCurrentFolder(rawdir);
106  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS",
109  hltNormRate_ = dbe_->book1D("hltRateNorm",
110  "Overall HLT Accept rate vs LS, scaled",
112  hltCount_= dbe_->book1D("hltCount", "Overall HLT Counts vs LS",
114 // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
115 // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
116  mergeCount_= dbe_->book1D("mergeCount", "Number of merge counts vs LS",
118 
119 
120 
121  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
122  updates_->setBinLabel(1, "Good Updates");
123  updates_->setBinLabel(2, "Incomplete Updates");
124 
125 
126 } // 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:722
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:398
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:434
virtual HLTScalersClient::~HLTScalersClient ( )
inlinevirtual

Destructor.

Definition at line 144 of file HLTScalersClient.h.

References debug_, and textfile_.

144  {
145  if ( debug_ ) {
146  textfile_.close();
147  }
148  };
std::ofstream textfile_

Member Function Documentation

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

Implements edm::EDAnalyzer.

Definition at line 589 of file HLTScalersClient.cc.

590 {
591  // nothing to do here
592 }
void HLTScalersClient::beginJob ( void  )
virtual

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 130 of file HLTScalersClient.cc.

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

131 {
132  LogDebug("HLTScalersClient") << "beingJob" ;
133  if (dbe_) {
135  }
136  first_ = true;
137  missingPathNames_ = true;
138 }
#define LogDebug(id)
std::string folderName_
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:434
void HLTScalersClient::beginRun ( const edm::Run run,
const edm::EventSetup c 
)
virtual

BeginRun.

beginRun

Reimplemented from edm::EDAnalyzer.

Definition at line 142 of file HLTScalersClient.cc.

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

143 {
144  missingPathNames_ = true;
145  first_ = true;
146  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
147 
148 } // 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 160 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(), gen::k, kPerHisto, kRateIntegWindow_, diffTwoXMLs::label, geometryCSVtoXML::line, LogDebug, edm::LuminosityBlockID::luminosityBlock(), MAX_LUMI_SEG_HLT, MAX_PATHS, maxFU_, relval_steps::merge(), mergeCount_, missingPathNames_, lumiQueryAPI::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_.

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 151 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

152 {
153  missingPathNames_ = true;
154  first_ = true;
155 }
std::pair< double, double > HLTScalersClient::getSlope_ ( HLTScalersClient::CountLSFifo_t  points)
private

Definition at line 598 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().

599 {
600  double slope, sigma_m;
601  if ( points.size() < points.targetSize() ) {
602  return std::pair<double,double>(-1,-1);
603  }
604  // just do a delta if we just want two bins
605  else if ( points.size() == 2 ) {
606  // just do diff and be done with it
607  double delta_ls = points.front().first - points.back().first;
608  double delta_cnt = points.front().second - points.back().second;
609  slope = delta_cnt / delta_ls ;
610  sigma_m = -1;
611  }
612  else { // do a fit
613  double xy = 0;
614  double x = 0;
615  double xsq = 0;
616  double y = 0;
617  double n = double(points.size());
618  for ( CountLSFifo_t::iterator i(points.begin());
619  i != points.end(); ++i ) {
620  if ( debug_ )
621  std::cout << "x = " << i->first << ", y = " << i->second
622  << std::endl;
623  xy += i->first * i->second;
624  x += i->first;
625  xsq += i->first*i->first;
626  y += i->second;
627  }
628  slope = (n*xy - x*y)/(n*xsq - x*x);
629 
630  // now get the uncertainty on the slope. Need intercept for this.
631  double intercept = (xsq*y - xy*x)/(n*xsq-x*x);
632  double sigma_ysq = 0;
633  for ( CountLSFifo_t::iterator i(points.begin());
634  i != points.end(); ++i ) {
635  sigma_ysq += pow(( i->second - slope * i->first - intercept),2.);
636  }
637 // if ( debug_ )
638 // std::cout << "chi^2 = " << sigma_ysq << std::endl;
639  sigma_ysq *= 1./(n-2.);
640 
641  sigma_m = sqrt( n*sigma_ysq/(n*xsq - x*x));
642  }
643 
644  // std::cout << "Slope is " << slope << std::endl;
645  slope /= SECS_PER_LUMI_SECTION;
646  if ( sigma_m >0 )
647  sigma_m /= SECS_PER_LUMI_SECTION;
648 // if ( debug_ ) {
649 // std::cout << "Slope = " << slope << " +- " << sigma_m
650 // << std::endl;
651 // std::cout << "intercept is " << intercept
652 // << std::endl;
653 // }
654 
655 
656  return std::pair<double,double>(slope, sigma_m);
657 }
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 180 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentLumiBlockNumber_
private

Definition at line 178 of file HLTScalersClient.h.

MonitorElement* HLTScalersClient::currentNormRate_
private

Definition at line 191 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::currentRate_
private

Definition at line 177 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::currentRun_
private

Definition at line 175 of file HLTScalersClient.h.

DQMStore* HLTScalersClient::dbe_
private

Definition at line 171 of file HLTScalersClient.h.

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

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

Definition at line 195 of file HLTScalersClient.h.

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

std::string HLTScalersClient::folderName_
private

Definition at line 196 of file HLTScalersClient.h.

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

MonitorElement* HLTScalersClient::hltCount_
private

Definition at line 184 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 193 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 182 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::hltNormRate_
private

Definition at line 190 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

MonitorElement* HLTScalersClient::hltRate_
private

Definition at line 183 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

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

Definition at line 200 of file HLTScalersClient.h.

unsigned int HLTScalersClient::kRateIntegWindow_
private

Definition at line 197 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

int HLTScalersClient::maxFU_
private

Definition at line 204 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

MonitorElement* HLTScalersClient::mergeCount_
private

Definition at line 187 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().

bool HLTScalersClient::missingPathNames_
private

Definition at line 195 of file HLTScalersClient.h.

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

int HLTScalersClient::nev_
private

Definition at line 173 of file HLTScalersClient.h.

int HLTScalersClient::nLumi_
private

Definition at line 174 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::string HLTScalersClient::processName_
private

Definition at line 198 of file HLTScalersClient.h.

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

Definition at line 179 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 192 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentNormedOverallCountsPerLS_
private

Definition at line 209 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 208 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

CountLSFifo_t HLTScalersClient::recentOverallCountsPerLS_
private

Definition at line 206 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

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

Definition at line 205 of file HLTScalersClient.h.

Referenced by endLuminosityBlock().

std::ofstream HLTScalersClient::textfile_
private

Definition at line 65 of file HLTScalersClient.h.

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

MonitorElement* HLTScalersClient::updates_
private

Definition at line 186 of file HLTScalersClient.h.

Referenced by endLuminosityBlock(), and HLTScalersClient().