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;
84 usesResource(
"DQMStore");
108 LogDebug(
"HLTScalersClient") <<
"beingJob";
120 LogDebug(
"HLTScalersClient") <<
"beginRun, run " <<
run.id();
139 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, " 142 std::cout <<
"No scalers ? Looking for " << scalHisto << std::endl;
146 int npaths =
scalers->getNbinsX();
149 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
157 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock " << npaths;
159 currentRate_ =
dbe_->
book1D(
"cur_rate",
"current lumi section rate per path", npaths, -0.5, npaths - 0.5);
161 dbe_->
book1D(
"cur_rate_norm",
"current norm. lumi section rate per path", npaths, -0.5, npaths - 0.5);
164 char rates_subfolder[256];
165 snprintf(rates_subfolder, 256,
"%s/RateHistory",
folderName_.c_str());
166 char counts_subfolder[256];
167 snprintf(counts_subfolder, 256,
"%s/CountHistory",
folderName_.c_str());
176 for (
int i = 0;
i < npaths; ++
i) {
180 snprintf(
name, 256,
"raw_rate_p%03d",
i);
183 snprintf(
name, 256,
"norm_rate_p%03d",
i);
187 snprintf(
name, 256,
"counts_p%03d",
i);
196 const int maxlen = 64;
197 char metitle[maxlen];
205 for (
int k = 0;
k < numHistos;
k++) {
208 snprintf(mename, maxlen,
"hltScalers_%0d",
k);
209 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low, npath_high);
213 snprintf(mename, maxlen,
"hltScalersNorm_%0d",
k);
214 snprintf(metitle, maxlen,
"HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
223 for (
int i = 0;
i < npaths; ++
i) {
225 const char *
name =
scalers->getTH1()->GetXaxis()->GetBinLabel(
i + 1);
235 snprintf(
pname, 256,
"Rate - path %s (Path # %03d)",
name,
i);
238 snprintf(
pname, 256,
"Counts - path %s (Path # %03d)",
name,
i);
252 std::ifstream
names(
"names.dat");
255 std::ostringstream
msg;
258 perror(
msg.str().c_str());
263 while (!
names.eof()) {
268 if (
fnames.str().find(
'#') == 0)
279 int whichHisto = (ipath - 1) /
kPerHisto;
280 int whichBin = (ipath - 1) %
kPerHisto + 1;
295 if (nLumi ==
nullptr) {
299 int testval = (nLumi !=
nullptr ? nLumi->
getIntValue() : -1);
300 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: " << testval <<
", local is " <<
nLumi_;
303 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, " << nL <<
" is greater than MAX_LUMI_SEG_HLT," 310 double num_fu = -1.0;
313 if (
merge !=
nullptr) {
314 num_fu =
merge->getBinContent(1);
316 std::cout <<
"Number of received entries: " << num_fu << std::endl;
326 for (
int i = 1;
i <= npaths; ++
i) {
327 double current_count =
scalers->getBinContent(
i);
334 if (hltScaler !=
nullptr) {
339 double slope = sl.first;
340 double slope_err = sl.second;
348 if (num_fu >= 0.95 *
maxFU_) {
355 for (
int i = 1;
i <= npaths; ++
i) {
356 double current_count =
scalers->getBinContent(
i);
359 std::cout <<
i <<
"\t-> good one: new => cnt, ls = " << current_count <<
", " << nL
368 double slope = sl.first;
369 double slope_err = sl.second;
390 if (hltScaler !=
nullptr) {
395 double slope = sl.first;
396 double slope_err = sl.second;
411 textfile_ << nL <<
"\t" << npaths <<
"\t";
412 for (
int i = 0;
i < npaths; ++
i) {
422 hltScaler =
dbe_->
get(overallScalerName);
423 if (hltScaler != 0) {
427 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu << std::endl;
442 for (
int i = 0;
i < npaths; ++
i) {
456 hltScaler =
dbe_->
get(overallScalerName);
457 if (hltScaler !=
nullptr) {
460 float sf = num_fu /
maxFU_;
462 std::cout <<
"Overall Norm: new => cnt, ls = " << cnt <<
", " << nL <<
", num_fu = " << num_fu <<
", sf = " << sf
468 double slope = sl.first;
469 double slope_err = sl.second;
476 slope_err =
slope *
sqrt(2. / num_fu + 2. / cnt);
485 double sf = num_fu /
maxFU_;
486 for (
int i = 1;
i <= npaths; ++
i) {
490 double slope = sl.first;
491 double slope_err = sl.second;
497 if (slope_err <= 0 && cnt > 0) {
499 slope_err =
slope *
sqrt(2. / num_fu + 2. / cnt);
501 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
527 double slope, sigma_m;
529 return std::pair<double, double>(-1, -1);
532 else if (points.size() == 2) {
534 double delta_ls = points.front().first - points.back().first;
535 double delta_cnt = points.front().second - points.back().second;
536 slope = delta_cnt / delta_ls;
543 double n = double(points.size());
544 for (
auto i(points.begin());
i != points.end(); ++
i) {
546 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second << std::endl;
547 xy +=
i->first *
i->second;
549 xsq +=
i->first *
i->first;
555 double intercept = (xsq *
y -
xy *
x) / (
n * xsq -
x *
x);
556 double sigma_ysq = 0;
557 for (
auto i(points.begin());
i != points.end(); ++
i) {
558 sigma_ysq +=
pow((
i->second -
slope *
i->first - intercept), 2.);
562 sigma_ysq *= 1. / (
n - 2.);
564 sigma_m =
sqrt(
n * sigma_ysq / (
n * xsq -
x *
x));
578 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
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_
unsigned int targetSize() const
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