9#include <dqm/analysis/modules/DQMHistAnalysisTrackingAbort.h>
37 "Maximum Fraction of Events in which Tracking Aborts before turning Canvas to Red. Will be taken from Epics by default, \
40 "Minimum Number of Events before scaring CR shifters. Will be taken from Epics by default, \
41 this value is only taken if Epics is not available!",
int(
m_statThreshold));
51 double buffThreshold(NAN);
52 double buffMinEvents(NAN);
53 double dummyLowerAlarm, dummyLowerWarn, dummyUpperWarn, dummyUpperAlarm;
59 if (!std::isnan(buffThreshold)) {
60 B2INFO(
getName() <<
": Setting failure rate threshold from EPICS. New failureRateThreshold " << buffThreshold);
63 if (!std::isnan(buffMinEvents)) {
64 B2INFO(
getName() <<
": Setting min number of events threshold from EPICS. New minNoEvents " << buffMinEvents);
75 m_cAbortRate =
new TCanvas(
"TrackingAnalysis/c_TrackingAbort");
78 m_cAbortRateIN =
new TCanvas(
"TrackingAnalysis/c_TrackingAbortIN");
92 registerEpicsPV(
"trackingHLT:abortRate_inActiveVeto",
"abortRate_inActiveVeto");
93 registerEpicsPV(
"trackingHLT:abortRate_outActiveVeto",
"abortRate_outActiveVeto");
94 registerEpicsPV(
"trackingHLT:abortRateBeforeFilter",
"abortRateBeforeFilter");
95 registerEpicsPV(
"trackingHLT:abortRateBeforeFilter_inActiveVeto",
"abortRateBeforeFilter_inActiveVeto");
96 registerEpicsPV(
"trackingHLT:abortRateBeforeFilter_outActiveVeto",
"abortRateBeforeFilter_outActiveVeto");
101 std::string histoName =
"EventsWithAborts";
102 std::string histoTitle =
"Fraction of Events With at Least one Abort [After Filter]";
103 m_hAbort =
new TH1F(TString::Format(
"%s", histoName.c_str()),
104 TString::Format(
"%s", histoTitle.c_str()),
106 m_hAbort->GetYaxis()->SetTitle(
"Number of Events");
107 m_hAbort->GetXaxis()->SetBinLabel(1,
"No Abort");
108 m_hAbort->GetXaxis()->SetBinLabel(2,
"At Least One Abort");
113 histoName =
"EventsWithAborts_beforeFilter";
114 histoTitle =
"Fraction of Events With at Least one Abort [Before Filter]";
115 m_hAbort_BF =
new TH1F(TString::Format(
"%s", histoName.c_str()),
116 TString::Format(
"%s", histoTitle.c_str()),
118 m_hAbort_BF->GetYaxis()->SetTitle(
"Number of Events");
119 m_hAbort_BF->GetXaxis()->SetBinLabel(1,
"No Abort");
120 m_hAbort_BF->GetXaxis()->SetBinLabel(2,
"At Least One Abort");
129 TH1* hAbortIn =
findHist(
"TrackingAbort/EventsWithAborts_IN");
130 TH1* hAbortOut =
findHist(
"TrackingAbort/EventsWithAborts_OUT");
135 if (hAbortIn !=
nullptr && hAbortOut !=
nullptr) {
137 nEventsIN = hAbortIn->GetEntries();
139 nEventsOUT = hAbortOut->GetEntries();
141 const int nEvents = nEventsIN + nEventsOUT;
143 m_hAbort->SetBinContent(1, hAbortIn->GetBinContent(1) + hAbortOut->GetBinContent(1));
144 m_hAbort->SetBinContent(2, hAbortIn->GetBinContent(2) + hAbortOut->GetBinContent(2));
146 const double abortRate = (double)
m_hAbort->GetBinContent(2) / (
m_hAbort->GetBinContent(1) +
m_hAbort->GetBinContent(2));
147 m_hAbort->SetTitle(Form(
"[After Filter] Fraction of Events in which Tracking Aborts = %.2f %%", abortRate * 100));
153 const double abortRate_in = hAbortIn->GetMean();
155 setEpicsPV(
"abortRate_inActiveVeto", abortRate_in);
157 const double abortRate_out = hAbortOut->GetMean();
159 setEpicsPV(
"abortRate_outActiveVeto", abortRate_out);
188 TH1* hAbortIn_BF =
findHist(
"TrackingAbort_before_filter/EventsWithAborts_IN");
189 TH1* hAbortOut_BF =
findHist(
"TrackingAbort_before_filter/EventsWithAborts_OUT");
192 int nEventsOUTbf = 0;
194 if (hAbortIn_BF !=
nullptr && hAbortOut_BF !=
nullptr) {
196 nEventsINbf = hAbortIn_BF->GetEntries();
198 nEventsOUTbf = hAbortOut_BF->GetEntries();
200 const int nEvents_BF = nEventsINbf + nEventsOUTbf;
202 m_hAbort_BF->SetBinContent(1, hAbortIn_BF->GetBinContent(1) + hAbortOut_BF->GetBinContent(1));
203 m_hAbort_BF->SetBinContent(2, hAbortIn_BF->GetBinContent(2) + hAbortOut_BF->GetBinContent(2));
206 m_hAbort_BF->SetTitle(Form(
"[Before Filter] Fraction of Events in which Tracking Aborts = %.2f %%", abortRate_BF * 100));
210 setEpicsPV(
"abortRateBeforeFilter", abortRate_BF);
212 const double abortRate_in = hAbortIn_BF->GetMean();
214 setEpicsPV(
"abortRateBeforeFilter_inActiveVeto", abortRate_in);
215 const double abortRate_out = hAbortOut_BF->GetMean();
217 setEpicsPV(
"abortRateBeforeFilter_outActiveVeto", abortRate_out);
224 hAbortOut_BF->Draw();
232 TH1F* hAbortReason_in = (TH1F*)
findHist(
"TrackingAbort/TrkAbortReason_IN");
234 TH1F* hAbortReason_out = (TH1F*)
findHist(
"TrackingAbort/TrkAbortReason_OUT");
236 TH1F* hAbortReason_in_BF = (TH1F*)
findHist(
"TrackingAbort_before_filter/TrkAbortReason_IN");
237 if (hAbortReason_in_BF !=
nullptr)
scaleAndSendToMirabelle(hAbortReason_in_BF, nEventsIN,
"BeforeFilter_inActiveVeto");
238 TH1F* hAbortReason_out_BF = (TH1F*)
findHist(
"TrackingAbort_before_filter/TrkAbortReason_OUT");
239 if (hAbortReason_out_BF !=
nullptr)
scaleAndSendToMirabelle(hAbortReason_out_BF, nEventsOUT,
"BeforeFilter_outActiveVeto");
243 TH1F* hAverage_in = (TH1F*)
findHist(
"TrackingAbort/averages_IN");
246 TH1F* hAverage_out = (TH1F*)
findHist(
"TrackingAbort/averages_OUT");
249 TH1F* hAverage_in_BF = (TH1F*)
findHist(
"TrackingAbort_before_filter/averages_IN");
250 if (hAverage_in_BF !=
nullptr)
scaleAndSendToMirabelle(hAverage_in_BF, nEventsINbf,
"BeforeFilter_inActiveVeto");
252 TH1F* hAverage_out_BF = (TH1F*)
findHist(
"TrackingAbort_before_filter/averages_OUT");
253 if (hAverage_out_BF !=
nullptr)
scaleAndSendToMirabelle(hAverage_out_BF, nEventsOUTbf,
"BeforeFilter_outActiveVeto");
256 TH1* hL3UOccIn =
findHist(
"TrackingAbort/SVDL3UOcc_IN");
257 if (hL3UOccIn !=
nullptr)
m_monObj->
setVariable(
"svdL3UOcc_inActiveVeto", hL3UOccIn->GetMean());
258 TH1* hL3UOccOut =
findHist(
"TrackingAbort/SVDL3UOcc_OUT");
259 if (hL3UOccOut !=
nullptr)
m_monObj->
setVariable(
"svdL3UOcc_outActiveVeto", hL3UOccOut->GetMean());
260 TH1* hL3UOccIn_BF =
findHist(
"TrackingAbort_before_filter/SVDL3UOcc_IN");
261 if (hL3UOccIn_BF !=
nullptr)
m_monObj->
setVariable(
"svdL3UOccBeforeFilter_inActiveVeto", hL3UOccIn_BF->GetMean());
262 TH1* hL3UOccOut_BF =
findHist(
"TrackingAbort_before_filter/SVDL3UOcc_OUT");
263 if (hL3UOccOut_BF !=
nullptr)
m_monObj->
setVariable(
"svdL3UOccBeforeFilter_outActiveVeto", hL3UOccOut_BF->GetMean());
267 TH1* hCDCExtraHitsIn =
findHist(
"TrackingAbort/nCDCExtraHits_IN");
268 if (hCDCExtraHitsIn !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHits_inActiveVeto", hCDCExtraHitsIn->GetMean());
269 TH1* hCDCExtraHitsOut =
findHist(
"TrackingAbort/nCDCExtraHits_OUT");
270 if (hCDCExtraHitsOut !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHits_outActiveVeto", hCDCExtraHitsOut->GetMean());
271 TH1* hCDCExtraHitsIn_BF =
findHist(
"TrackingAbort_before_filter/nCDCExtraHits_IN");
272 if (hCDCExtraHitsIn_BF !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHitsBeforeFilter_inActiveVeto", hCDCExtraHitsIn_BF->GetMean());
273 TH1* hCDCExtraHitsOut_BF =
findHist(
"TrackingAbort_before_filter/nCDCExtraHits_OUT");
274 if (hCDCExtraHitsOut_BF !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHitsBeforeFilter_outActiveVeto",
275 hCDCExtraHitsOut_BF->GetMean());
307 hAverage->Scale(1. / nEvents);
309 const int nBins = hAverage->GetNbinsX();
310 for (
int bin = 1; bin < nBins + 1; bin++) {
311 const TString binLabel = hAverage->GetXaxis()->GetBinLabel(bin);
312 const TString varName = TString::Format(
"%s%s", binLabel.Data(), tag.Data());
313 const float varValue = hAverage->GetBinContent(bin);
The base class for the histogram analysis module.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
void colorizeCanvas(TCanvas *canvas, EStatus status)
Helper function for Canvas colorization.
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
@ c_StatusTooFew
Not enough entries/event to judge.
EStatus makeStatus(bool enough, bool warn_flag, bool error_flag)
Helper function to judge the status for coloring and EPICS.
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 initialize() override final
Module function initialize.
int m_statThreshold
minimal number of events to judge
TH1F * m_hAbort_BF
totla abort (inside + outside) active veto region BEFORE FILTER
double m_failureRateThreshold
above this rate, there is maybe a problem?
TCanvas * m_cAbortRateIN
canvas for the abort rate inside the active veto region
MonitoringObject * m_monObj
Monitoring Object to be produced by this module, which contain defined canvases and monitoring variab...
void terminate() override final
Module function needed to delete pointer.
TCanvas * m_cAbortRate_BF
canvas for the abort rate plot BEFORE FILTER
TCanvas * m_cAbortRate
canvas for the abort rate plot
TH1F * m_hAbort
totla abort (inside + outside) active veto region
TCanvas * m_cAbortRateOUT
canvas for the abort rate outside the active veto region
void event() override final
Module function event.
bool m_printCanvas
if true print the pdf of the canvases
TCanvas * m_cAbortRateIN_BF
canvas for the abort rate inside the active veto region BEFORE FILTER
TCanvas * m_cAbortRateOUT_BF
canvas for the abort rate outside the active veto region BEFORE FILTER
void beginRun() override final
Module function doing stuff at beginning of a run.
void scaleAndSendToMirabelle(TH1F *hAverage, const int nEvents, const TString &tag)
scale hAverage and send bin contents to Mirabelle
DQMHistAnalysisTrackingAbortModule()
Constructor.
void setDescription(const std::string &description)
Sets the description of the module.
const std::string & getName() const
Returns the name 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.
Abstract base class for different kinds of events.