58 #define SECS_PER_LUMI_SECTION 23.31 66 currentLumiBlockNumber_(0),
68 missingPathNames_(
true),
69 folderName_(ps.getUntrackedParameter<
std::
string>(
"dqmFolder",
"HLT/HLScalers_EvF")),
70 kRateIntegWindow_(ps.getUntrackedParameter<unsigned
int>(
"rateIntegWindow", 3)),
71 processName_(ps.getParameter<
std::
string>(
"processName")),
73 debug_(ps.getUntrackedParameter<
bool>(
"debugDump",
false)),
74 maxFU_(ps.getUntrackedParameter<unsigned
int>(
"maxFU",
false)),
75 recentOverallCountsPerLS_(kRateIntegWindow_),
76 recentNormedOverallCountsPerLS_(2) {
77 LogDebug(
"HLTScalersClient") <<
"constructor";
81 std::cout <<
"constructor: can't open text file" << std::endl;
109 LogDebug(
"HLTScalersClient") <<
"beingJob";
121 LogDebug(
"HLTScalersClient") <<
"beginRun, run " << run.
id();
143 if (scalers ==
nullptr) {
144 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, " 147 std::cout <<
"No scalers ? Looking for " << scalHisto << std::endl;
154 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
162 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock " << npaths;
164 currentRate_ =
dbe_->
book1D(
"cur_rate",
"current lumi section rate per path", npaths, -0.5, npaths - 0.5);
166 dbe_->
book1D(
"cur_rate_norm",
"current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
169 char rates_subfolder[256];
170 snprintf(rates_subfolder, 256,
"%s/RateHistory",
folderName_.c_str());
171 char counts_subfolder[256];
172 snprintf(counts_subfolder, 256,
"%s/CountHistory",
folderName_.c_str());
181 for (
int i = 0;
i < npaths; ++
i) {
185 snprintf(name, 256,
"raw_rate_p%03d",
i);
188 snprintf(name, 256,
"norm_rate_p%03d",
i);
192 snprintf(name, 256,
"counts_p%03d",
i);
201 const int maxlen = 40;
202 char metitle[maxlen];
210 for (
int k = 0;
k < numHistos;
k++) {
212 int npath_high =
kPerHisto * (k + 1) - 1;
213 snprintf(mename, maxlen,
"hltScalers_%0d", k);
214 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low, npath_high);
218 snprintf(mename, maxlen,
"hltScalersNorm_%0d", k);
219 snprintf(metitle, maxlen,
"HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
228 for (
int i = 0;
i < npaths; ++
i) {
230 const char *
name = scalers->
getTH1()->GetXaxis()->GetBinLabel(
i + 1);
231 if (name && (strlen(name) > 0)) {
233 std::cout <<
"path " <<
i <<
" name is " << name << std::endl;
240 snprintf(pname, 256,
"Rate - path %s (Path # %03d)", name,
i);
243 snprintf(pname, 256,
"Counts - path %s (Path # %03d)", name,
i);
257 std::ifstream
names(
"names.dat");
260 std::ostringstream
msg;
263 perror(msg.str().c_str());
268 while (!names.eof()) {
269 getline(names, line);
270 std::istringstream fnames(line);
273 if (fnames.str().find(
"#") == 0)
275 if (fnames >> bin >> label) {
277 std::cout << bin <<
"--" << label <<
"(" << ipath <<
")" << std::endl;
284 int whichHisto = (ipath - 1) /
kPerHisto;
285 int whichBin = (ipath - 1) %
kPerHisto + 1;
300 if (nLumi ==
nullptr) {
304 int testval = (nLumi !=
nullptr ? nLumi->
getIntValue() : -1);
305 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: " << testval <<
", local is " <<
nLumi_;
308 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, " << nL <<
" is greater than MAX_LUMI_SEG_HLT," 315 double num_fu = -1.0;
318 if (merge !=
nullptr) {
321 std::cout <<
"Number of received entries: " << num_fu << std::endl;
331 for (
int i = 1;
i <= npaths; ++
i) {
339 if (hltScaler !=
nullptr) {
344 double slope = sl.first;
345 double slope_err = sl.second;
353 if (num_fu >= 0.95 *
maxFU_) {
360 for (
int i = 1;
i <= npaths; ++
i) {
364 std::cout <<
i <<
"\t-> good one: new => cnt, ls = " << current_count <<
", " << nL
373 double slope = sl.first;
374 double slope_err = sl.second;
395 if (hltScaler !=
nullptr) {
400 double slope = sl.first;
401 double slope_err = sl.second;
416 textfile_ << nL <<
"\t" << npaths <<
"\t";
417 for (
int i = 0;
i < npaths; ++
i) {
427 hltScaler =
dbe_->
get(overallScalerName);
428 if (hltScaler != 0) {
432 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu << std::endl;
438 std::cout <<
"Normalized slope = " << slope << std::endl;
447 for (
int i = 0;
i < npaths; ++
i) {
461 hltScaler =
dbe_->
get(overallScalerName);
462 if (hltScaler !=
nullptr) {
465 float sf = num_fu /
maxFU_;
467 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu <<
", sf = " << sf
473 double slope = sl.first;
474 double slope_err = sl.second;
476 std::cout <<
"Normalized slope = " << slope << std::endl;
481 slope_err = slope *
sqrt(2. / num_fu + 2. / cnt);
490 double sf = num_fu /
maxFU_;
491 for (
int i = 1;
i <= npaths; ++
i) {
495 double slope = sl.first;
496 double slope_err = sl.second;
502 if (slope_err <= 0 && cnt > 0) {
504 slope_err = slope *
sqrt(2. / num_fu + 2. / cnt);
506 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
532 double slope, sigma_m;
534 return std::pair<double, double>(-1, -1);
537 else if (points.size() == 2) {
539 double delta_ls = points.front().first - points.back().first;
540 double delta_cnt = points.front().second - points.back().second;
541 slope = delta_cnt / delta_ls;
548 double n = double(points.size());
549 for (
auto i(points.begin());
i != points.end(); ++
i) {
551 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second << std::endl;
552 xy +=
i->first *
i->second;
554 xsq +=
i->first *
i->first;
557 slope = (n * xy - x *
y) / (n * xsq - x * x);
560 double intercept = (xsq * y - xy *
x) / (n * xsq - x * x);
561 double sigma_ysq = 0;
562 for (
auto i(points.begin());
i != points.end(); ++
i) {
563 sigma_ysq +=
pow((
i->second - slope *
i->first - intercept), 2.);
567 sigma_ysq *= 1. / (n - 2.);
569 sigma_m =
sqrt(n * sigma_ysq / (n * xsq - x * x));
583 return std::pair<double, double>(
slope, sigma_m);
LuminosityBlockID id() const
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
int64_t getIntValue() const
MonitorElement * updates_
void setBinContent(int binx, double content)
set content of bin (1-D)
constexpr bool isNotFinite(T x)
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)
MonitorElement * book1D(char_string const &name, char_string const &title, int const nchX, double const lowX, double const highX)
Book 1D histogram.
const std::string names[nVars_]
std::vector< MonitorElement * > hltCurrentNormRate_
void beginJob(void) override
BeginJob.
#define SECS_PER_LUMI_SECTION
void beginRun(const edm::Run &run, const edm::EventSetup &c) override
BeginRun.
MonitorElement * hltRate_
MonitorElement * get(std::string const &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
void endRun(const edm::Run &run, const edm::EventSetup &c) override
EndRun.
MonitorElement * mergeCount_
unsigned int kRateIntegWindow_
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
std::vector< MonitorElement * > countHistories_
void setVerbose(unsigned level)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
bin
set the eta bin as selection string.
void setCurrentFolder(std::string const &fullpath)
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void showDirStructure() const
std::vector< MonitorElement * > hltCurrentRate_
void update(const CountLS_t &T)
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)
CountLSFifo_t recentNormedOverallCountsPerLS_
double getBinContent(int binx) const
get content of bin (1-D)
int getNbinsX() const
get # of bins in X-axis
MonitorElement * hltNormRate_
Power< A, B >::type pow(const A &a, const B &b)
unsigned int targetSize() const