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("refMCTP", m_refMeanP, "Mean of the signal time peak from Physics reference run", float(0.0)); // Approximate, from exp 20
50 addParam("refMCTC", m_refMeanC, "Mean of the signal time peak from Cosmic reference run", float(0.0)); //
51 addParam("samples3", m_3Samples, "if True 3 samples histograms analysis is performed", bool(false));
52 addParam("PVPrefix", m_pvPrefix, "PV Prefix", std::string("SVD:"));
53}
54
56
58{
59 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: initialized.");
60
61 m_cClusterOnTrackTime_L456V = new TCanvas("SVDAnalysis/c_ClusterOnTrackTime_L456V");
62
63 if (m_3Samples)
64 m_cClusterOnTrackTimeL456V3Samples = new TCanvas("SVDAnalysis/c_ClusterOnTrackTime_L456V3Samples");
65
66 //register limits for EPICS
67 registerEpicsPV(m_pvPrefix + "ratio3_6", "ratio3_6");
68 registerEpicsPV(m_pvPrefix + "clusterTimeOnTrackLimits", "clusTimeOnTrkLimits");
69}
70
71
73{
74 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: beginRun called.");
75
77
78 if (m_3Samples)
80
81 //Retrieve limits from EPICS
82 double timeWarnUp = 0.;
83 double timeErrorLo = 0.;
84 double timeWarnLo = 0.;
85 requestLimitsFromEpicsPVs("clusTimeOnTrkLimits", timeErrorLo, timeWarnLo, timeWarnUp, m_timeThreshold);
86 B2DEBUG(10, " SVD cluster time on track threshold taken from EPICS configuration file:");
87 B2DEBUG(10, " CLUSTER TIME ON TRACK: error > " << m_timeThreshold << " ns with minimum statistics of " << m_statThreshold);
88
89 // cluster time on tracks legend
90 m_legProblem->Clear();
91 m_legProblem->AddText("ERROR!");
92 m_legProblem->AddText(Form("abs(Mean) > %3.1f ns", m_timeThreshold));
93 m_legProblem->AddText("Mean (#pm 40 ns): 0.0 ns");
94
95
96 m_legWarning->Clear();
97 m_legWarning->AddText("WARNING!");
98
99 m_legNormal->Clear();
100 m_legNormal->AddText("TIME SHIFT UNDER LIMIT");
101 m_legNormal->AddText(Form("abs(Mean) < %3.1f ns", m_timeThreshold));
102 m_legNormal->AddText("Mean (#pm 40 ns): 0.0 ns");
103
104 m_legLowStat->Clear();
105 m_legLowStat->AddText("Not enough statistics");
106
107 m_legEmpty->Clear();
108 m_legEmpty->AddText("No data recieved");
109}
110
112{
113 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: event called.");
114
115 //find nEvents
116 TH1* hnEvnts = findHist("SVDExpReco/SVDDQM_nEvents", true);
117 if (hnEvnts == NULL) {
118 B2INFO("no events, nothing to do here");
119 return;
120 } else {
121 B2DEBUG(10, "SVDExpReco/SVDDQM_nEvents found");
122 }
123
124 string rtype = getRunType();
125 m_runtype = !rtype.empty() ? rtype.c_str() : "physics"; // per default
126
127 if (rtype.empty())
128 B2INFO("no run type found, put defaultwise physics");
129
130 TString tmp = hnEvnts->GetTitle();
131 Int_t pos = tmp.Last('~');
132 if (pos == -1) pos = 0;
133
134 TString runID = tmp(pos, tmp.Length() - pos);
135 B2INFO("DQMHistAnalysisSVDClustersOnTrackModule::runID = " << runID);
136 Float_t nEvents = hnEvnts->GetEntries();
137
138 // cluster time for clusters of track
139 double ratio3_6 = 0.;
140 TH1* m_h = findHist("SVDClsTrk/SVDTRK_ClusterTimeV456");
141
142 int status;
143 if (m_h != NULL) {
144
147 TString hName = getHistoNameFromCanvas(m_cClusterOnTrackTime_L456V->GetName());
148 m_hClusterOnTrackTime_L456V.SetName(hName.Data());
149 m_hClusterOnTrackTime_L456V.SetTitle(Form("ClusterOnTrack Time L456V %s", runID.Data()));
150
151 if (nEvents > m_statThreshold)
153 else
154 status = lowStat;
155
159
160 } else {
161 B2INFO("Histogram SVDClsTrk/c_SVDTRK_ClusterTimeV456 from SVDDQMClustersOnTrack module not found!");
165 }
166
167 if (m_printCanvas)
168 m_cClusterOnTrackTime_L456V->Print("c_SVDClusterOnTrackTime_L456V.pdf");
169
170
171 // cluster time for clusters of track for 3 samples
172 if (m_3Samples) {
173 m_h = findHist("SVDClsTrk/SVDTRK_Cluster3TimeV456");
174
175 if (m_h != NULL) {
179 m_hClusterOnTrackTimeL456V3Samples.SetName(hName.Data());
180 m_hClusterOnTrackTimeL456V3Samples.SetTitle(Form("ClusterOnTrack Time L456V 3 samples %s", runID.Data()));
181
182 if (nEvents > m_statThreshold)
184 else
185 status = lowStat;
186
190
191 } else {
192 B2INFO("Histogram SVDClsTrk/c_SVDTRK_Cluster3TimeV456 from SVDDQMClustersOnTrack module not found!");
196 }
197
198 if (m_printCanvas)
199 m_cClusterOnTrackTimeL456V3Samples->Print("c_SVDClusterOnTrack3Time_L456V.pdf");
200
201 ratio3_6 = m_hClusterOnTrackTimeL456V3Samples.GetEntries() / m_hClusterOnTrackTime_L456V.GetEntries();
202 }
203
204 setEpicsPV("ratio3_6", ratio3_6);
205}
206
208{
209 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: endRun called");
210}
211
212
214{
215 B2DEBUG(10, "DQMHistAnalysisSVDClustersOnTrack: terminate called");
216
219}
220
222{
223 int status = good;
224 histo.GetXaxis()->SetRange(110, 190); // [-40 ns,40 ns]
225 Float_t mean_PeakInCenter = histo.GetMean(); //
226 histo.GetXaxis()->SetRange(); // back to [-150 ns,150 ns]
227 Float_t difference = 0;
228
229 if (m_runtype == "physics")
230 difference = fabs(mean_PeakInCenter - m_refMeanP);
231
232 else if (m_runtype == "cosmic")
233 difference = fabs(mean_PeakInCenter - m_refMeanC);
234
235 else {// taking cosmic limits
236 B2WARNING("Run type:" << m_runtype << "taken cosmics criteria");
237 difference = fabs(mean_PeakInCenter - m_refMeanC);
238 }
239
240 if (difference > m_timeThreshold) {
241 status = error;
242 TText* text = m_legProblem->GetLine(m_legProblem->GetSize() - 1);
243 text->SetText(text->GetX(), text->GetY(), Form("Mean (#pm 40 ns): %3.1f ns", mean_PeakInCenter));
244 } else {
245 status = good;
246 TText* text = m_legNormal->GetLine(m_legNormal->GetSize() - 1);
247 text->SetText(text->GetX(), text->GetY(), Form("Mean (#pm 40 ns): %3.1f ns", mean_PeakInCenter));
248 }
249 return status;
250}
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
float m_refMeanC
mean of the signal time peak from Cosmic reference run
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.
float m_refMeanP
mean of the signal time peak from Physics reference run
TH1F m_hClusterOnTrackTimeL456V3Samples
time for clusters on Track for L456V histo for 3 samples
Class definition for common method.
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
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.