1 #define __STDC_FORMAT_MACROS 1
2 #define DQM_ROOT_METHODS 1
19 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
20 " element '%s' because it is not a ROOT object.",
23 TH1 *
h =
static_cast<TH1 *
>(tobj);
24 int ndim = h->GetDimension();
25 if (reqdim < 0 || reqdim > ndim)
26 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
27 " element '%s' because it requires %d dimensions; this"
28 " object of type '%s' has %d dimensions",
29 func, name.c_str(), reqdim,
typeid(*h).name(), ndim);
56 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
57 " to invalid type %d", (
int) kind);
70 assert(dynamic_cast<TH1F *>(rootobj));
76 assert(dynamic_cast<TH1S *>(rootobj));
82 assert(dynamic_cast<TH1D *>(rootobj));
88 assert(dynamic_cast<TH2F *>(rootobj));
94 assert(dynamic_cast<TH2S *>(rootobj));
100 assert(dynamic_cast<TH2D *>(rootobj));
106 assert(dynamic_cast<TH3F *>(rootobj));
112 assert(dynamic_cast<TProfile *>(rootobj));
118 assert(dynamic_cast<TProfile2D *>(rootobj));
124 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
125 " as a root object with type %d", (
int) kind);
141 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
142 " as a string with type %d", (
int) kind);
190 reference_(x.reference_),
191 refvalue_(x.refvalue_),
192 qreports_(x.qreports_)
238 THashList *l1 = (
const_cast<TAxis*
>(a1))->GetLabels();
239 THashList *l2 = (
const_cast<TAxis*
>(a2))->GetLabels();
247 if (l1->GetSize() != l2->GetSize() ) {
250 for (
int i = 1;
i <= a1->GetNbins(); ++
i) {
251 TString label1 = a1->GetBinLabel(
i);
252 TString label2 = a2->GetBinLabel(
i);
253 if (label1 != label2) {
304 ->Fill(static_cast<double>(x), 1);
307 ->Fill(static_cast<double>(x), 1);
310 ->Fill(static_cast<double>(x), 1);
359 int index = entries + 1 ;
360 int xlow = 2 ;
int xup =
nbins ;
362 if ( entries >= nbins )
365 xlow = entries - nbins + 3 ; xup = entries+1 ;
371 double N = entries - nbins + 1.;
372 if ( ye == 0. || y1err == 0. || y2err == 0.)
375 double sum = N*y1 + y2;
378 double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
380 y1err =
sqrt(s)/(N+1.);
387 double denom = (1./y1err + 1./y2err);
388 double mean = (y1/y1err + y2/y2err)/denom;
390 y1err =
sqrt(((y1-mean)*(y1-mean)/y1err +
391 (y2-mean)*(y2-mean)/y2err)/denom/2.);
410 sprintf (buffer,
"%d", xlow*xscale);
412 sprintf (buffer,
"%d", xup*xscale);
484 snprintf(buf,
sizeof(buf),
"%s%" PRId64, prefix,
scalar_.
num);
489 snprintf(buf,
sizeof(buf),
"%s%.*g", prefix, DBL_DIG+2,
scalar_.
real);
494 into.reserve(strlen(prefix) +
scalar_.
str.size());
535 result.reserve(6 + 2*
data_.
objname.size() + val.size());
538 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
548 size_t len = sprintf(buf,
"t=%" PRIu32,
data_.
tag);
553 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
566 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
576 size_t buflen = sprintf(buf,
"qr=st:%d:%.*g:", qv.
code, DBL_DIG+2, qv.
qtresult);
578 result.reserve(7 + 2*titlelen + buflen + qv.
algorithm.size() + qv.
message.size());
579 result +=
'<'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
581 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
594 std::vector<QReport *>
597 std::vector<QReport *>
result;
603 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
608 std::vector<QReport *>
611 std::vector<QReport *>
result;
618 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
623 std::vector<QReport *>
626 std::vector<QReport *>
result;
633 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
638 std::vector<QReport *>
641 std::vector<QReport *>
result;
650 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
675 int oldStatus = qv.
code;
679 if (oldStatus != qv.
code || oldMessage != qv.
message)
691 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
699 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
700 " element '%s' because it is not a root object",
719 ->GetMeanError(axis); }
731 ->GetRMSError(axis); }
755 ->GetBinContent(binx); }
761 ->GetBinContent(binx, biny); }
767 ->GetBinContent(binx, biny, binz); }
773 ->GetBinError(binx); }
779 ->GetBinError(binx, biny); }
785 ->GetBinError(binx, biny, binz); }
799 ->GetBinEntries(bin);
802 ->GetBinEntries(bin);
841 {
return getAxis(__PRETTY_FUNCTION__, axis)
858 ->SetBinContent(binx, content);
867 ->SetBinContent(binx, biny, content); }
875 ->SetBinContent(binx, biny, binz, content); }
883 ->SetBinError(binx, error);
892 ->SetBinError(binx, biny, error);
901 ->SetBinError(binx, biny, binz, error);
911 ->SetBinEntries(bin, nentries);
914 ->SetBinEntries(bin, nentries);
925 ->SetEntries(nentries);
933 if (
getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
935 getAxis(__PRETTY_FUNCTION__, axis)
936 ->SetBinLabel(bin, label.c_str());
941 std::cout <<
"*** MonitorElement: WARNING:"
942 <<
"setBinLabel: attempting to set label of non-existent bin number \n";
951 getAxis(__PRETTY_FUNCTION__, axis)
952 ->SetRangeUser(xmin, xmax);
960 getAxis(__PRETTY_FUNCTION__, axis)
961 ->SetTitle(title.c_str());
969 getAxis(__PRETTY_FUNCTION__, axis)
970 ->SetTimeDisplay(value);
978 getAxis(__PRETTY_FUNCTION__, axis)
979 ->SetTimeFormat(format);
987 getAxis(__PRETTY_FUNCTION__, axis)
988 ->SetTimeOffset(toffset, option);
997 ->SetTitle(title.c_str());
1013 raiseDQMError(
"MonitorElement",
"No such axis %d in monitor element"
1035 TH1F *orig =
static_cast<TH1F *
>(
object_);
1042 orig->GetXaxis()->GetXmin(),
1043 orig->GetXaxis()->GetXmax());
1053 TH1S *orig =
static_cast<TH1S *
>(
object_);
1060 orig->GetXaxis()->GetXmin(),
1061 orig->GetXaxis()->GetXmax());
1071 TH1D *orig =
static_cast<TH1D *
>(
object_);
1078 orig->GetXaxis()->GetXmin(),
1079 orig->GetXaxis()->GetXmax());
1089 TH2F *orig =
static_cast<TH2F *
>(
object_);
1096 orig->GetXaxis()->GetXmin(),
1097 orig->GetXaxis()->GetXmax(),
1099 orig->GetYaxis()->GetXmin(),
1100 orig->GetYaxis()->GetXmax());
1110 TH2S *orig =
static_cast<TH2S *
>(
object_);
1117 orig->GetXaxis()->GetXmin(),
1118 orig->GetXaxis()->GetXmax(),
1120 orig->GetYaxis()->GetXmin(),
1121 orig->GetYaxis()->GetXmax());
1131 TH2D *orig =
static_cast<TH2D *
>(
object_);
1138 orig->GetXaxis()->GetXmin(),
1139 orig->GetXaxis()->GetXmax(),
1141 orig->GetYaxis()->GetXmin(),
1142 orig->GetYaxis()->GetXmax());
1152 TH3F *orig =
static_cast<TH3F *
>(
object_);
1159 orig->GetXaxis()->GetXmin(),
1160 orig->GetXaxis()->GetXmax(),
1162 orig->GetYaxis()->GetXmin(),
1163 orig->GetYaxis()->GetXmax(),
1165 orig->GetZaxis()->GetXmin(),
1166 orig->GetZaxis()->GetXmax());
1176 TProfile *orig =
static_cast<TProfile *
>(
object_);
1177 TProfile *
r =
static_cast<TProfile *
>(
refvalue_);
1183 orig->GetXaxis()->GetXmin(),
1184 orig->GetXaxis()->GetXmax(),
1185 orig->GetYaxis()->GetXmin(),
1186 orig->GetYaxis()->GetXmax(),
1187 orig->GetErrorOption());
1197 TProfile2D *orig =
static_cast<TProfile2D *
>(
object_);
1198 TProfile2D *
r =
static_cast<TProfile2D *
>(
refvalue_);
1204 orig->GetXaxis()->GetXmin(),
1205 orig->GetXaxis()->GetXmax(),
1207 orig->GetYaxis()->GetXmin(),
1208 orig->GetYaxis()->GetXmax(),
1209 orig->GetZaxis()->GetXmin(),
1210 orig->GetZaxis()->GetXmax(),
1211 orig->GetErrorOption());
1237 TH1 *orig =
static_cast<TH1 *
>(
object_);
1242 TProfile *orig =
static_cast<TProfile *
>(
object_);
1243 TProfile *
r =
static_cast<TProfile *
>(
refvalue_);
1248 TProfile2D *orig =
static_cast<TProfile2D *
>(
object_);
1249 TProfile2D *
r =
static_cast<TProfile2D *
>(
refvalue_);
1269 static const Int_t NUM_STAT = 6;
1270 Double_t stats1[NUM_STAT];
1271 Double_t stats2[NUM_STAT];
1272 Double_t stats3[NUM_STAT];
1274 bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1275 sum->ResetBit(TH1::kCanRebin);
1277 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1278 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1280 h1->GetStats(stats1);
1281 h2->GetStats(stats2);
1283 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1284 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1286 stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1287 + c2*TMath::Abs(c2)*stats2[1];
1289 Double_t
entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1290 TArrayD* h1sumw2 = h1->GetSumw2();
1291 TArrayD* h2sumw2 = h2->GetSumw2();
1292 for (Int_t
bin = 0, nbin = sum->GetNbinsX()+1;
bin <= nbin; ++
bin)
1294 Double_t entries = c1*h1->GetBinEntries(
bin)
1295 + c2*h2->GetBinEntries(
bin);
1296 Double_t
content = c1*h1->GetBinEntries(
bin)*h1->GetBinContent(
bin)
1297 + c2*h2->GetBinEntries(
bin)*h2->GetBinContent(
bin);
1298 Double_t
error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[
bin]
1299 + c2*TMath::Abs(c2)*h2sumw2->fArray[
bin]);
1300 sum->SetBinContent(bin, content);
1301 sum->SetBinError(bin, error);
1302 sum->SetBinEntries(bin, entries);
1305 sum->SetEntries(entries);
1306 sum->PutStats(stats3);
1307 if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1319 static const Int_t NUM_STAT = 9;
1320 Double_t stats1[NUM_STAT];
1321 Double_t stats2[NUM_STAT];
1322 Double_t stats3[NUM_STAT];
1324 bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1325 sum->ResetBit(TH1::kCanRebin);
1327 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1328 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1330 h1->GetStats(stats1);
1331 h2->GetStats(stats2);
1333 for (Int_t
i = 0;
i < NUM_STAT;
i++)
1334 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1336 stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1337 + c2*TMath::Abs(c2)*stats2[1];
1339 Double_t
entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1340 TArrayD *h1sumw2 = h1->GetSumw2();
1341 TArrayD *h2sumw2 = h2->GetSumw2();
1342 for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1343 for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1345 Int_t
bin = sum->GetBin(xbin, ybin);
1346 Double_t entries = c1*h1->GetBinEntries(bin)
1347 + c2*h2->GetBinEntries(bin);
1348 Double_t
content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1349 + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1350 Double_t
error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1351 + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1353 sum->SetBinContent(bin, content);
1354 sum->SetBinError(bin, error);
1355 sum->SetBinEntries(bin, entries);
1357 sum->SetEntries(entries);
1358 sum->PutStats(stats3);
1359 if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1371 TList *fromf = from->GetListOfFunctions();
1372 TList *tof = to->GetListOfFunctions();
1373 for (
int i = 0, nfuncs = fromf ? fromf->GetSize() : 0;
i < nfuncs; ++
i)
1375 TObject *
obj = fromf->At(
i);
1377 if (!strcmp(obj->IsA()->GetName(),
"TPaveStats"))
1380 if (TF1 *fn = dynamic_cast<TF1 *>(obj))
1381 tof->Add(
new TF1(*fn));
1385 raiseDQMError(
"MonitorElement",
"Cannot extract function '%s' of type"
1386 " '%s' from monitor element '%s' for a copy",
1387 obj->GetName(), obj->IsA()->GetName(),
data_.
objname.c_str());
1395 if (orig->GetTitle() != from->GetTitle())
1396 orig->SetTitle(from->GetTitle());
1416 static_cast<TProfile *>(orig),
1422 static_cast<TProfile2D *>(orig),
1446 if (pos ==
end && ! create)
1448 else if (pos ==
end)
1457 q.
message =
"NO_MESSAGE_ASSIGNED";
1484 qv->
message =
"NO_MESSAGE_ASSIGNED";
1595 return static_cast<TProfile2D *
>(
accessRootObject(__PRETTY_FUNCTION__, 2));
1618 return static_cast<TH1F *
>
1627 return static_cast<TH1S *
>
1636 return static_cast<TH1D *
>
1645 return static_cast<TH2F *
>
1654 return static_cast<TH2S *
>
1663 return static_cast<TH2D *
>
1672 return static_cast<TH3F *
>
1681 return static_cast<TProfile *
>
1690 return static_cast<TProfile2D *
>
TH1F * getRefTH1F(void) const
TH2S * getTH2S(void) const
TH1S * getTH1S(void) 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)
void setBinContent(int binx, double content)
set content of bin (1-D)
TH1 * accessRootObject(const char *func, int reqdim) const
std::string getName(void) const
get name of quality test
MonitorElement * initialise(Kind kind)
MonitorElement & operator=(const MonitorElement &)
TProfile2D * getTProfile2D(void) const
TH1 * getRefTH1(void) const
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
void updateQReportStats(void)
Refresh QReport stats, usually after MEs were read in from a file.
std::vector< QReport > qreports_
std::string tagLabelString(void) const
return label string for the monitor element tag (eg. <name>t=12345</name>)
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)
TProfile2D * getRefTProfile2D(void) const
auto zw(V v) -> Vec2< typenamestd::remove_reference< decltype(v[0])>::type >
void disableSoftReset(void)
reverts action of softReset
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)
TH3F * getTH3F(void) const
TH1D * getTH1D(void) const
void runQTests(void)
run all quality tests
TH2D * getTH2D(void) const
const std::string * dirname
void update(void)
Mark the object updated.
double getEntries(void) const
get # of entries
double getMean(int axis=1) const
get mean value of histogram along x, y or z axis (axis=1, 2, 3 respectively)
double getMeanError(int axis=1) const
void packScalarData(std::string &into, const char *prefix) const
convert scalar data into a string.
int getNbinsY(void) const
get # of bins in Y-axis
std::vector< QReport * > getQErrors(void) const
get errors from last set of quality tests
bool wasUpdated(void) const
true if ME was updated in last monitoring cycle
TH3F * getRefTH3F(void) const
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
tuple path
else: Piece not in the list, fine.
TH2F * getRefTH2F(void) const
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
int getNbinsZ(void) const
get # of bins in Z-axis
void addProfiles(TProfile *h1, TProfile *h2, TProfile *sum, float c1, float c2)
std::string getTitle(void) const
get MonitorElement title
static const int DID_NOT_RUN
static const uint32_t DQM_PROP_REPORT_ERROR
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
void setBinError(int binx, double error)
set uncertainty on content of bin (1-D)
static const uint32_t DQM_PROP_REPORT_OTHER
Kind kind(void) const
Get the type of the monitor element.
void setEntries(double nentries)
set # of entries
std::string effLabelString(void) const
return label string for the monitor element tag (eg. <name>t=12345</name>)
bool isAccumulateEnabled(void) const
whether ME contents should be accumulated over multiple monitoring periods; default: false ...
const uint32_t streamId(void) const
std::string valueString(void) const
TH2D * getRefTH2D(void) const
TAxis * getAxis(const char *func, int axis) const
void setTitle(const std::string &title)
set (ie. change) histogram/profile title
double getRMSError(int axis=1) const
get RMS uncertainty of histogram along x, y or z axis(axis=1,2,3 respectively)
TObject * getRootObject(void) const
std::vector< QReport * > getQReports(void) const
get map of QReports
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::vector< QReport * > getQOthers(void) const
double getBinError(int binx) const
get uncertainty on content of bin (1-D) - See TH1::GetBinError for details
virtual float runTest(const MonitorElement *me)
TH1F * getTH1F(void) const
std::string tagString(void) const
static void packQualityData(std::string &into, const QReports &qr)
TProfile * getRefTProfile(void) const
void copyFunctions(TH1 *from, TH1 *to)
const uint32_t moduleId(void) 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)
double getYmax(void) const
get max Y value (for profiles)
TProfile * getTProfile(void) const
TH2S * getRefTH2S(void) const
bool isSoftResetEnabled(void) const
whether soft-reset is enabled; default is false
double getBinEntries(int bin) const
get # of bin entries (for profiles)
std::vector< QReport * > getQWarnings(void) const
get warnings from last set of quality tests
int getNbinsX(void) const
get # of bins in X-axis
static const int STATUS_OK
const uint32_t run(void) const
static const uint32_t DQM_PROP_NEW
TH2F * getTH2F(void) const
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
void Reset(void)
reset ME (ie. contents, errors, etc)
TObject * getRefRootObject(void) const
void setBinEntries(int bin, double nentries)
set # of bin entries (to be used for profiles)
TH1S * getRefTH1S(void) const
void addQReport(const DQMNet::QValue &desc, QCriterion *qc)
Add quality report, from DQMStore.
double getYmin(void) const
get min Y value (for profiles)
TH1D * getRefTH1D(void) const
static bool CheckBinLabels(const TAxis *a1, const TAxis *a2)
Check the consistency of the axis labels.
void raiseDQMError(const char *context, const char *fmt,...)