Belle II Software  release-08-00-10
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 
23 namespace Belle2 {
33 
34  public:
35 
40 
45 
49  void initialize() override final;
50 
54  void beginRun() override final;
55 
59  void event() override final;
60 
64  void endRun() override final;
65 
69  void terminate() override final;
70 
71 
72  private:
73 
77  enum EAlarmStates {
78  c_Gray = 0, // undefined
79  c_Green = 1, // good
80  c_Yellow = 2, // warning
81  c_Red = 3 // alarm
82  };
83 
88 
93 
98  const TH1F* makeDeadAndHotFractionsPlot();
99 
100 
105  void makePhotonYieldsAndBGRatePlots(const TH1F* activeFraction);
106 
110  void makeJunkFractionPlot();
111 
117  void setZAxisRange(const std::string& name, double scale);
118 
123  void makeBGSubtractedTimimgPlot(const std::string& name);
124 
130  void setMiraBelleVariables(const std::string& variableName, const TH1* histogram);
131 
139  int getAlarmState(double value, const std::vector<double>& alarmLevels, bool bigRed = true) const;
140 
146  int getAlarmColor(unsigned alarmState) const
147  {
148  if (alarmState < m_alarmColors.size()) return m_alarmColors[alarmState];
149  return m_alarmColors[c_Gray];
150  }
151 
160  void setAlarmLines(const std::vector<double>& alarmLevels, double xmin, double xmax, std::vector<TLine*>& alarmLines,
161  bool bigRed = true);
162 
166  void setAlarmLines();
167 
173  double getMean(const TH2* h);
174 
178  void setEpicsVariables();
179 
184  void updateLimits();
185 
190  void setIncludedBoardstacks(const std::vector<std::string>& excludedBoardstacks);
191 
192  // module parameters
193 
194  std::vector<int> m_asicWindowsBand = {215, 235};
195  std::vector<double> m_asicWindowsAlarmLevels = {0.002, 0.02};
196  std::vector<double> m_eventMonitorAlarmLevels = {1e-4, 2e-3};
197  std::vector<double> m_junkHitsAlarmLevels = {0.05, 0.25};
198  std::vector<double> m_deadChannelsAlarmLevels = {0.1, 0.35};
199  std::vector<double> m_backgroundAlarmLevels = {5.0, 10.0};
200  std::vector<double> m_photonYieldsAlarmLevels = {15.0, 25.0};
201  std::vector<std::string> m_excludedBoardstacks;
202  std::string m_pvPrefix;
204  // other
205 
206  std::vector<int> m_alarmColors = {kGray, kGreen, kYellow, kRed};
207  std::vector<bool> m_includedBoardstacks;
208  std::map<std::string, int> m_bsmap;
210  bool m_IsNullRun = false;
212  TH1D* m_windowFractions = nullptr;
215  TH1D* m_photonYields = nullptr;
216  TCanvas* m_c_photonYields = nullptr;
218  TH1D* m_backgroundRates = nullptr;
219  TCanvas* m_c_backgroundRates = nullptr;
221  TH1F* m_hotFraction = nullptr;
222  TH1F* m_deadFraction = nullptr;
223  TH1F* m_activeFraction = nullptr;
224  THStack* m_stack = nullptr;
225  TLegend* m_legend = nullptr;
226  TCanvas* m_c_deadAndHot = nullptr;
228  TH1F* m_junkFraction = nullptr;
229  TCanvas* m_c_junkFraction = nullptr;
231  std::vector<TLine*> m_asicWindowsBandLines;
232  std::vector<TLine*> m_verticalLines;
233  std::vector<TLine*> m_junkHitsAlarmLines;
234  std::vector<TLine*> m_deadChannelsAlarmLines;
235  std::vector<TLine*> m_backgroundAlarmLines;
236  std::vector<TLine*> m_photonYieldsAlarmLines;
238  TPaveText* m_text1 = nullptr;
239  TPaveText* m_text2 = nullptr;
240  TPaveText* m_text3 = nullptr;
244  };
246 } // end namespace Belle2
247 
The base class for the histogram analysis module.
Class for TOP histogram analysis.
void updateEventMonitorCanvas()
Updates canvas of event desynchronization monitor w/ alarming.
std::vector< int > m_alarmColors
alarm colors
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.
void initialize() override final
Initializer.
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.
TPaveText * m_text3
text to be written to background rates
std::vector< TLine * > m_deadChannelsAlarmLines
lines representing alarm levels
TPaveText * m_text1
text to be written to window_vs_slot
std::vector< TLine * > m_photonYieldsAlarmLines
lines representing alarm levels
std::vector< bool > m_includedBoardstacks
boardstacks included in alarming
std::vector< TLine * > m_verticalLines
vertical lines splitting slots
std::string m_pvPrefix
Epics PV prefix.
TH1D * m_photonYields
photon yields per slot (corrected for active channels)
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.
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.
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.
TH1F * m_deadFraction
fraction of dead channels per slot
TH1F * m_hotFraction
fraction of hot channels per slot
void makeBGSubtractedTimimgPlot(const std::string &name)
Makes background subtracted time distribution plot.
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
double getMean(const TH2 *h)
Returns histogram mean by excluding bins with zero content.
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< TLine * > m_asicWindowsBandLines
lines denoting a band of good windows
void makeJunkFractionPlot()
Makes a plot of fractions of junk hits per boardstack.
double m_totalWindowFraction
total fraction of windows outside the band
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.
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 setEpicsVariables()
Calculates and sets epics variables.
std::vector< double > m_junkHitsAlarmLevels
alarm levels for the fraction of junk hits
TH1D * m_windowFractions
fraction of windows outside the band denoting good windows, per slot
bool m_IsNullRun
Run type flag for null runs.
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.