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 <TFile.h>
14#include <TCanvas.h>
15#include <TH1.h>
16#include <TH2.h>
17#include <TLine.h>
18#include <TPaveText.h>
19#include <THStack.h>
20#include <TLegend.h>
21#include <vector>
22#include <string>
23#include <map>
24
25namespace Belle2 {
35
36 public:
37
42
47
51 void initialize() override final;
52
56 void beginRun() override final;
57
61 void event() override final;
62
66 void endRun() override final;
67
71 void terminate() override final;
72
73
74 private:
75
80 c_Gray = 0, // undefined
81 c_Green = 1, // good
82 c_Yellow = 2, // warning
83 c_Red = 3 // alarm
84 };
85
90
95
100
104 void updateEventT0Canvas();
105
110
114 void updateTimingCanvas();
115
122 bool sameHistDefinition(TH1* h1, TH1* h2);
123
128 const TH1F* makeDeadAndHotFractionsPlot();
129
134 void makePhotonYieldsAndBGRatePlots(const TH1F* activeFraction);
135
140
146 void setZAxisRange(const std::string& name, double scale);
147
154 void makeBGSubtractedTimingPlot(const std::string& name, const TH2F* trackHits, int slot);
155
160
165
171 void setMiraBelleVariables(const std::string& variableName, const TH1* histogram);
172
180 int getAlarmState(double value, const std::vector<double>& alarmLevels, bool bigRed = true) const;
181
187 int getAlarmColor(unsigned alarmState) const
188 {
189 if (alarmState < m_alarmColors.size()) return m_alarmColors[alarmState];
190 return m_alarmColors[c_Gray];
191 }
192
198 int getOffcialAlarmStatus(unsigned alarmState) const
199 {
200 if (alarmState < m_officialStates.size()) return m_officialStates[alarmState];
201 return c_StatusDefault;
202 }
203
212 void setAlarmLines(const std::vector<double>& alarmLevels, double xmin, double xmax, std::vector<TLine*>& alarmLines,
213 bool bigRed = true);
214
218 void setAlarmLines();
219
225 std::pair<double, double> getDeadAndHotCuts(const TH1* h);
226
230 void setEpicsVariables();
231
236 void updateLimits();
237
242 void setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks);
243
244 // module parameters
245
246 std::vector<int> m_asicWindowsBand = {215, 235};
247 std::vector<double> m_asicWindowsAlarmLevels = {0.002, 0.02};
248 std::vector<double> m_eventMonitorAlarmLevels = {1e-4, 2e-3};
249 std::vector<double> m_junkHitsAlarmLevels = {0.05, 0.25};
250 std::vector<double> m_deadChannelsAlarmLevels = {0.1, 0.35};
251 std::vector<double> m_backgroundAlarmLevels = {5.0, 10.0};
252 std::vector<double> m_photonYieldsAlarmLevels = {15.0, 25.0};
253 std::vector<std::string> m_excludedBoardstacks;
254 std::string m_pvPrefix;
256 std::vector<double> m_injectionBGAlarmLevels = {5, 10};
257 std::vector<double> m_timingAlarmLevels = {0.15, 0.30};
258 std::vector<double> m_eventT0MeanAlarmLevels = {8, 20};
259 std::vector<double> m_eventT0RmsAlarmLevels = {10, 20};
260 std::vector<double> m_offsetMeanAlarmLevels = {0.2, 0.5};
261 std::vector<double> m_offsetRmsAlarmLevels = {0.25, 0.50};
263 // other
264
267 std::vector<bool> m_includedBoardstacks;
268 std::map<std::string, int> m_bsmap;
270 double m_averageRate = 0;
272 bool m_IsNullRun = false;
273 std::string m_runType;
274 double m_numEvents = 0;
276 TH1D* m_photonYields = nullptr;
277 TH1D* m_backgroundRates = nullptr;
278 TCanvas* m_c_photonYields = nullptr;
279 TCanvas* m_c_backgroundRates = nullptr;
281 TH1F* m_hotFraction = nullptr;
282 TH1F* m_deadFraction = nullptr;
283 TH1F* m_excludedFraction = nullptr;
284 TH1F* m_activeFraction = nullptr;
285 THStack* m_stack = nullptr;
286 TLegend* m_legend = nullptr;
287 TCanvas* m_c_deadAndHot = nullptr;
289 TH1F* m_junkFraction = nullptr;
290 TH1F* m_excludedBSHisto = nullptr;
291 TCanvas* m_c_junkFraction = nullptr;
293 std::vector<TH1F*> m_pmtHitRates;
294 std::vector<TCanvas*> m_c_pmtHitRates;
296 std::map<std::string, TCanvas*> m_c_injBGs;
297 std::map<std::string, TProfile*> m_profiles;
298 std::map<std::string, TH1D*> m_projections;
300 std::vector<TLine*> m_asicWindowsBandLines;
301 std::vector<TLine*> m_verticalLines;
302 std::vector<TLine*> m_junkHitsAlarmLines;
303 std::vector<TLine*> m_deadChannelsAlarmLines;
304 std::vector<TLine*> m_backgroundAlarmLines;
305 std::vector<TLine*> m_photonYieldsAlarmLines;
306 TLine* m_injBGCutLine = nullptr;
308 TPaveText* m_text1 = nullptr;
309 TPaveText* m_text2 = nullptr;
310 TPaveText* m_text3 = nullptr;
311 TPaveText* m_text4 = nullptr;
313 std::map<std::string, double> m_mirabelleVariables;
316 };
318} // end namespace Belle2
319
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.