60 #define SECS_PER_LUMI_SECTION 23.31 71 currentLumiBlockNumber_(0),
72 first_(
true), missingPathNames_(
true),
73 folderName_(ps.getUntrackedParameter<
std::
string>(
"dqmFolder",
74 "HLT/HLScalers_EvF")),
75 kRateIntegWindow_(ps.getUntrackedParameter<unsigned
int>(
"rateIntegWindow",
77 processName_(ps.getParameter<
std::
string>(
"processName")),
79 debug_(ps.getUntrackedParameter<
bool>(
"debugDump",
false)),
80 maxFU_(ps.getUntrackedParameter<unsigned
int>(
"maxFU",
false)),
81 recentOverallCountsPerLS_(kRateIntegWindow_),
82 recentNormedOverallCountsPerLS_(2)
84 LogDebug(
"HLTScalersClient") <<
"constructor" ;
88 std::cout <<
"constructor: can't open text file" << std::endl;
103 "Overall HLT Accept rate vs LS, scaled",
125 LogDebug(
"HLTScalersClient") <<
"beingJob" ;
139 LogDebug(
"HLTScalersClient") <<
"beginRun, run " << run.
id();
165 if ( scalers ==
nullptr ) {
166 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, " 178 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
186 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock " 190 "current lumi section rate per path",
191 npaths, -0.5, npaths-0.5);
193 "current norm. lumi section rate per path",
194 npaths, -0.5, npaths-0.5);
197 char rates_subfolder[256]; snprintf(rates_subfolder, 256,
"%s/RateHistory",
199 char counts_subfolder[256]; snprintf(counts_subfolder, 256,
210 for (
int i = 0;
i < npaths; ++
i ) {
213 char name[256]; snprintf(name, 256,
"raw_rate_p%03d",
i);
217 snprintf(name, 256,
"norm_rate_p%03d",
i);
222 snprintf(name, 256,
"counts_p%03d",
i);
233 const int maxlen = 40;
234 char metitle[maxlen];
239 if ( remainder ) numHistos += 1;
241 for(
int k = 0;
k < numHistos;
k++ ) {
244 snprintf(mename, maxlen,
"hltScalers_%0d", k);
245 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low,
249 -0.5 + npath_low, npath_high+0.5));
251 snprintf(mename, maxlen,
"hltScalersNorm_%0d", k);
252 snprintf(metitle, maxlen,
253 "HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
267 for (
int i = 0;
i < npaths; ++
i ) {
269 const char*
name = scalers->
getTH1()->GetXaxis()->GetBinLabel(
i+1);
270 if ( name && (strlen(name) > 0)) {
272 std::cout <<
"path " <<
i <<
" name is " << name << std::endl;
279 snprintf(pname, 256,
"Rate - path %s (Path # %03d)", name,
i);
282 snprintf(pname, 256,
"Counts - path %s (Path # %03d)", name,
i);
297 std::ifstream
names(
"names.dat");
300 std::ostringstream
msg;
301 msg <<
"open of " <<
"names.dat";
302 perror(msg.str().c_str());
308 while ( ! names.eof() ) {
309 getline(names, line);
310 std::istringstream fnames(line);
312 if ( fnames.str().find(
"#") == 0 )
314 if ( fnames >> bin >> label ) {
316 std::cout << bin <<
"--" << label <<
"(" << ipath <<
")" 329 if ( ipath > npaths )
341 if ( nLumi ==
nullptr ) {
345 int testval = (nLumi!=
nullptr?nLumi->
getIntValue():-1);
346 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: " 348 <<
", local is " <<
nLumi_;
351 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, " 352 << nL <<
" is greater than MAX_LUMI_SEG_HLT," 360 double num_fu = -1.0;
363 if ( merge !=
nullptr ) {
366 std::cout <<
"Number of received entries: " << num_fu
378 for (
int i = 1;
i <= npaths; ++
i ) {
386 if ( hltScaler !=
nullptr ) {
391 double slope = sl.first;
double slope_err = sl.second;
401 if ( num_fu >= 0.95*
maxFU_ ) {
408 for (
int i = 1;
i <= npaths; ++
i ) {
412 std::cout <<
i <<
"\t-> good one: new => cnt, ls = " 413 << current_count <<
", " << nL
424 double slope = sl.first;
double slope_err = sl.second;
445 if ( hltScaler !=
nullptr ) {
450 double slope = sl.first;
double slope_err = sl.second;
467 for (
int i = 0;
i < npaths ; ++
i ) {
478 hltScaler =
dbe_->
get(overallScalerName);
479 if ( hltScaler != 0 ) {
483 std::cout <<
"Overall Norm: new => cnt, ls = " 485 <<
", num_fu = " << num_fu
492 std::cout <<
"Normalized slope = " << slope << std::endl;
501 for (
int i = 0;
i < npaths ; ++
i ) {
515 hltScaler =
dbe_->
get(overallScalerName);
516 if ( hltScaler !=
nullptr ) {
521 std::cout <<
"Overall Norm: new => cnt, ls = " 523 <<
", num_fu = " << num_fu <<
", sf = " << sf
529 double slope = sl.first;
double slope_err = sl.second;
531 std::cout <<
"Normalized slope = " << slope << std::endl;
535 if ( cnt > 0 ) slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
544 double sf = num_fu /
maxFU_;
545 for (
int i = 1;
i <= npaths ; ++
i ) {
549 double slope = sl.first;
double slope_err = sl.second;
555 if ( slope_err <= 0 && cnt > 0) {
557 slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
559 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
590 std::pair<double,double>
593 double slope, sigma_m;
595 return std::pair<double,double>(-1,-1);
598 else if ( points.size() == 2 ) {
600 double delta_ls = points.front().first - points.back().first;
601 double delta_cnt = points.front().second - points.back().second;
602 slope = delta_cnt / delta_ls ;
610 double n = double(points.size());
611 for (
auto i(points.begin());
612 i != points.end(); ++
i ) {
614 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second
616 xy +=
i->first *
i->second;
618 xsq +=
i->first*
i->first;
621 slope = (n*xy - x*
y)/(n*xsq - x*x);
624 double intercept = (xsq*y - xy*
x)/(n*xsq-x*x);
625 double sigma_ysq = 0;
626 for (
auto i (points.begin());
627 i != points.end(); ++
i ) {
628 sigma_ysq +=
pow((
i->second - slope *
i->first - intercept),2.);
632 sigma_ysq *= 1./(n-2.);
634 sigma_m =
sqrt( n*sigma_ysq/(n*xsq - x*x));
649 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)
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)
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_
std::vector< MonitorElement * > countHistories_
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)
void setVerbose(unsigned level)
MonitorElement * get(const std::string &path) const
get ME from full pathname (e.g. "my/long/dir/my_histo")
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
bin
set the eta bin as selection string.
void analyze(const edm::Event &e, const edm::EventSetup &c) override
void showDirStructure() const
void update(const CountLS_t &T)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
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)
std::vector< MonitorElement * > hltCurrentRate_
int getNbinsX() const
get # of bins in X-axis
MonitorElement * hltNormRate_
Power< A, B >::type pow(const A &a, const B &b)
void setCurrentFolder(const std::string &fullpath)
unsigned int targetSize() const
std::vector< MonitorElement * > rateNormHistories_