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

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 ()
 

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
CurrentProcessingContext const * currentContext () const
 

Detailed Description

Definition at line 62 of file HLTScalersClient.h.

Constructor & Destructor Documentation

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

Constructors.

Definition at line 68 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(), textfile_, and updates_.

68  :
69  dbe_(0),
70  nLumi_(0),
71  currentRate_(0),
73  first_(true), missingPathNames_(true),
74  folderName_(ps.getUntrackedParameter<std::string>("dqmFolder",
75  "HLT/HLScalers_EvF")),
76  kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>("rateIntegWindow",
77  3)),
78  processName_(ps.getParameter<std::string>("processName")),
79  ignores_(),
80  debug_(ps.getUntrackedParameter<bool>("debugDump", false)),
81  maxFU_(ps.getUntrackedParameter<unsigned int>("maxFU", false)),
84 {
85  LogDebug("HLTScalersClient") << "constructor" ;
86  if ( debug_ ) {
87  textfile_.open("debug.txt");
88  if ( ! textfile_ ) {
89  std::cout << "constructor: can't open text file" << std::endl;
90  }
91  }
92  // get back-end interface
94  dbe_->setVerbose(1);
96 
97 
98  std::string rawdir(folderName_ + "/raw");
99  dbe_->setCurrentFolder(rawdir);
100  hltRate_ = dbe_->book1D("hltRate", "Overall HLT Accept rate vs LS",
103  hltNormRate_ = dbe_->book1D("hltRateNorm",
104  "Overall HLT Accept rate vs LS, scaled",
106  hltCount_= dbe_->book1D("hltCount", "Overall HLT Counts vs LS",
108 // hltCountN_= dbe_->book1D("hltCountN", "Overall HLT Counts per LS vs LS",
109 // MAX_LUMI_SEG_HLT, -0.5, MAX_LUMI_SEG_HLT-0.5);
110  mergeCount_= dbe_->book1D("mergeCount", "Number of merge counts vs LS",
112 
113 
114 
115  updates_ = dbe_->book1D("updates", "Status of Updates", 2, 0, 2);
116  updates_->setBinLabel(1, "Good Updates");
117  updates_->setBinLabel(2, "Incomplete Updates");
118 
119 
120 } // 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:717
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:393
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:429
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 583 of file HLTScalersClient.cc.

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

BeginJob.

Reimplemented from edm::EDAnalyzer.

Definition at line 124 of file HLTScalersClient.cc.

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

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

BeginRun.

beginRun

Reimplemented from edm::EDAnalyzer.

Definition at line 136 of file HLTScalersClient.cc.

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

137 {
138  missingPathNames_ = true;
139  first_ = true;
140  LogDebug("HLTScalersClient") << "beginRun, run " << run.id();
141 
142 } // 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 154 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::detail::isnan(), 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, 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(), textfile_, HLTScalersClient::CountLSFifo_t::update(), and updates_.

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

EndRun.

Reimplemented from edm::EDAnalyzer.

Definition at line 145 of file HLTScalersClient.cc.

References first_, and missingPathNames_.

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

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

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