Belle II Software development
cdcDQM7.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 "cdc/modules/cdcDQM/cdcDQM7.h"
10
11#include <framework/core/HistoModule.h>
12
13// framework aux
14#include <framework/logging/Logger.h>
15
16#include <TDirectory.h>
17
18using namespace std;
19using namespace Belle2;
20
21//-----------------------------------------------------------------
22// Register the Module
23//-----------------------------------------------------------------
24REG_MODULE(cdcDQM7);
25
26//-----------------------------------------------------------------
27// Implementation
28//-----------------------------------------------------------------
29
31{
32 //Set module properties
33 setDescription("CDC DQM module");
35}
36
40
41//------------------------------------------------------------------
42// Function to define histograms
43//-----------------------------------------------------------------
44
45TH1D* h_nhits_L[56] = {0}; // hit in each layer
46
47TH1D* h_tdc_sL[9] = {0}; // tdc each super layer
48TH1D* h_adc_sL[9] = {0}; // adc each super layer
49
50TH1D* h_fast_tdc; // fastest TDC in each event
51TH1D* h_board_out_tdc; // out of range TDC
52TH2D* bmap_2; // board(copper-finess) status map 2D
53
54// add 20190205
55TH1D* h_occ; // occupancy
56TH1D* h_occ_L[56]; // occupancy layer dependent
57TH1D* h_hit_cell; // hit vs cell id
58
59TH1D* h_EoccAfterInjLER; /*<nhits after LER injection>*/
60TH1D* h_EoccAfterInjHER; /*<nhits after HER injection>*/
61TH1D* h_occAfterInjLER; /*<occupancy after LER injection>*/
62TH1D* h_occAfterInjHER; /*<occupancy after HER injection>*/
63
64
66{
67
68 TDirectory* oldDir = gDirectory;
69 TDirectory* dirDAQ = oldDir->mkdir("CDC");
70
71 dirDAQ->cd();
72
73 int bmin = 0;
74 int bmax;
75 const int ndiv[9] = {160, 160, 192, 224, 256, 288, 320, 352, 384};
76
77 for (int b = 0; b < 56; b++) {
78
79 if (b < 8) {
80 bmax = ndiv[0];
81 } else if (b < 14) {
82 bmax = ndiv[1];
83 } else if (b < 20) {
84 bmax = ndiv[2];
85 } else if (b < 26) {
86 bmax = ndiv[3];
87 } else if (b < 32) {
88 bmax = ndiv[4];
89 } else if (b < 38) {
90 bmax = ndiv[5];
91 } else if (b < 44) {
92 bmax = ndiv[6];
93 } else if (b < 50) {
94 bmax = ndiv[7];
95 } else {
96 bmax = ndiv[8];
97 }
98
99 // nhits_L
100 h_nhits_L[b] = new TH1D(Form("nhits_L%d", b), Form("nhits Layer %d", b), bmax - bmin, bmin, bmax);
101 h_nhits_L[b]->SetMinimum(0);
102 h_nhits_L[b]->SetFillColor(7);
103
104 h_occ_L[b] = new TH1D(Form("h_occ_L%d", b), "occ. each layer", 100, 0, 1); //
105 h_occ_L[b]->SetFillColor(96);
106 h_occ_L[b]->SetMinimum(0);
107 h_occ_L[b]->SetStats(0);
108
109 }
110
111 for (int s = 0; s < 9; s++) {
112 h_tdc_sL[s] = new TH1D(Form("tdc_sL%d", s), Form("tdc sLayer %d", s), 250, 4200, 5200);
113 h_tdc_sL[s]->SetMinimum(0);
114 h_tdc_sL[s]->SetFillColor(6);
115
116 h_adc_sL[s] = new TH1D(Form("adc_sL%d", s), Form("adc sLayer %d", s), 100, 0, 500);
117 h_adc_sL[s]->SetMinimum(0);
118 h_adc_sL[s]->SetFillColor(8);
119 }
120
121 h_fast_tdc = new TH1D("fast_tdc", "fastest TDC", 50, 4800, 5000);
122 h_fast_tdc->SetFillColor(6);
123
124 h_board_out_tdc = new TH1D("h_board_out_tdc", "out of range TDC", 300, 0, 300);
125 h_board_out_tdc->SetFillColor(95);
126
127 // 20190205
128 h_occ = new TH1D("occ", "occ. total", 100, 0, 1.);
129 h_occ->SetFillColor(95);
130
131 // 20191108
132 h_hit_cell = new TH1D("h_hit_cell", "Hit of each cell", 14336, 0, 14335);
133 h_hit_cell->SetFillColor(20);
134 //
135 bmap_2 = new TH2D("bmap_2", "", 75, 0, 75, 4, 0, 4);
136
137 h_tdc_sL[6]->SetOption("hist");
138
139 h_board_out_tdc->SetOption("hist");
140
141 // set
142 h_fast_tdc->SetStats(1);
143 bmap_2->SetOption("zcol"); //
144 bmap_2->SetStats(0);
145
146 h_EoccAfterInjLER = new TH1D("EoccAfterInjLer", "Eocc after LER injection", 4000, 0, 20000);
147 h_EoccAfterInjLER->SetMinimum(0);
148 h_EoccAfterInjLER->SetFillColor(7);
149
150 h_EoccAfterInjHER = new TH1D("EoccAfterInjHer", "Eocc after HER injection", 4000, 0, 20000);
151 h_EoccAfterInjHER->SetMinimum(0);
152 h_EoccAfterInjHER->SetFillColor(7);
153
154 h_occAfterInjLER = new TH1D("occAfterInjLer", "occupancy after LER injection", 4000, 0, 20000);
155 h_occAfterInjLER->SetMinimum(0);
156 h_occAfterInjLER->SetFillColor(7);
157
158 h_occAfterInjHER = new TH1D("occAfterInjHer", "occupancy after HER injection", 4000, 0, 20000);
159 h_occAfterInjHER->SetMinimum(0);
160 h_occAfterInjHER->SetFillColor(7);
161
162 oldDir->cd();//
163
164}
165
167{
168 REG_HISTOGRAM // required to register histograms to HistoManager
169 // register dataobjects
170 m_rawFTSW.isOptional();
171 m_CDCRawHits.isRequired();
172 m_CDCHits.isRequired();
173}
174
176{
177 for (int i = 0; i < 56; i++) {
178 h_nhits_L[i]->Reset();
179 h_occ_L[i]->Reset();
180
181 }
182
183 for (int j = 0; j < 9; j++) {
184 h_tdc_sL[j]->Reset();
185 h_adc_sL[j]->Reset();
186 }
187
188 h_fast_tdc->Reset();
189 h_board_out_tdc->Reset();
190 bmap_2->Reset();
191 h_occ->Reset();
192 h_hit_cell->Reset();
193
194 h_EoccAfterInjLER->Reset();
195 h_EoccAfterInjHER->Reset();
196 h_occAfterInjLER->Reset();
197 h_occAfterInjHER->Reset();
198
199}
200
202{
203 int nent = m_CDCHits.getEntries();
204 int ftdc = 0;
205
206 // occ total
207 double occ_total = nent / 14336.;
208 h_occ->Fill(occ_total);
209
210 // for layer dependent occupancy
211 int whits_L[56] = {}; // wire hits
212 double occ_L[56] = {}; // occupancy
213
214 const int ndiv[9] = {160, 160, 192, 224, 256, 288, 320, 352, 384};
215
216 for (int i = 0; i < nent; i++) {
217 const CDCHit* cdchit = static_cast<CDCHit*>(m_CDCHits[i]);
218
219 int sL = cdchit->getISuperLayer();
220 int iL = cdchit->getILayer();
221 int wid = cdchit->getIWire();
222 int adcsum = cdchit->getADCCount();
223 // cppcheck-suppress variableScope ; kept next to the related declarations for readability
224 int vtdc = cdchit->getTDCCount();
225
226 if (sL > 8) continue; // error
227 if (iL > 8) continue; // error
228
229 int num = sL * 6 + iL + 2;
230 if (num > 55) continue; // error
231
232 // wire hits
233 if (sL == 0) {
234 whits_L[iL]++;
235 } else {
236 whits_L[num]++;
237 }
238
239 if (adcsum > -1) {
240
241 if (sL == 0) {
242 h_nhits_L[iL]->Fill(wid);
243 } else {
244 h_nhits_L[num]->Fill(wid);
245 }
246
247 //
248 if (vtdc > ftdc && adcsum > 20) {
249 ftdc = vtdc;
250 }// fastest
251
252 }// adc
253
254 // add by J.H. Yin
255 if (adcsum > 25) {
256 int cid(0);
257 if (sL == 0) {
258 cid = iL * ndiv[sL] + wid;
259 } else {
260 for (int isl = 0; isl < sL; isl ++) {
261 cid += 6 * ndiv[isl];
262 }
263 cid += 2 * ndiv[0] + iL * ndiv[sL] + wid;
264 }
265 h_hit_cell -> Fill(cid);
266 }
267 }// cdchit
268
269 h_fast_tdc->Fill(ftdc);
270
271 // each layer
272 for (int b = 0; b < 56; b++) {
273 int n_wire = 0;
274 if (b < 8) {
275 n_wire = ndiv[0];
276 } else if (b < 14) {
277 n_wire = ndiv[1];
278 } else if (b < 20) {
279 n_wire = ndiv[2];
280 } else if (b < 26) {
281 n_wire = ndiv[3];
282 } else if (b < 32) {
283 n_wire = ndiv[4];
284 } else if (b < 38) {
285 n_wire = ndiv[5];
286 } else if (b < 44) {
287 n_wire = ndiv[6];
288 } else if (b < 50) {
289 n_wire = ndiv[7];
290 } else {
291 n_wire = ndiv[8];
292 }
293
294 // cal. occupancy
295 occ_L[b] = (double)whits_L[b] / n_wire;
296 h_occ_L[b]->Fill(occ_L[b]);
297 }
298
299
300 //
301 int r_nent = m_CDCRawHits.getEntries();
302
303 // new
304 for (int j = 0; j < r_nent; j++) {
305 const CDCRawHit* cdcrawhit = static_cast<CDCRawHit*>(m_CDCRawHits[j]);
306
307 int brd = cdcrawhit->getBoardId();
308 int v_adc = cdcrawhit->getFADC();
309 int v_tdc = cdcrawhit->getTDC();
310 int n_tot = cdcrawhit->getTOT();
311 int n_node = cdcrawhit->getNode();
312 int n_fns = cdcrawhit->getFiness();
313
314 bmap_2->Fill(n_node, n_fns);
315
316 if (v_tdc > 5200 || v_tdc < 4200) {
317 h_board_out_tdc->Fill(brd);
318 }
319
320 // printf("%d, %d:\n", j, board);
321 if (brd > 299) continue;
322 if (n_tot < 4) continue;
323 if (v_adc < 35) continue;
324
325 // each sL
326 if (brd < 28) {
327 h_tdc_sL[0]->Fill(v_tdc);
328 h_adc_sL[0]->Fill(v_adc);
329 } else if (brd < 48) {
330 h_tdc_sL[1]->Fill(v_tdc);
331 h_adc_sL[1]->Fill(v_adc);
332 } else if (brd < 72) {
333 h_tdc_sL[2]->Fill(v_tdc);
334 h_adc_sL[2]->Fill(v_adc);
335 } else if (brd < 100) {
336 h_tdc_sL[3]->Fill(v_tdc);
337 h_adc_sL[3]->Fill(v_adc);
338 } else if (brd < 132) {
339 h_tdc_sL[4]->Fill(v_tdc);
340 h_adc_sL[4]->Fill(v_adc);
341 } else if (brd < 168) {
342 h_tdc_sL[5]->Fill(v_tdc);
343 h_adc_sL[5]->Fill(v_adc);
344 } else if (brd < 208) {
345 h_tdc_sL[6]->Fill(v_tdc);
346 h_adc_sL[6]->Fill(v_adc);
347 } else if (brd < 252) {
348 h_tdc_sL[7]->Fill(v_tdc);
349 h_adc_sL[7]->Fill(v_adc);
350 } else {
351 h_tdc_sL[8]->Fill(v_tdc);
352 h_adc_sL[8]->Fill(v_adc);
353 }
354
355
356 }// cdcrawhits
357
358 for (auto& it : m_rawFTSW) {
359 B2DEBUG(29, "TTD FTSW : " << hex << it.GetTTUtime(0) << " " << it.GetTTCtime(0) << " EvtNr " << it.GetEveNo(0) << " Type " <<
360 (it.GetTTCtimeTRGType(0) & 0xF) << " TimeSincePrev " << it.GetTimeSincePrevTrigger(0) << " TimeSinceInj " <<
361 it.GetTimeSinceLastInjection(0) << " IsHER " << it.GetIsHER(0) << " Bunch " << it.GetBunchNumber(0));
362 auto difference = it.GetTimeSinceLastInjection(0);
363 if (difference != 0x7FFFFFFF) {
364 //unsigned int nentries = m_digits.getEntries();
365 float diff2 = difference / 127.; // 127MHz clock ticks to us, inexact rounding
366 if (it.GetIsHER(0)) {
367 h_occAfterInjHER->Fill(diff2, occ_total);
368 h_EoccAfterInjHER->Fill(diff2);
369 } else {
370 h_occAfterInjLER->Fill(diff2, occ_total);
371 h_EoccAfterInjLER->Fill(diff2);
372 }
373 }
374 }
375
376
377
378
379}
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
Definition CDCHit.h:40
unsigned short getIWire() const
Getter for iWire.
Definition CDCHit.h:166
short getTDCCount() const
Getter for TDC count.
Definition CDCHit.h:219
unsigned short getADCCount() const
Getter for integrated charge.
Definition CDCHit.h:230
unsigned short getISuperLayer() const
Getter for iSuperLayer.
Definition CDCHit.h:184
unsigned short getILayer() const
Getter for iLayer.
Definition CDCHit.h:172
The CDCRawHit (suppressed mode) class.
Definition CDCRawHit.h:25
unsigned short getTOT(void) const
Getter for TOT value.
Definition CDCRawHit.h:116
unsigned short getBoardId(void) const
Getter for boar ID.
Definition CDCRawHit.h:92
unsigned short getTDC(void) const
Getter for TDC value.
Definition CDCRawHit.h:108
unsigned short getNode(void) const
Getter for Node ID.
Definition CDCRawHit.h:59
unsigned short getFiness(void) const
Getter for Finess ID.
Definition CDCRawHit.h:68
unsigned short getFADC(void) const
Getter for FADC value.
Definition CDCRawHit.h:100
HistoModule()
Constructor.
Definition HistoModule.h:32
void setDescription(const std::string &description)
Sets the description of the module.
Definition Module.cc:214
void setPropertyFlags(unsigned int propertyFlags)
Sets the flags for the module properties.
Definition Module.cc:208
@ c_ParallelProcessingCertified
This module can be run in parallel processing mode safely (All I/O must be done through the data stor...
Definition Module.h:80
TH1D * h_board_out_tdc
board w/ out of range TDC
Definition cdcDQM7.h:69
TH1D * h_fast_tdc
fastest TDC in each event
Definition cdcDQM7.h:68
TH1D * h_tdc_sL[9]
tdc each super layer
Definition cdcDQM7.h:65
TH1D * h_occAfterInjLER
occupancy after LER injection.
Definition cdcDQM7.h:80
void initialize() override
Module functions.
Definition cdcDQM7.cc:166
void event() override
action per each event
Definition cdcDQM7.cc:201
StoreArray< CDCRawHit > m_CDCRawHits
CDC raw hits.
Definition cdcDQM7.h:58
StoreArray< RawFTSW > m_rawFTSW
Input array for DAQ Status.
Definition cdcDQM7.h:83
TH2D * bmap_2
board status map 2D
Definition cdcDQM7.h:71
TH1D * h_EoccAfterInjLER
nhits after LER injection.
Definition cdcDQM7.h:78
TH1D * h_EoccAfterInjHER
nhits after HER injection.
Definition cdcDQM7.h:79
TH1D * h_nhits_L[56]
histogram hit in each layer
Definition cdcDQM7.h:63
void beginRun() override
action at runbegin
Definition cdcDQM7.cc:175
TH1D * h_occAfterInjHER
occupancy after HER injection.
Definition cdcDQM7.h:81
TH1D * h_adc_sL[9]
adc each super layer
Definition cdcDQM7.h:66
TH1D * h_occ_L[56]
occupancy-layer-dep.
Definition cdcDQM7.h:74
virtual ~cdcDQM7Module() override
Destructor.
Definition cdcDQM7.cc:37
cdcDQM7Module()
Constructor.
Definition cdcDQM7.cc:30
TH1D * h_hit_cell
hits-of-cell
Definition cdcDQM7.h:76
TH1D * h_occ
occupancy
Definition cdcDQM7.h:73
void defineHisto() override
action at run end termination action
Definition cdcDQM7.cc:65
StoreArray< CDCHit > m_CDCHits
CDC hits.
Definition cdcDQM7.h:61
#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.