Belle II Software development
DQMHistAnalysisTOP.h
1/**************************************************************************
2 * basf2 (Belle II Analysis Software Framework) *
3 * Author: The Belle II Collaboration *
4 * *
5 * See git log for contributors and copyright holders. *
6 * This file is licensed under LGPL-3.0, see LICENSE.md. *
7 **************************************************************************/
8
9#pragma once
10
11#include <dqm/core/DQMHistAnalysis.h>
12
13#include <TCanvas.h>
14#include <TH1.h>
15#include <TH2.h>
16#include <TLine.h>
17#include <TPaveText.h>
18#include <THStack.h>
19#include <TLegend.h>
20#include <vector>
21#include <string>
22#include <map>
23
24namespace Belle2 {
34
35 public:
36
41
46
50 void initialize() override final;
51
55 void beginRun() override final;
56
60 void event() override final;
61
65 void endRun() override final;
66
70 void terminate() override final;
71
72
73 private:
74
79 c_Gray = 0, // undefined
80 c_Green = 1, // good
81 c_Yellow = 2, // warning
82 c_Red = 3 // alarm
83 };
84
89
94
99
103 void updateEventT0Canvas();
104
109
113 void updateTimingCanvas();
114
121 bool sameHistDefinition(TH1* h1, TH1* h2);
122
127 const TH1F* makeDeadAndHotFractionsPlot();
128
133 void makePhotonYieldsAndBGRatePlots(const TH1F* activeFraction);
134
139
145 void setZAxisRange(const std::string& name, double scale);
146
153 void makeBGSubtractedTimingPlot(const std::string& name, const TH2F* trackHits, int slot);
154
159
164
170 void setMiraBelleVariables(const std::string& variableName, const TH1* histogram);
171
179 int getAlarmState(double value, const std::vector<double>& alarmLevels, bool bigRed = true) const;
180
186 int getAlarmColor(unsigned alarmState) const
187 {
188 if (alarmState < m_alarmColors.size()) return m_alarmColors[alarmState];
189 return m_alarmColors[c_Gray];
190 }
191
197 int getOffcialAlarmStatus(unsigned alarmState) const
198 {
199 if (alarmState < m_officialStates.size()) return m_officialStates[alarmState];
200 return c_StatusDefault;
201 }
202
211 void setAlarmLines(const std::vector<double>& alarmLevels, double xmin, double xmax, std::vector<TLine*>& alarmLines,
212 bool bigRed = true);
213
217 void setAlarmLines();
218
224 std::pair<double, double> getDeadAndHotCuts(const TH1* h);
225
229 void setEpicsVariables();
230
235 void updateLimits();
236
241 void setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks);
242
243 // module parameters
244
245 std::vector<int> m_asicWindowsBand = {215, 235};
246 std::vector<double> m_asicWindowsAlarmLevels = {0.002, 0.02};
247 std::vector<double> m_eventMonitorAlarmLevels = {1e-4, 2e-3};
248 std::vector<double> m_junkHitsAlarmLevels = {0.05, 0.25};
249 std::vector<double> m_deadChannelsAlarmLevels = {0.1, 0.35};
250 std::vector<double> m_backgroundAlarmLevels = {5.0, 10.0};
251 std::vector<double> m_photonYieldsAlarmLevels = {15.0, 25.0};
252 std::vector<std::string> m_excludedBoardstacks;
253 std::string m_pvPrefix;
255 std::vector<double> m_injectionBGAlarmLevels = {5, 10};
256 std::vector<double> m_timingAlarmLevels = {0.15, 0.30};
257 std::vector<double> m_eventT0MeanAlarmLevels = {8, 20};
258 std::vector<double> m_eventT0RmsAlarmLevels = {10, 20};
259 std::vector<double> m_offsetMeanAlarmLevels = {0.2, 0.5};
260 std::vector<double> m_offsetRmsAlarmLevels = {0.25, 0.50};
262 // other
263
266 std::vector<bool> m_includedBoardstacks;
267 std::map<std::string, int> m_bsmap;
269 double m_averageRate = 0;
271 bool m_IsNullRun = false;
272 std::string m_runType;
273 double m_numEvents = 0;
275 TH1D* m_photonYields = nullptr;
276 TH1D* m_backgroundRates = nullptr;
277 TCanvas* m_c_photonYields = nullptr;
278 TCanvas* m_c_backgroundRates = nullptr;
280 TH1F* m_hotFraction = nullptr;
281 TH1F* m_deadFraction = nullptr;
282 TH1F* m_excludedFraction = nullptr;
283 TH1F* m_activeFraction = nullptr;
284 THStack* m_stack = nullptr;
285 TLegend* m_legend = nullptr;
286 TCanvas* m_c_deadAndHot = nullptr;
288 TH1F* m_junkFraction = nullptr;
289 TH1F* m_excludedBSHisto = nullptr;
290 TCanvas* m_c_junkFraction = nullptr;
292 std::vector<TH1F*> m_pmtHitRates;
293 std::vector<TCanvas*> m_c_pmtHitRates;
295 std::map<std::string, TCanvas*> m_c_injBGs;
296 std::map<std::string, TProfile*> m_profiles;
297 std::map<std::string, TH1D*> m_projections;
299 std::vector<TLine*> m_asicWindowsBandLines;
300 std::vector<TLine*> m_verticalLines;
301 std::vector<TLine*> m_junkHitsAlarmLines;
302 std::vector<TLine*> m_deadChannelsAlarmLines;
303 std::vector<TLine*> m_backgroundAlarmLines;
304 std::vector<TLine*> m_photonYieldsAlarmLines;
305 TLine* m_injBGCutLine = nullptr;
307 TPaveText* m_text1 = nullptr;
308 TPaveText* m_text2 = nullptr;
309 TPaveText* m_text3 = nullptr;
310 TPaveText* m_text4 = nullptr;
312 std::map<std::string, double> m_mirabelleVariables;
315 };
317} // end namespace Belle2
318
The base class for the histogram analysis module.
@ c_ColorWarning
Analysis result: Warning, there may be minor issues.
@ c_ColorError
Analysis result: Severe issue found.
@ c_ColorTooFew
Not enough entries/event to judge.
@ c_ColorGood
Analysis result: Good.
@ c_StatusDefault
default for non-coloring
@ c_StatusTooFew
Not enough entries/event to judge.
@ c_StatusError
Analysis result: Severe issue found.
@ c_StatusWarning
Analysis result: Warning, there may be minor issues.
@ c_StatusGood
Analysis result: Good.
Class for TOP histogram analysis.
void updateEventMonitorCanvas()
Updates canvas of event desynchronization monitor w/ alarming.
std::vector< int > m_alarmColors
alarm colors (see base class)
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
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
EAlarmStates
Alarm states enumerator.
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.
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)
std::vector< int > m_officialStates
official alarm states
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
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.
MonitoringObject is a basic object to hold data for the run-dependency monitoring Run summary TCanvas...
Abstract base class for different kinds of events.