9#include <dqm/analysis/modules/DQMHistAnalysisTOP.h>
10#include <boost/format.hpp>
11#include <boost/algorithm/string.hpp>
17#include <TProfile2D.h>
55 "boarstacks to be excluded from alarming. Names are given like '5c', '13d' etc.",
m_excludedBoardstacks);
60 "alarm levels for time distribution (residual fraction w.r.t reference plot)",
m_timingAlarmLevels);
70 B2DEBUG(20,
"DQMHistAnalysisTOP: Constructor done.");
82 if (
m_asicWindowsBand.size() != 2) B2ERROR(
"Parameter list 'asicWindowsBand' must contain two numbers");
83 if (
m_asicWindowsAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'asicWindowsAlarmLevels' must contain two numbers");
85 if (
m_junkHitsAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'junkHitsAlarmLevels' must contain two numbers");
87 if (
m_backgroundAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'backgroundAlarmLevels' must contain two numbers");
89 if (
m_injectionBGAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'injectionBGAlarmLevels' must contain two numbers");
90 if (
m_timingAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'timingAlarmLevels' must contain two numbers");
91 if (
m_eventT0MeanAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'eventT0MeanAlarmLevels' must contain two numbers");
92 if (
m_eventT0RmsAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'eventT0RmsAlarmLevels' must contain two numbers");
93 if (
m_offsetMeanAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'offsetMeanAlarmLevels' must contain two numbers");
94 if (
m_offsetRmsAlarmLevels.size() != 2) B2ERROR(
"Parameter list 'offsetRmsAlarmLevels' must contain two numbers");
99 for (
int slot = 1; slot <= 16; slot++) {
100 string slotstr = to_string(slot);
101 for (std::string bs : {
"a",
"b",
"c",
"d"}) {
149 m_deadFraction =
new TH1F(
"TOP/deadFraction",
"Fraction of dead channels in included boardstacks", 16, 0.5, 16.5);
152 m_hotFraction =
new TH1F(
"TOP/hotFraction",
"Fraction of hot channels in included boardstacks", 16, 0.5, 16.5);
155 m_excludedFraction =
new TH1F(
"TOP/excludedFraction",
"Fraction of hot and dead channels in excluded bordstacks", 16, 0.5, 16.5);
158 m_activeFraction =
new TH1F(
"TOP/activeFraction",
"Fraction of active channels", 16, 0.5, 16.5);
161 m_c_deadAndHot =
new TCanvas(
"TOP/c_deadAndHotChannels",
"c_deadAndHotChannels");
163 m_junkFraction =
new TH1F(
"TOP/junkFraction",
"Fraction of junk hits per boardstack", 64, 0.5, 16.5);
167 m_excludedBSHisto =
new TH1F(
"TOP/excludedBSHisto",
"Fraction of junk hits per boardstack", 64, 0.5, 16.5);
172 for (
int slot = 1; slot <= 16; slot++) {
173 string hname =
"TOP/pmtHitRates_" + to_string(slot);
174 string htitle =
"PMT hits per event for slot #" + to_string(slot);
175 auto* h =
new TH1F(hname.c_str(), htitle.c_str(), 32, 0.5, 32.5);
176 h->SetXTitle(
"PMT number");
177 h->SetYTitle(
"Number of good hits per event");
179 string cname =
"TOP/c_pmtHitRates_" + to_string(slot);
180 string ctitle =
"c_pmtHitRates_" + to_string(slot);
184 for (std::string name : {
185 "nhitInjLER",
"nhitInjHER",
"nhitInjLERcut",
"nhitInjHERcut",
186 "eventInjLER",
"eventInjHER",
"eventInjLERcut",
"eventInjHERcut"
188 for (std::string proj : {
"_px",
"_py"}) {
189 std::string cname =
"TOP/c_" + name + proj;
190 m_c_injBGs[cname] =
new TCanvas(cname.c_str(), (name + proj).c_str());
194 m_text1 =
new TPaveText(0.125, 0.8, 0.675, 0.88,
"NDC");
195 m_text1->SetFillColorAlpha(kWhite, 0);
197 m_text2 =
new TPaveText(0.55, 0.8, 0.85, 0.89,
"NDC");
198 m_text2->SetFillColorAlpha(kWhite, 0);
200 m_text3 =
new TPaveText(0.47, 0.8, 0.85, 0.89,
"NDC");
201 m_text3->SetFillColorAlpha(kWhite, 0);
203 m_text4 =
new TPaveText(0.125, 0.8, 0.675, 0.88,
"NDC");
204 m_text4->SetFillColorAlpha(kWhite, 0);
207 for (
int slot = 1; slot < 16; slot++) {
208 auto* line =
new TLine(slot + 0.5, 0, slot + 0.5, 1);
209 line->SetLineWidth(1);
210 line->SetLineStyle(2);
216 B2DEBUG(20,
"DQMHistAnalysisTOP: initialized.");
224 B2DEBUG(20,
"DQMHistAnalysisTOP: beginRun called.");
231 auto* rtype =
findHist(
"DQMInfo/rtype");
232 m_runType = rtype ? rtype->GetTitle() :
"";
236 auto* goodHitsPerEvent =
findHist(
"TOP/goodHitsPerEventAll");
237 m_numEvents = goodHitsPerEvent ? goodHitsPerEvent->GetEntries() : 0;
239 bool zeroSupp = gStyle->GetHistMinimumZero();
240 gStyle->SetHistMinimumZero(
true);
280 auto* trackHits = (TH2F*)
findHist(
"TOP/trackHits");
282 for (
int slot = 1; slot <= 16; slot++) {
299 gStyle->SetHistMinimumZero(zeroSupp);
313 B2DEBUG(20, var.first <<
" " << var.second);
316 B2DEBUG(20,
"DQMHistAnalysisTOP : endRun called");
322 B2DEBUG(20,
"terminate called");
328 int alarmState = c_Gray;
331 auto* hraw = (TH2F*)
findHist(
"TOP/window_vs_slot");
333 auto* px = hraw->ProjectionX(
"tmp_px");
335 band->Add(px, band, 1, -1);
336 double total = px->Integral();
337 double totalWindowFraction = (total != 0) ? band->Integral() / total : 0;
338 band->Divide(band, px);
343 m_text1->AddText(Form(
"Fraction outside red lines: %.2f %%", totalWindowFraction * 100.0));
351 auto* canvas =
findCanvas(
"TOP/c_window_vs_slot");
355 if (hraw) hraw->Draw();
358 canvas->Pad()->SetFrameFillColor(10);
367 int alarmState = c_Gray;
370 auto* evtMonitor = (TH1F*)
findHist(
"TOP/BoolEvtMonitor");
372 double totalEvts = evtMonitor->Integral();
373 double badEvts = evtMonitor->GetBinContent(2);
375 double badRatio = badEvts / totalEvts;
377 m_text2->AddText(Form(
"Fraction: %.4f %%", badRatio * 100.0));
383 auto* canvas =
findCanvas(
"TOP/c_BoolEvtMonitor");
387 canvas->Pad()->SetFrameFillColor(10);
396 int alarmState = c_Gray;
402 auto* h = (TH1F*)
findHist(
"TOP/goodHitsPerEventAll");
404 double totalEvts = h->GetEntries();
405 if (totalEvts > 1000) {
407 xcut = h->GetBinCenter(h->GetMaximumBin()) + 900;
408 ymax = h->GetMaximum() / 2;
409 fract = h->Integral(h->FindBin(xcut), h->GetNbinsX() + 1) / totalEvts * 100;
411 m_text4->AddText(Form(
"Events w/ Injection BG: %.2f %%", fract));
418 auto* canvas =
findCanvas(
"TOP/c_goodHitsPerEventAll");
432 canvas->Pad()->SetFrameFillColor(10);
441 int alarmState = c_Gray;
443 auto* h = (TH1F*)
findHist(
"TOP/eventT0");
445 double totalEvts = h->GetEntries();
446 if (totalEvts > 100) {
447 double mean = h->GetMean();
448 double rms = h->GetRMS();
458 canvas->Pad()->SetFrameFillColor(10);
467 int alarmState = c_Gray;
469 auto* h = (TH1F*)
findHist(
"TOP/bunchOffset");
471 double totalEvts = h->GetEntries();
472 if (totalEvts > 100) {
473 double mean = h->GetMean();
474 double rms = h->GetRMS();
481 auto* canvas =
findCanvas(
"TOP/c_bunchOffset");
484 canvas->Pad()->SetFrameFillColor(10);
493 int alarmState = c_Gray;
495 auto* h = (TH1F*)
findHist(
"TOP/goodHitTimes");
496 auto* href = (TH1F*)
findRefHist(
"TOP/goodHitTimes");
498 double n = h->Integral();
499 double nref = href->Integral();
501 auto* h_clone = (TH1F*) h->Clone(
"tmp");
502 auto* href_clone = (TH1F*) href->Clone(
"tmpref");
503 h_clone->Scale(1 / n);
504 href_clone->Scale(1 / nref);
505 h_clone->Add(h_clone, href_clone, 1, -1);
508 for (
int i = 1; i <= h_clone->GetNbinsX(); i++) {
509 sumDiff += fabs(h_clone->GetBinContent(i));
510 errDiff += pow(h_clone->GetBinError(i), 2);
512 errDiff =
sqrt(errDiff);
513 if (sumDiff < 5 * errDiff) sumDiff = 0;
522 auto* canvas =
findCanvas(
"TOP/c_goodHitTimes");
525 canvas->Pad()->SetFrameFillColor(10);
533 if (h1->GetNbinsX() != h2->GetNbinsX())
return false;
534 if (h1->GetXaxis()->GetXmin() != h2->GetXaxis()->GetXmin())
return false;
535 if (h1->GetXaxis()->GetXmax() != h2->GetXaxis()->GetXmax())
return false;
545 double inactiveFract = 0;
547 for (
int slot = 1; slot <= 16; slot++) {
548 auto* h = (TH1F*)
findHist(
"TOP/good_channel_hits_" + std::to_string(slot));
552 double deadCut = cuts.first;
553 double hotCut = cuts.second;
554 double deadFract = 0;
556 double deadFractIncl = 0;
557 double hotFractIncl = 0;
558 for (
int chan = 0; chan < h->GetNbinsX(); chan++) {
559 double y = h->GetBinContent(chan + 1);
560 int bs = chan / 128 + (slot - 1) * 4;
564 if (included) deadFractIncl += 1;
565 }
else if (y > hotCut) {
567 if (included) hotFractIncl += 1;
570 deadFract /= h->GetNbinsX();
571 hotFract /= h->GetNbinsX();
572 deadFractIncl /= h->GetNbinsX();
573 hotFractIncl /= h->GetNbinsX();
576 m_excludedFraction->SetBinContent(slot, deadFract - deadFractIncl + hotFract - hotFractIncl);
578 inactiveFract = std::max(inactiveFract, deadFractIncl + hotFractIncl);
583 int alarmState = c_Gray;
608 canvas->Pad()->SetFrameFillColor(10);
610 m_stack =
new THStack(
"TOP/stack",
"Fraction of dead and hot channels");
621 m_legend =
new TLegend(0.8, 0.87, 0.99, 0.99);
639 canvas->Pad()->SetFrameFillColor(10);
645 auto* signalHits = (TProfile*)
findHist(
"TOP/signalHits");
646 if (not signalHits)
return;
648 auto* backgroundHits = (TProfile*)
findHist(
"TOP/backgroundHits");
649 if (not backgroundHits)
return;
655 auto* activeFract = (TH1F*) activeFraction->Clone(
"tmp");
656 for (
int i = 1; i <= activeFract->GetNbinsX(); i++) activeFract->SetBinError(i, 0);
662 int alarmState = c_Gray;
663 if (signalHits->GetEntries() > 0 and activeFraction->Integral() > 0) {
666 if (signalHits->GetBinEntries(i) < 10)
continue;
692 if (backgroundHits->GetEntries() > 100 and activeFraction->Integral() > 0) {
698 double error = fun->GetParError(0);
729 for (
int slot = 1; slot <= 16; slot++) {
730 auto* good = (TH1F*)
findHist(
"TOP/good_channel_hits_" + std::to_string(slot));
731 if (not good)
continue;
732 auto* bad = (TH1F*)
findHist(
"TOP/bad_channel_hits_" + std::to_string(slot));
733 if (not bad)
continue;
734 for (
int i = 0; i < 512; i++) {
736 allHits->Fill(slot + bs / 4. - 0.5, good->GetBinContent(i + 1) + bad->GetBinContent(i + 1));
737 m_junkFraction->Fill(slot + bs / 4. - 0.5, bad->GetBinContent(i + 1));
743 int alarmState = c_Gray;
744 if (allHits->Integral() > 0) {
758 canvas->Pad()->SetFrameFillColor(10);
777 double totalHits = 0;
778 std::vector<TH2F*> histos;
779 for (
int slot = 1; slot <= 16; slot++) {
780 TH2F* h = (TH2F*)
findHist(name + std::to_string(slot));
783 totalHits += h->Integral();
785 if (histos.empty())
return;
786 double average = totalHits / 512 / histos.size();
788 for (
auto* h : histos) h->GetZaxis()->SetRangeUser(0, std::max(average * scale, 1.0));
795 if (not canvas)
return;
797 auto* h = (TH1F*)
findHist(
"TOP/" + name);
800 auto* hb = (TH1F*)
findHist(
"TOP/" + name +
"BG");
805 double s = (slot == 0) ? trackHits->Integral(1, 16, 2, 2) : trackHits->GetBinContent(slot, 2);
807 double sb = (slot == 0) ? trackHits->Integral(1, 16, 1, 1) : trackHits->GetBinContent(slot, 1);
809 h->Add(h, hb, 1, -s / sb);
812 int i0 = h->GetXaxis()->FindBin(0.);
813 double s = h->Integral(1, i0);
815 double sb = hb->Integral(1, i0);
817 if (s / sb > 1)
return;
818 h->Add(h, hb, 1, -s / sb);
821 TString title = TString(h->GetTitle()) +
" (BG subtracted)";
833 auto* h0 = (TH1F*)
findHist(
"TOP/goodHitsPerEventAll");
835 double numEvents = h0->GetEntries();
836 if (numEvents == 0)
return;
839 for (
int slot = 1; slot <= numSlots; slot++) {
840 string name =
"TOP/good_hits_xy_" + to_string(slot);
842 if (not hxy)
continue;
843 std::vector<double> pmts(32, 0);
844 for (
int row = 0; row < 8; row++) {
845 for (
int col = 0; col < 64; col++) {
846 int pmt = col / 4 + (row / 4) * 16;
847 pmts[pmt] += hxy->GetBinContent(col + 1, row + 1);
851 for (
size_t i = 0; i < pmts.size(); i++) {
852 h->SetBinContent(i + 1, pmts[i] / numEvents);
866 for (std::string name : {
"nhitInjLER",
"nhitInjHER",
"nhitInjLERcut",
"nhitInjHERcut"}) {
867 std::string hname =
"TOP/" + name;
868 auto* h = (TProfile2D*)
findHist(hname);
870 for (std::string proj : {
"_px",
"_py"}) {
871 std::string cname =
"TOP/c_" + name + proj;
873 if (not canvas)
continue;
877 if (hproj)
delete hproj;
878 hproj = (proj ==
"_px") ? h->ProfileX((hname + proj).c_str()) : h->ProfileY((hname + proj).c_str());
879 std::string xtitle = (proj ==
"_px") ? h->GetXaxis()->GetTitle() : h->GetYaxis()->GetTitle();
880 hproj->SetXTitle(xtitle.c_str());
881 hproj->SetYTitle(h->GetZaxis()->GetTitle());
882 hproj->SetMinimum(0);
888 for (std::string name : {
"eventInjLER",
"eventInjHER",
"eventInjLERcut",
"eventInjHERcut"}) {
889 std::string hname =
"TOP/" + name;
892 for (std::string proj : {
"_px",
"_py"}) {
893 std::string cname =
"TOP/c_" + name + proj;
895 if (not canvas)
continue;
899 if (hproj)
delete hproj;
900 hproj = (proj ==
"_px") ? h->ProjectionX((hname + proj).c_str()) : h->ProjectionY((hname + proj).c_str());
901 std::string xtitle = (proj ==
"_px") ? h->GetXaxis()->GetTitle() : h->GetYaxis()->GetTitle();
902 hproj->SetXTitle(xtitle.c_str());
903 hproj->SetYTitle(h->GetZaxis()->GetTitle());
904 hproj->SetMinimum(0);
915 for (
int slot = 1; slot <= 16; slot++) {
916 auto vname = variableName + std::to_string(slot);
917 double value = histogram ? histogram->GetBinContent(slot) : 0;
928 if (value < alarmLevels[0])
return c_Green;
929 else if (value < alarmLevels[1])
return c_Yellow;
932 if (value < alarmLevels[0])
return c_Red;
933 else if (value < alarmLevels[1])
return c_Yellow;
940 std::vector<TLine*>& alarmLines,
bool bigRed)
942 std::vector<int> colors = {kOrange, kRed};
943 if (not bigRed) std::reverse(colors.begin(), colors.end());
944 for (
size_t i = 0; i < std::min(colors.size(), alarmLevels.size()); i++) {
945 if (i < alarmLines.size()) {
946 auto* line = alarmLines[i];
949 line->SetY1(alarmLevels[i]);
950 line->SetY2(alarmLevels[i]);
952 auto* line =
new TLine(xmin, alarmLevels[i], xmax, alarmLevels[i]);
953 line->SetLineWidth(2);
954 line->SetLineStyle(2);
955 line->SetLineColor(colors[i]);
956 alarmLines.push_back(line);
971 auto* line =
new TLine(0.5, y, 16.5, y);
972 line->SetLineWidth(2);
973 line->SetLineColor(kRed);
987 std::vector<double> binContents;
988 for (
int k = 1; k <= h->GetNbinsY(); k++) {
989 for (
int i = 1; i <= h->GetNbinsX(); i++) {
990 binContents.push_back(h->GetBinContent(i, k));
995 double rms = h->GetMaximum();
996 for (
int iter = 0; iter < 5; iter++) {
1000 for (
auto y : binContents) {
1001 if (y == 0 or fabs(y - mean) > 3 * rms)
continue;
1006 if (n == 0)
continue;
1008 rms =
sqrt(sumyy / n - mean * mean);
1011 return std::make_pair(mean / 5, std::max(mean * 2, mean + 6 * rms));
1017 int badBoardstacks = 0;
1018 int badCarriers = 0;
1020 for (
int slot = 1; slot <= 16; slot++) {
1021 std::string hname =
"TOP/good_hits_asics_" + to_string(slot);
1023 if (not h)
continue;
1026 double deadCut = cuts.first;
1027 double hotCut = cuts.second;
1028 std::vector<int> asics(64, 0);
1029 std::vector<int> carriers(16, 0);
1030 std::vector<int> boardstacks(4, 0);
1031 for (
int asic = 0; asic < 64; asic++) {
1032 int carrier = asic / 4;
1033 int boardstack = carrier / 4;
1034 for (
int chan = 0; chan < 8; chan++) {
1035 double y = h->GetBinContent(asic + 1, chan + 1);
1036 if (y > deadCut and y <= hotCut) {
1038 carriers[carrier]++;
1039 boardstacks[boardstack]++;
1043 for (
int n : asics)
if (n == 0) badAsics++;
1044 for (
int n : carriers)
if (n == 0) badCarriers++;
1045 for (
int n : boardstacks)
if (n == 0) badBoardstacks++;
1047 badAsics -= badCarriers * 4;
1048 badCarriers -= badBoardstacks * 4;
1051 for (
int slot = 1; slot <= 16; slot++) {
1052 std::string hname =
"TOP/good_hits_xy_" + to_string(slot);
1054 if (not h)
continue;
1057 double deadCut = cuts.first;
1058 double hotCut = cuts.second;
1059 std::vector<int> pmts(32, 0);
1060 for (
int row = 0; row < 8; row++) {
1061 for (
int col = 0; col < 64; col++) {
1062 int pmt = col / 4 + (row / 4) * 16;
1063 double y = h->GetBinContent(col + 1, row + 1);
1064 if (y > deadCut and y <= hotCut) pmts[pmt]++;
1067 for (
int n : pmts)
if (n == 0) badPMTs++;
1069 badPMTs -= badBoardstacks * 8;
1071 setEpicsPV(
"badBoardstacks", badBoardstacks);
1081 B2DEBUG(20,
"badBoardstacks: " << badBoardstacks);
1082 B2DEBUG(20,
"badCarriers: " << badCarriers);
1083 B2DEBUG(20,
"badAsics: " << badAsics);
1084 B2DEBUG(20,
"badPMTs: " << badPMTs);
1085 B2DEBUG(20,
"excludedBS: " << numBS);
1116 bool status =
false;
1122 for (
auto c : excludedBS) {
1123 if (isspace(c))
continue;
1124 else if (ispunct(c)) {
1125 if (not name.empty()) {
1129 }
else name.push_back(c);
1131 if (not name.empty()) {
1154 if (ss.size() > 2) {ss.pop_back(); ss.pop_back();}
1155 B2DEBUG(20,
"excludedBoardstacks: [" << ss <<
"]");
1164 for (
const auto& bsname : excludedBoardstacks) {
1167 else B2ERROR(
"Invalid boardstack name: " << bsname);
The base class for the histogram analysis module.
TCanvas * findCanvas(TString cname)
Find canvas by name.
static TH1 * findRefHist(const std::string &histname, ERefScaling scaling=ERefScaling::c_RefScaleNone, const TH1 *hist=nullptr)
Get referencehistogram from list (no other search).
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
std::string getEpicsStringPV(std::string keyname, bool &status)
Read value from a EPICS PV.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
void updateEventMonitorCanvas()
Updates canvas of event desynchronization monitor w/ alarming.
std::vector< int > m_asicWindowsBand
lower and upper bin of a band denoting good windows
void setZAxisRange(const std::string &name, double scale)
Sets z-axis range of 2D histograms.
TCanvas * m_c_photonYields
Canvas: photon yields per slot.
std::vector< double > m_offsetRmsAlarmLevels
alarm levels for r.m.s.
void initialize() override final
Initializer.
void makePMTHitRatesPlots()
Makes plots of the number of PMT hits per event.
TH1F * m_excludedFraction
fraction of dead and hot channels per slot in excluded boardstacks only
void updateEventT0Canvas()
Updates canvas of event T0 w/ alarming.
std::vector< double > m_deadChannelsAlarmLevels
alarm levels for the fraction of dead + hot channels
std::vector< double > m_asicWindowsAlarmLevels
alarm levels for fraction of windows outside the band
TPaveText * m_text2
text to be written to event desynchonization monitor
TCanvas * m_c_junkFraction
Canvas: fraction of junk hits per boardstack.
THStack * m_stack
stack for drawing dead, hot and active channel fractions
const TH1F * makeDeadAndHotFractionsPlot()
Makes a plot of dead and hot channel fractions per slot.
void makeBGSubtractedTimingPlot(const std::string &name, const TH2F *trackHits, int slot)
Makes background subtracted time distribution plot.
void updateTimingCanvas()
Updates canvas of timing plot w/ alarming.
TPaveText * m_text3
text to be written to background rates
~DQMHistAnalysisTOPModule()
Destructor.
std::vector< TLine * > m_deadChannelsAlarmLines
lines representing alarm levels
std::vector< TCanvas * > m_c_pmtHitRates
Canvases of PMT hits per event (index = slot - 1)
int m_alarmStateOverall
overall alarm state of histograms to be sent by EpicsPV
TPaveText * m_text1
text to be written to window_vs_slot
std::vector< TLine * > m_photonYieldsAlarmLines
lines representing alarm levels
std::pair< double, double > getDeadAndHotCuts(const TH1 *h)
Returns cut levels for dead and hot channels.
std::vector< double > m_offsetMeanAlarmLevels
alarm levels for mean of bunch offset [ns]
std::vector< bool > m_includedBoardstacks
boardstacks included in alarming
bool sameHistDefinition(TH1 *h1, TH1 *h2)
Checks if histograms are defined in the same way (nbins, xmin, xmax)
TPaveText * m_text4
text to be written to number of good hits per event
std::vector< TLine * > m_verticalLines
vertical lines splitting slots
std::string m_pvPrefix
Epics PV prefix.
TH1D * m_photonYields
photon yields per slot
TH1D * m_backgroundRates
background rates per slot
MonitoringObject * m_monObj
MiraBelle monitoring object.
TCanvas * m_c_backgroundRates
Canvas: background rates per slot.
std::map< std::string, TCanvas * > m_c_injBGs
Canvases for projections of injection BG histograms.
std::vector< double > m_eventMonitorAlarmLevels
alarm levels for fraction of desynchronized digits
void terminate() override final
This method is called at the end of the event processing.
std::map< std::string, double > m_mirabelleVariables
variables for MiraBelle
void setAlarmLines()
Sets all alarm lines.
TH1F * m_activeFraction
fraction of active channels per slot
int getAlarmColor(unsigned alarmState) const
Converts alarm state to color.
std::vector< double > m_eventT0MeanAlarmLevels
alarm levels for mean of event T0 [ns]
void event() override final
This method is called for each event.
std::string m_runType
Run type.
void makeInjectionBGPlots()
Makes projections of injection BG plots.
std::vector< double > m_photonYieldsAlarmLevels
alarm levels for the number of photons per track
std::vector< TLine * > m_junkHitsAlarmLines
lines representing alarm levels
void setIncludedBoardstacks(const std::vector< std::string > &excludedBoardstacks)
Sets flags for boardstacks to be included in alarming.
std::vector< double > m_injectionBGAlarmLevels
alarm levels for injection background (in % of events)
TH1F * m_deadFraction
fraction of dead channels per slot (included boardstacks only)
double m_averageRate
average BG rate (to pass to EpicsPV)
TH1F * m_hotFraction
fraction of hot channels per slot (included boardstacks only)
std::vector< std::string > m_excludedBoardstacks
list of boarstacks to be excluded from alarming
void makePhotonYieldsAndBGRatePlots(const TH1F *activeFraction)
Make plots of dead-and-hot-channel corrected photon yields and BG rates per slot.
TH1F * m_junkFraction
fraction of junk hits per boardstack
void endRun() override final
This method is called if the current run ends.
int getAlarmState(double value, const std::vector< double > &alarmLevels, bool bigRed=true) const
Returns alarm state.
std::vector< double > m_eventT0RmsAlarmLevels
alarm levels for r.m.s.
std::vector< TLine * > m_asicWindowsBandLines
lines denoting a band of good windows
void makeJunkFractionPlot()
Makes a plot of fractions of junk hits per boardstack.
void beginRun() override final
Called when entering a new run.
TLegend * m_legend
legend for dead and hot channels
TCanvas * m_c_deadAndHot
Canvas: fractin of dead and hot channels.
std::vector< TLine * > m_backgroundAlarmLines
lines representing alarm levels
DQMHistAnalysisTOPModule()
Constructor.
void updateWindowVsSlotCanvas()
Updates canvas of window_vs_slot w/ alarming.
double m_numEvents
number of events processed with TOPDQM module
std::map< std::string, int > m_bsmap
a map of boardstack names to ID's
std::vector< double > m_backgroundAlarmLevels
alarm levels for background rates [MHz/PMT]
std::map< std::string, TH1D * > m_projections
projections of injection BG
void updateBunchOffsetCanvas()
Updates canvas of bunch offset w/ alarming.
void setEpicsVariables()
Calculates and sets epics variables.
std::vector< double > m_junkHitsAlarmLevels
alarm levels for the fraction of junk hits
bool m_IsNullRun
Run type flag for null runs.
void updateNGoodHitsCanvas()
Updates canvas of number of good hits per event w/ alarming (injection BG)
TLine * m_injBGCutLine
a line denoting the cut on the number of hits for injection BG counting
std::vector< double > m_timingAlarmLevels
alarm levels for time distribution (fraction of area difference)
int getOffcialAlarmStatus(unsigned alarmState) const
Converts alarm state to official status (see EStatus of the base class)
std::vector< TH1F * > m_pmtHitRates
histograms of PMT hits per event (index = slot - 1)
TH1F * m_excludedBSHisto
histogram to show excluded boardstacks on junk fraction plot
std::map< std::string, TProfile * > m_profiles
profiles of injection BG
void updateLimits()
Updates limits defined by module parameters using EpicsPVs.
void setMiraBelleVariables(const std::string &variableName, const TH1 *histogram)
Sets MiraBelle variables from the histogram with bins corresponding to slot numbers.
void setDescription(const std::string &description)
Sets the description of the module.
void setVariable(const std::string &var, float val, float upErr=-1., float dwErr=-1)
set value to float variable (new variable is made if not yet existing)
void addParam(const std::string &name, T ¶mVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
double sqrt(double a)
sqrt for double
Abstract base class for different kinds of events.