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