58 #define SECS_PER_LUMI_SECTION 23.31
69 currentLumiBlockNumber_(0),
70 first_(
true), missingPathNames_(
true),
71 folderName_(ps.getUntrackedParameter<std::string>(
"dqmFolder",
72 "HLT/HLScalers_EvF")),
73 kRateIntegWindow_(ps.getUntrackedParameter<unsigned int>(
"rateIntegWindow",
75 processName_(ps.getParameter<std::string>(
"processName")),
77 debug_(ps.getUntrackedParameter<bool>(
"debugDump",
false)),
78 maxFU_(ps.getUntrackedParameter<unsigned int>(
"maxFU",
false)),
79 recentOverallCountsPerLS_(kRateIntegWindow_),
80 recentNormedOverallCountsPerLS_(2)
82 LogDebug(
"HLTScalersClient") <<
"constructor" ;
86 std::cout <<
"constructor: can't open text file" << std::endl;
101 "Overall HLT Accept rate vs LS, scaled",
123 LogDebug(
"HLTScalersClient") <<
"beingJob" ;
137 LogDebug(
"HLTScalersClient") <<
"beginRun, run " << run.
id();
161 std::string scalHisto =
folderName_ +
"/raw/hltScalers";
163 if ( scalers == 0 ) {
164 LogDebug(
"HLTScalersClient") <<
"cannot get hlt scalers histogram, "
176 LogDebug(
"HLTScalersClient") <<
"I see " << npaths <<
" paths. ";
184 LogDebug(
"HLTScalersClient") <<
"Setting up paths on first endLumiBlock "
188 "current lumi section rate per path",
189 npaths, -0.5, npaths-0.5);
191 "current norm. lumi section rate per path",
192 npaths, -0.5, npaths-0.5);
195 char rates_subfolder[256]; snprintf(rates_subfolder, 256,
"%s/RateHistory",
197 char counts_subfolder[256]; snprintf(counts_subfolder, 256,
208 for (
int i = 0;
i < npaths; ++
i ) {
211 char name[256]; snprintf(name, 256,
"raw_rate_p%03d",
i);
215 snprintf(name, 256,
"norm_rate_p%03d",
i);
220 snprintf(name, 256,
"counts_p%03d",
i);
231 const int maxlen = 40;
232 char metitle[maxlen];
237 if ( remainder ) numHistos += 1;
239 for(
int k = 0;
k < numHistos;
k++ ) {
242 snprintf(mename, maxlen,
"hltScalers_%0d", k);
243 snprintf(metitle, maxlen,
"HLT scalers - Paths %d to %d", npath_low,
247 -0.5 + npath_low, npath_high+0.5));
249 snprintf(mename, maxlen,
"hltScalersNorm_%0d", k);
250 snprintf(metitle, maxlen,
251 "HLT Rate (scaled) - Paths %d to %d", npath_low, npath_high);
265 for (
int i = 0;
i < npaths; ++
i ) {
267 const char*
name = scalers->
getTH1()->GetXaxis()->GetBinLabel(
i+1);
268 if ( name && (strlen(name) > 0)) {
270 std::cout <<
"path " <<
i <<
" name is " << name << std::endl;
277 snprintf(pname, 256,
"Rate - path %s (Path # %03d)", name,
i);
280 snprintf(pname, 256,
"Counts - path %s (Path # %03d)", name,
i);
295 std::ifstream
names(
"names.dat");
298 std::ostringstream
msg;
299 msg <<
"open of " <<
"names.dat";
300 perror(msg.str().c_str());
306 while ( ! names.eof() ) {
307 getline(names, line);
308 std::istringstream fnames(line);
310 if ( fnames.str().find(
"#") == 0 )
312 if ( fnames >> bin >> label ) {
314 std::cout << bin <<
"--" << label <<
"(" << ipath <<
")"
327 if ( ipath > npaths )
337 std::string nLumiHisto(
folderName_ +
"/nLumiBlock");
344 LogDebug(
"HLTScalersClient") <<
"Lumi Block from DQM: "
346 <<
", local is " <<
nLumi_;
349 LogDebug(
"HLTScalersClient") <<
"Too many Lumi segments, "
350 << nL <<
" is greater than MAX_LUMI_SEG_HLT,"
358 double num_fu = -1.0;
359 std::string mergeName(
folderName_ +
"/raw/hltMerge");
364 std::cout <<
"Number of received entries: " << num_fu
376 for (
int i = 1;
i <= npaths; ++
i ) {
382 std::string overallScalerName(
folderName_ +
"/raw/hltOverallScaler");
384 if ( hltScaler != 0 ) {
389 double slope = sl.first;
double slope_err = sl.second;
392 if ( !
std::isnan(slope_err ) && (slope_err >= 0 ) )
399 if ( num_fu >= 0.95*
maxFU_ ) {
406 for (
int i = 1;
i <= npaths; ++
i ) {
410 std::cout <<
i <<
"\t-> good one: new => cnt, ls = "
411 << current_count <<
", " << nL
422 double slope = sl.first;
double slope_err = sl.second;
429 if ( !
std::isnan(slope_err ) && (slope_err >= 0 ) ) {
441 std::string overallScalerName(
folderName_ +
"/raw/hltOverallScaler");
443 if ( hltScaler != 0 ) {
448 double slope = sl.first;
double slope_err = sl.second;
451 if ( !
std::isnan(slope_err ) && (slope_err >= 0 ) )
465 for (
int i = 0;
i < npaths ; ++
i ) {
475 overallScalerName = std::string(
folderName_ +
"/raw/hltOverallScalerN");
476 hltScaler =
dbe_->
get(overallScalerName);
477 if ( hltScaler != 0 ) {
481 std::cout <<
"Overall Norm: new => cnt, ls = "
483 <<
", num_fu = " << num_fu
490 std::cout <<
"Normalized slope = " << slope << std::endl;
496 std::string scalHistoNorm =
folderName_ +
"/raw/hltScalersN";
499 for (
int i = 0;
i < npaths ; ++
i ) {
512 overallScalerName = std::string(
folderName_ +
"/raw/hltOverallScaler");
513 hltScaler =
dbe_->
get(overallScalerName);
514 if ( hltScaler != 0 ) {
519 std::cout <<
"Overall Norm: new => cnt, ls = "
521 <<
", num_fu = " << num_fu <<
", sf = " << sf
527 double slope = sl.first;
double slope_err = sl.second;
529 std::cout <<
"Normalized slope = " << slope << std::endl;
533 if ( cnt > 0 ) slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
534 if ( !
std::isnan(slope_err ) && (slope_err >= 0 ) )
539 std::string scalHistoNorm =
folderName_ +
"/raw/hltScalers";
542 double sf = num_fu /
maxFU_;
543 for (
int i = 1;
i <= npaths ; ++
i ) {
547 double slope = sl.first;
double slope_err = sl.second;
553 if ( slope_err <= 0 && cnt > 0) {
555 slope_err = slope*
sqrt( 2./num_fu + 2./cnt);
557 std::cout <<
"Slope err " <<
i <<
" = " << slope_err << std::endl;
560 if ( !
std::isnan(slope_err ) && (slope_err >= 0 ) ) {
588 std::pair<double,double>
591 double slope, sigma_m;
593 return std::pair<double,double>(-1,-1);
596 else if ( points.size() == 2 ) {
598 double delta_ls = points.front().first - points.back().first;
599 double delta_cnt = points.front().second - points.back().second;
600 slope = delta_cnt / delta_ls ;
608 double n = double(points.size());
609 for ( CountLSFifo_t::iterator
i(points.begin());
610 i != points.end(); ++
i ) {
612 std::cout <<
"x = " <<
i->first <<
", y = " <<
i->second
614 xy +=
i->first *
i->second;
616 xsq +=
i->first*
i->first;
619 slope = (n*xy - x*
y)/(n*xsq - x*x);
622 double intercept = (xsq*y - xy*
x)/(n*xsq-x*x);
623 double sigma_ysq = 0;
624 for ( CountLSFifo_t::iterator
i(points.begin());
625 i != points.end(); ++
i ) {
626 sigma_ysq +=
pow((
i->second - slope *
i->first - intercept),2.);
630 sigma_ysq *= 1./(n-2.);
632 sigma_m =
sqrt( n*sigma_ysq/(n*xsq - x*x));
647 return std::pair<double,double>(
slope, sigma_m);
std::pair< double, double > getSlope_(CountLSFifo_t points)
LuminosityBlockID id() const
void endRun(const edm::Run &run, const edm::EventSetup &c)
EndRun.
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)
void beginJob(void)
BeginJob.
void analyze(const edm::Event &e, const edm::EventSetup &c)
std::vector< MonitorElement * > hltCurrentNormRate_
#define SECS_PER_LUMI_SECTION
MonitorElement * hltRate_
std::vector< MonitorElement * > countHistories_
void beginRun(const edm::Run &run, const edm::EventSetup &c)
BeginRun.
unsigned int targetSize()
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")
void endLuminosityBlock(const edm::LuminosityBlock &lumiSeg, const edm::EventSetup &c)
CountLSFifo_t recentOverallCountsPerLS_
MonitorElement * currentRate_
Basic2DVector< T > xy() const
void update(const CountLS_t &T)
std::vector< CountLSFifo_t > recentPathCountsPerLS_
int64_t getIntValue(void) const
LuminosityBlockNumber_t luminosityBlock() const
MonitorElement * hltCount_
HLTScalersClient(const edm::ParameterSet &ps)
Constructors.
CountLSFifo_t recentNormedOverallCountsPerLS_
double getBinContent(int binx) const
get content of bin (1-D)
std::vector< MonitorElement * > hltCurrentRate_
int getNbinsX(void) const
get # of bins in X-axis
MonitorElement * hltNormRate_
void showDirStructure(void) const
static const HistoName names[]
Power< A, B >::type pow(const A &a, const B &b)
void setCurrentFolder(const std::string &fullpath)
std::vector< MonitorElement * > rateNormHistories_