Belle II Software  release-06-00-14
DQMHistAnalysisSVDDose.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 #ifdef _BELLE2_EPICS
12 #include "cadef.h"
13 #endif
14 
15 #include <dqm/analysis/modules/DQMHistAnalysis.h>
16 #include <TCanvas.h>
17 #include <TString.h>
18 #include <TPaveText.h>
19 #include <TH2.h>
20 #include <TH1.h>
21 #include <string>
22 #include <vector>
23 
24 namespace Belle2 {
47  public:
50 
51  private:
55  typedef struct SensorGroup {
56  TString nameSuffix;
57  TString titleSuffix;
58  const char* pvMiddle;
59  int nStrips;
61 
62 #ifdef _BELLE2_EPICS
64  typedef struct MyPV {
65  chid mychid = nullptr;
66  double lastNHits = 0.0;
67  double lastNEvts = 0.0;
68  } MyPV;
69 #endif
70 
71  void initialize() override final;
72  void beginRun() override final;
73  void event() override final;
74  void endRun() override final;
75 
76  void updateCanvases();
79  template<typename T>
80  inline T* findHistT(TString name) { return dynamic_cast<T*>(findHist(name.Data())); }
81 
92  template<typename T>
93  static T* divide(T* num, T* den, float scale = 1.0f)
94  {
95  TString name = TString("occu_from_") + num->GetName();
96  T* res = (T*)num->Clone(name);
97  for (int i = 0; i < num->GetNcells(); i++) {
98  float n = num->GetBinContent(i), d = den->GetBinContent(i), e = num->GetBinError(i);
99  res->SetBinContent(i, d ? scale * n / d : 0.0f);
100  res->SetBinError(i, d ? scale * e / d : 0.0f);
101  }
102  return res;
103  }
104 
106  static void carryOverflowOver(TH1F* h);
107 
108  // Steerable data members (parameters)
109  std::string m_pvPrefix;
110  bool m_useEpics;
112  std::string m_pvSuffix;
113  std::string m_deltaTPVSuffix;
114  std::string m_statePVSuffix;
116  // Data members for outputs
118  TPaveText* m_legend = nullptr;
119  // Canvases & output histos for Poisson trigger (TTYP_POIS) events
120  std::vector<TCanvas*> m_c_instOccu;
121  std::vector<TCanvas*> m_c_occuLER;
122  std::vector<TCanvas*> m_c_occuHER;
123  std::vector<TCanvas*> m_c_occuLER1;
124  std::vector<TCanvas*> m_c_occuHER1;
125  // Canvases & output histos for all events
126  std::vector<TCanvas*> m_c_instOccuAll;
127  std::vector<TCanvas*> m_c_occuLERAll;
128  std::vector<TCanvas*> m_c_occuHERAll;
129  std::vector<TCanvas*> m_c_occuLER1All;
130  std::vector<TCanvas*> m_c_occuHER1All;
132 #ifdef _BELLE2_EPICS
133  std::vector<MyPV> m_myPVs;
134  double m_lastPVUpdate = -1.0;
135  chid m_timeSinceLastPVUpdateChan = nullptr;
136  struct dbr_ctrl_enum m_stateCtrl;
137  chid m_stateChan = nullptr;
138 #endif
139 
143  static const std::vector<SensorGroup> c_sensorGroups;
144  };
146 }
The base class for the histogram analysis module.
static TH1 * findHist(const std::string &histname)
Find histogram.
The SVD dose-monitoring DQM analysis module.
void initialize() override final
Initialize the Module.
std::vector< TCanvas * > m_c_occuLER
Canvases for the occu.
std::string m_deltaTPVSuffix
Suffix of the update-time monitoring PV.
std::vector< TCanvas * > m_c_occuHERAll
Canvases for the occu.
std::vector< TCanvas * > m_c_instOccu
Canvases for the instantaneous occupancy.
double m_epicsUpdateSeconds
Minimum interval between successive PV updates.
std::vector< TCanvas * > m_c_occuLER1
Canvases for the 1D occu.
std::string m_pvPrefix
Prefix for EPICS PVs.
MonitoringObject * m_monObj
Monitoring object for MiraBelle.
std::vector< TCanvas * > m_c_occuLER1All
Canvases for the 1D occu.
void event() override final
This method is the core of the module.
std::string m_statePVSuffix
Suffix of the state PV.
std::vector< TCanvas * > m_c_occuLERAll
Canvases for the occu.
std::vector< TCanvas * > m_c_occuHER
Canvases for the occu.
std::vector< TCanvas * > m_c_occuHER1All
Canvases for the 1D occu.
static void carryOverflowOver(TH1F *h)
Carries the content of the overflow bin into the last bin.
static const std::vector< SensorGroup > c_sensorGroups
List of sensors groups.
void endRun() override final
This method is called if the current run ends.
struct Belle2::DQMHistAnalysisSVDDoseModule::SensorGroup SensorGroup
A struct to define the sensors group we average over.
T * findHistT(TString name)
Utility method.
void beginRun() override final
Called when entering a new run.
static T * divide(T *num, T *den, float scale=1.0f)
Divide two histograms, ignoring errors on the second histogram.
bool m_useEpics
Whether to update EPICS PVs.
std::vector< TCanvas * > m_c_instOccuAll
Canvases for the instantaneous occupancy.
TPaveText * m_legend
Legend of the inst.
std::vector< TCanvas * > m_c_occuHER1
Canvases for the 1D occu.
std::string m_pvSuffix
Suffix for EPICS PVs.
MonitoringObject is a basic object to hold data for the run-dependency monitoring Run summary TCanvas...
Abstract base class for different kinds of events.
A struct to define the sensors group we average over.
const char * pvMiddle
Middle part of the PV name.
TString titleSuffix
Suffix for the title of the canvases.
TString nameSuffix
Suffix of the name of the histograms.
int nStrips
Total number of strips in the sensor group.