1 #define __STDC_FORMAT_MACROS 1 2 #define DQM_ROOT_METHODS 1 15 #if !WITHOUT_CMS_FRAMEWORK 23 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor" 24 " element '%s' because it is not a ROOT object.",
27 auto *
h =
static_cast<TH1 *
>(tobj);
28 int ndim = h->GetDimension();
29 if (reqdim < 0 || reqdim > ndim)
30 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor" 31 " element '%s' because it requires %d dimensions; this" 32 " object of type '%s' has %d dimensions",
33 func, name.c_str(), reqdim,
typeid(*h).name(), ndim);
60 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element" 61 " to invalid type %d", (
int) kind);
74 assert(dynamic_cast<TH1F *>(rootobj));
80 assert(dynamic_cast<TH1S *>(rootobj));
86 assert(dynamic_cast<TH1D *>(rootobj));
92 assert(dynamic_cast<TH2F *>(rootobj));
98 assert(dynamic_cast<TH2S *>(rootobj));
104 assert(dynamic_cast<TH2D *>(rootobj));
110 assert(dynamic_cast<TH3F *>(rootobj));
116 assert(dynamic_cast<TProfile *>(rootobj));
122 assert(dynamic_cast<TProfile2D *>(rootobj));
128 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element" 129 " as a root object with type %d", (
int) kind);
145 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element" 146 " as a string with type %d", (
int) kind);
235 o.refvalue_ =
nullptr;
250 THashList *l1 = (
const_cast<TAxis*
>(a1))->GetLabels();
251 THashList *l2 = (
const_cast<TAxis*
>(a2))->GetLabels();
259 if (l1->GetSize() != l2->GetSize() ) {
262 for (
int i = 1;
i <= a1->GetNbins(); ++
i) {
263 TString label1 = a1->GetBinLabel(
i);
264 TString label2 = a2->GetBinLabel(
i);
265 if (label1 != label2) {
316 ->Fill(static_cast<double>(x), 1);
319 ->Fill(static_cast<double>(x), 1);
322 ->Fill(static_cast<double>(x), 1);
371 int index = entries + 1 ;
372 int xlow = 2 ;
int xup =
nbins ;
374 if ( entries >= nbins )
377 xlow = entries - nbins + 3 ; xup = entries+1 ;
383 double N = entries - nbins + 1.;
384 if ( ye == 0. || y1err == 0. || y2err == 0.)
387 double sum = N*y1 + y2;
390 double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
392 y1err =
sqrt(s)/(N+1.);
399 double denom = (1./y1err + 1./y2err);
400 double mean = (y1/y1err + y2/y2err)/denom;
402 y1err =
sqrt(((y1-mean)*(y1-mean)/y1err +
403 (y2-mean)*(y2-mean)/y2err)/denom/2.);
422 sprintf (buffer,
"%d", xlow*xscale);
424 sprintf (buffer,
"%d", xup*xscale);
496 snprintf(buf,
sizeof(buf),
"%s%" PRId64, prefix,
scalar_.
num);
501 snprintf(buf,
sizeof(buf),
"%s%.*g", prefix, DBL_DIG+2,
scalar_.
real);
506 into.reserve(strlen(prefix) +
scalar_.
str.size());
547 result.reserve(6 + 2*
data_.
objname.size() + val.size());
550 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
560 size_t len = sprintf(buf,
"t=%" PRIu32,
data_.
tag);
565 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
578 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
588 size_t buflen = sprintf(buf,
"qr=st:%d:%.*g:", qv.
code, DBL_DIG+2, qv.
qtresult);
590 result.reserve(7 + 2*titlelen + buflen + qv.
algorithm.size() + qv.
message.size());
591 result +=
'<'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
593 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
606 std::vector<QReport *>
609 std::vector<QReport *>
result;
615 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
620 std::vector<QReport *>
623 std::vector<QReport *>
result;
630 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
635 std::vector<QReport *>
638 std::vector<QReport *>
result;
645 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
650 std::vector<QReport *>
653 std::vector<QReport *>
result;
662 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
687 int oldStatus = qv.
code;
691 if (oldStatus != qv.
code || oldMessage != qv.
message)
703 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor" 711 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor" 712 " element '%s' because it is not a root object",
731 ->GetMeanError(axis); }
743 ->GetRMSError(axis); }
767 ->GetBinContent(binx); }
773 ->GetBinContent(binx, biny); }
779 ->GetBinContent(binx, biny, binz); }
785 ->GetBinError(binx); }
791 ->GetBinError(binx, biny); }
797 ->GetBinError(binx, biny, binz); }
811 ->GetBinEntries(bin);
814 ->GetBinEntries(bin);
853 {
return getAxis(__PRETTY_FUNCTION__, axis)
870 ->SetBinContent(binx, content);
879 ->SetBinContent(binx, biny, content); }
887 ->SetBinContent(binx, biny, binz, content); }
895 ->SetBinError(binx, error);
904 ->SetBinError(binx, biny, error);
913 ->SetBinError(binx, biny, binz, error);
923 ->SetBinEntries(bin, nentries);
926 ->SetBinEntries(bin, nentries);
937 ->SetEntries(nentries);
945 if (
getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
947 getAxis(__PRETTY_FUNCTION__, axis)
948 ->SetBinLabel(bin, label.c_str());
952 #if WITHOUT_CMS_FRAMEWORK 957 <<
"*** MonitorElement: WARNING:" 958 <<
"setBinLabel: attempting to set label of non-existent bin number for ME: "<<
getFullname() <<
" \n";
967 getAxis(__PRETTY_FUNCTION__, axis)
968 ->SetRangeUser(xmin, xmax);
976 getAxis(__PRETTY_FUNCTION__, axis)
977 ->SetTitle(title.c_str());
985 getAxis(__PRETTY_FUNCTION__, axis)
986 ->SetTimeDisplay(value);
994 getAxis(__PRETTY_FUNCTION__, axis)
995 ->SetTimeFormat(format);
1003 getAxis(__PRETTY_FUNCTION__, axis)
1004 ->SetTimeOffset(toffset, option);
1013 ->SetTitle(title.c_str());
1029 raiseDQMError(
"MonitorElement",
"No such axis %d in monitor element" 1051 auto *orig =
static_cast<TH1F *
>(
object_);
1056 r->SetDirectory(
nullptr);
1065 auto *orig =
static_cast<TH1S *
>(
object_);
1070 r->SetDirectory(
nullptr);
1079 auto *orig =
static_cast<TH1D *
>(
object_);
1084 r->SetDirectory(
nullptr);
1093 auto *orig =
static_cast<TH2F *
>(
object_);
1098 r->SetDirectory(
nullptr);
1107 auto *orig =
static_cast<TH2S *
>(
object_);
1112 r->SetDirectory(
nullptr);
1121 auto *orig =
static_cast<TH2D *
>(
object_);
1126 r->SetDirectory(
nullptr);
1135 auto *orig =
static_cast<TH3F *
>(
object_);
1140 r->SetDirectory(
nullptr);
1149 auto *orig =
static_cast<TProfile *
>(
object_);
1150 auto *
r =
static_cast<TProfile *
>(
refvalue_);
1154 r->SetDirectory(
nullptr);
1163 auto *orig =
static_cast<TProfile2D *
>(
object_);
1164 auto *
r =
static_cast<TProfile2D *
>(
refvalue_);
1168 r->SetDirectory(
nullptr);
1193 auto *orig =
static_cast<TH1 *
>(
object_);
1198 auto *orig =
static_cast<TProfile *
>(
object_);
1199 auto *
r =
static_cast<TProfile *
>(
refvalue_);
1204 auto *orig =
static_cast<TProfile2D *
>(
object_);
1205 auto *
r =
static_cast<TProfile2D *
>(
refvalue_);
1225 static const Int_t NUM_STAT = 6;
1226 Double_t stats1[NUM_STAT];
1227 Double_t stats2[NUM_STAT];
1228 Double_t stats3[NUM_STAT];
1230 bool isRebinOn = sum->CanExtendAllAxes();
1231 sum->SetCanExtend(TH1::kNoAxis);
1233 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1234 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1236 h1->GetStats(stats1);
1237 h2->GetStats(stats2);
1239 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1240 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1245 Double_t entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1246 TArrayD* h1sumw2 = h1->GetSumw2();
1247 TArrayD* h2sumw2 = h2->GetSumw2();
1248 for (Int_t
bin = 0, nbin = sum->GetNbinsX()+1;
bin <= nbin; ++
bin)
1250 Double_t entries = c1*h1->GetBinEntries(
bin)
1251 + c2*h2->GetBinEntries(
bin);
1252 Double_t
content = c1*h1->GetBinEntries(
bin)*h1->GetBinContent(
bin)
1253 + c2*h2->GetBinEntries(
bin)*h2->GetBinContent(
bin);
1256 sum->SetBinContent(bin, content);
1257 sum->SetBinError(bin, error);
1258 sum->SetBinEntries(bin, entries);
1261 sum->SetEntries(entries);
1262 sum->PutStats(stats3);
1263 if (isRebinOn) sum->SetCanExtend(TH1::kAllAxes);
1275 static const Int_t NUM_STAT = 9;
1276 Double_t stats1[NUM_STAT];
1277 Double_t stats2[NUM_STAT];
1278 Double_t stats3[NUM_STAT];
1280 bool isRebinOn = sum->CanExtendAllAxes();
1281 sum->SetCanExtend(TH1::kNoAxis);
1283 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1284 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1286 h1->GetStats(stats1);
1287 h2->GetStats(stats2);
1289 for (Int_t
i = 0;
i < NUM_STAT;
i++)
1290 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1295 Double_t entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1296 TArrayD *h1sumw2 = h1->GetSumw2();
1297 TArrayD *h2sumw2 = h2->GetSumw2();
1298 for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1299 for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1301 Int_t
bin = sum->GetBin(xbin, ybin);
1302 Double_t entries = c1*h1->GetBinEntries(bin)
1303 + c2*h2->GetBinEntries(bin);
1304 Double_t
content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1305 + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1309 sum->SetBinContent(bin, content);
1310 sum->SetBinError(bin, error);
1311 sum->SetBinEntries(bin, entries);
1313 sum->SetEntries(entries);
1314 sum->PutStats(stats3);
1315 if (isRebinOn) sum->SetCanExtend(TH1::kAllAxes);
1327 TList *fromf = from->GetListOfFunctions();
1328 TList *tof = to->GetListOfFunctions();
1329 for (
int i = 0, nfuncs = fromf ? fromf->GetSize() : 0;
i < nfuncs; ++
i)
1331 TObject *
obj = fromf->At(
i);
1333 if (!strcmp(obj->IsA()->GetName(),
"TPaveStats"))
1336 if (
auto *fn = dynamic_cast<TF1 *>(obj))
1337 tof->Add(
new TF1(*fn));
1341 raiseDQMError(
"MonitorElement",
"Cannot extract function '%s' of type" 1342 " '%s' from monitor element '%s' for a copy",
1343 obj->GetName(), obj->IsA()->GetName(),
data_.
objname.c_str());
1351 if (orig->GetTitle() != from->GetTitle())
1352 orig->SetTitle(from->GetTitle());
1372 static_cast<TProfile *>(orig),
1378 static_cast<TProfile2D *>(orig),
1402 if (pos ==
end && ! create)
1404 else if (pos ==
end)
1413 q.
message =
"NO_MESSAGE_ASSIGNED";
1440 qv->
message =
"NO_MESSAGE_ASSIGNED";
1451 switch (qreport.code)
1551 return static_cast<TProfile2D *
>(
accessRootObject(__PRETTY_FUNCTION__, 2));
1574 return static_cast<TH1F *
> 1583 return static_cast<TH1S *
> 1592 return static_cast<TH1D *
> 1601 return static_cast<TH2F *
> 1610 return static_cast<TH2S *
> 1619 return static_cast<TH2D *
> 1628 return static_cast<TH3F *
> 1637 return static_cast<TProfile *
> 1646 return static_cast<TProfile2D *
>
TProfile * getTProfile() const
static const uint32_t DQM_PROP_REPORT_WARN
void incompatible(const char *func) const
const QReport * getQReport(const std::string &qtname) const
get QReport corresponding to <qtname> (null pointer if QReport does not exist)
std::string valueString() const
void setBinContent(int binx, double content)
set content of bin (1-D)
TH1 * accessRootObject(const char *func, int reqdim) const
MonitorElement * initialise(Kind kind)
TProfile2D * getTProfile2D() const
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
int getNbinsZ() const
get # of bins in Z-axis
std::vector< QReport * > getQOthers() const
def create(alignables, pedeDump, additionalData, outputFile, config)
void setAxisRange(double xmin, double xmax, int axis=1)
set x-, y- or z-axis range (axis=1, 2, 3 respectively)
void setAxisTimeFormat(const char *format="", int axis=1)
set the format of the time values that are displayed on an axis
std::vector< QReport > qreports_
TObject * getRootObject() const
bool isSoftResetEnabled() const
whether soft-reset is enabled; default is false
std::string qualityTagString(const DQMNet::QValue &qv) const
std::string getAxisTitle(int axis=1) const
get x-, y- or z-axis title (axis=1, 2, 3 respectively)
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)
TProfile2D * getRefTProfile2D() const
const std::string * dirname
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
TObject * getRefRootObject() const
void disableSoftReset()
reverts action of softReset
TH2S * getRefTH2S() const
double getMeanError(int axis=1) const
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
bool wasUpdated() const
true if ME was updated in last monitoring cycle
void update()
Mark the object updated.
TH1F * getRefTH1F() const
std::string getTitle() const
get MonitorElement title
void ShiftFillLast(double y, double ye=0., int32_t xscale=1)
static TH1 * checkRootObject(const std::string &name, TObject *tobj, const char *func, int reqdim)
void packQualityData(std::string &into) const
serialise quality report information into a string.
static const uint32_t DQM_PROP_HAS_REFERENCE
void setAxisTimeDisplay(int value, int axis=1)
set x-, y-, or z-axis to display time values
void doFill(int64_t x)
"Fill" ME method for int64_t
TH1S * getRefTH1S() const
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
std::string tagString() const
TH3F * getRefTH3F() const
static const int DID_NOT_RUN
static const uint32_t DQM_PROP_REPORT_ERROR
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
static const uint32_t DQM_PROP_REPORT_OTHER
void setEntries(double nentries)
set # of entries
void Reset()
reset ME (ie. contents, errors, etc)
std::vector< QReport * > getQErrors() const
get errors from last set of quality tests
void updateQReportStats()
Refresh QReport stats, usually after MEs were read in from a file.
bin
set the eta bin as selection string.
TAxis * getAxis(const char *func, int axis) const
const std::string getFullname() const
get full name of ME including Pathname
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
void runQTests()
run all quality tests
double getRMSError(int axis=1) const
get RMS uncertainty of histogram along x, y or z axis(axis=1,2,3 respectively)
double getEntries() const
get # of entries
void setAxisTimeOffset(double toffset, const char *option="local", int axis=1)
set the time offset, if option = "gmt" then the offset is treated as a GMT time
std::string effLabelString() const
return label string for the monitor element tag (eg. <name>t=12345</name>)
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
virtual float runTest(const MonitorElement *me)
std::string tagLabelString() const
return label string for the monitor element tag (eg. <name>t=12345</name>)
TH2D * getRefTH2D() const
static void packQualityData(std::string &into, const QReports &qr)
std::vector< QReport * > getQReports() const
get map of QReports
int getNbinsY() const
get # of bins in Y-axis
double getYmin() const
get min Y value (for profiles)
void copyFunctions(TH1 *from, TH1 *to)
TH2F * getRefTH2F() const
double getBinContent(int binx) const
get content of bin (1-D)
double getRMS(int axis=1) const
get RMS of histogram along x, y or z axis (axis=1, 2, 3 respectively)
const uint32_t moduleId() const
double getBinEntries(int bin) const
get # of bin entries (for profiles)
double getYmax() const
get max Y value (for profiles)
std::string getName() const
get name of quality test
static const int STATUS_OK
TH1D * getRefTH1D() const
auto zw(V v) -> Vec2< typename std::remove_reference< decltype(v[0])>::type >
int getNbinsX() const
get # of bins in X-axis
static const uint32_t DQM_PROP_NEW
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
TProfile * getRefTProfile() const
void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
void addQReport(const DQMNet::QValue &desc, QCriterion *qc)
Add quality report, from DQMStore.
Kind kind() const
Get the type of the monitor element.
std::vector< QReport * > getQWarnings() const
get warnings from last set of quality tests
bool isAccumulateEnabled() const
whether ME contents should be accumulated over multiple monitoring periods; default: false ...
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.
const uint32_t run() const
void raiseDQMError(const char *context, const char *fmt,...)