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 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 int vtdc = cdchit->getTDCCount();
224
225 if (sL > 8) continue; // error
226 if (iL > 8) continue; // error
227
228 int num = sL * 6 + iL + 2;
229 if (num > 55) continue; // error
230
231 // wire hits
232 if (sL == 0) {
233 whits_L[iL]++;
234 } else {
235 whits_L[num]++;
236 }
237
238 if (adcsum > -1) {
239
240 if (sL == 0) {
241 h_nhits_L[iL]->Fill(wid);
242 } else {
243 h_nhits_L[num]->Fill(wid);
244 }
245
246 //
247 if (vtdc > ftdc && adcsum > 20) {
248 ftdc = vtdc;
249 }// fastest
250
251 }// adc
252
253 // add by J.H. Yin
254 if (adcsum > 25) {
255 int cid(0);
256 if (sL == 0) {
257 cid = iL * ndiv[sL] + wid;
258 } else {
259 for (int isl = 0; isl < sL; isl ++) {
260 cid += 6 * ndiv[isl];
261 }
262 cid += 2 * ndiv[0] + iL * ndiv[sL] + wid;
263 }
264 h_hit_cell -> Fill(cid);
265 }
266 }// cdchit
267
268 h_fast_tdc->Fill(ftdc);
269
270 // each layer
271 for (int b = 0; b < 56; b++) {
272 int n_wire = 0;
273 if (b < 8) {
274 n_wire = ndiv[0];
275 } else if (b < 14) {
276 n_wire = ndiv[1];
277 } else if (b < 20) {
278 n_wire = ndiv[2];
279 } else if (b < 26) {
280 n_wire = ndiv[3];
281 } else if (b < 32) {
282 n_wire = ndiv[4];
283 } else if (b < 38) {
284 n_wire = ndiv[5];
285 } else if (b < 44) {
286 n_wire = ndiv[6];
287 } else if (b < 50) {
288 n_wire = ndiv[7];
289 } else {
290 n_wire = ndiv[8];
291 }
292
293 // cal. occupancy
294 occ_L[b] = (double)whits_L[b] / n_wire;
295 h_occ_L[b]->Fill(occ_L[b]);
296 }
297
298
299 //
300 int r_nent = m_CDCRawHits.getEntries();
301
302 // new
303 for (int j = 0; j < r_nent; j++) {
304 CDCRawHit* cdcrawhit = static_cast<CDCRawHit*>(m_CDCRawHits[j]);
305
306 int brd = cdcrawhit->getBoardId();
307 int v_adc = cdcrawhit->getFADC();
308 int v_tdc = cdcrawhit->getTDC();
309 int n_tot = cdcrawhit->getTOT();
310 int n_node = cdcrawhit->getNode();
311 int n_fns = cdcrawhit->getFiness();
312
313 bmap_2->Fill(n_node, n_fns);
314
315 if (v_tdc > 5200 || v_tdc < 4200) {
316 h_board_out_tdc->Fill(brd);
317 }
318
319 // printf("%d, %d:\n", j, board);
320 if (brd > 299) continue;
321 if (n_tot < 4) continue;
322 if (v_adc < 35) continue;
323
324 // each sL
325 if (brd < 28) {
326 h_tdc_sL[0]->Fill(v_tdc);
327 h_adc_sL[0]->Fill(v_adc);
328 } else if (brd < 48) {
329 h_tdc_sL[1]->Fill(v_tdc);
330 h_adc_sL[1]->Fill(v_adc);
331 } else if (brd < 72) {
332 h_tdc_sL[2]->Fill(v_tdc);
333 h_adc_sL[2]->Fill(v_adc);
334 } else if (brd < 100) {
335 h_tdc_sL[3]->Fill(v_tdc);
336 h_adc_sL[3]->Fill(v_adc);
337 } else if (brd < 132) {
338 h_tdc_sL[4]->Fill(v_tdc);
339 h_adc_sL[4]->Fill(v_adc);
340 } else if (brd < 168) {
341 h_tdc_sL[5]->Fill(v_tdc);
342 h_adc_sL[5]->Fill(v_adc);
343 } else if (brd < 208) {
344 h_tdc_sL[6]->Fill(v_tdc);
345 h_adc_sL[6]->Fill(v_adc);
346 } else if (brd < 252) {
347 h_tdc_sL[7]->Fill(v_tdc);
348 h_adc_sL[7]->Fill(v_adc);
349 } else {
350 h_tdc_sL[8]->Fill(v_tdc);
351 h_adc_sL[8]->Fill(v_adc);
352 }
353
354
355 }// cdcrawhits
356
357 for (auto& it : m_rawFTSW) {
358 B2DEBUG(29, "TTD FTSW : " << hex << it.GetTTUtime(0) << " " << it.GetTTCtime(0) << " EvtNr " << it.GetEveNo(0) << " Type " <<
359 (it.GetTTCtimeTRGType(0) & 0xF) << " TimeSincePrev " << it.GetTimeSincePrevTrigger(0) << " TimeSinceInj " <<
360 it.GetTimeSinceLastInjection(0) << " IsHER " << it.GetIsHER(0) << " Bunch " << it.GetBunchNumber(0));
361 auto difference = it.GetTimeSinceLastInjection(0);
362 if (difference != 0x7FFFFFFF) {
363 //unsigned int nentries = m_digits.getEntries();
364 float diff2 = difference / 127.; // 127MHz clock ticks to us, inexact rounding
365 if (it.GetIsHER(0)) {
366 h_occAfterInjHER->Fill(diff2, occ_total);
367 h_EoccAfterInjHER->Fill(diff2);
368 } else {
369 h_occAfterInjLER->Fill(diff2, occ_total);
370 h_EoccAfterInjLER->Fill(diff2);
371 }
372 }
373 }
374
375
376
377
378}
379
380
382{
383 //
384}
385
386
388{
389 //
390}
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: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:166
void event() override
action per each event
Definition cdcDQM7.cc:201
StoreArray< CDCRawHit > m_CDCRawHits
CDC raw hits.
Definition cdcDQM7.h:60
void endRun() override
action at run end
Definition cdcDQM7.cc:381
StoreArray< RawFTSW > m_rawFTSW
Input array for DAQ Status.
Definition cdcDQM7.h:85
virtual ~cdcDQM7Module()
Destructor.
Definition cdcDQM7.cc:37
void terminate() override
termination action
Definition cdcDQM7.cc:387
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:175
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:30
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:65
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:649
Abstract base class for different kinds of events.
STL namespace.