Belle II Software development
DQMHistAnalysisSVDDose.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#include <dqm/analysis/modules/DQMHistAnalysisSVDDose.h>
10#include <framework/utilities/Utils.h>
11#include <TROOT.h>
12#include <TText.h>
13
14using namespace std;
15using namespace Belle2;
16
17// Utility function
18inline double getClockSeconds() { return Utils::getClock() / 1e9; }
19
20REG_MODULE(DQMHistAnalysisSVDDose);
21
22DQMHistAnalysisSVDDoseModule::DQMHistAnalysisSVDDoseModule()
23{
24 setDescription("Monitoring of SVD Dose with events from Poisson trigger w/o inj. veto. See also SVDDQMDoseModule.");
25 // THIS MODULE CAN NOT BE RUN IN PARALLEL
26 addParam("pvPrefix", m_pvPrefix, "Prefix for EPICS PVs.", std::string("DQM:SVD:"));
27 addParam("epicsUpdateSeconds", m_epicsUpdateSeconds,
28 "Minimum interval between two successive PV updates (in seconds).", 1000.0);
29 addParam("pvSuffix", m_pvSuffix, "Suffix for EPICS PVs.", std::string(":Occ:Pois:Avg"));
30 addParam("deltaTPVSuffix", m_deltaTPVSuffix, "Suffix for the PV that monitors the update interval of the PVs.",
31 std::string("Occ:Pois:UpdateInterval"));
32 addParam("statePVSuffix", m_statePVSuffix, "Suffix for the PV with the state of the monitoring.",
33 std::string("Occ:Pois:State"));
34}
35
37{
38 B2DEBUG(18, "DQMHistAnalysisSVDDose: initialize");
39
40 gROOT->cd(); // Don't know why I need this, but DQMHistAnalysisSVDOnMiraBelle uses it
41
42 m_monObj = getMonitoringObject("svd"); // To write to MiraBelle
43
44 m_c_instOccu.reserve(c_sensorGroups.size());
45 m_c_occuLER.reserve(c_sensorGroups.size());
46 m_h_occuLER.reserve(c_sensorGroups.size());
47 m_c_occuHER.reserve(c_sensorGroups.size());
48 m_h_occuHER.reserve(c_sensorGroups.size());
49 m_c_occuLER1.reserve(c_sensorGroups.size());
50 m_h_occuLER1.reserve(c_sensorGroups.size());
51 m_c_occuHER1.reserve(c_sensorGroups.size());
52 m_h_occuHER1.reserve(c_sensorGroups.size());
53 m_c_instOccuAll.reserve(c_sensorGroups.size());
54 m_c_occuLERAll.reserve(c_sensorGroups.size());
55 m_h_occuLERAll.reserve(c_sensorGroups.size());
56 m_c_occuHERAll.reserve(c_sensorGroups.size());
57 m_h_occuHERAll.reserve(c_sensorGroups.size());
58 m_c_occuLER1All.reserve(c_sensorGroups.size());
59 m_h_occuLER1All.reserve(c_sensorGroups.size());
60 m_c_occuHER1All.reserve(c_sensorGroups.size());
61 m_h_occuHER1All.reserve(c_sensorGroups.size());
62 for (const auto& group : c_sensorGroups) {
63 TCanvas* c = new TCanvas("SVDDOSE/c_svd_instOccupancy_" + group.nameSuffix + "_pois",
64 "Instantaneous occupancy (Pois. trig.) " + group.titleSuffix);
65 m_c_instOccu.push_back(c);
66 c = new TCanvas("SVDDOSE/c_svd_occuLER_" + group.nameSuffix + "_pois",
67 "Occupancy vs time since LER inj. (Pois. trig.) " + group.titleSuffix);
68 m_c_occuLER.push_back(c);
69 m_h_occuLER.push_back(nullptr);
70 c = new TCanvas("SVDDOSE/c_svd_occuHER_" + group.nameSuffix + "_pois",
71 "Occupancy vs time since HER inj. (Pois. trig.) " + group.titleSuffix);
72 m_c_occuHER.push_back(c);
73 m_h_occuHER.push_back(nullptr);
74 c = new TCanvas("SVDDOSE/c_svd_1DoccuLER_" + group.nameSuffix + "_pois",
75 "Occupancy vs time since LER inj. (Pois. trig.) " + group.titleSuffix);
76 m_c_occuLER1.push_back(c);
77 m_h_occuLER1.push_back(nullptr);
78 c = new TCanvas("SVDDOSE/c_svd_1DoccuHER_" + group.nameSuffix + "_pois",
79 "Occupancy vs time since HER inj. (Pois. trig.) " + group.titleSuffix);
80 m_c_occuHER1.push_back(c);
81 m_h_occuHER1.push_back(nullptr);
82
83 c = new TCanvas("SVDDOSE/c_svd_instOccupancy_" + group.nameSuffix + "_all",
84 "Instantaneous occupancy (all events) " + group.titleSuffix);
85 m_c_instOccuAll.push_back(c);
86 c = new TCanvas("SVDDOSE/c_svd_occuLER_" + group.nameSuffix + "_all",
87 "Occupancy vs time since LER inj. (all events) " + group.titleSuffix);
88 m_c_occuLERAll.push_back(c);
89 m_h_occuLERAll.push_back(nullptr);
90 c = new TCanvas("SVDDOSE/c_svd_occuHER_" + group.nameSuffix + "_all",
91 "Occupancy vs time since HER inj. (all events) " + group.titleSuffix);
92 m_c_occuHERAll.push_back(c);
93 m_h_occuHERAll.push_back(nullptr);
94 c = new TCanvas("SVDDOSE/c_svd_1DoccuLER_" + group.nameSuffix + "_all",
95 "Occupancy vs time since LER inj. (all events) " + group.titleSuffix);
96 m_c_occuLER1All.push_back(c);
97 m_h_occuLER1All.push_back(nullptr);
98 c = new TCanvas("SVDDOSE/c_svd_1DoccuHER_" + group.nameSuffix + "_all",
99 "Occupancy vs time since HER inj. (all events) " + group.titleSuffix);
100 m_c_occuHER1All.push_back(c);
101 m_h_occuHER1All.push_back(nullptr);
102 }
103
104 m_legend = new TPaveText(0.53, 0.73, 0.68, 0.88, "brNDC");
105 m_legend->AddText("LER inj."); ((TText*)m_legend->GetListOfLines()->Last())->SetTextColor(kRed);
106 m_legend->AddText("HER inj."); ((TText*)m_legend->GetListOfLines()->Last())->SetTextColor(kAzure);
107 m_legend->AddText("No inj."); ((TText*)m_legend->GetListOfLines()->Last())->SetTextColor(kBlack);
108
109#ifdef _BELLE2_EPICS
110 if (getUseEpics()) {
111 // Channels for the occupancies
112 m_myPVs.resize(c_sensorGroups.size());
113 for (unsigned int g = 0; g < c_sensorGroups.size(); g++)
114 SEVCHK(ca_create_channel((m_pvPrefix + c_sensorGroups[g].pvMiddle + m_pvSuffix).data(),
115 NULL, NULL, 10, &m_myPVs[g].mychid), "ca_create_channel");
116 // Channels for update interval and state
117 SEVCHK(ca_create_channel((m_pvPrefix + m_deltaTPVSuffix).data(),
118 NULL, NULL, 10, &m_timeSinceLastPVUpdateChan), "ca_create_channel");
119 SEVCHK(ca_create_channel((m_pvPrefix + m_statePVSuffix).data(),
120 NULL, NULL, 10, &m_stateChan), "ca_create_channel");
121 // Actually do create the channels, communicating with the IOC
122 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
123 // Get the state enum
124 if (m_stateChan) {
125 SEVCHK(ca_get(DBR_CTRL_ENUM, m_stateChan, &m_stateCtrl), "ca_get");
126 B2DEBUG(19, "State PV initialized (ca_get)" << LogVar("value", m_stateCtrl.value));
127 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
128 } else {
129 B2DEBUG(18, "State PV failed to initialize, will retry in beginRun(), event() and endRun().");
130 }
131 // First update should happen m_epicsUpdateSeconds from now
132 m_lastPVUpdate = getClockSeconds();
133 }
134#endif
135}
136
138{
139 // Set status PV to running, reset last update time
140#ifdef _BELLE2_EPICS
141 if (getUseEpics()) {
142 B2DEBUG(19, "beginRun: setting state PV to RUNNING");
143 m_stateCtrl.value = 1;
144 if (m_stateChan) {
145 SEVCHK(ca_put(DBR_ENUM, m_stateChan, &m_stateCtrl.value), "ca_put");
146 } else {
147 SEVCHK(ca_create_channel((m_pvPrefix + m_statePVSuffix).data(),
148 NULL, NULL, 10, &m_stateChan), "ca_create_channel (reconnection)");
149 }
150 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
151 // First update should happen m_epicsUpdateSeconds from now
152 m_lastPVUpdate = getClockSeconds();
153 }
154#endif
155}
156
158{
159 // Update PVs ("write" to EPICS)
160#ifdef _BELLE2_EPICS
161 double timeSinceLastPVUpdate = getClockSeconds() - m_lastPVUpdate;
162 if (getUseEpics() && timeSinceLastPVUpdate >= m_epicsUpdateSeconds) {
163 // Dummy ca_get to ensure reconnection to the IOC in case of past errors
164 if (m_stateChan) {
165 SEVCHK(ca_get(DBR_CTRL_ENUM, m_stateChan, &m_stateCtrl), "ca_get");
166 } else {
167 SEVCHK(ca_create_channel((m_pvPrefix + m_statePVSuffix).data(),
168 NULL, NULL, 10, &m_stateChan), "ca_create_channel (reconnection)");
169 }
170 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
171
172 // Write updateInterval PV and state PV first
173 if (m_timeSinceLastPVUpdateChan) {
174 SEVCHK(ca_put(DBR_DOUBLE, m_timeSinceLastPVUpdateChan, (void*)&timeSinceLastPVUpdate), "ca_put");
175 } else {
176 SEVCHK(ca_create_channel((m_pvPrefix + m_deltaTPVSuffix).data(), NULL, NULL, 10, &m_timeSinceLastPVUpdateChan),
177 "ca_create_channel (reconnection)");
178 }
179 m_stateCtrl.value = 1; // If IOC is restarted this PV must be re-updated
180 if (m_stateChan) {
181 SEVCHK(ca_put(DBR_ENUM, m_stateChan, &m_stateCtrl.value), "ca_put");
182 } else {
183 SEVCHK(ca_create_channel((m_pvPrefix + m_statePVSuffix).data(),
184 NULL, NULL, 10, &m_stateChan), "ca_create_channel (reconnection)");
185 }
186 // Update occupancy PVs
187 for (unsigned int g = 0; g < c_sensorGroups.size(); g++) {
188 const auto& group = c_sensorGroups[g];
189 double nHits = 0.0, nEvts = 0.0;
190 for (TString dir : {"SVDDoseLERInjPois", "SVDDoseHERInjPois", "SVDDoseNoInjPois"}) {
191 auto hHits = findHistT<TH2F>(dir + "/SVDHitsVsTime_" + group.nameSuffix);
192 auto hEvts = findHistT<TH2F>(dir + "/SVDEvtsVsTime");
193 if (!hHits || !hEvts) {
194 B2WARNING("Histograms needed for Average Poisson Occupancy U-side not found.");
195 nEvts = 0.0;
196 break;
197 }
198 nHits += hHits->GetEntries();
199 nEvts += hEvts->GetEntries();
200 }
201
202 B2DEBUG(19, "DQMHistAnalysisSVDDose: PV write"
203 << LogVar("group", group.nameSuffix.Data())
204 << LogVar("nEvts", nEvts) << LogVar("nHits", nHits));
205
206 auto& pv = m_myPVs[g];
207 double delta_nHits = nHits - pv.lastNHits;
208 double delta_nEvts = nEvts - pv.lastNEvts;
209 double occ = delta_nEvts > 0.0 ? (delta_nHits / delta_nEvts * 100.0 / group.nStrips) : -1.0;
210 if (pv.mychid) {
211 SEVCHK(ca_put(DBR_DOUBLE, pv.mychid, (void*)&occ), "ca_put");
212 } else {
213 SEVCHK(ca_create_channel((m_pvPrefix + c_sensorGroups[g].pvMiddle + m_pvSuffix).data(),
214 NULL, NULL, 10, &m_myPVs[g].mychid), "ca_create_channel (reconnection)");
215 }
216 pv.lastNEvts = nEvts;
217 pv.lastNHits = nHits;
218 }
219
220 // Actually write all the PVs
221 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
222 m_lastPVUpdate = getClockSeconds();
223 }
224#endif
225
227}
228
230{
231 B2DEBUG(18, "DQMHistAnalysisSVDDose: endRun");
232
233 // EPICS: reset the counters used for the delta computation, set state to NOT RUNNING
234#ifdef _BELLE2_EPICS
235 if (getUseEpics()) {
236 B2DEBUG(19, "endRun: setting state PV to NOT RUNNING");
237 m_stateCtrl.value = 0;
238 if (m_stateChan) {
239 SEVCHK(ca_put(DBR_ENUM, m_stateChan, &m_stateCtrl.value), "ca_put");
240 } else {
241 SEVCHK(ca_create_channel((m_pvPrefix + m_statePVSuffix).data(),
242 NULL, NULL, 10, &m_stateChan), "ca_create_channel (reconnection)");
243 }
244 SEVCHK(ca_pend_io(2.0), "ca_pend_io");
245 // Reset events and hits counters
246 for (auto& pv : m_myPVs)
247 pv.lastNEvts = pv.lastNHits = 0.0;
248 }
249#endif
250
251 // Write to MiraBelle
252 for (unsigned int g = 0; g < c_sensorGroups.size(); g++) {
253 const auto& group = c_sensorGroups[g];
254 double nHits = 0.0, nEvts = 0.0;
255 for (TString dir : {"SVDDoseLERInjPois", "SVDDoseHERInjPois", "SVDDoseNoInjPois"}) {
256 auto hHits = findHistT<TH2F>(dir + "/SVDHitsVsTime_" + group.nameSuffix);
257 auto hEvts = findHistT<TH2F>(dir + "/SVDEvtsVsTime");
258 if (!hHits || !hEvts) {
259 B2WARNING("Histograms needed for Average Poisson Occupancy U-side not found.");
260 nEvts = 0.0;
261 break;
262 }
263 nHits += hHits->GetEntries();
264 nEvts += hEvts->GetEntries();
265 }
266
267 B2DEBUG(19, "DQMHistAnalysisSVDDose: MonObj write"
268 << LogVar("group", group.nameSuffix.Data())
269 << LogVar("nEvts", nEvts) << LogVar("nHits", nHits));
270
271 if (nEvts > 0) {
272 const double occ = nHits / nEvts * 100.0 / group.nStrips;
273 TString vName = group.nameSuffix + "OccPoisAvg"; // e.g. L3XXUOccPoisAvg
274 m_monObj->setVariable(vName.Data(), occ);
275 }
276 }
277
279}
280
282{
283 B2DEBUG(18, "DQMHistAnalysisSVDDose: updating canvases");
284
285 for (unsigned int g = 0; g < c_sensorGroups.size(); g++) {
286 const auto& group = c_sensorGroups[g];
287
288 auto c = m_c_instOccu[g];
289 auto hLER = findHistT<TH1F>("SVDDoseLERInjPois/SVDInstOccu_" + group.nameSuffix);
290 auto hHER = findHistT<TH1F>("SVDDoseHERInjPois/SVDInstOccu_" + group.nameSuffix);
291 auto hNo = findHistT<TH1F>("SVDDoseNoInjPois/SVDInstOccu_" + group.nameSuffix);
292 if (hLER && hHER && hNo) {
293 hLER->SetLineColor(kRed);
294 hHER->SetLineColor(kAzure);
295 hNo->SetLineColor(kBlack);
296 carryOverflowOver(hLER);
297 carryOverflowOver(hHER);
299 c->Clear();
300 c->cd(0);
301 hNo->SetTitle("SVD instantaneous occu. " + group.titleSuffix + " U-side Pois. trig.");
302 hNo->Draw("hist"); // hNo usually has the larger maximum by far
303 hLER->Draw("hist same");
304 hHER->Draw("hist same");
305 c->SetLogy();
306 m_legend->Draw();
307 }
308
309 c = m_c_occuLER[g];
310 auto hHits = findHistT<TH2F>("SVDDoseLERInjPois/SVDHitsVsTime_" + group.nameSuffix);
311 auto hEvts = findHistT<TH2F>("SVDDoseLERInjPois/SVDEvtsVsTime");
312 if (hHits && hEvts) {
313 m_h_occuLER[g] = divide(hHits, hEvts, 100.0f / group.nStrips, m_h_occuLER[g]);
314 m_h_occuLER[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - LER inj. Pois. trig."
315 ";Time since last injection [#mus];Time in beam cycle [#mus]"
316 ";Occupancy [%]");
317 m_h_occuLER[g]->SetMinimum(1e-3);
318 m_h_occuLER[g]->SetMaximum(10);
319 c->Clear();
320 c->cd(0);
321 c->SetRightMargin(0.16); // For the colorbar
322 m_h_occuLER[g]->Draw("COLZ");
323 c->SetLogz();
324 }
325
326 c = m_c_occuLER1[g];
327 auto hpEvts = findHistT<TH1F>("SVDDoseLERInjPois/SVDEvtsVsTime1");
328 auto hpHits = findHistT<TH1F>("SVDDoseLERInjPois/SVDHitsVsTime1_" + group.nameSuffix);
329 if (hpHits && hpEvts) {
330 m_h_occuLER1[g] = divide(hpHits, hpEvts, 100.0f / group.nStrips, m_h_occuLER1[g]);
331 m_h_occuLER1[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - LER inj. Pois. trig."
332 ";Time since last injection [#mus];Occupancy [%]");
333 m_h_occuLER1[g]->SetMinimum(1e-3);
334 m_h_occuLER1[g]->SetMaximum(10);
335 c->Clear();
336 c->cd(0);
337 m_h_occuLER1[g]->SetMarkerStyle(7);
338 m_h_occuLER1[g]->Draw("hist P");
339 c->SetLogy();
340 }
341
342 c = m_c_occuHER[g];
343 hHits = findHistT<TH2F>("SVDDoseHERInjPois/SVDHitsVsTime_" + group.nameSuffix);
344 hEvts = findHistT<TH2F>("SVDDoseHERInjPois/SVDEvtsVsTime");
345 if (hHits && hEvts) {
346 m_h_occuHER[g] = divide(hHits, hEvts, 100.0f / group.nStrips, m_h_occuHER[g]);
347 m_h_occuHER[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - HER inj. Pois. trig."
348 ";Time since last injection [#mus];Time in beam cycle [#mus]"
349 ";Occupancy [%]");
350 m_h_occuHER[g]->SetMinimum(1e-3);
351 m_h_occuHER[g]->SetMaximum(10);
352 c->Clear();
353 c->cd(0);
354 c->SetRightMargin(0.16); // For the colorbar
355 m_h_occuHER[g]->Draw("COLZ");
356 c->SetLogz();
357 }
358
359 c = m_c_occuHER1[g];
360 hpEvts = findHistT<TH1F>("SVDDoseHERInjPois/SVDEvtsVsTime1");
361 hpHits = findHistT<TH1F>("SVDDoseHERInjPois/SVDHitsVsTime1_" + group.nameSuffix);
362 if (hpHits && hpEvts) {
363 m_h_occuHER1[g] = divide(hpHits, hpEvts, 100.0f / group.nStrips, m_h_occuHER1[g]);
364 m_h_occuHER1[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - HER inj. Pois. trig."
365 ";Time since last injection [#mus];Occupancy [%]");
366 m_h_occuHER1[g]->SetMinimum(1e-3);
367 m_h_occuHER1[g]->SetMaximum(10);
368 c->Clear();
369 c->cd(0);
370 m_h_occuHER1[g]->SetMarkerStyle(7);
371 m_h_occuHER1[g]->Draw("hist P");
372 c->SetLogy();
373 }
374
375 // ========== All events =============
376 c = m_c_instOccuAll[g];
377 hLER = findHistT<TH1F>("SVDDoseLERInjAll/SVDInstOccu_" + group.nameSuffix);
378 hHER = findHistT<TH1F>("SVDDoseHERInjAll/SVDInstOccu_" + group.nameSuffix);
379 hNo = findHistT<TH1F>("SVDDoseNoInjAll/SVDInstOccu_" + group.nameSuffix);
380 if (hLER && hHER && hNo) {
381 hLER->SetLineColor(kRed);
382 hHER->SetLineColor(kAzure);
383 hNo->SetLineColor(kBlack);
384 carryOverflowOver(hLER);
385 carryOverflowOver(hHER);
387 c->Clear();
388 c->cd(0);
389 hNo->SetTitle("SVD instantaneous occu. " + group.titleSuffix + " U-side all events");
390 hNo->Draw("hist"); // hNo usually has the larger maximum by far
391 hLER->Draw("hist same");
392 hHER->Draw("hist same");
393 c->SetLogy();
394 m_legend->Draw();
395 }
396
397 c = m_c_occuLERAll[g];
398 hHits = findHistT<TH2F>("SVDDoseLERInjAll/SVDHitsVsTime_" + group.nameSuffix);
399 hEvts = findHistT<TH2F>("SVDDoseLERInjAll/SVDEvtsVsTime");
400 if (hHits && hEvts) {
401 m_h_occuLERAll[g] = divide(hHits, hEvts, 100.0f / group.nStrips, m_h_occuLERAll[g]);
402 m_h_occuLERAll[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - LER inj. all events"
403 ";Time since last injection [#mus];Time in beam cycle [#mus]"
404 ";Occupancy [%]");
405 m_h_occuLERAll[g]->SetMinimum(1e-3);
406 m_h_occuLERAll[g]->SetMaximum(10);
407 c->Clear();
408 c->cd(0);
409 c->SetRightMargin(0.16); // For the colorbar
410 m_h_occuLERAll[g]->Draw("COLZ");
411 c->SetLogz();
412 }
413
414 c = m_c_occuLER1All[g];
415 hpEvts = findHistT<TH1F>("SVDDoseLERInjAll/SVDEvtsVsTime1");
416 hpHits = findHistT<TH1F>("SVDDoseLERInjAll/SVDHitsVsTime1_" + group.nameSuffix);
417 if (hpHits && hpEvts) {
418 m_h_occuLER1All[g] = divide(hpHits, hpEvts, 100.0f / group.nStrips, m_h_occuLER1All[g]);
419 m_h_occuLER1All[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - LER inj. all events"
420 ";Time since last injection [#mus];Occupancy [%]");
421 m_h_occuLER1All[g]->SetMinimum(1e-3);
422 m_h_occuLER1All[g]->SetMaximum(10);
423 c->Clear();
424 c->cd(0);
425 m_h_occuLER1All[g]->SetMarkerStyle(7);
426 m_h_occuLER1All[g]->Draw("hist P");
427 c->SetLogy();
428 }
429
430 c = m_c_occuHERAll[g];
431 hHits = findHistT<TH2F>("SVDDoseHERInjAll/SVDHitsVsTime_" + group.nameSuffix);
432 hEvts = findHistT<TH2F>("SVDDoseHERInjAll/SVDEvtsVsTime");
433 if (hHits && hEvts) {
434 m_h_occuHERAll[g] = divide(hHits, hEvts, 100.0f / group.nStrips, m_h_occuHERAll[g]);
435 m_h_occuHERAll[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - HER inj. all events"
436 ";Time since last injection [#mus];Time in beam cycle [#mus]"
437 ";Occupancy [%]");
438 m_h_occuHERAll[g]->SetMinimum(1e-3);
439 m_h_occuHERAll[g]->SetMaximum(10);
440 c->Clear();
441 c->cd(0);
442 c->SetRightMargin(0.16); // For the colorbar
443 m_h_occuHERAll[g]->Draw("COLZ");
444 c->SetLogz();
445 }
446
447 c = m_c_occuHER1All[g];
448 hpEvts = findHistT<TH1F>("SVDDoseHERInjAll/SVDEvtsVsTime1");
449 hpHits = findHistT<TH1F>("SVDDoseHERInjAll/SVDHitsVsTime1_" + group.nameSuffix);
450 if (hpHits && hpEvts) {
451 m_h_occuHER1All[g] = divide(hpHits, hpEvts, 100.0f / group.nStrips, m_h_occuHER1All[g]);
452 m_h_occuHER1All[g]->SetTitle("SVD Occupancy " + group.titleSuffix + " - HER inj. all events"
453 ";Time since last injection [#mus];Occupancy [%]");
454 m_h_occuHER1All[g]->SetMinimum(1e-3);
455 m_h_occuHER1All[g]->SetMaximum(10);
456 c->Clear();
457 c->cd(0);
458 m_h_occuHER1All[g]->SetMarkerStyle(7);
459 m_h_occuHER1All[g]->Draw("hist P");
460 c->SetLogy();
461 }
462 }
463}
464
466{
467 int i = h->GetNbinsX();
468 float t = h->GetBinContent(i) + h->GetBinContent(i + 1);
469 h->SetBinContent(i, t);
470 h->SetBinContent(i + 1, 0);
471}
472
473const vector<DQMHistAnalysisSVDDoseModule::SensorGroup> DQMHistAnalysisSVDDoseModule::c_sensorGroups = {
474 {"L31XU", "L3.1", "L3:1", 768 * 2},
475 {"L32XU", "L3.2", "L3:2", 768 * 2},
476 {"L3XXU", "L3 avg.", "L3", 768 * 14},
477 {"L4XXU", "L4 avg.", "L4", 768 * 30},
478 {"L5XXU", "L5 avg.", "L5", 768 * 48},
479 {"L6XXU", "L6 avg.", "L6", 768 * 80}
480};
static bool getUseEpics(void)
Getter for EPICS usage.
static MonitoringObject * getMonitoringObject(const std::string &name)
Get MonitoringObject with given name (new object is created if non-existing)
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.
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.
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
Class to store variables with their name which were sent to the logging service.
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
double getClock()
Return current value of the real-time clock.
Definition Utils.cc:71
Abstract base class for different kinds of events.
STL namespace.