Skip to content

Commit

Permalink
Implement TH2Poly in DQM GUI
Browse files Browse the repository at this point in the history
  • Loading branch information
ywkao committed May 24, 2023
1 parent 33172c3 commit faf05ce
Show file tree
Hide file tree
Showing 11 changed files with 144 additions and 29 deletions.
4 changes: 4 additions & 0 deletions src/cpp/DQM/DQMNet.cc
Original file line number Diff line number Diff line change
Expand Up @@ -346,6 +346,10 @@ DQMNet::reinstateObject(DQMStore *store, Object &o)
obj = store->book2DD(name, dynamic_cast<TH2D *>(o.object));
break;

case DQM_PROP_TYPE_TH2Poly:
obj = store->book2DPoly(name, dynamic_cast<TH2Poly *>(o.object));
break;

case DQM_PROP_TYPE_TH3F:
obj = store->book3D(name, dynamic_cast<TH3F *>(o.object));
break;
Expand Down
41 changes: 21 additions & 20 deletions src/cpp/DQM/DQMNet.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
34 changes: 34 additions & 0 deletions src/cpp/DQM/DQMStore.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down Expand Up @@ -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)
{
Expand Down Expand Up @@ -2254,6 +2272,17 @@ DQMStore::extract(TObject *obj, const std::string &dir,
collate2DD(me, h, verbose_);
refcheck = me;
}
else if (TH2Poly *h = dynamic_cast<TH2Poly *>(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<TH3F *>(obj))
{
MonitorElement *me = findObject(dir, h->GetName());
Expand Down Expand Up @@ -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);
Expand Down
9 changes: 9 additions & 0 deletions src/cpp/DQM/DQMStore.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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);
Expand All @@ -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);
Expand Down
44 changes: 44 additions & 0 deletions src/cpp/DQM/MonitorElement.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -116,6 +117,12 @@ MonitorElement::initialise(Kind kind, TH1 *rootobj)
object_ = rootobj;
break;

case DQM_KIND_TH2Poly:
assert(dynamic_cast<TH2Poly *>(rootobj));
assert(! reference_ || dynamic_cast<TH2Poly *>(reference_));
object_ = rootobj;
break;

case DQM_KIND_TH3F:
assert(dynamic_cast<TH3F *>(rootobj));
assert(! reference_ || dynamic_cast<TH3F *>(reference_));
Expand Down Expand Up @@ -334,6 +341,7 @@ MonitorElement::Fill(double x, double yw)
static_cast<TH2S *>(accessRootObject(__PRETTY_FUNCTION__, 2))
->Fill(x, yw, 1);
else if (kind() == DQM_KIND_TH2D) static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1);
else if (kind() == DQM_KIND_TH2Poly) static_cast<TH2Poly *>(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1);
else if (kind() == DQM_KIND_TH2I) static_cast<TH2I *>(accessRootObject(__PRETTY_FUNCTION__, 2))->Fill(x, yw, 1);
else if (kind() == DQM_KIND_TPROFILE)
static_cast<TProfile *>(accessRootObject(__PRETTY_FUNCTION__, 1))
Expand Down Expand Up @@ -430,6 +438,9 @@ MonitorElement::Fill(double x, double y, double zw)
else if (kind() == DQM_KIND_TH2D)
static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2))
->Fill(x, y, zw);
else if (kind() == DQM_KIND_TH2Poly)
static_cast<TH2Poly *>(accessRootObject(__PRETTY_FUNCTION__, 2))
->Fill(x, y, zw);
else if (kind() == DQM_KIND_TH3F)
static_cast<TH3F *>(accessRootObject(__PRETTY_FUNCTION__, 2))
->Fill(x, y, zw, 1);
Expand Down Expand Up @@ -1128,6 +1139,20 @@ MonitorElement::softReset(void)
r->Add(orig);
orig->Reset();
}
else if (kind() == DQM_KIND_TH2Poly)
{
TH2Poly *orig = static_cast<TH2Poly *>(object_);
TH2Poly *r = static_cast<TH2Poly *>(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<TH3F *>(object_);
Expand Down Expand Up @@ -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<TH1 *>(object_);
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1539,6 +1566,14 @@ MonitorElement::getTH2D(void) const
return static_cast<TH2D *>(accessRootObject(__PRETTY_FUNCTION__, 2));
}

TH2Poly *
MonitorElement::getTH2Poly(void) const
{
assert(kind() == DQM_KIND_TH2Poly);
const_cast<MonitorElement *>(this)->update();
return static_cast<TH2Poly *>(accessRootObject(__PRETTY_FUNCTION__, 2));
}

TH3F *
MonitorElement::getTH3F(void) const
{
Expand Down Expand Up @@ -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<MonitorElement *>(this)->update();
return static_cast<TH2Poly *>
(checkRootObject(data_.objname, reference_, __PRETTY_FUNCTION__, 2));
}

TH3F *
MonitorElement::getRefTH3F(void) const
{
Expand Down
5 changes: 5 additions & 0 deletions src/cpp/DQM/MonitorElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -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 <sys/time.h>
# include <string>
# include <set>
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand All @@ -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;
Expand Down
12 changes: 12 additions & 0 deletions src/cpp/DQM/QTest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
1 change: 1 addition & 0 deletions src/cpp/DQM/VisDQMIndex.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion src/cpp/DQM/VisDQMTools.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
4 changes: 4 additions & 0 deletions src/cpp/DQM/index.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down
17 changes: 9 additions & 8 deletions src/cpp/DQM/serverext.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit faf05ce

Please sign in to comment.