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
166 void setMiraBelleVariables(const std::string& variableName, const TH1* histogram);
167
175 int getAlarmState(double value, const std::vector<double>& alarmLevels, bool bigRed = true) const;
176
182 int getAlarmColor(unsigned alarmState) const
183 {
184 if (alarmState < m_alarmColors.size()) return m_alarmColors[alarmState];
185 return m_alarmColors[c_Gray];
186 }
187
193 int getOffcialAlarmStatus(unsigned alarmState) const
194 {
195 if (alarmState < m_officialStates.size()) return m_officialStates[alarmState];
196 return c_StatusDefault;
197 }
198
207 void setAlarmLines(const std::vector<double>& alarmLevels, double xmin, double xmax, std::vector<TLine*>& alarmLines,
208 bool bigRed = true);
209
213 void setAlarmLines();
214
220 std::pair<double, double> getDeadAndHotCuts(const TH1* h);
221
225 void setEpicsVariables();
226
231 void updateLimits();
232
237 void setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks);
238
239 // module parameters
240
241 std::vector<int> m_asicWindowsBand = {215, 235};
242 std::vector<double> m_asicWindowsAlarmLevels = {0.002, 0.02};
243 std::vector<double> m_eventMonitorAlarmLevels = {1e-4, 2e-3};
244 std::vector<double> m_junkHitsAlarmLevels = {0.05, 0.25};
245 std::vector<double> m_deadChannelsAlarmLevels = {0.1, 0.35};
246 std::vector<double> m_backgroundAlarmLevels = {5.0, 10.0};
247 std::vector<double> m_photonYieldsAlarmLevels = {15.0, 25.0};
248 std::vector<std::string> m_excludedBoardstacks;
249 std::string m_pvPrefix;
251 std::vector<double> m_injectionBGAlarmLevels = {5, 10};
252 std::vector<double> m_timingAlarmLevels = {0.15, 0.30};
253 std::vector<double> m_eventT0MeanAlarmLevels = {8, 20};
254 std::vector<double> m_eventT0RmsAlarmLevels = {10, 20};
255 std::vector<double> m_offsetMeanAlarmLevels = {0.2, 0.5};
256 std::vector<double> m_offsetRmsAlarmLevels = {0.25, 0.50};
257 std::string m_refFileName;
259 // other
260
263 std::vector<bool> m_includedBoardstacks;
264 std::map<std::string, int> m_bsmap;
266 double m_averageRate = 0;
268 bool m_IsNullRun = false;
269 std::string m_runType;
270 double m_numEvents = 0;
272 TFile* m_refFile = nullptr;
273 std::map<std::string, TH1F*> m_refTimingHisto;
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::vector<TLine*> m_asicWindowsBandLines;
296 std::vector<TLine*> m_verticalLines;
297 std::vector<TLine*> m_junkHitsAlarmLines;
298 std::vector<TLine*> m_deadChannelsAlarmLines;
299 std::vector<TLine*> m_backgroundAlarmLines;
300 std::vector<TLine*> m_photonYieldsAlarmLines;
301 TLine* m_injBGCutLine = nullptr;
303 TPaveText* m_text1 = nullptr;
304 TPaveText* m_text2 = nullptr;
305 TPaveText* m_text3 = nullptr;
306 TPaveText* m_text4 = nullptr;
308 std::map<std::string, double> m_mirabelleVariables;
311 };
313} // end namespace Belle2
314
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
std::string m_refFileName
file name of reference histograms
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::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.
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]
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)
std::map< std::string, TH1F * > m_refTimingHisto
timing reference histograms for different run types
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
void updateLimits()
Updates limits defined by module parameters using EpicsPVs.
TFile * m_refFile
file containing reference histograms
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.