From faf05cee0b93df75fef377a6ed56b1b0c16e70f3 Mon Sep 17 00:00:00 2001 From: ywkao Date: Wed, 24 May 2023 14:08:33 +0200 Subject: [PATCH] Implement TH2Poly in DQM GUI --- src/cpp/DQM/DQMNet.cc | 4 ++++ src/cpp/DQM/DQMNet.h | 41 ++++++++++++++++---------------- src/cpp/DQM/DQMStore.cc | 34 +++++++++++++++++++++++++++ src/cpp/DQM/DQMStore.h | 9 +++++++ src/cpp/DQM/MonitorElement.cc | 44 +++++++++++++++++++++++++++++++++++ src/cpp/DQM/MonitorElement.h | 5 ++++ src/cpp/DQM/QTest.cc | 12 ++++++++++ src/cpp/DQM/VisDQMIndex.h | 1 + src/cpp/DQM/VisDQMTools.h | 2 +- src/cpp/DQM/index.cc | 4 ++++ src/cpp/DQM/serverext.cc | 17 +++++++------- 11 files changed, 144 insertions(+), 29 deletions(-) diff --git a/src/cpp/DQM/DQMNet.cc b/src/cpp/DQM/DQMNet.cc index bdc2834..e70da76 100644 --- a/src/cpp/DQM/DQMNet.cc +++ b/src/cpp/DQM/DQMNet.cc @@ -346,6 +346,10 @@ DQMNet::reinstateObject(DQMStore *store, Object &o) obj = store->book2DD(name, dynamic_cast(o.object)); break; + case DQM_PROP_TYPE_TH2Poly: + obj = store->book2DPoly(name, dynamic_cast(o.object)); + break; + case DQM_PROP_TYPE_TH3F: obj = store->book3D(name, dynamic_cast(o.object)); break; diff --git a/src/cpp/DQM/DQMNet.h b/src/cpp/DQM/DQMNet.h index 8ef7b69..4eea988 100644 --- a/src/cpp/DQM/DQMNet.h +++ b/src/cpp/DQM/DQMNet.h @@ -22,26 +22,27 @@ class DQMNet { public: - static const uint32_t DQM_PROP_TYPE_MASK = 0x000000ff; - static const uint32_t DQM_PROP_TYPE_SCALAR = 0x0000000f; - static const uint32_t DQM_PROP_TYPE_INVALID = 0x00000000; - static const uint32_t DQM_PROP_TYPE_INT = 0x00000001; - static const uint32_t DQM_PROP_TYPE_REAL = 0x00000002; - static const uint32_t DQM_PROP_TYPE_STRING = 0x00000003; - static const uint32_t DQM_PROP_TYPE_TH1F = 0x00000010; - static const uint32_t DQM_PROP_TYPE_TH1S = 0x00000011; - static const uint32_t DQM_PROP_TYPE_TH1D = 0x00000012; - static const uint32_t DQM_PROP_TYPE_TH1I = 0x00000013; - static const uint32_t DQM_PROP_TYPE_TH2F = 0x00000020; - static const uint32_t DQM_PROP_TYPE_TH2S = 0x00000021; - static const uint32_t DQM_PROP_TYPE_TH2D = 0x00000022; - static const uint32_t DQM_PROP_TYPE_TH2I = 0x00000023; - static const uint32_t DQM_PROP_TYPE_TH3F = 0x00000030; - static const uint32_t DQM_PROP_TYPE_TH3S = 0x00000031; - static const uint32_t DQM_PROP_TYPE_TH3D = 0x00000032; - static const uint32_t DQM_PROP_TYPE_TPROF = 0x00000040; - static const uint32_t DQM_PROP_TYPE_TPROF2D = 0x00000041; - static const uint32_t DQM_PROP_TYPE_DATABLOB = 0x00000050; + static const uint32_t DQM_PROP_TYPE_MASK = 0x000000ff; + static const uint32_t DQM_PROP_TYPE_SCALAR = 0x0000000f; + static const uint32_t DQM_PROP_TYPE_INVALID = 0x00000000; + static const uint32_t DQM_PROP_TYPE_INT = 0x00000001; + static const uint32_t DQM_PROP_TYPE_REAL = 0x00000002; + static const uint32_t DQM_PROP_TYPE_STRING = 0x00000003; + static const uint32_t DQM_PROP_TYPE_TH1F = 0x00000010; + static const uint32_t DQM_PROP_TYPE_TH1S = 0x00000011; + static const uint32_t DQM_PROP_TYPE_TH1D = 0x00000012; + static const uint32_t DQM_PROP_TYPE_TH1I = 0x00000013; + static const uint32_t DQM_PROP_TYPE_TH2F = 0x00000020; + static const uint32_t DQM_PROP_TYPE_TH2S = 0x00000021; + static const uint32_t DQM_PROP_TYPE_TH2D = 0x00000022; + static const uint32_t DQM_PROP_TYPE_TH2I = 0x00000023; + static const uint32_t DQM_PROP_TYPE_TH2Poly = 0x00000024; + static const uint32_t DQM_PROP_TYPE_TH3F = 0x00000030; + static const uint32_t DQM_PROP_TYPE_TH3S = 0x00000031; + static const uint32_t DQM_PROP_TYPE_TH3D = 0x00000032; + static const uint32_t DQM_PROP_TYPE_TPROF = 0x00000040; + static const uint32_t DQM_PROP_TYPE_TPROF2D = 0x00000041; + static const uint32_t DQM_PROP_TYPE_DATABLOB = 0x00000050; static const uint32_t DQM_PROP_REPORT_MASK = 0x00000f00; static const uint32_t DQM_PROP_REPORT_CLEAR = 0x00000000; diff --git a/src/cpp/DQM/DQMStore.cc b/src/cpp/DQM/DQMStore.cc index 4344bfb..a1deafa 100644 --- a/src/cpp/DQM/DQMStore.cc +++ b/src/cpp/DQM/DQMStore.cc @@ -1149,6 +1149,17 @@ DQMStore::book2D(const std::string &name, const std::string &title, nchY, lowY, highY)); } +/// Book TH2Poly histogram. +MonitorElement * +DQMStore::book2DPoly(const char *name, const char *title, + double lowX, double highX, + double lowY, double highY) +{ + return book2DPoly(pwd_, name, new TH2Poly(name, title, + lowX, highX, + lowY, highY)); +} + /// Book 2S histogram. MonitorElement * DQMStore::book2S(const char *name, const char *title, int nchX, double lowX, double highX, int nchY, double lowY, double highY){ return book2S(pwd_, name, new TH2S(name, title, nchX, lowX, highX, nchY, lowY, highY)); @@ -1593,6 +1604,13 @@ DQMStore::collate2D(MonitorElement *me, TH2F *h, unsigned verbose) me->getTH2F()->Add(h); } +void +DQMStore::collate2DPoly(MonitorElement *me, TH2Poly *h, unsigned verbose) +{ + if (checkBinningMatches(me,h,verbose)) + me->getTH2Poly()->Add(h); +} + void DQMStore::collate2S(MonitorElement *me, TH2S *h, unsigned verbose) { @@ -2254,6 +2272,17 @@ DQMStore::extract(TObject *obj, const std::string &dir, collate2DD(me, h, verbose_); refcheck = me; } + else if (TH2Poly *h = dynamic_cast(obj)) + { + MonitorElement *me = findObject(dir, h->GetName()); + if (! me) + me = book2DPoly(dir, h->GetName(), (TH2Poly *) h->Clone()); + else if (overwrite) + me->copyFrom(h); + else if (isCollateME(me) || collateHistograms) + collate2DPoly(me, h, verbose_); + refcheck = me; + } else if (TH3F *h = dynamic_cast(obj)) { MonitorElement *me = findObject(dir, h->GetName()); @@ -3525,6 +3554,11 @@ DQMStore::scaleElements(void) me.getTH2D()->Scale(factor); break; } + case MonitorElement::DQM_KIND_TH2Poly: + { + me.getTH2Poly()->Scale(factor); + break; + } case MonitorElement::DQM_KIND_TH3F: { me.getTH3F()->Scale(factor); diff --git a/src/cpp/DQM/DQMStore.h b/src/cpp/DQM/DQMStore.h index a6273d7..363860c 100644 --- a/src/cpp/DQM/DQMStore.h +++ b/src/cpp/DQM/DQMStore.h @@ -40,10 +40,12 @@ class TH1D; class TH2F; class TH2S; class TH2D; +class TH2Poly; class TH3F; class TProfile; class TProfile2D; class TNamed; +class TGraph; /** Implements RegEx patterns which occur often in a high-performant @@ -417,6 +419,11 @@ class DQMStore MonitorElement * book2DD (const char *name, TH2D *h); MonitorElement * book2DD (const std::string &name, TH2D *h); + MonitorElement * book2DPoly (const char *name, + const char *title, + double lowX, double highX, + double lowY, double highY); + MonitorElement * book3D (const char *name, const char *title, int nchX, double lowX, double highX, @@ -663,6 +670,7 @@ class DQMStore MonitorElement * book2D(const std::string &dir, const std::string &name, TH2F *h); MonitorElement * book2S(const std::string &dir, const std::string &name, TH2S *h); MonitorElement * book2DD(const std::string &dir, const std::string &name, TH2D *h); + MonitorElement * book2DPoly(const std::string &dir, const std::string &name, TH2Poly *h); MonitorElement * book3D(const std::string &dir, const std::string &name, TH3F *h); MonitorElement * bookProfile(const std::string &dir, const std::string &name, TProfile *h); MonitorElement * bookProfile2D(const std::string &folder, const std::string &name, TProfile2D *h); @@ -677,6 +685,7 @@ class DQMStore static void collate2D(MonitorElement *me, TH2F *h, unsigned verbose); static void collate2S(MonitorElement *me, TH2S *h, unsigned verbose); static void collate2DD(MonitorElement *me, TH2D *h, unsigned verbose); + static void collate2DPoly(MonitorElement *me, TH2Poly *h, unsigned verbose); static void collate3D(MonitorElement *me, TH3F *h, unsigned verbose); static void collateProfile(MonitorElement *me, TProfile *h, unsigned verbose); static void collateProfile2D(MonitorElement *me, TProfile2D *h, unsigned verbose); diff --git a/src/cpp/DQM/MonitorElement.cc b/src/cpp/DQM/MonitorElement.cc index 3606d16..86ff15e 100644 --- a/src/cpp/DQM/MonitorElement.cc +++ b/src/cpp/DQM/MonitorElement.cc @@ -47,6 +47,7 @@ MonitorElement::initialise(Kind kind) case DQM_KIND_TH2F: case DQM_KIND_TH2S: case DQM_KIND_TH2D: + case DQM_KIND_TH2Poly: case DQM_KIND_TH3F: case DQM_KIND_TPROFILE: case DQM_KIND_TPROFILE2D: @@ -116,6 +117,12 @@ MonitorElement::initialise(Kind kind, TH1 *rootobj) object_ = rootobj; break; + case DQM_KIND_TH2Poly: + assert(dynamic_cast(rootobj)); + assert(! reference_ || dynamic_cast(reference_)); + object_ = rootobj; + break; + case DQM_KIND_TH3F: assert(dynamic_cast(rootobj)); assert(! reference_ || dynamic_cast(reference_)); @@ -334,6 +341,7 @@ MonitorElement::Fill(double x, double yw) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)) ->Fill(x, yw, 1); else if (kind() == DQM_KIND_TH2D) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1); + else if (kind() == DQM_KIND_TH2Poly) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1); else if (kind() == DQM_KIND_TH2I) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1); else if (kind() == DQM_KIND_TPROFILE) static_cast(accessRootObject(__PRETTY_FUNCTION__, 1)) @@ -430,6 +438,9 @@ MonitorElement::Fill(double x, double y, double zw) else if (kind() == DQM_KIND_TH2D) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)) ->Fill(x, y, zw); + else if (kind() == DQM_KIND_TH2Poly) + static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)) + ->Fill(x, y, zw); else if (kind() == DQM_KIND_TH3F) static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)) ->Fill(x, y, zw, 1); @@ -1128,6 +1139,20 @@ MonitorElement::softReset(void) r->Add(orig); orig->Reset(); } + else if (kind() == DQM_KIND_TH2Poly) + { + TH2Poly *orig = static_cast(object_); + TH2Poly *r = static_cast(refvalue_); + if (! r) + { + refvalue_ = r = (TH2Poly*)orig->Clone((std::string(orig->GetName()) + "_ref").c_str()); + r->SetDirectory(0); + r->Reset(); + } + + r->Add(orig); + orig->Reset(); + } else if (kind() == DQM_KIND_TH3F) { TH3F *orig = static_cast(object_); @@ -1188,6 +1213,7 @@ MonitorElement::disableSoftReset(void) || kind() == DQM_KIND_TH2F || kind() == DQM_KIND_TH2S || kind() == DQM_KIND_TH2D + || kind() == DQM_KIND_TH2Poly || kind() == DQM_KIND_TH3F) { TH1 *orig = static_cast(object_); @@ -1364,6 +1390,7 @@ MonitorElement::copyFrom(TH1 *from) || kind() == DQM_KIND_TH2F || kind() == DQM_KIND_TH2S || kind() == DQM_KIND_TH2D + || kind() == DQM_KIND_TH2Poly || kind() == DQM_KIND_TH3F) // subtract "reference" orig->Add(from, refvalue_, 1, -1); @@ -1539,6 +1566,14 @@ MonitorElement::getTH2D(void) const return static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)); } +TH2Poly * +MonitorElement::getTH2Poly(void) const +{ + assert(kind() == DQM_KIND_TH2Poly); + const_cast(this)->update(); + return static_cast(accessRootObject(__PRETTY_FUNCTION__, 2)); +} + TH3F * MonitorElement::getTH3F(void) const { @@ -1644,6 +1679,15 @@ MonitorElement::getRefTH2D(void) const (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2)); } +TH2Poly * +MonitorElement::getRefTH2Poly(void) const +{ + assert(kind() == DQM_KIND_TH2Poly); + const_cast(this)->update(); + return static_cast + (checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2)); +} + TH3F * MonitorElement::getRefTH3F(void) const { diff --git a/src/cpp/DQM/MonitorElement.h b/src/cpp/DQM/MonitorElement.h index e3d1d97..b9ed6be 100644 --- a/src/cpp/DQM/MonitorElement.h +++ b/src/cpp/DQM/MonitorElement.h @@ -12,11 +12,13 @@ # include "TH2F.h" # include "TH2S.h" # include "TH2D.h" +# include "TH2Poly.h" # include "TH3F.h" # include "TProfile.h" # include "TProfile2D.h" # include "TObjString.h" # include "TAxis.h" +# include "TGraph.h" # include # include # include @@ -60,6 +62,7 @@ class MonitorElement DQM_KIND_TH2F = DQMNet::DQM_PROP_TYPE_TH2F, DQM_KIND_TH2S = DQMNet::DQM_PROP_TYPE_TH2S, DQM_KIND_TH2D = DQMNet::DQM_PROP_TYPE_TH2D, + DQM_KIND_TH2Poly = DQMNet::DQM_PROP_TYPE_TH2Poly, DQM_KIND_TH3F = DQMNet::DQM_PROP_TYPE_TH3F, DQM_KIND_TH1I = DQMNet::DQM_PROP_TYPE_TH1I, DQM_KIND_TH2I = DQMNet::DQM_PROP_TYPE_TH2I, @@ -349,6 +352,7 @@ class MonitorElement TH2F *getTH2F(void) const; TH2S *getTH2S(void) const; TH2D *getTH2D(void) const; + TH2Poly *getTH2Poly(void) const; TH3F *getTH3F(void) const; TProfile *getTProfile(void) const; TProfile2D *getTProfile2D(void) const; @@ -363,6 +367,7 @@ class MonitorElement TH2F *getRefTH2F(void) const; TH2S *getRefTH2S(void) const; TH2D *getRefTH2D(void) const; + TH2Poly *getRefTH2Poly(void) const; TH3F *getRefTH3F(void) const; TProfile *getRefTProfile(void) const; TProfile2D *getRefTProfile2D(void) const; diff --git a/src/cpp/DQM/QTest.cc b/src/cpp/DQM/QTest.cc index b09a4d8..a994a23 100644 --- a/src/cpp/DQM/QTest.cc +++ b/src/cpp/DQM/QTest.cc @@ -135,6 +135,18 @@ float Comp2RefEqualH::runTest(const MonitorElement*me) if (nbins != nbinsref) return -1; } + //-- TH2Poly + else if (me->kind()==MonitorElement::DQM_KIND_TH2Poly) + { + nbins = me->getTH2Poly()->GetXaxis()->GetNbins() * + me->getTH2Poly()->GetYaxis()->GetNbins(); + nbinsref = me->getRefTH2Poly()->GetXaxis()->GetNbins() * + me->getRefTH2Poly()->GetYaxis()->GetNbins(); + h = me->getTH2Poly(); // access Test histo + ref_ = me->getRefTH2Poly(); //access Ref hiso + if (nbins != nbinsref) return -1; + } + //-- TH3 else if (me->kind()==MonitorElement::DQM_KIND_TH3F) { diff --git a/src/cpp/DQM/VisDQMIndex.h b/src/cpp/DQM/VisDQMIndex.h index f3e2000..bf9444b 100644 --- a/src/cpp/DQM/VisDQMIndex.h +++ b/src/cpp/DQM/VisDQMIndex.h @@ -201,6 +201,7 @@ class VisDQMIndex static const uint32_t SUMMARY_PROP_TYPE_TH2S = 0x00000021; static const uint32_t SUMMARY_PROP_TYPE_TH2D = 0x00000022; static const uint32_t SUMMARY_PROP_TYPE_TH2I = 0x00000023; + static const uint32_t SUMMARY_PROP_TYPE_TH2Poly = 0x00000024; static const uint32_t SUMMARY_PROP_TYPE_TH3F = 0x00000030; static const uint32_t SUMMARY_PROP_TYPE_TH3S = 0x00000031; static const uint32_t SUMMARY_PROP_TYPE_TH3D = 0x00000032; diff --git a/src/cpp/DQM/VisDQMTools.h b/src/cpp/DQM/VisDQMTools.h index 52d0345..686f264 100644 --- a/src/cpp/DQM/VisDQMTools.h +++ b/src/cpp/DQM/VisDQMTools.h @@ -255,7 +255,7 @@ buildCompleteStreamerInfo(std::string &data) "TH1F", "TH1S", "TH1D", "TH1I", "TH2F", "TH2S", "TH2D", "TH2I", "TH3F", "TH3S", "TH3D", "TH3I", - "TProfile", "TProfile2D", 0 + "TH2Poly", "TProfile", "TProfile2D", 0 }; int i = 0; diff --git a/src/cpp/DQM/index.cc b/src/cpp/DQM/index.cc index cae8efd..20879d5 100644 --- a/src/cpp/DQM/index.cc +++ b/src/cpp/DQM/index.cc @@ -486,6 +486,7 @@ classifyMonitorElement(DQMStore & /* store */, case MonitorElement::DQM_KIND_TH2F: case MonitorElement::DQM_KIND_TH2S: case MonitorElement::DQM_KIND_TH2D: + case MonitorElement::DQM_KIND_TH2Poly: case MonitorElement::DQM_KIND_TH2I: case MonitorElement::DQM_KIND_TH3F: case MonitorElement::DQM_KIND_TPROFILE: @@ -1135,6 +1136,7 @@ extend(VisDQMIndex &ix, case MonitorElement::DQM_KIND_TH2F: case MonitorElement::DQM_KIND_TH2S: case MonitorElement::DQM_KIND_TH2D: + case MonitorElement::DQM_KIND_TH2Poly: case MonitorElement::DQM_KIND_TH2I: case MonitorElement::DQM_KIND_TH3F: case MonitorElement::DQM_KIND_TPROFILE: @@ -1366,6 +1368,7 @@ readFileStream(FileInfo &fi, case MonitorElement::DQM_KIND_TH2S: case MonitorElement::DQM_KIND_TH2I: case MonitorElement::DQM_KIND_TH2D: + case MonitorElement::DQM_KIND_TH2Poly: case MonitorElement::DQM_KIND_TH3F: case MonitorElement::DQM_KIND_TPROFILE: case MonitorElement::DQM_KIND_TPROFILE2D: @@ -1493,6 +1496,7 @@ readFileStreamProtocolBuffer(FileInfo &fi, case MonitorElement::DQM_KIND_TH2S: case MonitorElement::DQM_KIND_TH2I: case MonitorElement::DQM_KIND_TH2D: + case MonitorElement::DQM_KIND_TH2Poly: case MonitorElement::DQM_KIND_TH3F: case MonitorElement::DQM_KIND_TPROFILE: case MonitorElement::DQM_KIND_TPROFILE2D: diff --git a/src/cpp/DQM/serverext.cc b/src/cpp/DQM/serverext.cc index 31a7de6..da5997b 100644 --- a/src/cpp/DQM/serverext.cc +++ b/src/cpp/DQM/serverext.cc @@ -945,14 +945,15 @@ static void objectToJSON(const std::string &name, const std::string &path, : type == DQMNet::DQM_PROP_TYPE_TH2F ? "TH2F" : type == DQMNet::DQM_PROP_TYPE_TH2S ? "TH2S" : type == DQMNet::DQM_PROP_TYPE_TH2I ? "TH2I" - : type == DQMNet::DQM_PROP_TYPE_TH2D ? "TH2D" - : type == DQMNet::DQM_PROP_TYPE_TH3F ? "TH3F" - : type == DQMNet::DQM_PROP_TYPE_TH3S ? "TH3S" - : type == DQMNet::DQM_PROP_TYPE_TH3D ? "TH3D" - : type == DQMNet::DQM_PROP_TYPE_TPROF ? "TPROF" - : type == DQMNet::DQM_PROP_TYPE_TPROF2D ? "TPROF2D" - : type == DQMNet::DQM_PROP_TYPE_DATABLOB ? "DATABLOB" - : "OTHER") + : type == DQMNet::DQM_PROP_TYPE_TH2Poly ? "TH2Poly" + : type == DQMNet::DQM_PROP_TYPE_TH2D ? "TH2D" + : type == DQMNet::DQM_PROP_TYPE_TH3F ? "TH3F" + : type == DQMNet::DQM_PROP_TYPE_TH3S ? "TH3S" + : type == DQMNet::DQM_PROP_TYPE_TH3D ? "TH3D" + : type == DQMNet::DQM_PROP_TYPE_TPROF ? "TPROF" + : type == DQMNet::DQM_PROP_TYPE_TPROF2D ? "TPROF2D" + : type == DQMNet::DQM_PROP_TYPE_DATABLOB ? "DATABLOB" + : "OTHER") .arg((unsigned long)lumisect) .arg((report & DQMNet::DQM_PROP_REPORT_ALARM) ? 1 : 0) .arg((report & DQMNet::DQM_PROP_REPORT_ERROR) ? 1 : 0)