67 #define SECS_PER_LUMI_SECTION 23.31
78 currentLumiBlockNumber_(0),
79 first_(
true), missingPathNames_(
true),
80 folderName_(ps.getUntrackedParameter<std::
string>(
"dqmFolder",
81 "HLT/HLScalers_EvF")),
82 kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>(
"rateIntegWindow",
84 processName_(ps.getParameter<std::
string>(
"processName")),
86 debug_(ps.getUntrackedParameter<bool>(
"debugDump",
false)),
87 maxFU_(ps.getUntrackedParameter<unsigned int>(
"maxFU",
false)),
88 recentOverallCountsPerLS_(kRateIntegWindow_),
89 recentNormedOverallCountsPerLS_(2)
91 LogDebug(
"HLTScalersClient") <<
"constructor" ;
95 std::cout <<
"constructor: can't open text file" << std::endl;
110 "Overall HLT Accept rate vs LS, scaled",
132 LogDebug(
"HLTScalersClient") <<
"beingJob" ;
146 LogDebug(
"HLTScalersClient") <<
"beginRun, run " << run.
id();
172 if ( scalers == 0 ) {
173 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, "
185 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
193 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock "
197 "current lumi section rate per path",
198 npaths, -0.5, npaths-0.5);
200 "current norm. lumi section rate per path",
201 npaths, -0.5, npaths-0.5);
204 char rates_subfolder[256]; snprintf(rates_subfolder, 256,
"%s/RateHistory",
206 char counts_subfolder[256]; snprintf(counts_subfolder, 256,
217 for (
int i = 0;
i < npaths; ++
i ) {
220 char name[256]; snprintf(name, 256,
"raw_rate_p%03d",
i);
224 snprintf(name, 256,
"norm_rate_p%03d",
i);
229 snprintf(name, 256,
"counts_p%03d",
i);
240 const int maxlen = 40;
241 char metitle[maxlen];
246 if ( remainder ) numHistos += 1;
248 for(
int k = 0;
k < numHistos;
k++ ) {
251 snprintf(mename, maxlen,
"hltScalers_%0d", k);
252 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low,
256 -0.5 + npath_low, npath_high+0.5));
258 snprintf(mename, maxlen,
"hltScalersNorm_%0d", k);
259 snprintf(metitle, maxlen,
260 "HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
274 for (
int i = 0;
i < npaths; ++
i ) {
276 const char*
name = scalers->
getTH1()->GetXaxis()->GetBinLabel(
i+1);
277 if ( name && (strlen(name) > 0)) {
279 std::cout <<
"path " <<
i <<
" name is " << name << std::endl;
286 snprintf(pname, 256,
"Rate - path %s (Path # %03d)", name,
i);
289 snprintf(pname, 256,
"Counts - path %s (Path # %03d)", name,
i);
304 std::ifstream
names(
"names.dat");
307 std::ostringstream
msg;
308 msg <<
"open of " <<
"names.dat";
309 perror(msg.str().c_str());
315 while ( ! names.eof() ) {
316 getline(names, line);
317 std::istringstream fnames(line);
319 if ( fnames.str().find(
"#") == 0 )
321 if ( fnames >> bin >> label ) {
323 std::cout << bin <<
"--" << label <<
"(" << ipath <<
")"
336 if ( ipath > npaths )
353 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: "
355 <<
", local is " <<
nLumi_;
358 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, "
359 << nL <<
" is greater than MAX_LUMI_SEG_HLT,"
367 double num_fu = -1.0;
373 std::cout <<
"Number of received entries: " << num_fu
385 for (
int i = 1;
i <= npaths; ++
i ) {
393 if ( hltScaler != 0 ) {
398 double slope = sl.first;
double slope_err = sl.second;
408 if ( num_fu >= 0.95*
maxFU_ ) {
415 for (
int i = 1;
i <= npaths; ++
i ) {
419 std::cout <<
i <<
"\t-> good one: new => cnt, ls = "
420 << current_count <<
", " << nL
431 double slope = sl.first;
double slope_err = sl.second;
452 if ( hltScaler != 0 ) {
457 double slope = sl.first;
double slope_err = sl.second;
474 for (
int i = 0;
i < npaths ; ++
i ) {
485 hltScaler =
dbe_->
get(overallScalerName);
486 if ( hltScaler != 0 ) {
490 std::cout <<
"Overall Norm: new => cnt, ls = "
492 <<
", num_fu = " << num_fu
499 std::cout <<
"Normalized slope = " << slope << std::endl;
508 for (
int i = 0;
i < npaths ; ++
i ) {
522 hltScaler =
dbe_->
get(overallScalerName);
523 if ( hltScaler != 0 ) {
528 std::cout <<
"Overall Norm: new => cnt, ls = "
530 <<
", num_fu = " << num_fu <<
", sf = " << sf
536 double slope = sl.first;
double slope_err = sl.second;
538 std::cout <<
"Normalized slope = " << slope << std::endl;
542 if ( cnt > 0 ) slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
551 double sf = num_fu /
maxFU_;
552 for (
int i = 1;
i <= npaths ; ++
i ) {
556 double slope = sl.first;
double slope_err = sl.second;
562 if ( slope_err <= 0 && cnt > 0) {
564 slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
566 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
597 std::pair<double,double>
600 double slope, sigma_m;
602 return std::pair<double,double>(-1,-1);
605 else if ( points.size() == 2 ) {
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 ;
617 double n = double(points.size());
618 for ( CountLSFifo_t::iterator
i(points.begin());
619 i != points.end(); ++
i ) {
621 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second
623 xy +=
i->first *
i->second;
625 xsq +=
i->first*
i->first;
628 slope = (n*xy - x*
y)/(n*xsq - x*x);
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.);
639 sigma_ysq *= 1./(n-2.);
641 sigma_m =
sqrt( n*sigma_ysq/(n*xsq - x*x));
656 return std::pair<double,double>(
slope, sigma_m);
std::pair< double, double > getSlope_(CountLSFifo_t points)
LuminosityBlockID id() const
void endRun(const edm::Run &run, const edm::EventSetup &c)
EndRun.
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.
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 beginJob(void)
BeginJob.
void analyze(const edm::Event &e, const edm::EventSetup &c)
std::vector< MonitorElement * > hltCurrentNormRate_
#define SECS_PER_LUMI_SECTION
MonitorElement * hltRate_
std::vector< MonitorElement * > countHistories_
void beginRun(const edm::Run &run, const edm::EventSetup &c)
BeginRun.
unsigned int targetSize()
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
void setVerbose(unsigned level)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
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_
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
CountLSFifo_t recentNormedOverallCountsPerLS_
double getBinContent(int binx) const
get content of bin (1-D)
std::vector< MonitorElement * > hltCurrentRate_
int getNbinsX(void) const
get # of bins in X-axis
MonitorElement * hltNormRate_
void showDirStructure(void) const
Power< A, B >::type pow(const A &a, const B &b)
void setCurrentFolder(const std::string &fullpath)
std::vector< MonitorElement * > rateNormHistories_