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) {
275 int from_bin = hCDCExtraHitsOut->FindBin(2700);
276 int to_bin = hCDCExtraHitsOut->GetNbinsX() + 1;
277 double integral = hCDCExtraHitsOut->Integral(from_bin, to_bin);
278 if (hCDCExtraHitsOut->GetEntries() > 0) {
279 m_monObj->
setVariable(
"fEventsWithCDCExtraHitsAbove2700_outActiveVeto", integral / hCDCExtraHitsOut->GetEntries());
282 TH1* hCDCExtraHitsIn_BF =
findHist(
"TrackingAbort_before_filter/nCDCExtraHits_IN");
283 if (hCDCExtraHitsIn_BF !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHitsBeforeFilter_inActiveVeto", hCDCExtraHitsIn_BF->GetMean());
284 TH1* hCDCExtraHitsOut_BF =
findHist(
"TrackingAbort_before_filter/nCDCExtraHits_OUT");
285 if (hCDCExtraHitsOut_BF !=
nullptr)
m_monObj->
setVariable(
"nCDCExtraHitsBeforeFilter_outActiveVeto",
286 hCDCExtraHitsOut_BF->GetMean());
289 TH1* noCDCHitsInSLIn_BF =
findHist(
"TrackingAbort_before_filter/noCDCHitsInSL_IN");
290 if ((noCDCHitsInSLIn_BF !=
nullptr) && (nEventsINbf > 0)) {
291 noCDCHitsInSLIn_BF->Scale(1. / nEventsINbf);
292 noCDCHitsInSLIn_BF->GetYaxis()->SetTitle(
"Fraction of Events");
294 TH1* noCDCHitsInSLOut_BF =
findHist(
"TrackingAbort_before_filter/noCDCHitsInSL_OUT");
295 if ((noCDCHitsInSLOut_BF !=
nullptr) && (nEventsOUTbf > 0)) {
296 noCDCHitsInSLOut_BF->Scale(1. / nEventsOUTbf);
297 noCDCHitsInSLOut_BF->GetYaxis()->SetTitle(
"Fraction of Events");
299 TH1* noCDCHitsInSLIn =
findHist(
"TrackingAbort/noCDCHitsInSL_IN");
300 if ((noCDCHitsInSLIn !=
nullptr) && (nEventsIN > 0)) {
301 noCDCHitsInSLIn->Scale(1. / nEventsIN);
302 noCDCHitsInSLIn->GetYaxis()->SetTitle(
"Fraction of Events");
304 TH1* noCDCHitsInSLOut =
findHist(
"TrackingAbort/noCDCHitsInSL_OUT");
305 if ((noCDCHitsInSLOut !=
nullptr) && (nEventsOUT > 0)) {
306 noCDCHitsInSLOut->Scale(1. / nEventsOUT);
307 noCDCHitsInSLOut->GetYaxis()->SetTitle(
"Fraction of Events");
309 for (
int sl = 0; sl < 9; sl++) {
311 TH1* hCDCExtraHitsSLIn_BF =
findHist(Form(
"TrackingAbort_before_filter/nCDCExtraHitsSL%d_IN", sl));
312 if (hCDCExtraHitsSLIn_BF !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCExtraHitsSL%dBeforeFilter_inActiveVeto", sl),
313 hCDCExtraHitsSLIn_BF->GetMean());
314 TH1* hCDCExtraHitsSLOut_BF =
findHist(Form(
"TrackingAbort_before_filter/nCDCExtraHitsSL%d_OUT", sl));
315 if (hCDCExtraHitsSLOut_BF !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCExtraHitsSL%dBeforeFilter_outActiveVeto", sl),
316 hCDCExtraHitsSLOut_BF->GetMean());
317 TH1* hCDCHitsSLIn_BF =
findHist(Form(
"TrackingAbort_before_filter/nCDCHitsSL%d_IN", sl));
318 if (hCDCHitsSLIn_BF !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCHitsSL%dBeforeFilter_inActiveVeto", sl),
319 hCDCHitsSLIn_BF->GetMean());
320 TH1* hCDCHitsSLOut_BF =
findHist(Form(
"TrackingAbort_before_filter/nCDCHitsSL%d_OUT", sl));
321 if (hCDCHitsSLOut_BF !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCHitsSL%dBeforeFilter_outActiveVeto", sl),
322 hCDCHitsSLOut_BF->GetMean());
324 TH1* hCDCExtraHitsSLIn =
findHist(Form(
"TrackingAbort/nCDCExtraHitsSL%d_IN", sl));
325 if (hCDCExtraHitsSLIn !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCExtraHitsSL%d_inActiveVeto", sl),
326 hCDCExtraHitsSLIn->GetMean());
327 TH1* hCDCExtraHitsSLOut =
findHist(Form(
"TrackingAbort/nCDCExtraHitsSL%d_OUT", sl));
328 if (hCDCExtraHitsSLOut !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCExtraHitsSL%d_outActiveVeto", sl),
329 hCDCExtraHitsSLOut->GetMean());
330 TH1* hCDCHitsSLIn =
findHist(Form(
"TrackingAbort/nCDCHitsSL%d_IN", sl));
332 hCDCHitsSLIn->GetMean());
333 TH1* hCDCHitsSLOut =
findHist(Form(
"TrackingAbort/nCDCHitsSL%d_OUT", sl));
334 if (hCDCHitsSLOut !=
nullptr)
m_monObj->
setVariable(Form(
"nCDCHitsSL%d_outActiveVeto", sl),
335 hCDCHitsSLOut->GetMean());
338 if (noCDCHitsInSLIn_BF !=
nullptr)
m_monObj->
setVariable(Form(
"noCDCHitsSL%dBeforeFilter_inActiveVeto", sl),
339 noCDCHitsInSLIn_BF->GetBinContent(sl + 1));
340 if (noCDCHitsInSLOut_BF !=
nullptr)
m_monObj->
setVariable(Form(
"noCDCHitsSL%dBeforeFilter_outActiveVeto", sl),
341 noCDCHitsInSLOut_BF->GetBinContent(sl + 1));
342 if (noCDCHitsInSLIn !=
nullptr)
m_monObj->
setVariable(Form(
"noCDCHitsSL%d_inActiveVeto", sl),
343 noCDCHitsInSLIn->GetBinContent(sl + 1));
344 if (noCDCHitsInSLOut !=
nullptr)
m_monObj->
setVariable(Form(
"noCDCHitsSL%d_outActiveVeto", sl),
345 noCDCHitsInSLOut->GetBinContent(sl + 1));
380 hAverage->Scale(1. / nEvents);
382 const int nBins = hAverage->GetNbinsX();
383 for (
int bin = 1; bin < nBins + 1; bin++) {
384 const TString binLabel = hAverage->GetXaxis()->GetBinLabel(bin);
385 const TString varName = TString::Format(
"%s%s", binLabel.Data(), tag.Data());
386 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.