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#ifdef _BELLE2_EPICS
12#include "cadef.h"
13#endif
14
15#include <dqm/core/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
24namespace Belle2 {
46 class DQMHistAnalysisSVDDoseModule final : public DQMHistAnalysisModule {
47 public:
48 DQMHistAnalysisSVDDoseModule();
49
50 private:
54 typedef struct SensorGroup {
55 TString nameSuffix;
56 TString titleSuffix;
57 const char* pvMiddle;
58 int nStrips;
60
61#ifdef _BELLE2_EPICS
63 typedef struct MyPV {
64 chid mychid = nullptr;
65 double lastNHits = 0.0;
66 double lastNEvts = 0.0;
67 } MyPV;
68#endif
69
73 void initialize() override final;
74
78 void beginRun() override final;
79
83 void event() override final;
84
88 void endRun() override final;
89
90 void updateCanvases();
91
93 template<typename T>
94 inline T* findHistT(TString name) { return dynamic_cast<T*>(findHist(name.Data())); }
95
110 template<typename T>
111 static T* divide(T* num, T* den, float scale = 1.0f, T* res = nullptr)
112 {
113 if (!res) {
114 TString name = TString("occu_from_") + num->GetName();
115 res = (T*)num->Clone(name);
116 }
117 for (int i = 0; i < num->GetNcells(); i++) {
118 float n = num->GetBinContent(i), d = den->GetBinContent(i), e = num->GetBinError(i);
119 res->SetBinContent(i, d ? scale * n / d : 0.0f);
120 res->SetBinError(i, d ? scale * e / d : 0.0f);
121 }
122 return res;
123 }
124
126 static void carryOverflowOver(TH1F* h);
127
128 // Steerable data members (parameters)
129 std::string m_pvPrefix;
131 std::string m_pvSuffix;
132 std::string m_deltaTPVSuffix;
133 std::string m_statePVSuffix;
134
135 // Data members for outputs
137 TPaveText* m_legend = nullptr;
138 // Canvases & output histos for Poisson trigger (TTYP_POIS) events
139 std::vector<TCanvas*> m_c_instOccu;
140 std::vector<TCanvas*> m_c_occuLER;
141 std::vector<TH2F*> m_h_occuLER;
142 std::vector<TCanvas*> m_c_occuHER;
143 std::vector<TH2F*> m_h_occuHER;
144 std::vector<TCanvas*> m_c_occuLER1;
145 std::vector<TH1F*> m_h_occuLER1;
146 std::vector<TCanvas*> m_c_occuHER1;
147 std::vector<TH1F*> m_h_occuHER1;
148 // Canvases & output histos for all events
149 std::vector<TCanvas*> m_c_instOccuAll;
150 std::vector<TCanvas*> m_c_occuLERAll;
151 std::vector<TH2F*> m_h_occuLERAll;
152 std::vector<TCanvas*> m_c_occuHERAll;
153 std::vector<TH2F*> m_h_occuHERAll;
154 std::vector<TCanvas*> m_c_occuLER1All;
155 std::vector<TH1F*> m_h_occuLER1All;
156 std::vector<TCanvas*> m_c_occuHER1All;
157 std::vector<TH1F*> m_h_occuHER1All;
158
159#ifdef _BELLE2_EPICS
160 std::vector<MyPV> m_myPVs;
161 double m_lastPVUpdate = -1.0;
162 chid m_timeSinceLastPVUpdateChan = nullptr;
163 struct dbr_ctrl_enum m_stateCtrl;
164 chid m_stateChan = nullptr;
165#endif
166
170 static const std::vector<SensorGroup> c_sensorGroups;
171 };
172
173}
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
DQMHistAnalysisModule()
Constructor / Destructor.
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.
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.
T * findHistT(TString name)
Utility method.
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.