9 #include <dqm/analysis/modules/DQMHistAnalysisTrackingHLT.h>
31 DQMHistAnalysisTrackingHLTModule::DQMHistAnalysisTrackingHLTModule()
38 "Maximum Fraction of Events in which Tracking Aborts before turning Canvas to Red. Will be taken from Epics by default, \
41 "Minimum Number of Events before scaring CR shifters. Will be taken from Epics by default, \
42 this value is only taken if Epics is not available!",
int(
m_statThreshold));
52 double buffThreshold(NAN);
53 double buffMinEvents(NAN);
54 double dummy_lowerAlarm, dummy_lowerWarn, dummy_upperWarn, dummy_upperAlarm;
60 if (!std::isnan(buffThreshold)) {
61 B2INFO(
getName() <<
": Setting failure rate threshold from EPICS. New failureRateThreshold " << buffThreshold);
64 if (!std::isnan(buffMinEvents)) {
65 B2INFO(
getName() <<
": Setting min number of events threshold from EPICS. New minNoEvents " << buffMinEvents);
76 m_cAbortRate =
new TCanvas(
"TrackingAnalysis/c_AbortRate");
87 registerEpicsPV(
"trackingHLT:nTracksPerEvent",
"nTracksPerEvent",
false);
88 registerEpicsPV(
"trackingHLT:nVXDTracksPerEvent",
"nVXDTracksPerEvent",
false);
89 registerEpicsPV(
"trackingHLT:nCDCTracksPerEvent",
"nCDCTracksPerEvent",
false);
90 registerEpicsPV(
"trackingHLT:nVXDCDCTracksPerEvent",
"nVXDCDCTracksPerEvent",
false);
99 TH1* hAbort =
findHist(
"TrackingHLTDQM/NumberTrackingErrorFlags");
100 if (hAbort !=
nullptr) {
102 bool hasError =
false;
103 int nEvents = hAbort->GetEntries();
104 double abortRate = hAbort->GetMean();
105 hAbort->SetTitle(Form(
"Fraction of Events in which Tracking aborts = %.4f %%", abortRate * 100));
124 B2WARNING(
"Histogram TrackingHLTDQM/NumberTrackingErrorFlags from Tracking DQM not found!");
137 TH2F* hAbortHER =
dynamic_cast<TH2F*
>(
findHist(
"TrackingHLTDQM/TrkAbortVsTimeHER"));
138 TH2F* hAllHER =
dynamic_cast<TH2F*
>(
findHist(
"TrackingHLTDQM/allEvtsVsTimeHER"));
139 if (hAbortHER !=
nullptr && hAllHER !=
nullptr) {
141 TH2F* hAbortRateHER =
new TH2F(*hAbortHER);
143 for (
int i = 0; i < hAbortRateHER->GetXaxis()->GetNbins(); i++)
144 for (
int j = 0; j < hAbortRateHER->GetYaxis()->GetNbins(); j++) {
145 int den = hAllHER->GetBinContent(i + 1, j + 1);
146 int num = hAbortHER->GetBinContent(i + 1, j + 1);
148 if (den > 0) hAbortRateHER->SetBinContent(i + 1, j + 1, num * 1. / den);
149 else hAbortRateHER->SetBinContent(i + 1, j + 1, 0);
154 hAbortRateHER->SetTitle(
"Fraction of Events with Tracking Aborts vs HER injection");
155 hAbortRateHER->GetZaxis()->SetTitle(
"Fraction of events / bin");
156 hAbortRateHER->Draw(
"colz");
160 B2WARNING(
"Histograms TrackingHLTDQM/TrkAbortVsTimeHER or allEvtsVsTimeHER from Tracking DQM not found!");
168 TH2F* hAbortLER =
dynamic_cast<TH2F*
>(
findHist(
"TrackingHLTDQM/TrkAbortVsTimeLER"));
169 TH2F* hAllLER =
dynamic_cast<TH2F*
>(
findHist(
"TrackingHLTDQM/allEvtsVsTimeLER"));
170 if (hAbortLER !=
nullptr && hAllLER !=
nullptr) {
172 TH2F* hAbortRateLER =
new TH2F(*hAbortLER);
174 for (
int i = 0; i < hAbortRateLER->GetXaxis()->GetNbins(); i++)
175 for (
int j = 0; j < hAbortRateLER->GetYaxis()->GetNbins(); j++) {
176 int den = hAllLER->GetBinContent(i + 1, j + 1);
177 int num = hAbortLER->GetBinContent(i + 1, j + 1);
179 if (den > 0) hAbortRateLER->SetBinContent(i + 1, j + 1, num * 1. / den);
180 else hAbortRateLER->SetBinContent(i + 1, j + 1, 0);
185 hAbortRateLER->SetTitle(
"Fraction of Events with Tracking Aborts vs LER injection");
186 hAbortRateLER->GetZaxis()->SetTitle(
"Fraction of events / bin");
187 hAbortRateLER->Draw(
"colz");
190 B2WARNING(
"Histograms TrackingHLTDQM/TrkAbortVsTimeLER or allEvtsVsTimeLER from Tracking DQM not found!");
197 TH1* hnTracks =
findHist(
"TrackingHLTDQM/NoOfTracks");
198 if (hnTracks !=
nullptr && hnTracks->GetEntries() >=
m_statThreshold) {
199 double averageNTracks = hnTracks->GetMean();
201 setEpicsPV(
"nTracksPerEvent", averageNTracks);
204 TH1* hnVXDTracks =
findHist(
"TrackingHLTDQM/NoOfTracksInVXDOnly");
205 if (hnVXDTracks !=
nullptr && hnVXDTracks->GetEntries() >=
m_statThreshold) {
206 double averageNVXDTracks = hnVXDTracks->GetMean();
208 setEpicsPV(
"nVXDTracksPerEvent", averageNVXDTracks);
211 TH1* hnCDCTracks =
findHist(
"TrackingHLTDQM/NoOfTracksInCDCOnly");
212 if (hnCDCTracks !=
nullptr && hnCDCTracks->GetEntries() >=
m_statThreshold) {
213 double averageNCDCTracks = hnCDCTracks->GetMean();
215 setEpicsPV(
"nCDCTracksPerEvent", averageNCDCTracks);
218 TH1* hnVXDCDCTracks =
findHist(
"TrackingHLTDQM/NoOfTracksInVXDCDC");
219 if (hnVXDCDCTracks !=
nullptr && hnVXDCDCTracks->GetEntries() >=
m_statThreshold) {
220 double averageNVXDCDCTracks = hnVXDCDCTracks->GetMean();
222 setEpicsPV(
"nVXDCDCTracksPerEvent", averageNVXDCDCTracks);
The base class for the histogram analysis module.
int registerEpicsPV(std::string pvname, std::string keyname="", bool update_pvs=true)
EPICS related Functions.
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.
static MonitoringObject * getMonitoringObject(const std::string &histname)
Get MonitoringObject with given name (new object is created if non-existing)
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
double m_failureRateThreshold
above this rate, there is maybe a problem?
MonitoringObject * m_monObj
Monitoring Object to be produced by this module, which contain defined canvases and monitoring variab...
TCanvas * m_cAbortRate
canvas for the abort rate plot
void event() override final
Module function event.
TCanvas * m_cAbortRateHER
canvas for the 2D abort rate plot for HER
TCanvas * m_cAbortRateLER
canvas for the 2D abort rate plot for LER
bool m_printCanvas
if true print the pdf of the canvases
void beginRun() override final
Module function doing stuff at beginning of a run.
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.