9 #include "cdc/modules/cdcDQM/cdcDQM7.h"
11 #include <framework/core/HistoModule.h>
14 #include <framework/gearbox/Unit.h>
15 #include <framework/gearbox/Const.h>
16 #include <framework/logging/Logger.h>
18 #include <TDirectory.h>
35 setDescription(
"CDC DQM module");
36 setPropertyFlags(c_ParallelProcessingCertified);
39 cdcDQM7Module::~cdcDQM7Module()
47 TH1D* h_nhits_L[56] = {0};
49 TH1D* h_tdc_sL[9] = {0};
50 TH1D* h_adc_sL[9] = {0};
53 TH1D* h_board_out_tdc;
61 TH1D* h_EoccAfterInjLER;
62 TH1D* h_EoccAfterInjHER;
63 TH1D* h_occAfterInjLER;
64 TH1D* h_occAfterInjHER;
67 void cdcDQM7Module::defineHisto()
70 TDirectory* oldDir = gDirectory;
71 TDirectory* dirDAQ = oldDir->mkdir(
"CDC");
77 int ndiv[9] = {160, 160, 192, 224, 256, 288, 320, 352, 384};
79 for (
int b = 0; b < 56; b++) {
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);
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);
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);
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);
123 h_fast_tdc =
new TH1D(
"fast_tdc",
"fastest TDC", 50, 4800, 5000);
124 h_fast_tdc->SetFillColor(6);
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);
130 h_occ =
new TH1D(
"occ",
"occ. total", 100, 0, 1.);
131 h_occ->SetFillColor(95);
134 h_hit_cell =
new TH1D(
"h_hit_cell",
"Hit of each cell", 14336, 0, 14335);
135 h_hit_cell->SetFillColor(20);
137 bmap_2 =
new TH2D(
"bmap_2",
"", 75, 0, 75, 4, 0, 4);
140 h_tdc_sL[6]->SetOption(
"LIVE");
141 h_tdc_sL[6]->SetOption(
"hist");
143 h_board_out_tdc->SetOption(
"LIVE");
144 h_board_out_tdc->SetOption(
"hist");
147 h_fast_tdc->SetStats(1);
148 bmap_2->SetOption(
"zcol");
151 h_EoccAfterInjLER =
new TH1D(
"EoccAfterInjLer",
"Eocc after LER injection", 4000, 0, 20000);
152 h_EoccAfterInjLER->SetMinimum(0);
153 h_EoccAfterInjLER->SetFillColor(7);
155 h_EoccAfterInjHER =
new TH1D(
"EoccAfterInjHer",
"Eocc after HER injection", 4000, 0, 20000);
156 h_EoccAfterInjHER->SetMinimum(0);
157 h_EoccAfterInjHER->SetFillColor(7);
159 h_occAfterInjLER =
new TH1D(
"occAfterInjLer",
"occupancy after LER injection", 4000, 0, 20000);
160 h_occAfterInjLER->SetMinimum(0);
161 h_occAfterInjLER->SetFillColor(7);
163 h_occAfterInjHER =
new TH1D(
"occAfterInjHer",
"occupancy after HER injection", 4000, 0, 20000);
164 h_occAfterInjHER->SetMinimum(0);
165 h_occAfterInjHER->SetFillColor(7);
171 void cdcDQM7Module::initialize()
175 m_rawFTSW.isOptional();
176 m_CDCRawHits.isRequired();
177 m_CDCHits.isRequired();
180 void cdcDQM7Module::beginRun()
182 for (
int i = 0; i < 56; i++) {
183 h_nhits_L[i]->Reset();
188 for (
int j = 0; j < 9; j++) {
189 h_tdc_sL[j]->Reset();
190 h_adc_sL[j]->Reset();
194 h_board_out_tdc->Reset();
199 h_EoccAfterInjLER->Reset();
200 h_EoccAfterInjHER->Reset();
201 h_occAfterInjLER->Reset();
202 h_occAfterInjHER->Reset();
206 void cdcDQM7Module::event()
208 int nent = m_CDCHits.getEntries();
212 double occ_total = nent / 14336.;
213 h_occ->Fill(occ_total);
216 int whits_L[56] = {};
217 double occ_L[56] = {};
219 int ndiv[9] = {160, 160, 192, 224, 256, 288, 320, 352, 384};
221 for (
int i = 0; i < nent; i++) {
230 if (sL > 8)
continue;
231 if (iL > 8)
continue;
233 int num = sL * 6 + iL + 2;
234 if (num > 55)
continue;
246 h_nhits_L[iL]->Fill(wid);
248 h_nhits_L[num]->Fill(wid);
252 if (vtdc > ftdc && adcsum > 20) {
262 cid = iL * ndiv[sL] + wid;
264 for (
int isl = 0; isl < sL; isl ++) {
265 cid += 6 * ndiv[isl];
267 cid += 2 * ndiv[0] + iL * ndiv[sL] + wid;
269 h_hit_cell -> Fill(cid);
273 h_fast_tdc->Fill(ftdc);
276 for (
int b = 0; b < 56; b++) {
299 occ_L[b] = (double)whits_L[b] / n_wire;
300 h_occ_L[b]->Fill(occ_L[b]);
305 int r_nent = m_CDCRawHits.getEntries();
308 for (
int j = 0; j < r_nent; j++) {
312 int v_adc = cdcrawhit->
getFADC();
313 int v_tdc = cdcrawhit->
getTDC();
314 int n_tot = cdcrawhit->
getTOT();
315 int n_node = cdcrawhit->
getNode();
318 bmap_2->Fill(n_node, n_fns);
320 if (v_tdc > 5200 || v_tdc < 4200) {
321 h_board_out_tdc->Fill(brd);
325 if (brd > 299)
continue;
326 if (n_tot < 4)
continue;
327 if (v_adc < 35)
continue;
331 h_tdc_sL[0]->Fill(v_tdc);
332 h_adc_sL[0]->Fill(v_adc);
333 }
else if (brd < 48) {
334 h_tdc_sL[1]->Fill(v_tdc);
335 h_adc_sL[1]->Fill(v_adc);
336 }
else if (brd < 72) {
337 h_tdc_sL[2]->Fill(v_tdc);
338 h_adc_sL[2]->Fill(v_adc);
339 }
else if (brd < 100) {
340 h_tdc_sL[3]->Fill(v_tdc);
341 h_adc_sL[3]->Fill(v_adc);
342 }
else if (brd < 132) {
343 h_tdc_sL[4]->Fill(v_tdc);
344 h_adc_sL[4]->Fill(v_adc);
345 }
else if (brd < 168) {
346 h_tdc_sL[5]->Fill(v_tdc);
347 h_adc_sL[5]->Fill(v_adc);
348 }
else if (brd < 208) {
349 h_tdc_sL[6]->Fill(v_tdc);
350 h_adc_sL[6]->Fill(v_adc);
351 }
else if (brd < 252) {
352 h_tdc_sL[7]->Fill(v_tdc);
353 h_adc_sL[7]->Fill(v_adc);
355 h_tdc_sL[8]->Fill(v_tdc);
356 h_adc_sL[8]->Fill(v_adc);
362 for (
auto& it : m_rawFTSW) {
363 B2DEBUG(29,
"TTD FTSW : " << hex << it.GetTTUtime(0) <<
" " << it.GetTTCtime(0) <<
" EvtNr " << it.GetEveNo(0) <<
" Type " <<
364 (it.GetTTCtimeTRGType(0) & 0xF) <<
" TimeSincePrev " << it.GetTimeSincePrevTrigger(0) <<
" TimeSinceInj " <<
365 it.GetTimeSinceLastInjection(0) <<
" IsHER " << it.GetIsHER(0) <<
" Bunch " << it.GetBunchNumber(0));
366 auto difference = it.GetTimeSinceLastInjection(0);
367 if (difference != 0x7FFFFFFF) {
369 float diff2 = difference / 127.;
370 if (it.GetIsHER(0)) {
371 h_occAfterInjHER->Fill(diff2, occ_total);
372 h_EoccAfterInjHER->Fill(diff2);
374 h_occAfterInjLER->Fill(diff2, occ_total);
375 h_EoccAfterInjLER->Fill(diff2);
386 void cdcDQM7Module::endRun()
392 void cdcDQM7Module::terminate()
Class containing the result of the unpacker in raw data and the result of the digitizer in simulation...
unsigned short getIWire() const
Getter for iWire.
short getTDCCount() const
Getter for TDC count.
unsigned short getADCCount() const
Getter for integrated charge.
unsigned short getISuperLayer() const
Getter for iSuperLayer.
unsigned short getILayer() const
Getter for iLayer.
The CDCRawHit (suppressed mode) class.
unsigned short getTOT(void) const
Getter for TOT value.
unsigned short getBoardId(void) const
Getter for boar ID.
unsigned short getTDC(void) const
Getter for TDC value.
unsigned short getNode(void) const
Getter for Node ID.
unsigned short getFiness(void) const
Getter fot Finess ID.
unsigned short getFADC(void) const
Getter for FADC value.
HistoModule.h is supposed to be used instead of Module.h for the modules with histogram definitions t...
The module for Data Quality Monitor.
#define REG_MODULE(moduleName)
Register the given module (without 'Module' suffix) with the framework.
Abstract base class for different kinds of events.