Belle II Software development
DQMCommonUtils Class Reference

The class collects utility functions for creating DQM histograms: prepared for PXD, SVD, VXD and Track DQM histograms. More...

#include <DQMCommonUtils.h>

Static Public Member Functions

static int SetFlag (int Type, int bin, const double *pars, double ratio, TH1F *hist, TH1F *refhist, TH1I *flaghist)
 Function return flag histogram filled based on condition from TH1F source.
 
static int SetFlag (int Type, int bin, const double *pars, double ratio, TH1I *hist, TH1I *refhist, TH1I *flaghist)
 Function return flag histogram filled based on condition from TH1I source.
 
static void CreateDBHisto (TH1F *HistoBD)
 Function for filling of TH1F histogram to database.
 
static void CreateDBHisto (TH1I *HistoBD)
 Function for filling of TH1I histogram to database.
 
static void CreateDBHistoGroup (TH1F **HistoBD, int number)
 Function for filling of group of TH1F histogram to database.
 
static void CreateDBHistoGroup (TH1I **HistoBD, int number)
 Function for filling of group of TH1I histogram to database.
 
static int LoadDBHisto (TH1F *HistoBD)
 Function for loading of TH1F histogram from database.
 
static int LoadDBHisto (TH1I *HistoBD)
 Function for loading of TH1I histogram from database.
 
static int LoadDBHistoGroup (TH1F **HistoBD, int number)
 Function for loading of group of TH1F histogram from database.
 
static int LoadDBHistoGroup (TH1I **HistoBD, int number)
 Function for loading of group of TH1I histogram from database.
 

Detailed Description

The class collects utility functions for creating DQM histograms: prepared for PXD, SVD, VXD and Track DQM histograms.

Definition at line 22 of file DQMCommonUtils.h.

Member Function Documentation

◆ CreateDBHisto() [1/2]

void CreateDBHisto ( TH1F *  HistoBD)
static

Function for filling of TH1F histogram to database.

Parameters
HistoBDHistogram for DB.

Definition at line 161 of file DQMCommonUtils.cc.

162{
163 IntervalOfValidity iov(0, 0, -1, -1);
164 TString Name = Form("%s_Ref", HistoDB->GetName());
165 DBImportObjPtr<TVectorD> DBHisto(Name.Data());
166 DBHisto.construct(HistoDB->GetNbinsX() + 3);
167 double* Content = new double[HistoDB->GetNbinsX() + 3];
168 Content[0] = HistoDB->GetNbinsX();
169 Content[1] = HistoDB->GetXaxis()->GetXmin();
170 Content[2] = HistoDB->GetXaxis()->GetXmax();
171 for (int i = 0; i < HistoDB->GetNbinsX(); i++) {
172 Content[i + 3] = HistoDB->GetBinContent(i + 1);
173 }
174 DBHisto->SetElements(Content);
175 DBHisto.import(iov);
176 delete [] Content;
177}
Class for importing a single object to the database.
A class that describes the interval of experiments/runs for which an object in the database is valid.

◆ CreateDBHisto() [2/2]

void CreateDBHisto ( TH1I *  HistoBD)
static

Function for filling of TH1I histogram to database.

Parameters
HistoBDHistogram for DB.

Definition at line 180 of file DQMCommonUtils.cc.

181{
182 IntervalOfValidity iov(0, 0, -1, -1);
183 TString Name = Form("%s_Ref", HistoDB->GetName());
184 DBImportObjPtr<TVectorD> DBHisto(Name.Data());
185 DBHisto.construct(HistoDB->GetNbinsX() + 3);
186 double* Content = new double[HistoDB->GetNbinsX() + 3];
187 Content[0] = HistoDB->GetNbinsX();
188 Content[1] = HistoDB->GetXaxis()->GetXmin();
189 Content[2] = HistoDB->GetXaxis()->GetXmax();
190 for (int i = 0; i < HistoDB->GetNbinsX(); i++) {
191 Content[i + 3] = HistoDB->GetBinContent(i + 1);
192 }
193 DBHisto->SetElements(Content);
194 DBHisto.import(iov);
195 delete [] Content;
196}

◆ CreateDBHistoGroup() [1/2]

void CreateDBHistoGroup ( TH1F **  HistoBD,
int  number 
)
static

Function for filling of group of TH1F histogram to database.

Parameters
HistoBDHistogram for DB.
numberNumber of histograms to glue to one.

Definition at line 199 of file DQMCommonUtils.cc.

200{
201 IntervalOfValidity iov(0, 0, -1, -1);
202 TString Name = Form("%s_Ref", HistoDB[0]->GetName());
203 DBImportObjPtr<TVectorD> DBHisto(Name.Data());
204 DBHisto.construct(number * HistoDB[0]->GetNbinsX() + 3);
205 double* Content = new double[number * HistoDB[0]->GetNbinsX() + 3];
206 Content[0] = HistoDB[0]->GetNbinsX();
207 Content[1] = HistoDB[0]->GetXaxis()->GetXmin();
208 Content[2] = HistoDB[0]->GetXaxis()->GetXmax();
209 for (int j = 0; j < number; j++) {
210 for (int i = 0; i < HistoDB[j]->GetNbinsX(); i++) {
211 Content[j * HistoDB[j]->GetNbinsX() + i + 3] = HistoDB[j]->GetBinContent(i + 1);
212 }
213 }
214 DBHisto->SetElements(Content);
215 DBHisto.import(iov);
216 delete [] Content;
217}

◆ CreateDBHistoGroup() [2/2]

void CreateDBHistoGroup ( TH1I **  HistoBD,
int  number 
)
static

Function for filling of group of TH1I histogram to database.

Parameters
HistoBDHistogram for DB.
numberNumber of histograms to glue to one.

Definition at line 220 of file DQMCommonUtils.cc.

221{
222 IntervalOfValidity iov(0, 0, -1, -1);
223 TString Name = Form("%s_Ref", HistoDB[0]->GetName());
224 DBImportObjPtr<TVectorD> DBHisto(Name.Data());
225 DBHisto.construct(number * HistoDB[0]->GetNbinsX() + 3);
226 double* Content = new double[number * HistoDB[0]->GetNbinsX() + 3];
227 Content[0] = HistoDB[0]->GetNbinsX();
228 Content[1] = HistoDB[0]->GetXaxis()->GetXmin();
229 Content[2] = HistoDB[0]->GetXaxis()->GetXmax();
230 for (int j = 0; j < number; j++) {
231 for (int i = 0; i < HistoDB[j]->GetNbinsX(); i++) {
232 Content[j * HistoDB[j]->GetNbinsX() + i + 3] = HistoDB[j]->GetBinContent(i + 1);
233 }
234 }
235 DBHisto->SetElements(Content);
236 DBHisto.import(iov);
237 delete [] Content;
238}

◆ LoadDBHisto() [1/2]

int LoadDBHisto ( TH1F *  HistoBD)
static

Function for loading of TH1F histogram from database.

Parameters
HistoBDHistogram for DB.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 241 of file DQMCommonUtils.cc.

242{
243 TString Name = Form("%s_Ref", HistoDB->GetName());
244 DBObjPtr<TVectorD> DBHisto(Name.Data());
245 int ret = 0;
246 if (DBHisto.isValid()) {
247 ret = 1;
248 if (HistoDB->GetNbinsX() != (int)DBHisto->GetMatrixArray()[0]) ret = 0;
249 if (HistoDB->GetXaxis()->GetXmin() != DBHisto->GetMatrixArray()[1]) ret = 0;
250 if (HistoDB->GetXaxis()->GetXmax() != DBHisto->GetMatrixArray()[2]) ret = 0;
251 if (ret) {
252 for (int i = 0; i < HistoDB->GetNbinsX(); i++) {
253 HistoDB->SetBinContent(i + 1, (int)DBHisto->GetMatrixArray()[i + 3]);
254 }
255 }
256 }
257 if (!ret) {
258 B2INFO("ERROR to open reference histogram: " << Name.Data());
259 }
260 return ret;
261}
Class for accessing objects in the database.
Definition: DBObjPtr.h:21

◆ LoadDBHisto() [2/2]

int LoadDBHisto ( TH1I *  HistoBD)
static

Function for loading of TH1I histogram from database.

Parameters
HistoBDHistogram for DB.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 264 of file DQMCommonUtils.cc.

265{
266 TString Name = Form("%s_Ref", HistoDB->GetName());
267 DBObjPtr<TVectorD> DBHisto(Name.Data());
268 int ret = 0;
269 if (DBHisto.isValid()) {
270 ret = 1;
271 if (HistoDB->GetNbinsX() != (int)DBHisto->GetMatrixArray()[0]) ret = 0;
272 if (HistoDB->GetXaxis()->GetXmin() != DBHisto->GetMatrixArray()[1]) ret = 0;
273 if (HistoDB->GetXaxis()->GetXmax() != DBHisto->GetMatrixArray()[2]) ret = 0;
274 if (ret) {
275 for (int i = 0; i < HistoDB->GetNbinsX(); i++) {
276 HistoDB->SetBinContent(i + 1, (int)DBHisto->GetMatrixArray()[i + 3]);
277 }
278 }
279 }
280 if (!ret) {
281 B2INFO("ERROR to open reference histogram: " << Name.Data());
282 }
283 return ret;
284}

◆ LoadDBHistoGroup() [1/2]

int LoadDBHistoGroup ( TH1F **  HistoBD,
int  number 
)
static

Function for loading of group of TH1F histogram from database.

Parameters
HistoBDHistogram for DB.
numberNumber of histograms to extract from DB.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 287 of file DQMCommonUtils.cc.

288{
289 TString Name = Form("%s_Ref", HistoDB[0]->GetName());
290 DBObjPtr<TVectorD> DBHisto(Name.Data());
291 int ret = 0;
292 if (DBHisto.isValid()) {
293 ret = 1;
294 if (HistoDB[0]->GetNbinsX() != (int)DBHisto->GetMatrixArray()[0]) ret = 0;
295 if (HistoDB[0]->GetXaxis()->GetXmin() != DBHisto->GetMatrixArray()[1]) ret = 0;
296 if (HistoDB[0]->GetXaxis()->GetXmax() != DBHisto->GetMatrixArray()[2]) ret = 0;
297 for (int j = 0; j < number; j++) {
298 for (int i = 0; i < HistoDB[j]->GetNbinsX(); i++) {
299 HistoDB[j]->SetBinContent(i + 1, DBHisto->GetMatrixArray()[j * HistoDB[j]->GetNbinsX() + i + 3]);
300 }
301 }
302 }
303 if (!ret) {
304 B2INFO("ERROR to open reference histogram: " << Name.Data());
305 }
306 return ret;
307}

◆ LoadDBHistoGroup() [2/2]

int LoadDBHistoGroup ( TH1I **  HistoBD,
int  number 
)
static

Function for loading of group of TH1I histogram from database.

Parameters
HistoBDHistogram for DB.
numberNumber of histograms to extract from DB.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 310 of file DQMCommonUtils.cc.

311{
312 TString Name = Form("%s_Ref", HistoDB[0]->GetName());
313 DBObjPtr<TVectorD> DBHisto(Name.Data());
314 int ret = 0;
315 if (DBHisto.isValid()) {
316 ret = 1;
317 if (HistoDB[0]->GetNbinsX() != (int)DBHisto->GetMatrixArray()[0]) ret = 0;
318 if (HistoDB[0]->GetXaxis()->GetXmin() != DBHisto->GetMatrixArray()[1]) ret = 0;
319 if (HistoDB[0]->GetXaxis()->GetXmax() != DBHisto->GetMatrixArray()[2]) ret = 0;
320 for (int j = 0; j < number; j++) {
321 for (int i = 0; i < HistoDB[j]->GetNbinsX(); i++) {
322 HistoDB[j]->SetBinContent(i + 1, DBHisto->GetMatrixArray()[j * HistoDB[j]->GetNbinsX() + i + 3]);
323 }
324 }
325 }
326 if (!ret) {
327 B2INFO("ERROR to open reference histogram: " << Name.Data());
328 }
329 return ret;
330}

◆ SetFlag() [1/2]

int SetFlag ( int  Type,
int  bin,
const double *  pars,
double  ratio,
TH1F *  hist,
TH1F *  refhist,
TH1I *  flaghist 
)
static

Function return flag histogram filled based on condition from TH1F source.

Flag values: -3: nonexisting Type -2: histogram is missing or masked -1: less than 100 samples, skip comparison 0: good much with reference 1: warning level = diff > 6 * sigma and < error level 2: error level = diff > 10 * sigma

Parameters
TypeSet type of condition for flag calculation. 1: use counts, mean and RMS. 2: use counts only. 3: use mean only. 4: use RMS only. 5: use counts and mean. 9: use bin content only. 10: use Chi2 condition and pars[0] and pars[1]. 100: nothing do just fill flags as OK.
binbin which is fill in flag histogram.
parsarray of parameters need for condition.
ratioRatio of acquired events to reference events.
histHistogram of sources.
refhistReference histogram.
flaghistHistogram of flags.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 21 of file DQMCommonUtils.cc.

23{
24 int iret = 0;
25 float WarningLevel = 6.0;
26 float ErrorLevel = 10.0;
27 auto temp = std::unique_ptr<TH1F>(new TH1F("temp", "temp", hist->GetNbinsX(), hist->GetXaxis()->GetXmin(),
28 hist->GetXaxis()->GetXmax()));
29 double NEvents = 0;
30 double flagInt = 0;
31 double flagrInt = 0;
32 for (int j = 0; j < hist->GetNbinsX(); j++) {
33 double val = hist->GetBinContent(j + 1);
34 NEvents += val;
35 val = val / ratio;
36 temp->SetBinContent(j + 1, val);
37 flagInt += temp->GetBinContent(j + 1);
38 flagrInt += refhist->GetBinContent(j + 1);
39 }
40 if (NEvents < 100) { // not enough information for comparison
41 iret = -1;
42 flaghist->SetBinContent(bin + 1, -1);
43 return iret;
44 }
45 double flag = temp->GetMean();
46 double flagErr = temp->GetMeanError();
47 double flagRMS = temp->GetRMS();
48 double flagRMSErr = temp->GetRMSError();
49 double flagr = refhist->GetMean();
50 double flagrErr = refhist->GetMeanError();
51 double flagrRMS = refhist->GetRMS();
52 double flagrRMSErr = refhist->GetRMSError();
53 TString strDebugInfo = Form("Conditions for Flag--->\n source %f %f+-%f %f+-%f\n referen %f %f+-%f %f+-%f\n",
54 flagInt, flag, flagErr, flagRMS, flagRMSErr,
55 flagrInt, flagr, flagrErr, flagrRMS, flagrRMSErr
56 );
57 B2DEBUG(130, strDebugInfo.Data());
58 if (Type == 1) { // counts+mean+RMS use
59 if ((fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) ||
60 (fabs(flagRMS - flagrRMS) > ErrorLevel * (flagRMSErr + flagrRMSErr)) ||
61 (fabs(flagInt - flagrInt) > ErrorLevel * (sqrt(flagInt) + sqrt(flagrInt)))
62 ) {
63 flaghist->SetBinContent(bin + 1, 2);
64 } else if ((fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) ||
65 (fabs(flagRMS - flagrRMS) > WarningLevel * (flagRMSErr + flagrRMSErr)) ||
66 (fabs(flagInt - flagrInt) > WarningLevel * (sqrt(flagInt) + sqrt(flagrInt)))
67 ) {
68 flaghist->SetBinContent(bin + 1, 1);
69 } else {
70 flaghist->SetBinContent(bin + 1, 0);
71 }
72 iret = 1;
73 } else if (Type == 2) { // counts use
74 if (fabs(flagInt - flagrInt) > ErrorLevel * (sqrt(flagInt) + sqrt(flagrInt))) {
75 flaghist->SetBinContent(bin + 1, 2);
76 } else if (fabs(flagInt - flagrInt) > WarningLevel * (sqrt(flagInt) + sqrt(flagrInt))) {
77 flaghist->SetBinContent(bin + 1, 1);
78 } else {
79 flaghist->SetBinContent(bin + 1, 0);
80 }
81 iret = 1;
82 } else if (Type == 3) { // mean use
83 if (fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) {
84 flaghist->SetBinContent(bin + 1, 2);
85 } else if (fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) {
86 flaghist->SetBinContent(bin + 1, 1);
87 } else {
88 flaghist->SetBinContent(bin + 1, 0);
89 }
90 iret = 1;
91 } else if (Type == 4) { // RMS use
92 if (fabs(flagRMS - flagrRMS) > ErrorLevel * (flagRMSErr + flagrRMSErr)) {
93 flaghist->SetBinContent(bin + 1, 2);
94 } else if (fabs(flagRMS - flagrRMS) > WarningLevel * (flagRMSErr + flagrRMSErr)) {
95 flaghist->SetBinContent(bin + 1, 1);
96 } else {
97 flaghist->SetBinContent(bin + 1, 0);
98 }
99 iret = 1;
100 } else if (Type == 5) { // counts+mean use
101 if ((fabs(flag - flagr) > ErrorLevel * (flagErr + flagrErr)) ||
102 (fabs(flagInt - flagrInt) > ErrorLevel * (sqrt(flagInt) + sqrt(flagrInt)))
103 ) {
104 flaghist->SetBinContent(bin + 1, 2);
105 } else if ((fabs(flag - flagr) > WarningLevel * (flagErr + flagrErr)) ||
106 (fabs(flagInt - flagrInt) > WarningLevel * (sqrt(flagInt) + sqrt(flagrInt)))
107 ) {
108 flaghist->SetBinContent(bin + 1, 1);
109 } else {
110 flaghist->SetBinContent(bin + 1, 0);
111 }
112 iret = 1;
113 } else if (Type == 9) { // bin content use
114 flagInt = temp->GetBinContent(bin + 1);
115 flagrInt = refhist->GetBinContent(bin + 1);
116 if (fabs(flagInt - flagrInt) > ErrorLevel * (sqrt(flagInt) + sqrt(flagrInt))) {
117 flaghist->SetBinContent(bin + 1, 2);
118 } else if (fabs(flagInt - flagrInt) > WarningLevel * (sqrt(flagInt) + sqrt(flagrInt))) {
119 flaghist->SetBinContent(bin + 1, 1);
120 } else {
121 flaghist->SetBinContent(bin + 1, 0);
122 }
123 iret = 1;
124 } else if (Type == 10) {
125 float flag2 = refhist->Chi2Test(temp.get());
126 flaghist->SetBinContent(bin + 1, 0);
127 if (flag2 > pars[1])
128 flaghist->SetBinContent(bin + 1, 2);
129 if (flag2 > pars[0])
130 flaghist->SetBinContent(bin + 1, 1);
131 iret = 1;
132 } else if (Type == 100) {
133 flaghist->SetBinContent(bin + 1, 0);
134 iret = 1;
135 } else {
136 flaghist->SetBinContent(bin + 1, -3);
137 iret = -1;
138 }
139 strDebugInfo = Form("SetFlag---> %f, type %i\n", flaghist->GetBinContent(bin + 1), Type);
140 B2DEBUG(130, strDebugInfo.Data());
141 return iret;
142}
double sqrt(double a)
sqrt for double
Definition: beamHelpers.h:28

◆ SetFlag() [2/2]

int SetFlag ( int  Type,
int  bin,
const double *  pars,
double  ratio,
TH1I *  hist,
TH1I *  refhist,
TH1I *  flaghist 
)
static

Function return flag histogram filled based on condition from TH1I source.

Flag values: -3: nonexisting Type -2: histogram is missing or masked -1: less than 100 samples, skip comparison 0: good much with reference 1: warning level = diff > 6 * sigma and < error level 2: error level = diff > 10 * sigma

Parameters
TypeSet type of condition for flag calculation. 1: use counts, mean and RMS. 2: use counts only. 3: use mean only. 4: use RMS only. 5: use counts and mean. 9: use bin content only. 10: use Chi2 condition and pars[0] and pars[1]. 100: nothing do just fill flags as OK.
binbin which is fill in flag histogram.
parsarray of parameters need for condition.
ratioRatio of acquired events to reference events.
histHistogram of sources.
refhistReference histogram.
flaghistHistogram of flags.
Returns
Indication of success of realizing of condition, 1: OK.

Definition at line 145 of file DQMCommonUtils.cc.

147{
148 auto histF = std::unique_ptr<TH1F>(new TH1F("histF", "histF", hist->GetNbinsX(), hist->GetXaxis()->GetXmin(),
149 hist->GetXaxis()->GetXmax()));
150 auto refhistF = std::unique_ptr<TH1F>(new TH1F("refhistF", "refhistF", refhist->GetNbinsX(), refhist->GetXaxis()->GetXmin(),
151 refhist->GetXaxis()->GetXmax()));
152 for (int j = 0; j < hist->GetNbinsX(); j++) {
153 histF->SetBinContent(j + 1, hist->GetBinContent(j + 1));
154 refhistF->SetBinContent(j + 1, refhist->GetBinContent(j + 1));
155 }
156 int ret = SetFlag(Type, bin, pars, ratio, histF.get(), refhistF.get(), flaghist);
157 return ret;
158}
static int SetFlag(int Type, int bin, const double *pars, double ratio, TH1F *hist, TH1F *refhist, TH1I *flaghist)
Function return flag histogram filled based on condition from TH1F source.

The documentation for this class was generated from the following files: