1 #define __STDC_FORMAT_MACROS 1
2 #define DQM_ROOT_METHODS 1
18 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
19 " element '%s' because it is not a ROOT object.",
22 TH1 *
h =
static_cast<TH1 *
>(tobj);
23 int ndim = h->GetDimension();
24 if (reqdim < 0 || reqdim > ndim)
25 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
26 " element '%s' because it requires %d dimensions; this"
27 " object of type '%s' has %d dimensions",
28 func, name.c_str(), reqdim,
typeid(*h).name(), ndim);
55 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
56 " to invalid type %d", (
int) kind);
69 assert(dynamic_cast<TH1F *>(rootobj));
75 assert(dynamic_cast<TH1S *>(rootobj));
81 assert(dynamic_cast<TH1D *>(rootobj));
87 assert(dynamic_cast<TH2F *>(rootobj));
93 assert(dynamic_cast<TH2S *>(rootobj));
99 assert(dynamic_cast<TH2D *>(rootobj));
105 assert(dynamic_cast<TH3F *>(rootobj));
111 assert(dynamic_cast<TProfile *>(rootobj));
117 assert(dynamic_cast<TProfile2D *>(rootobj));
123 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
124 " as a root object with type %d", (
int) kind);
140 raiseDQMError(
"MonitorElement",
"cannot initialise monitor element"
141 " as a string with type %d", (
int) kind);
177 reference_(x.reference_),
178 refvalue_(x.refvalue_),
179 qreports_(x.qreports_)
263 ->Fill(static_cast<double>(x), 1);
266 ->Fill(static_cast<double>(x), 1);
269 ->Fill(static_cast<double>(x), 1);
318 int index = entries + 1 ;
319 int xlow = 2 ;
int xup =
nbins ;
321 if ( entries >= nbins )
324 xlow = entries - nbins + 3 ; xup = entries+1 ;
330 double N = entries - nbins + 1.;
331 if ( ye == 0. || y1err == 0. || y2err == 0.)
334 double sum = N*y1 + y2;
337 double s=(N+1.)*(N*y1*y1 + y2*y2) - sum*sum;
339 y1err =
sqrt(s)/(N+1.);
346 double denom = (1./y1err + 1./y2err);
347 double mean = (y1/y1err + y2/y2err)/denom;
349 y1err =
sqrt(((y1-mean)*(y1-mean)/y1err +
350 (y2-mean)*(y2-mean)/y2err)/denom/2.);
369 sprintf (buffer,
"%d", xlow*xscale);
371 sprintf (buffer,
"%d", xup*xscale);
443 snprintf(buf,
sizeof(buf),
"%s%" PRId64, prefix,
scalar_.
num);
448 snprintf(buf,
sizeof(buf),
"%s%.*g", prefix, DBL_DIG+2,
scalar_.
real);
453 into.reserve(strlen(prefix) +
scalar_.
str.size());
494 result.reserve(6 + 2*
data_.
objname.size() + val.size());
497 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
507 size_t len = sprintf(buf,
"t=%" PRIu32,
data_.
tag);
512 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
525 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'>';
535 size_t buflen = sprintf(buf,
"qr=st:%d:%.*g:", qv.
code, DBL_DIG+2, qv.
qtresult);
537 result.reserve(7 + 2*titlelen + buflen + qv.
algorithm.size() + qv.
message.size());
538 result +=
'<'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
540 result +=
'<'; result +=
'/'; result +=
data_.
objname; result +=
'.'; result += qv.
qtname; result +=
'>';
553 std::vector<QReport *>
556 std::vector<QReport *>
result;
562 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
567 std::vector<QReport *>
570 std::vector<QReport *>
result;
577 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
582 std::vector<QReport *>
585 std::vector<QReport *>
result;
592 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
597 std::vector<QReport *>
600 std::vector<QReport *>
result;
609 result.push_back(const_cast<QReport *>(&
qreports_[
i]));
633 std::string oldMessage = qv.
message;
634 int oldStatus = qv.
code;
638 if (oldStatus != qv.
code || oldMessage != qv.
message)
650 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
658 raiseDQMError(
"MonitorElement",
"Method '%s' cannot be invoked on monitor"
659 " element '%s' because it is not a root object",
678 ->GetMeanError(axis); }
690 ->GetRMSError(axis); }
714 ->GetBinContent(binx); }
720 ->GetBinContent(binx, biny); }
726 ->GetBinContent(binx, biny, binz); }
732 ->GetBinError(binx); }
738 ->GetBinError(binx, biny); }
744 ->GetBinError(binx, biny, binz); }
758 ->GetBinEntries(bin);
761 ->GetBinEntries(bin);
800 {
return getAxis(__PRETTY_FUNCTION__, axis)
817 ->SetBinContent(binx, content);
826 ->SetBinContent(binx, biny, content); }
834 ->SetBinContent(binx, biny, binz, content); }
842 ->SetBinError(binx, error);
851 ->SetBinError(binx, biny, error);
860 ->SetBinError(binx, biny, binz, error);
870 ->SetBinEntries(bin, nentries);
873 ->SetBinEntries(bin, nentries);
884 ->SetEntries(nentries);
892 if (
getAxis(__PRETTY_FUNCTION__, axis)->GetNbins() >= bin )
894 getAxis(__PRETTY_FUNCTION__, axis)
895 ->SetBinLabel(bin, label.c_str());
900 std::cout <<
"*** MonitorElement: WARNING:"
901 <<
"setBinLabel: attempting to set label of non-existent bin number \n";
910 getAxis(__PRETTY_FUNCTION__, axis)
911 ->SetRangeUser(xmin, xmax);
919 getAxis(__PRETTY_FUNCTION__, axis)
920 ->SetTitle(title.c_str());
928 getAxis(__PRETTY_FUNCTION__, axis)
929 ->SetTimeDisplay(value);
937 getAxis(__PRETTY_FUNCTION__, axis)
938 ->SetTimeFormat(format);
946 getAxis(__PRETTY_FUNCTION__, axis)
947 ->SetTimeOffset(toffset, option);
956 ->SetTitle(title.c_str());
972 raiseDQMError(
"MonitorElement",
"No such axis %d in monitor element"
994 TH1F *orig =
static_cast<TH1F *
>(
object_);
998 refvalue_ = r =
new TH1F((std::string(orig->GetName()) +
"_ref").c_str(),
1001 orig->GetXaxis()->GetXmin(),
1002 orig->GetXaxis()->GetXmax());
1012 TH1S *orig =
static_cast<TH1S *
>(
object_);
1016 refvalue_ = r =
new TH1S((std::string(orig->GetName()) +
"_ref").c_str(),
1019 orig->GetXaxis()->GetXmin(),
1020 orig->GetXaxis()->GetXmax());
1030 TH1D *orig =
static_cast<TH1D *
>(
object_);
1034 refvalue_ = r =
new TH1D((std::string(orig->GetName()) +
"_ref").c_str(),
1037 orig->GetXaxis()->GetXmin(),
1038 orig->GetXaxis()->GetXmax());
1048 TH2F *orig =
static_cast<TH2F *
>(
object_);
1052 refvalue_ = r =
new TH2F((std::string(orig->GetName()) +
"_ref").c_str(),
1055 orig->GetXaxis()->GetXmin(),
1056 orig->GetXaxis()->GetXmax(),
1058 orig->GetYaxis()->GetXmin(),
1059 orig->GetYaxis()->GetXmax());
1069 TH2S *orig =
static_cast<TH2S *
>(
object_);
1073 refvalue_ = r =
new TH2S((std::string(orig->GetName()) +
"_ref").c_str(),
1076 orig->GetXaxis()->GetXmin(),
1077 orig->GetXaxis()->GetXmax(),
1079 orig->GetYaxis()->GetXmin(),
1080 orig->GetYaxis()->GetXmax());
1090 TH2D *orig =
static_cast<TH2D *
>(
object_);
1094 refvalue_ = r =
new TH2D((std::string(orig->GetName()) +
"_ref").c_str(),
1097 orig->GetXaxis()->GetXmin(),
1098 orig->GetXaxis()->GetXmax(),
1100 orig->GetYaxis()->GetXmin(),
1101 orig->GetYaxis()->GetXmax());
1111 TH3F *orig =
static_cast<TH3F *
>(
object_);
1115 refvalue_ = r =
new TH3F((std::string(orig->GetName()) +
"_ref").c_str(),
1118 orig->GetXaxis()->GetXmin(),
1119 orig->GetXaxis()->GetXmax(),
1121 orig->GetYaxis()->GetXmin(),
1122 orig->GetYaxis()->GetXmax(),
1124 orig->GetZaxis()->GetXmin(),
1125 orig->GetZaxis()->GetXmax());
1135 TProfile *orig =
static_cast<TProfile *
>(
object_);
1136 TProfile *
r =
static_cast<TProfile *
>(
refvalue_);
1139 refvalue_ = r =
new TProfile((std::string(orig->GetName()) +
"_ref").c_str(),
1142 orig->GetXaxis()->GetXmin(),
1143 orig->GetXaxis()->GetXmax(),
1144 orig->GetYaxis()->GetXmin(),
1145 orig->GetYaxis()->GetXmax(),
1146 orig->GetErrorOption());
1156 TProfile2D *orig =
static_cast<TProfile2D *
>(
object_);
1157 TProfile2D *
r =
static_cast<TProfile2D *
>(
refvalue_);
1160 refvalue_ = r =
new TProfile2D((std::string(orig->GetName()) +
"_ref").c_str(),
1163 orig->GetXaxis()->GetXmin(),
1164 orig->GetXaxis()->GetXmax(),
1166 orig->GetYaxis()->GetXmin(),
1167 orig->GetYaxis()->GetXmax(),
1168 orig->GetZaxis()->GetXmin(),
1169 orig->GetZaxis()->GetXmax(),
1170 orig->GetErrorOption());
1196 TH1 *orig =
static_cast<TH1 *
>(
object_);
1201 TProfile *orig =
static_cast<TProfile *
>(
object_);
1202 TProfile *
r =
static_cast<TProfile *
>(
refvalue_);
1207 TProfile2D *orig =
static_cast<TProfile2D *
>(
object_);
1208 TProfile2D *
r =
static_cast<TProfile2D *
>(
refvalue_);
1228 static const Int_t NUM_STAT = 6;
1229 Double_t stats1[NUM_STAT];
1230 Double_t stats2[NUM_STAT];
1231 Double_t stats3[NUM_STAT];
1233 bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1234 sum->ResetBit(TH1::kCanRebin);
1236 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1237 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1239 h1->GetStats(stats1);
1240 h2->GetStats(stats2);
1242 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1243 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1245 stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1246 + c2*TMath::Abs(c2)*stats2[1];
1248 Double_t
entries = c1*h1->GetEntries() + c2* h2->GetEntries();
1249 TArrayD* h1sumw2 = h1->GetSumw2();
1250 TArrayD* h2sumw2 = h2->GetSumw2();
1251 for (Int_t
bin = 0, nbin = sum->GetNbinsX()+1;
bin <= nbin; ++
bin)
1253 Double_t entries = c1*h1->GetBinEntries(
bin)
1254 + c2*h2->GetBinEntries(
bin);
1255 Double_t
content = c1*h1->GetBinEntries(
bin)*h1->GetBinContent(
bin)
1256 + c2*h2->GetBinEntries(
bin)*h2->GetBinContent(
bin);
1257 Double_t
error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[
bin]
1258 + c2*TMath::Abs(c2)*h2sumw2->fArray[
bin]);
1259 sum->SetBinContent(bin, content);
1260 sum->SetBinError(bin, error);
1261 sum->SetBinEntries(bin, entries);
1264 sum->SetEntries(entries);
1265 sum->PutStats(stats3);
1266 if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1278 static const Int_t NUM_STAT = 9;
1279 Double_t stats1[NUM_STAT];
1280 Double_t stats2[NUM_STAT];
1281 Double_t stats3[NUM_STAT];
1283 bool isRebinOn = sum->TestBit(TH1::kCanRebin);
1284 sum->ResetBit(TH1::kCanRebin);
1286 for (Int_t
i = 0;
i < NUM_STAT; ++
i)
1287 stats1[
i] = stats2[
i] = stats3[
i] = 0;
1289 h1->GetStats(stats1);
1290 h2->GetStats(stats2);
1292 for (Int_t
i = 0;
i < NUM_STAT;
i++)
1293 stats3[
i] = c1*stats1[
i] + c2*stats2[
i];
1295 stats3[1] = c1*TMath::Abs(c1)*stats1[1]
1296 + c2*TMath::Abs(c2)*stats2[1];
1298 Double_t
entries = c1*h1->GetEntries() + c2*h2->GetEntries();
1299 TArrayD *h1sumw2 = h1->GetSumw2();
1300 TArrayD *h2sumw2 = h2->GetSumw2();
1301 for (Int_t xbin = 0, nxbin = sum->GetNbinsX()+1; xbin <= nxbin; ++xbin)
1302 for (Int_t ybin = 0, nybin = sum->GetNbinsY()+1; ybin <= nybin; ++ybin)
1304 Int_t
bin = sum->GetBin(xbin, ybin);
1305 Double_t entries = c1*h1->GetBinEntries(bin)
1306 + c2*h2->GetBinEntries(bin);
1307 Double_t
content = c1*h1->GetBinEntries(bin)*h1->GetBinContent(bin)
1308 + c2*h2->GetBinEntries(bin)*h2->GetBinContent(bin);
1309 Double_t
error = TMath::Sqrt(c1*TMath::Abs(c1)*h1sumw2->fArray[bin]
1310 + c2*TMath::Abs(c2)*h2sumw2->fArray[bin]);
1312 sum->SetBinContent(bin, content);
1313 sum->SetBinError(bin, error);
1314 sum->SetBinEntries(bin, entries);
1316 sum->SetEntries(entries);
1317 sum->PutStats(stats3);
1318 if (isRebinOn) sum->SetBit(TH1::kCanRebin);
1330 TList *fromf = from->GetListOfFunctions();
1331 TList *tof = to->GetListOfFunctions();
1332 for (
int i = 0, nfuncs = fromf ? fromf->GetSize() : 0;
i < nfuncs; ++
i)
1334 TObject *
obj = fromf->At(
i);
1336 if (!strcmp(obj->IsA()->GetName(),
"TPaveStats"))
1339 if (TF1 *fn = dynamic_cast<TF1 *>(obj))
1340 tof->Add(
new TF1(*fn));
1344 raiseDQMError(
"MonitorElement",
"Cannot extract function '%s' of type"
1345 " '%s' from monitor element '%s' for a copy",
1346 obj->GetName(), obj->IsA()->GetName(),
data_.
objname.c_str());
1354 if (orig->GetTitle() != from->GetTitle())
1355 orig->SetTitle(from->GetTitle());
1375 static_cast<TProfile *>(orig),
1381 static_cast<TProfile2D *>(orig),
1405 if (pos ==
end && ! create)
1407 else if (pos ==
end)
1416 q.
message =
"NO_MESSAGE_ASSIGNED";
1443 qv->
message =
"NO_MESSAGE_ASSIGNED";
1554 return static_cast<TProfile2D *
>(
accessRootObject(__PRETTY_FUNCTION__, 2));
1577 return static_cast<TH1F *
>
1586 return static_cast<TH1S *
>
1595 return static_cast<TH1D *
>
1604 return static_cast<TH2F *
>
1613 return static_cast<TH2S *
>
1622 return static_cast<TH2D *
>
1631 return static_cast<TH3F *
>
1640 return static_cast<TProfile *
>
1649 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
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
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
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 ...
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
static std::string from(" from ")
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
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
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)
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
perl if(1 lt scalar(@::datatypes))
static const int STATUS_OK
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
void raiseDQMError(const char *context, const char *fmt,...)