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