34 TRootEmbeddedCanvas(
"onmon_report",
45 this->GetCanvas()->SetRightMargin(0.12);
46 this->GetCanvas()->Draw();
47 this->GetCanvas()->AddExec(
"ex1",
"om::PlotViewer::Exec()");
56 int evti = gPad->GetEvent();
57 bool single_click = (evti==1);
58 bool double_click = (evti==61);
59 if (!(single_click||double_click))
return;
82 om::cout <<
"ERROR: Could not get histogram data " 99 if (hd->fType==
kTH1F) {
105 if (hd->fType==
kTH2F) {
119 gStyle->SetPalette(2,palette);
121 else gStyle->SetPalette(1);
123 this->GetCanvas()->cd();
124 this->GetCanvas()->Clear();
130 if (hd->fType==
kTH1F) {
133 om::cout <<
"ERROR: Could not get copy of histogram " 140 h->SetLineColor(kBlack);
141 h->SetFillColor(
kGreen-10);
144 this->GetCanvas()->Update();
152 if (hd->fType==
kTH2F) {
155 om::cout <<
"ERROR: Could not get copy of histogram " 164 h->GetYaxis()->SetTickLength(0);
165 h->GetYaxis()->SetLabelColor(0);
173 this->GetCanvas()->Update();
184 om::cout <<
"ERROR: Histogram Source not defined" 189 om::cout <<
"ERROR: Current Histogram not defined" 212 gStyle->SetPalette(1);
214 this->GetCanvas()->cd();
215 this->GetCanvas()->Clear();
221 if (hd->fType==
kTH1F) {
231 CompareHistoName +=
"_prev_";
233 switch (hd->fReset) {
241 CompareHistoName +=
tag;
245 CompareHistoName += LB;
252 om::cout <<
"ERROR: Could not get copy of current histogram " 257 h1->SetName(
"ComparisonHistogram");
261 h2 =
f1.GetTH1FCopy(CompareHistoName.c_str());
263 h2 =
f2.GetTH1FCopy(CompareHistoName.c_str());
265 om::cout <<
"ERROR: Could not get copy of reference histogram " 277 double area1 = h1->Integral();
278 double area2 = h2->Integral();
283 unsigned int NXbins = h1->GetNbinsX();
286 double peak1 = -1.0e9;
287 double peak2 = -1.0e9;
289 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
290 bin1 = h1->GetBinContent(
i);
291 bin2 = h2->GetBinContent(
i);
292 if(bin1 > peak1) peak1 = bin1;
293 if(bin2 > peak2) peak2 = bin2;
313 h1->SetTitle(
"Overlay Plot: (black = current histo, red = comparison histo)");
315 h1->SetLineColor(kBlack);
316 h2->SetLineColor(
kRed);
327 unsigned int NXbins = h1->GetNbinsX();
333 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
334 bin1 = h1->GetBinContent(
i);
335 bin2 = h2->GetBinContent(
i);
337 err =
sqrt(bin1+bin2);
338 h1->SetBinContent(
i,fill);
339 h1->SetBinError(
i,err);
346 h1->SetTitle(
"Difference Comparison: (current - reference)");
357 unsigned int NXbins = h1->GetNbinsX();
363 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
364 bin1 = h1->GetBinContent(
i);
365 bin2 = h2->GetBinContent(
i);
366 if(bin2 == 0.0) fill = 0.0;
367 else fill = bin1/bin2;
368 err =
sqrt(bin1+bin2);
369 h1->SetBinContent(
i,fill);
370 h1->SetBinError(
i,err);
376 h1->SetTitle(
"Ratio Comparison: (current/reference)");
385 unsigned int NXbins = h1->GetNbinsX();
391 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
392 bin1 = h1->GetBinContent(
i);
393 bin2 = h2->GetBinContent(
i);
394 if(bin1 == 0.0 && bin2 == 0.0) fill = 0.0;
395 else fill = (bin1-bin2)/(bin1+bin2);
396 err =
sqrt(bin1+bin2);
397 h1->SetBinContent(
i,fill);
398 h1->SetBinError(
i,err);
404 h1->SetTitle(
"Asymmetry Comparison: (current - reference)/(current + reference)");
412 unsigned int NXbins = h1->GetNbinsX();
418 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
419 bin1 = h1->GetBinContent(
i);
420 bin2 = h2->GetBinContent(
i);
421 if(bin2 == 0.0) fill = 0.0;
422 else fill = (bin1-bin2)/
sqrt(bin2);
423 err =
sqrt(bin1+bin2);
424 h1->SetBinContent(
i,fill);
425 h1->SetBinError(
i,err);
432 h1->SetTitle(
"Chi Comparison: (current - reference)/Sqrt(reference)");
441 unsigned int NXbins = h1->GetNbinsX();
443 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
444 h1->SetBinContent(
i,h2->GetBinContent(
i));
450 h1->SetTitle(
"Reference Histogram");
466 h2->DrawCopy(
"same");
468 this->GetCanvas()->Update();
481 if (hd->fType==
kTH2F) {
488 CompareHistoName +=
"_prev_";
490 switch (hd->fReset) {
498 CompareHistoName +=
tag;
502 CompareHistoName += LB;
509 om::cout <<
"ERROR: Could not get copy of current histogram " 514 h1->SetName(
"ComparisonHistogram");
518 h2 =
f1.GetTH2FCopy(CompareHistoName.c_str());
520 h2 =
f2.GetTH2FCopy(CompareHistoName.c_str());
522 om::cout <<
"ERROR: Could not get copy of reference histogram " 534 double area1 = h1->Integral();
535 double area2 = h2->Integral();
540 unsigned int NXbins = h1->GetNbinsX();
541 unsigned int NYbins = h1->GetNbinsY();
544 double peak1 = -1.0e9;
545 double peak2 = -1.0e9;
547 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
548 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
549 bin1 = h1->GetBinContent(
i,
j);
550 bin2 = h2->GetBinContent(
i,
j);
551 if(bin1 > peak1) peak1 = bin1;
552 if(bin2 > peak2) peak2 = bin2;
572 h2->GetXaxis()->SetAxisColor(0);
573 h2->GetYaxis()->SetAxisColor(0);
574 h2->GetXaxis()->SetLabelColor(0);
575 h2->GetYaxis()->SetLabelColor(0);
576 h2->GetXaxis()->SetTickLength(0);
577 h2->GetYaxis()->SetTickLength(0);
581 h2->SetLineColor(
kRed);
583 h1->SetTitle(
"Overlay Plot: (colz = current histo, box = comparison histo)");
601 unsigned int NXbins = h1->GetNbinsX();
602 unsigned int NYbins = h1->GetNbinsY();
608 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
609 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
610 bin1 = h1->GetBinContent(
i,
j);
611 bin2 = h2->GetBinContent(
i,
j);
613 err =
sqrt(bin1+bin2);
614 h1->SetBinContent(
i,
j,fill);
615 h1->SetBinError(
i,
j,err);
622 h1->SetTitle(
"Difference Comparison: (current - reference)");
632 unsigned int NXbins = h1->GetNbinsX();
633 unsigned int NYbins = h1->GetNbinsY();
639 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
640 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
641 bin1 = h1->GetBinContent(
i,
j);
642 bin2 = h2->GetBinContent(
i,
j);
643 if(bin2 == 0.0) fill = 0.0;
644 else fill = bin1/bin2;
645 err =
sqrt(bin1+bin2);
646 h1->SetBinContent(
i,
j,fill);
647 h1->SetBinError(
i,
j,err);
654 h1->SetTitle(
"Ratio Comparison: (current/reference)");
660 unsigned int NXbins = h1->GetNbinsX();
661 unsigned int NYbins = h1->GetNbinsY();
667 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
668 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
669 bin1 = h1->GetBinContent(
i,
j);
670 bin2 = h2->GetBinContent(
i,
j);
671 if(bin1 == 0.0 && bin2 == 0.0) fill = 0.0;
672 else fill = (bin1-bin2)/(bin1+bin2);
673 err =
sqrt(bin1+bin2);
674 h1->SetBinContent(
i,
j,fill);
675 h1->SetBinError(
i,
j,err);
682 h1->SetTitle(
"Asymmetry Comparison: (current - reference)/(current + reference)");
690 unsigned int NXbins = h1->GetNbinsX();
691 unsigned int NYbins = h1->GetNbinsY();
697 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
698 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
699 bin1 = h1->GetBinContent(
i,
j);
700 bin2 = h2->GetBinContent(
i,
j);
701 if(bin2 == 0.0) fill = 0.0;
702 else fill = (bin1-bin2)/
sqrt(bin2);
703 err =
sqrt(bin1+bin2);
704 h1->SetBinContent(
i,
j,fill);
705 h1->SetBinError(
i,
j,err);
713 h1->SetTitle(
"Chi Comparison: (current - reference)/Sqrt(reference)");
722 unsigned int NXbins = h1->GetNbinsX();
723 unsigned int NYbins = h1->GetNbinsY();
725 for(
unsigned int i = 1;
i <= NXbins; ++
i) {
726 for(
unsigned int j = 1;
j <= NYbins; ++
j) {
727 h1->SetBinContent(
i,
j,h2->GetBinContent(
i,
j));
734 h1->SetTitle(
"Reference Histogram");
750 h2->DrawCopy(
"box:same");
752 this->GetCanvas()->Update();
770 this->GetCanvas()->cd();
771 this->GetCanvas()->Clear();
774 om::cout <<
"ERROR: Could not get copy of histogram " 782 double mx = h->GetMaximum();
783 double mn = h->GetMinimum();
785 if(mx > 0.0) mx = 1.3*mx;
787 if(mn > 0.0) mn = 0.7*mn;
791 if (mx>0.0) mx =
log10(mx);
793 if (mn>0.0) mn =
log10(mn);
804 sprintf(buff,
"%s;log10(content);number of bins",hd->
fName.c_str());
807 sprintf(buff,
"%s;content;number of bins",hd->
fName.c_str());
809 htmp =
new TH1F(
"htmp",buff,100,mn,mx);
810 htmp->SetLineColor(kBlack);
811 htmp->SetFillColor(
kGreen-10);
814 for (i=1; i<=h->GetNbinsX(); ++
i) {
815 double c = h->GetBinContent(i);
816 double e = h->GetBinError(i);
818 if (dolog) c =
log10(c);
824 if (c != 0.0 || e != 0.0)
828 this->GetCanvas()->Update();
843 this->GetCanvas()->cd();
844 this->GetCanvas()->Clear();
847 om::cout <<
"ERROR: Could not get copy of histogram " 855 double mx = h->GetMaximum();
856 double mn = h->GetMinimum();
858 if(mx > 0.0) mx = 1.3*mx;
860 if(mn > 0.0) mn = 0.7*mn;
864 if (mx>0.0) mx =
log10(mx);
866 if (mn>0.0) mn =
log10(mn);
877 sprintf(buff,
"%s;log10(content);number of bins",hd->
fName.c_str());
880 sprintf(buff,
"%s;content;number of bins",hd->
fName.c_str());
885 htmp =
new TH1F(
"htmp",buff,nBins,mn,mx);
886 htmp->SetFillColor(
kGreen-10);
889 for (i=1; i<=h->GetNbinsX(); ++
i) {
890 for (j=1; j<=h->GetNbinsY(); ++
j) {
891 double c = h->GetBinContent(i,j);
892 double e = h->GetBinError(i,j);
894 if (dolog) c =
log10(c);
900 if (c != 0.0 || e != 0.0)
905 this->GetCanvas()->Update();
916 if (this->
GetLock()==
false)
return;
927 if ( (which & kComparisonUpdateID) ) {
936 this->GetCanvas()->Print(n.c_str());
937 om::cout <<
"Printed to file " << n <<
"";
unsigned int fWhich
Which histo. to compare to?
void DoubleClick(const PlotOptions &plotopt)
unsigned int fLookBack
Which "look back" histogram to compare to?
const HistoData * LookUp(const char *nm) const
static const unsigned int kCurrentHistogramID
bool fFEButc
Draw lines for FEB vs. hour plots.
void UpdateCompare(const ComparisonOptions &COpt)
void ContentProjectionTH2F(const HistoData *hd, TH2F *h)
Base class for subscribers to ticker updates.
void ContentProjectionTH1F(const HistoData *hd, TH1F *h)
Class to read, hold, and deliver histogram data.
static const unsigned int kPrintID
static const unsigned int kComparisonUpdateID
ComparisonOptions fComparisonOpt
static GUIModel & Instance()
static PlotViewer * gsPlotViewer
void Set(const std::vector< std::string > &opt)
std::string fName
C++ name of this histogram.
void SingleClick(const PlotOptions &plotopt)
std::string fCurrentHistogram
What histogram is being shown?
std::string fHistogramSource
Source to pull histograms from.
unsigned int fMethod
How to show the comparison?
bool fAlert
Draw histo in "alert" mode.
const char * Current() const
static const unsigned int kHistogramSourceID
PlotOptions fPlotOpt
Options for plotting.
std::string fHistogramSource
CurrentHistogram fCurrentHistogram
bool fDCMutc
Draw lines for DCM vs. hour plots.
bool fSpecial
Draw a special case histo label.
void fill(std::vector< T > &x, const S &y)
void GUIModelDataIssue(const GUIModelData &m, unsigned int which)
unsigned int fContentProjection
static HistoTable & Instance(const char *f=0, Detector_t d=kALLDET)
unsigned int fNormalize
How to normalize the histos?
std::string fReferenceFile
Reference file for comparison histograms.
const XML_Char XML_Content * model
const GUIModelData & Data() const
Canvas on which plots and reports are drawn.
Online Monitoring package header.
static const unsigned int kPlotViewRefreshID
void MakeLabels(const TH1 *h, const HistoData *hd)