Belle II Software development
DQMHistAnalysisSVDClustersOnTrack.cc
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// File : DQMHistAnalysisSVDClustersOnTrack.cc
10// Description : module for DQM histogram analysis of SVD sensors occupancies
11//-
12
13
14#include <dqm/analysis/modules/DQMHistAnalysisSVDClustersOnTrack.h>
15#include <vxd/geometry/GeoCache.h>
16
17#include <TROOT.h>
18#include <TStyle.h>
19#include <TString.h>
20#include <TAxis.h>
21
22#include <TMath.h>
23#include <iostream>
24
25using namespace std;
26using namespace Belle2;
27
28//-----------------------------------------------------------------
29// Register the Module
30//-----------------------------------------------------------------
31REG_MODULE(DQMHistAnalysisSVDClustersOnTrack);
32
33//-----------------------------------------------------------------
34// Implementation
35//-----------------------------------------------------------------
36
39{
40 //Parameter definition
41 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: Constructor done.");
42
43 setDescription("DQM Analysis Module that produces colored canvas for a straightforward interpretation of the SVD Data Quality.");
44
45 addParam("printCanvas", m_printCanvas, "if True prints pdf of the analysis canvas", bool(false));
46 addParam("statThreshold", m_statThreshold, "Minimal number of events to compare histograms", double(10000.));
47 addParam("timeThreshold", m_timeThreshold, "Acceptable difference between mean of central peak for present and reference run",
48 double(6)); // 6 ns
49 addParam("samples3", m_3Samples, "if True 3 samples histograms analysis is performed", bool(false));
50 addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("SVD:"));
51}
52
54
56{
57 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: initialized.");
58
59 m_cClusterOnTrackTime_L456V = new TCanvas("SVDAnalysis/c_ClusterOnTrackTime_L456V");
60
61 if (m_3Samples)
62 m_cClusterOnTrackTimeL456V3Samples = new TCanvas("SVDAnalysis/c_ClusterOnTrackTime_L456V3Samples");
63
64 //register limits for EPICS
65 registerEpicsPV(m_pvPrefix + "ratio3_6", "ratio3_6");
66 registerEpicsPV(m_pvPrefix + "clusterTimeOnTrackLimits", "clusTimeOnTrkLimits");
67}
68
69
71{
72 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: beginRun called.");
73
75
76 if (m_3Samples)
78
79 //Retrieve limits from EPICS
80 double timeWarnUp = 0.;
81 double timeErrorLo = 0.;
82 double timeWarnLo = 0.;
83 requestLimitsFromEpicsPVs("clusTimeOnTrkLimits", timeErrorLo, timeWarnLo, timeWarnUp, m_timeThreshold);
84 B2DEBUG(10, " SVD cluster time on track threshold taken from EPICS configuration file:");
85 B2DEBUG(10, " CLUSTER TIME ON TRACK: error > " << m_timeThreshold << " ns with minimum statistics of " << m_statThreshold);
86
87 // cluster time on tracks legend
88 m_legProblem->Clear();
89 m_legProblem->AddText("ERROR!");
90 m_legProblem->AddText(Form("abs(Mode) > %3.1f ns", m_timeThreshold));
91 m_legProblem->AddText("Mode: 0.0 ns");
92
93
94 m_legWarning->Clear();
95 m_legWarning->AddText("WARNING!");
96
97 m_legNormal->Clear();
98 m_legNormal->AddText("TIME SHIFT UNDER LIMIT");
99 m_legNormal->AddText(Form("abs(Mode) < %3.1f ns", m_timeThreshold));
100 m_legNormal->AddText("Mode: 0.0 ns");
101
102 m_legLowStat->Clear();
103 m_legLowStat->AddText("Not enough statistics");
104
105 m_legEmpty->Clear();
106 m_legEmpty->AddText("No data recieved");
107}
108
110{
111 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: event called.");
112
113 //find nEvents
114 TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents", true);
115 if (hnEvnts == NULL) {
116 B2INFO("no events, nothing to do here");
117 return;
118 } else {
119 B2DEBUG(10, "SVDExpReco/SVDDQM_nEvents found");
120 }
121
122 string rtype = getRunType();
123 m_runtype = !rtype.empty() ? rtype.c_str() : "physics"; // per default
124
125 if (rtype.empty())
126 B2INFO("no run type found, put defaultwise physics");
127
128 TString tmp = hnEvnts->GetTitle();
129 Int_t pos = tmp.Last('~');
130 if (pos == -1) pos = 0;
131
132 TString runID = tmp(pos, tmp.Length() - pos);
133 B2INFO("DQMHistAnalysisSVDClustersOnTrackModule::runID = " << runID);
134 Float_t nEvents = hnEvnts->GetEntries();
135
136 // cluster time for clusters of track
137 double ratio3_6 = 0.;
138 TH1* m_h = findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
139
140 int status;
141 if (m_h != NULL) {
142
145 TString hName = getHistoNameFromCanvas(m_cClusterOnTrackTime_L456V->GetName());
146 m_hClusterOnTrackTime_L456V.SetName(hName.Data());
147 m_hClusterOnTrackTime_L456V.SetTitle(Form("ClusterOnTrack Time L456V %s", runID.Data()));
148 m_hClusterOnTrackTime_L456V.SetStats(false);
149
150 Int_t binMax = m_hClusterOnTrackTime_L456V.GetMaximumBin();
151 double mode = m_hClusterOnTrackTime_L456V.GetXaxis()->GetBinCenter(binMax);
152
153 if (nEvents > m_statThreshold)
154 status = getCanvasStatus(mode);
155 else
156 status = lowStat;
157
161
162 } else {
163 B2INFO("Histogram SVDClsTrk/c_SVDTRK_ClusterTimeV456 from SVDDQMClustersOnTrack module not found!");
167 }
168
169 if (m_printCanvas)
170 m_cClusterOnTrackTime_L456V->Print("c_SVDClusterOnTrackTime_L456V.pdf");
171
172
173 // cluster time for clusters of track for 3 samples
174 if (m_3Samples) {
175 m_h = findHist("SVDClsTrk/SVDTRK_Cluster3TimeV456");
176
177 if (m_h != NULL) {
181 m_hClusterOnTrackTimeL456V3Samples.SetName(hName.Data());
182 m_hClusterOnTrackTimeL456V3Samples.SetTitle(Form("ClusterOnTrack Time L456V 3 samples %s", runID.Data()));
183
184 Int_t binMax = m_hClusterOnTrackTime_L456V.GetMaximumBin();
185 double mode = m_hClusterOnTrackTime_L456V.GetXaxis()->GetBinCenter(binMax);
186
187
188 if (nEvents > m_statThreshold)
189 status = getCanvasStatus(mode);
190 else
191 status = lowStat;
192
196
197 } else {
198 B2INFO("Histogram SVDClsTrk/c_SVDTRK_Cluster3TimeV456 from SVDDQMClustersOnTrack module not found!");
202 }
203
204 if (m_printCanvas)
205 m_cClusterOnTrackTimeL456V3Samples->Print("c_SVDClusterOnTrack3Time_L456V.pdf");
206
207 ratio3_6 = m_hClusterOnTrackTimeL456V3Samples.GetEntries() / m_hClusterOnTrackTime_L456V.GetEntries();
208 }
209
210 setEpicsPV("ratio3_6", ratio3_6);
211}
212
214{
215 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: endRun called");
216}
217
218
220{
221 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: terminate called");
222
225}
226
228{
229 int status = good;
230
231 if (fabs(mode) > m_timeThreshold) {
232 status = error;
233 TText* text = m_legProblem->GetLine(m_legProblem->GetSize() - 1);
234 text->SetText(text->GetX(), text->GetY(), Form("Mode: %3.1f ns", mode));
235 } else {
236 status = good;
237 TText* text = m_legNormal->GetLine(m_legNormal->GetSize() - 1);
238 text->SetText(text->GetX(), text->GetY(), Form("Mode: %3.1f ns", mode));
239 }
240
241 return status;
242}
static TH1 * findHist(const std::string &histname, bool onlyIfUpdated=false)
Get histogram from list (no other search).
static const std::string & getRunType(void)
Get the list of the reference histograms.
void setEpicsPV(std::string keyname, double value)
Write value to a EPICS PV.
int registerEpicsPV(std::string pvname, std::string keyname="")
EPICS related Functions.
bool requestLimitsFromEpicsPVs(chid id, double &lowerAlarm, double &lowerWarn, double &upperWarn, double &upperAlarm)
Get Alarm Limits from EPICS PV.
TCanvas * m_cClusterOnTrackTimeL456V3Samples
time for clusters on Track for L456V canvas for 3 sampples
double m_statThreshold
minimal number of events to compare histograms
double m_timeThreshold
difference between mean of cluster time for present and reference run
TString m_runtype
string with runtype: physics or cosmic
void terminate() override final
This method is called at the end of the event processing.
void event() override final
This method is called for each event.
bool m_printCanvas
Parameters accesible from basf2 scripts.
bool m_3Samples
if true enable 3 samples histograms analysis
TH1F m_hClusterOnTrackTime_L456V
time for clusters on Track for L456V histo
void endRun() override final
This method is called if the current run ends.
TCanvas * m_cClusterOnTrackTime_L456V
time for clusters on Track for L456V canvas
void beginRun() override final
Called when entering a new run.
TH1F m_hClusterOnTrackTimeL456V3Samples
time for clusters on Track for L456V histo for 3 samples
TString getHistoNameFromCanvas(TString cName, TString view="", TString cPrefix="c_", TString hPrefix="")
get histogram name from Canvas name
TPaveText * m_legEmpty
plot legend, empty
TPaveText * m_legLowStat
plot legend, low stats
DQMHistAnalysisSVDModule(bool panelTop=false, bool online=false)
Constructor.
TPaveText * m_legWarning
plot legend, warning
void setStatusOfCanvas(int status, TCanvas *canvas, bool plotLeg=true, bool online=false)
set status of Canvas
TPaveText * m_legNormal
plot legend, normal
TPaveText * m_legProblem
plot legend, problem
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void addParam(const std::string &name, T &paramVariable, const std::string &description, const T &defaultValue)
Adds a new parameter to the module.
Definition Module.h:559
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Definition Module.h:649
Abstract base class for different kinds of events.
STL namespace.