57 #define SECS_PER_LUMI_SECTION 23.31 64 currentRate_(nullptr),
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();
138 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, " 141 std::cout <<
"No scalers ? Looking for " << scalHisto << std::endl;
145 int npaths =
scalers->getNbinsX();
148 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
156 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock " << npaths;
158 currentRate_ =
dbe_->
book1D(
"cur_rate",
"current lumi section rate per path", npaths, -0.5, npaths - 0.5);
160 dbe_->
book1D(
"cur_rate_norm",
"current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
163 char rates_subfolder[256];
164 snprintf(rates_subfolder, 256,
"%s/RateHistory",
folderName_.c_str());
165 char counts_subfolder[256];
166 snprintf(counts_subfolder, 256,
"%s/CountHistory",
folderName_.c_str());
175 for (
int i = 0;
i < npaths; ++
i) {
179 snprintf(
name, 256,
"raw_rate_p%03d",
i);
182 snprintf(
name, 256,
"norm_rate_p%03d",
i);
186 snprintf(
name, 256,
"counts_p%03d",
i);
195 const int maxlen = 64;
196 char metitle[maxlen];
204 for (
int k = 0;
k < numHistos;
k++) {
207 snprintf(mename, maxlen,
"hltScalers_%0d",
k);
208 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low, npath_high);
212 snprintf(mename, maxlen,
"hltScalersNorm_%0d",
k);
213 snprintf(metitle, maxlen,
"HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
222 for (
int i = 0;
i < npaths; ++
i) {
224 const char *
name =
scalers->getTH1()->GetXaxis()->GetBinLabel(
i + 1);
234 snprintf(
pname, 256,
"Rate - path %s (Path # %03d)",
name,
i);
237 snprintf(
pname, 256,
"Counts - path %s (Path # %03d)",
name,
i);
251 std::ifstream
names(
"names.dat");
254 std::ostringstream
msg;
257 perror(
msg.str().c_str());
262 while (!
names.eof()) {
267 if (
fnames.str().find(
'#') == 0)
278 int whichHisto = (ipath - 1) /
kPerHisto;
279 int whichBin = (ipath - 1) %
kPerHisto + 1;
294 if (nLumi ==
nullptr) {
298 int testval = (nLumi !=
nullptr ? nLumi->
getIntValue() : -1);
299 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: " << testval <<
", local is " <<
nLumi_;
302 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, " << nL <<
" is greater than MAX_LUMI_SEG_HLT," 309 double num_fu = -1.0;
312 if (
merge !=
nullptr) {
313 num_fu =
merge->getBinContent(1);
315 std::cout <<
"Number of received entries: " << num_fu << std::endl;
325 for (
int i = 1;
i <= npaths; ++
i) {
326 double current_count =
scalers->getBinContent(
i);
333 if (hltScaler !=
nullptr) {
338 double slope = sl.first;
339 double slope_err = sl.second;
347 if (num_fu >= 0.95 *
maxFU_) {
354 for (
int i = 1;
i <= npaths; ++
i) {
355 double current_count =
scalers->getBinContent(
i);
358 std::cout <<
i <<
"\t-> good one: new => cnt, ls = " << current_count <<
", " << nL
367 double slope = sl.first;
368 double slope_err = sl.second;
389 if (hltScaler !=
nullptr) {
394 double slope = sl.first;
395 double slope_err = sl.second;
410 textfile_ << nL <<
"\t" << npaths <<
"\t";
411 for (
int i = 0;
i < npaths; ++
i) {
421 hltScaler =
dbe_->
get(overallScalerName);
422 if (hltScaler != 0) {
426 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu << std::endl;
441 for (
int i = 0;
i < npaths; ++
i) {
455 hltScaler =
dbe_->
get(overallScalerName);
456 if (hltScaler !=
nullptr) {
459 float sf = num_fu /
maxFU_;
461 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu <<
", sf = " << sf
467 double slope = sl.first;
468 double slope_err = sl.second;
475 slope_err =
slope *
sqrt(2. / num_fu + 2. / cnt);
484 double sf = num_fu /
maxFU_;
485 for (
int i = 1;
i <= npaths; ++
i) {
489 double slope = sl.first;
490 double slope_err = sl.second;
496 if (slope_err <= 0 && cnt > 0) {
498 slope_err =
slope *
sqrt(2. / num_fu + 2. / cnt);
500 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
526 double slope, sigma_m;
528 return std::pair<double, double>(-1, -1);
531 else if (
points.size() == 2) {
533 double delta_ls =
points.front().first -
points.back().first;
534 double delta_cnt =
points.front().second -
points.back().second;
535 slope = delta_cnt / delta_ls;
542 double n = double(
points.size());
545 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second << std::endl;
546 xy +=
i->first *
i->second;
548 xsq +=
i->first *
i->first;
554 double intercept = (xsq *
y -
xy *
x) / (
n * xsq -
x *
x);
555 double sigma_ysq = 0;
557 sigma_ysq +=
pow((
i->second -
slope *
i->first - intercept), 2.);
561 sigma_ysq *= 1. / (
n - 2.);
563 sigma_m =
sqrt(
n * sigma_ysq / (
n * xsq -
x *
x));
577 return std::pair<double, double>(
slope, sigma_m);
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c) override
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * updates_
constexpr bool isNotFinite(T x)
static const double slope[3]
MonitorElement * currentNormRate_
void setCurrentFolder(std::string const &fullpath) override
dqm::legacy::DQMStore * dbe_
std::vector< CountLSFifo_t > recentNormedPathCountsPerLS_
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_
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)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
std::vector< MonitorElement * > rateNormHistories_
Log< level::Info, false > LogInfo
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)
LuminosityBlockID id() const
std::vector< CountLSFifo_t > recentPathCountsPerLS_
std::vector< MonitorElement * > rateHistories_
MonitorElement * hltCount_
virtual MonitorElement * get(std::string const &fullpath) const
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
std::pair< double, double > getSlope_(const CountLSFifo_t &points)
CountLSFifo_t recentNormedOverallCountsPerLS_
virtual void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
MonitorElement * hltNormRate_
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Power< A, B >::type pow(const A &a, const B &b)
virtual double getBinContent(int binx) const
get content of bin (1-D)
virtual int64_t getIntValue() const