57 #define SECS_PER_LUMI_SECTION 23.31 65 currentLumiBlockNumber_(0),
67 missingPathNames_(
true),
68 folderName_(ps.getUntrackedParameter<
std::
string>(
"dqmFolder",
"HLT/HLScalers_EvF")),
69 kRateIntegWindow_(ps.getUntrackedParameter<unsigned
int>(
"rateIntegWindow", 3)),
70 processName_(ps.getParameter<
std::
string>(
"processName")),
72 debug_(ps.getUntrackedParameter<
bool>(
"debugDump",
false)),
73 maxFU_(ps.getUntrackedParameter<unsigned
int>(
"maxFU",
false)),
74 recentOverallCountsPerLS_(kRateIntegWindow_),
75 recentNormedOverallCountsPerLS_(2) {
76 LogDebug(
"HLTScalersClient") <<
"constructor";
80 std::cout <<
"constructor: can't open text file" << std::endl;
107 LogDebug(
"HLTScalersClient") <<
"beingJob";
119 LogDebug(
"HLTScalersClient") <<
"beginRun, run " << run.
id();
141 if (scalers ==
nullptr) {
142 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, " 145 std::cout <<
"No scalers ? Looking for " << scalHisto << std::endl;
152 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
160 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock " << npaths;
162 currentRate_ =
dbe_->
book1D(
"cur_rate",
"current lumi section rate per path", npaths, -0.5, npaths - 0.5);
164 dbe_->
book1D(
"cur_rate_norm",
"current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
167 char rates_subfolder[256];
168 snprintf(rates_subfolder, 256,
"%s/RateHistory",
folderName_.c_str());
169 char counts_subfolder[256];
170 snprintf(counts_subfolder, 256,
"%s/CountHistory",
folderName_.c_str());
179 for (
int i = 0;
i < npaths; ++
i) {
183 snprintf(name, 256,
"raw_rate_p%03d",
i);
186 snprintf(name, 256,
"norm_rate_p%03d",
i);
190 snprintf(name, 256,
"counts_p%03d",
i);
199 const int maxlen = 64;
200 char metitle[maxlen];
208 for (
int k = 0;
k < numHistos;
k++) {
210 int npath_high =
kPerHisto * (k + 1) - 1;
211 snprintf(mename, maxlen,
"hltScalers_%0d", k);
212 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low, npath_high);
216 snprintf(mename, maxlen,
"hltScalersNorm_%0d", k);
217 snprintf(metitle, maxlen,
"HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
226 for (
int i = 0;
i < npaths; ++
i) {
228 const char *
name = scalers->
getTH1()->GetXaxis()->GetBinLabel(
i + 1);
229 if (name && (strlen(name) > 0)) {
231 std::cout <<
"path " <<
i <<
" name is " << name << std::endl;
238 snprintf(pname, 256,
"Rate - path %s (Path # %03d)", name,
i);
241 snprintf(pname, 256,
"Counts - path %s (Path # %03d)", name,
i);
255 std::ifstream
names(
"names.dat");
258 std::ostringstream
msg;
261 perror(msg.str().c_str());
266 while (!names.eof()) {
267 getline(names, line);
268 std::istringstream
fnames(line);
271 if (fnames.str().find(
"#") == 0)
273 if (fnames >> bin >> label) {
275 std::cout << bin <<
"--" << label <<
"(" << ipath <<
")" << std::endl;
282 int whichHisto = (ipath - 1) /
kPerHisto;
283 int whichBin = (ipath - 1) %
kPerHisto + 1;
298 if (nLumi ==
nullptr) {
302 int testval = (nLumi !=
nullptr ? nLumi->
getIntValue() : -1);
303 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: " << testval <<
", local is " <<
nLumi_;
306 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, " << nL <<
" is greater than MAX_LUMI_SEG_HLT," 313 double num_fu = -1.0;
316 if (merge !=
nullptr) {
319 std::cout <<
"Number of received entries: " << num_fu << std::endl;
329 for (
int i = 1;
i <= npaths; ++
i) {
337 if (hltScaler !=
nullptr) {
342 double slope = sl.first;
343 double slope_err = sl.second;
351 if (num_fu >= 0.95 *
maxFU_) {
358 for (
int i = 1;
i <= npaths; ++
i) {
362 std::cout <<
i <<
"\t-> good one: new => cnt, ls = " << current_count <<
", " << nL
371 double slope = sl.first;
372 double slope_err = sl.second;
393 if (hltScaler !=
nullptr) {
398 double slope = sl.first;
399 double slope_err = sl.second;
414 textfile_ << nL <<
"\t" << npaths <<
"\t";
415 for (
int i = 0;
i < npaths; ++
i) {
425 hltScaler =
dbe_->
get(overallScalerName);
426 if (hltScaler != 0) {
430 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu << std::endl;
436 std::cout <<
"Normalized slope = " << slope << std::endl;
445 for (
int i = 0;
i < npaths; ++
i) {
459 hltScaler =
dbe_->
get(overallScalerName);
460 if (hltScaler !=
nullptr) {
463 float sf = num_fu /
maxFU_;
465 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu <<
", sf = " << sf
471 double slope = sl.first;
472 double slope_err = sl.second;
474 std::cout <<
"Normalized slope = " << slope << std::endl;
479 slope_err = slope *
sqrt(2. / num_fu + 2. / cnt);
488 double sf = num_fu /
maxFU_;
489 for (
int i = 1;
i <= npaths; ++
i) {
493 double slope = sl.first;
494 double slope_err = sl.second;
500 if (slope_err <= 0 && cnt > 0) {
502 slope_err = slope *
sqrt(2. / num_fu + 2. / cnt);
504 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
530 double slope, sigma_m;
532 return std::pair<double, double>(-1, -1);
535 else if (points.size() == 2) {
537 double delta_ls = points.front().first - points.back().first;
538 double delta_cnt = points.front().second - points.back().second;
539 slope = delta_cnt / delta_ls;
546 double n = double(points.size());
547 for (
auto i(points.begin());
i != points.end(); ++
i) {
549 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second << std::endl;
550 xy +=
i->first *
i->second;
552 xsq +=
i->first *
i->first;
555 slope = (n * xy - x *
y) / (n * xsq - x * x);
558 double intercept = (xsq * y - xy *
x) / (n * xsq - x * x);
559 double sigma_ysq = 0;
560 for (
auto i(points.begin());
i != points.end(); ++
i) {
561 sigma_ysq +=
pow((
i->second - slope *
i->first - intercept), 2.);
565 sigma_ysq *= 1. / (n - 2.);
567 sigma_m =
sqrt(n * sigma_ysq / (n * xsq - x * x));
581 return std::pair<double, double>(
slope, sigma_m);
LuminosityBlockID id() const
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
MonitorElement * updates_
constexpr bool isNotFinite(T x)
static const double slope[3]
MonitorElement * currentNormRate_
dqm::legacy::DQMStore * dbe_
virtual int64_t getIntValue() const
std::vector< CountLSFifo_t > recentNormedPathCountsPerLS_
const std::string names[nVars_]
std::vector< MonitorElement * > hltCurrentNormRate_
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
virtual int getNbinsX() const
get # of bins in X-axis
void beginJob(void) override
BeginJob.
#define SECS_PER_LUMI_SECTION
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
BeginRun.
MonitorElement * hltRate_
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
std::vector< MonitorElement * > countHistories_
virtual 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)
virtual double getBinContent(int binx) const
get content of bin (1-D)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
void analyze(const edm::Event &e, const edm::EventSetup &c) override
std::vector< MonitorElement * > hltCurrentRate_
void update(const CountLS_t &T)
virtual void setBinContent(int binx, double content)
set content of bin (1-D)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
std::vector< MonitorElement * > rateHistories_
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * hltCount_
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
void setCurrentFolder(std::string const &fullpath)
CountLSFifo_t recentNormedOverallCountsPerLS_
void showDirStructure() const
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * hltNormRate_
virtual TH1 * getTH1() const
Power< A, B >::type pow(const A &a, const B &b)
unsigned int targetSize() const