Belle II Software development
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#include <dqm/core/DQMHistAnalysis.h>
12#include <TString.h>
13#include <TPaveText.h>
14#include <TH2.h>
15#include <string>
16#include <vector>
17
18namespace Belle2 {
40 class DQMHistAnalysisSVDDoseModule final : public DQMHistAnalysisModule {
41 public:
42 DQMHistAnalysisSVDDoseModule();
43
44 private:
48 typedef struct SensorGroup {
49 TString nameSuffix;
50 TString titleSuffix;
51 const char* pvMiddle;
52 int nStrips;
54
55#ifdef _BELLE2_EPICS
57 typedef struct MyPV {
58 chid mychid = nullptr;
59 double lastNHits = 0.0;
60 double lastNEvts = 0.0;
61 } MyPV;
62#endif
63
67 void initialize() override final;
68
72 void beginRun() override final;
73
77 void event() override final;
78
82 void endRun() override final;
83
84 void updateCanvases();
85
87 template<typename T>
88 static T* findHistT(TString name) { return dynamic_cast<T*>(findHist(name.Data())); }
89
104 template<typename T>
105 static T* divide(T* num, T* den, float scale = 1.0f, T* res = nullptr)
106 {
107 if (!res) {
108 TString name = TString("occu_from_") + num->GetName();
109 res = dynamic_cast<T*>(num->Clone(name));
110 }
111 for (int i = 0; i < num->GetNcells(); i++) {
112 float n = num->GetBinContent(i), d = den->GetBinContent(i), e = num->GetBinError(i);
113 res->SetBinContent(i, d ? scale * n / d : 0.0f);
114 res->SetBinError(i, d ? scale * e / d : 0.0f);
115 }
116 return res;
117 }
118
120 static void carryOverflowOver(TH1F* h);
121
122 // Steerable data members (parameters)
123 std::string m_pvPrefix;
125 std::string m_pvSuffix;
126 std::string m_deltaTPVSuffix;
127 std::string m_statePVSuffix;
128
129 // Data members for outputs
131 TPaveText* m_legend = nullptr;
132 // Canvases & output histos for Poisson trigger (TTYP_POIS) events
133 std::vector<TCanvas*> m_c_instOccu;
134 std::vector<TCanvas*> m_c_occuLER;
135 std::vector<TH2F*> m_h_occuLER;
136 std::vector<TCanvas*> m_c_occuHER;
137 std::vector<TH2F*> m_h_occuHER;
138 std::vector<TCanvas*> m_c_occuLER1;
139 std::vector<TH1F*> m_h_occuLER1;
140 std::vector<TCanvas*> m_c_occuHER1;
141 std::vector<TH1F*> m_h_occuHER1;
142 // Canvases & output histos for all events
143 std::vector<TCanvas*> m_c_instOccuAll;
144 std::vector<TCanvas*> m_c_occuLERAll;
145 std::vector<TH2F*> m_h_occuLERAll;
146 std::vector<TCanvas*> m_c_occuHERAll;
147 std::vector<TH2F*> m_h_occuHERAll;
148 std::vector<TCanvas*> m_c_occuLER1All;
149 std::vector<TH1F*> m_h_occuLER1All;
150 std::vector<TCanvas*> m_c_occuHER1All;
151 std::vector<TH1F*> m_h_occuHER1All;
152
153#ifdef _BELLE2_EPICS
154 std::vector<MyPV> m_myPVs;
155 double m_lastPVUpdate = -1.0;
156 chid m_timeSinceLastPVUpdateChan = nullptr;
157 struct dbr_ctrl_enum m_stateCtrl;
158 chid m_stateChan = nullptr;
159#endif
160
164 static const std::vector<SensorGroup> c_sensorGroups;
165 };
166
167}
DQMHistAnalysisModule()
Constructor / Destructor.
static TH1 * findHist(const std::string &dirname, const std::string &histname="", bool onlyIfUpdated=false)
Find histogram.
void initialize() override final
Initializer.
std::vector< TCanvas * > m_c_occuLER
Canvases for the occu.
std::vector< TH2F * > m_h_occuHERAll
Histograms for the occu.
std::vector< TH1F * > m_h_occuLER1
Histograms for the 1D 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.
std::vector< TH2F * > m_h_occuLER
Histograms for the occ.
double m_epicsUpdateSeconds
Minimum interval between successive PV updates.
std::vector< TH2F * > m_h_occuLERAll
Histograms for the occu.
std::vector< TCanvas * > m_c_occuLER1
Canvases for the 1D occu.
std::string m_pvPrefix
Prefix for EPICS PVs.
std::vector< TH1F * > m_h_occuHER1All
Histograms for the 1D occu.
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 called for each event.
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.
std::vector< TH1F * > m_h_occuLER1All
Histograms for the 1D occu.
void endRun() override final
This method is called if the current run ends.
static T * findHistT(TString name)
Utility method.
struct Belle2::DQMHistAnalysisSVDDoseModule::SensorGroup SensorGroup
A struct to define the sensors group we average over.
void beginRun() override final
Called when entering a new run.
std::vector< TH1F * > m_h_occuHER1
Histograms for the 1D occu.
std::vector< TCanvas * > m_c_instOccuAll
Canvases for the instantaneous occupancy.
static T * divide(T *num, T *den, float scale=1.0f, T *res=nullptr)
Divide two histograms, ignoring errors on the second histogram.
TPaveText * m_legend
Legend of the inst.
std::vector< TCanvas * > m_c_occuHER1
Canvases for the 1D occu.
std::vector< TH2F * > m_h_occuHER
Histograms for the 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.