-
Notifications
You must be signed in to change notification settings - Fork 4.2k
/
SiStripQualityDQM.cc
457 lines (377 loc) · 16.9 KB
/
SiStripQualityDQM.cc
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
#include "DQM/SiStripMonitorSummary/interface/SiStripQualityDQM.h"
#include "DQMServices/Core/interface/DQMStore.h"
#include "TCanvas.h"
SiStripQualityDQM::SiStripQualityDQM(edm::ESGetToken<SiStripQuality, SiStripQualityRcd> token,
edm::RunNumber_t iRun,
edm::ParameterSet const &hPSet,
edm::ParameterSet const &fPSet,
const TrackerTopology *tTopo,
const TkDetMap *tkDetMap)
: SiStripBaseCondObjDQMGet<SiStripQuality, SiStripQualityRcd>{token, iRun, hPSet, fPSet, tTopo} {
if (HistoMaps_On_) {
Tk_HM_ = std::make_unique<TkHistoMap>(tkDetMap, "SiStrip/Histo_Map", "Quality_TkMap", 0.);
}
}
SiStripQualityDQM::~SiStripQualityDQM() {}
void SiStripQualityDQM::getActiveDetIds(const edm::EventSetup &eSetup) {
getConditionObject(eSetup);
condObj_->getDetIds(activeDetIds);
}
void SiStripQualityDQM::fillModMEs(const std::vector<uint32_t> &selectedDetIds) {
ModMEs CondObj_ME;
for (const auto det : selectedDetIds) {
fillMEsForDet(CondObj_ME, det);
}
}
void SiStripQualityDQM::fillMEsForDet(const ModMEs &_selModME_, uint32_t selDetId_) {
ModMEs selModME_ = _selModME_;
getModMEs(selModME_, selDetId_);
const auto qualityRange = condObj_->getRange(selDetId_);
int nStrip = reader->getNumberOfApvsAndStripLength(selDetId_).first * 128;
for (int istrip = 0; istrip < nStrip; ++istrip) {
selModME_.ProfileDistr->Fill(istrip + 1, condObj_->IsStripBad(qualityRange, istrip) ? 0. : 1.);
} // istrip
}
void SiStripQualityDQM::fillSummaryMEs(const std::vector<uint32_t> &selectedDetIds) {
for (const auto det : selectedDetIds) {
fillMEsForLayer(/*SummaryMEsMap_,*/ det);
}
for (const auto &itm : SummaryMEsMap_) {
ModMEs selME;
selME = itm.second;
if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel") &&
fPSet_.getParameter<bool>("OutputSummaryAtLayerLevelAsImage")) {
TCanvas c1("c1");
selME.SummaryDistr->getTH1()->Draw();
std::string name(selME.SummaryDistr->getTitle());
name += ".png";
c1.Print(name.c_str());
}
}
}
void SiStripQualityDQM::fillMEsForLayer(
/* std::map<uint32_t, ModMEs> selMEsMap_,*/ uint32_t selDetId_) {
float numberOfBadStrips = 0;
SiStripHistoId hidmanager;
if (hPSet_.getParameter<bool>("FillSummaryAtLayerLevel")) {
std::string hSummary_description;
hSummary_description = hPSet_.getParameter<std::string>("Summary_description");
std::string hSummary_name;
// ----
int subDetId_ = ((selDetId_ >> 25) & 0x7);
if (subDetId_ < 3 || subDetId_ > 6) {
edm::LogError("SiStripQualityDQM") << "[SiStripQualityDQM::fillMEsForLayer] WRONG INPUT : no such "
"subdetector type : "
<< subDetId_ << " no folder set!" << std::endl;
return;
}
// ----
hSummary_name = hidmanager.createHistoLayer(hSummary_description, "layer", getLayerNameAndId(selDetId_).first, "");
const auto selMEsMapIter_ = SummaryMEsMap_.find(getLayerNameAndId(selDetId_).second);
ModMEs selME_;
if (selMEsMapIter_ != SummaryMEsMap_.end())
selME_ = selMEsMapIter_->second;
getSummaryMEs(selME_, selDetId_);
std::vector<uint32_t> sameLayerDetIds_;
sameLayerDetIds_.clear();
sameLayerDetIds_ = GetSameLayerDetId(activeDetIds, selDetId_);
// -----
// unsigned int iBin=0;
//%%%%%%%%%%%%%%%%%%%
//%%% FIXME: patch to fix the bug causing double counting on each layer
//%%%%%%%%%%%%%%%%%%%%%%%
if (std::binary_search(alreadyFilledLayers.begin(), alreadyFilledLayers.end(), sameLayerDetIds_[0]))
return;
alreadyFilledLayers.push_back(sameLayerDetIds_[0]);
sort(alreadyFilledLayers.begin(), alreadyFilledLayers.end());
//%%%%%%%%%%%%%%%%%%%%%%% END %%%%%%%%%%
for (unsigned int i = 0; i < sameLayerDetIds_.size(); i++) {
const auto qualityRange = condObj_->getRange(sameLayerDetIds_[i]);
int nStrip = reader->getNumberOfApvsAndStripLength(sameLayerDetIds_[i]).first * 128;
numberOfBadStrips = 0;
for (int istrip = 0; istrip < nStrip; ++istrip) {
if (condObj_->IsStripBad(qualityRange, istrip)) {
numberOfBadStrips++;
}
}
float fr = 100 * float(numberOfBadStrips) / nStrip;
selME_.SummaryDistr->Fill(i + 1, fr);
if (fr > 20) {
char c[9];
sprintf(c, "%d", sameLayerDetIds_[i]);
selME_.SummaryDistr->setBinLabel(i + 1, c);
}
// Fill the TkHistoMap with Quality output :
if (HistoMaps_On_)
Tk_HM_->setBinContent(sameLayerDetIds_[i], fr);
// Fill the TkMap
if (fPSet_.getParameter<bool>("TkMap_On") || hPSet_.getParameter<bool>("TkMap_On")) {
fillTkMap(sameLayerDetIds_[i], fr);
}
}
} // if Fill ...
}
void SiStripQualityDQM::fillGrandSummaryMEs() {
std::string hSummary_BadObjects_xTitle = hPSet_.getParameter<std::string>("Summary_BadObjects_histo_xTitle");
std::string hSummary_BadModules_name = hPSet_.getParameter<std::string>("Summary_BadModules_histo_name");
std::string hSummary_BadModules_yTitle = hPSet_.getParameter<std::string>("Summary_BadModules_histo_yTitle");
std::string hSummary_BadFibers_name = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_name");
std::string hSummary_BadFibers_yTitle = hPSet_.getParameter<std::string>("Summary_BadFibers_histo_yTitle");
std::string hSummary_BadApvs_name = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_name");
std::string hSummary_BadApvs_yTitle = hPSet_.getParameter<std::string>("Summary_BadApvs_histo_yTitle");
std::string hSummary_BadStrips_name = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_name");
std::string hSummary_BadStrips_yTitle = hPSet_.getParameter<std::string>("Summary_BadStrips_histo_yTitle");
int NchX = 34;
double LowX = 0.5;
double HighX = 34.5;
MonitorElement *ME[4];
DQMStore *dqmStore_ = edm::Service<DQMStore>().operator->();
std::string FolderName = fPSet_.getParameter<std::string>("FolderName_For_QualityAndCabling_SummaryHistos");
dqmStore_->setCurrentFolder(FolderName);
ME[0] = dqmStore_->book1D(hSummary_BadModules_name, hSummary_BadModules_name, NchX, LowX, HighX);
ME[0]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
ME[0]->setAxisTitle(hSummary_BadModules_yTitle, 2);
ME[1] = dqmStore_->book1D(hSummary_BadFibers_name, hSummary_BadFibers_name, NchX, LowX, HighX);
ME[1]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
ME[1]->setAxisTitle(hSummary_BadFibers_yTitle, 2);
ME[2] = dqmStore_->book1D(hSummary_BadApvs_name, hSummary_BadApvs_name, NchX, LowX, HighX);
ME[2]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
ME[2]->setAxisTitle(hSummary_BadApvs_yTitle, 2);
ME[3] = dqmStore_->book1D(hSummary_BadStrips_name, hSummary_BadStrips_name, NchX, LowX, HighX);
ME[3]->setAxisTitle(hSummary_BadObjects_xTitle, 1);
ME[3]->setAxisTitle(hSummary_BadStrips_yTitle, 2);
//==============================
for (int i = 0; i < 4; ++i) {
NTkBadComponent[i] = 0;
for (int j = 0; j < 19; ++j) {
ssV[i][j].str("");
for (int k = 0; k < 4; ++k)
NBadComponent[i][j][k] = 0;
}
}
std::stringstream ss;
ss.str("");
for (const auto det : reader->getAllDetIds()) {
ss << "detid " << det << " IsModuleUsable " << condObj_->IsModuleUsable(det) << "\n";
}
LogDebug("SiStripQualityDQM") << ss.str() << std::endl;
std::vector<SiStripQuality::BadComponent> BC = condObj_->getBadComponentList();
for (size_t i = 0; i < BC.size(); ++i) {
//&&&&&&&&&&&&&
// Full Tk
//&&&&&&&&&&&&&
if (BC[i].BadModule)
NTkBadComponent[0]++;
if (BC[i].BadFibers)
NTkBadComponent[1] += ((BC[i].BadFibers >> 2) & 0x1) + ((BC[i].BadFibers >> 1) & 0x1) + ((BC[i].BadFibers) & 0x1);
if (BC[i].BadApvs)
NTkBadComponent[2] += ((BC[i].BadApvs >> 5) & 0x1) + ((BC[i].BadApvs >> 4) & 0x1) + ((BC[i].BadApvs >> 3) & 0x1) +
((BC[i].BadApvs >> 2) & 0x1) + ((BC[i].BadApvs >> 1) & 0x1) + ((BC[i].BadApvs) & 0x1);
//&&&&&&&&&&&&&&&&&
// Single SubSyste
//&&&&&&&&&&&&&&&&&
int component;
SiStripDetId a(BC[i].detid);
if (a.subdetId() == SiStripDetId::TIB) {
//&&&&&&&&&&&&&&&&&
// TIB
//&&&&&&&&&&&&&&&&&
component = tTopo_->tibLayer(BC[i].detid);
SetBadComponents(0, component, BC[i]);
} else if (a.subdetId() == SiStripDetId::TID) {
//&&&&&&&&&&&&&&&&&
// TID
//&&&&&&&&&&&&&&&&&
component = tTopo_->tidSide(BC[i].detid) == 2 ? tTopo_->tidWheel(BC[i].detid) : tTopo_->tidWheel(BC[i].detid) + 3;
SetBadComponents(1, component, BC[i]);
} else if (a.subdetId() == SiStripDetId::TOB) {
//&&&&&&&&&&&&&&&&&
// TOB
//&&&&&&&&&&&&&&&&&
component = tTopo_->tobLayer(BC[i].detid);
SetBadComponents(2, component, BC[i]);
} else if (a.subdetId() == SiStripDetId::TEC) {
//&&&&&&&&&&&&&&&&&
// TEC
//&&&&&&&&&&&&&&&&&
component = tTopo_->tecSide(BC[i].detid) == 2 ? tTopo_->tecWheel(BC[i].detid) : tTopo_->tecWheel(BC[i].detid) + 9;
SetBadComponents(3, component, BC[i]);
}
}
//&&&&&&&&&&&&&&&&&&
// Single Strip Info
//&&&&&&&&&&&&&&&&&&
SiStripQuality::RegistryIterator rbegin = condObj_->getRegistryVectorBegin();
SiStripQuality::RegistryIterator rend = condObj_->getRegistryVectorEnd();
for (SiStripBadStrip::RegistryIterator rp = rbegin; rp != rend; ++rp) {
uint32_t detid = rp->detid;
int subdet = 0;
int component = 0;
SiStripDetId a(detid);
if (a.subdetId() == 3) {
subdet = 0;
component = tTopo_->tibLayer(detid);
} else if (a.subdetId() == 4) {
subdet = 1;
component = tTopo_->tidSide(detid) == 2 ? tTopo_->tidWheel(detid) : tTopo_->tidWheel(detid) + 3;
} else if (a.subdetId() == 5) {
subdet = 2;
component = tTopo_->tobLayer(detid);
} else if (a.subdetId() == 6) {
subdet = 3;
component = tTopo_->tecSide(detid) == 2 ? tTopo_->tecWheel(detid) : tTopo_->tecWheel(detid) + 9;
}
SiStripQuality::Range sqrange =
SiStripQuality::Range(condObj_->getDataVectorBegin() + rp->ibegin, condObj_->getDataVectorBegin() + rp->iend);
for (int it = 0; it < sqrange.second - sqrange.first; it++) {
unsigned int range = condObj_->decode(*(sqrange.first + it)).range;
NTkBadComponent[3] += range;
NBadComponent[subdet][0][3] += range;
NBadComponent[subdet][component][3] += range;
}
}
//&&&&&&&&&&&&&&&&&&
// printout
//&&&&&&&&&&&&&&&&&&
ss.str("");
ss << "\n-----------------\nGlobal Info\n-----------------";
ss << "\nBadComponent \t Modules \tFibers "
"\tApvs\tStrips\n------------------------------------------------------"
"----------";
ss << "\nTracker:\t\t" << NTkBadComponent[0] << "\t" << NTkBadComponent[1] << "\t" << NTkBadComponent[2] << "\t"
<< NTkBadComponent[3];
ss << "\n";
ss << "\nTIB:\t\t\t" << NBadComponent[0][0][0] << "\t" << NBadComponent[0][0][1] << "\t" << NBadComponent[0][0][2]
<< "\t" << NBadComponent[0][0][3];
ss << "\nTID:\t\t\t" << NBadComponent[1][0][0] << "\t" << NBadComponent[1][0][1] << "\t" << NBadComponent[1][0][2]
<< "\t" << NBadComponent[1][0][3];
ss << "\nTOB:\t\t\t" << NBadComponent[2][0][0] << "\t" << NBadComponent[2][0][1] << "\t" << NBadComponent[2][0][2]
<< "\t" << NBadComponent[2][0][3];
ss << "\nTEC:\t\t\t" << NBadComponent[3][0][0] << "\t" << NBadComponent[3][0][1] << "\t" << NBadComponent[3][0][2]
<< "\t" << NBadComponent[3][0][3];
ss << "\n";
for (int i = 1; i < 5; ++i) {
ss << "\nTIB Layer " << i << " :\t\t" << NBadComponent[0][i][0] << "\t" << NBadComponent[0][i][1] << "\t"
<< NBadComponent[0][i][2] << "\t" << NBadComponent[0][i][3];
std::stringstream binlabel;
binlabel << "TIB L " << i;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i, NBadComponent[0][i][j]);
ME[j]->setBinLabel(i, binlabel.str());
}
}
ss << "\n";
for (int i = 1; i < 4; ++i) {
ss << "\nTID+ Disk " << i << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
<< NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
std::stringstream binlabel;
binlabel << "TID+ D " << i;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i + 4, NBadComponent[1][i][j]);
ME[j]->setBinLabel(i + 4, binlabel.str());
}
}
for (int i = 4; i < 7; ++i) {
ss << "\nTID- Disk " << i - 3 << " :\t\t" << NBadComponent[1][i][0] << "\t" << NBadComponent[1][i][1] << "\t"
<< NBadComponent[1][i][2] << "\t" << NBadComponent[1][i][3];
std::stringstream binlabel;
binlabel << "TID- D " << i - 3;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i + 4, NBadComponent[1][i][j]);
ME[j]->setBinLabel(i + 4, binlabel.str());
}
}
ss << "\n";
for (int i = 1; i < 7; ++i) {
ss << "\nTOB Layer " << i << " :\t\t" << NBadComponent[2][i][0] << "\t" << NBadComponent[2][i][1] << "\t"
<< NBadComponent[2][i][2] << "\t" << NBadComponent[2][i][3];
std::stringstream binlabel;
binlabel << "TOB L " << i;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i + 10, NBadComponent[2][i][j]);
ME[j]->setBinLabel(i + 10, binlabel.str());
}
}
ss << "\n";
for (int i = 1; i < 10; ++i) {
ss << "\nTEC+ Disk " << i << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
<< NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
std::stringstream binlabel;
binlabel << "TEC+ D " << i;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i + 16, NBadComponent[3][i][j]);
ME[j]->setBinLabel(i + 16, binlabel.str());
}
}
for (int i = 10; i < 19; ++i) {
ss << "\nTEC- Disk " << i - 9 << " :\t\t" << NBadComponent[3][i][0] << "\t" << NBadComponent[3][i][1] << "\t"
<< NBadComponent[3][i][2] << "\t" << NBadComponent[3][i][3];
std::stringstream binlabel;
binlabel << "TEC- D " << i - 9;
for (int j = 0; j < 4; j++) {
ME[j]->Fill(i + 16, NBadComponent[3][i][j]);
ME[j]->setBinLabel(i + 16, binlabel.str());
}
}
ss << "\n";
ss << "\n----------------------------------------------------------------"
"\n\t\t Detid \tModules Fibers "
"Apvs\n---------------------------------------------------------------"
"-";
for (int i = 1; i < 5; ++i)
ss << "\nTIB Layer " << i << " :" << ssV[0][i].str();
ss << "\n";
for (int i = 1; i < 4; ++i)
ss << "\nTID+ Disk " << i << " :" << ssV[1][i].str();
for (int i = 4; i < 7; ++i)
ss << "\nTID- Disk " << i - 3 << " :" << ssV[1][i].str();
ss << "\n";
for (int i = 1; i < 7; ++i)
ss << "\nTOB Layer " << i << " :" << ssV[2][i].str();
ss << "\n";
for (int i = 1; i < 10; ++i)
ss << "\nTEC+ Disk " << i << " :" << ssV[3][i].str();
for (int i = 10; i < 19; ++i)
ss << "\nTEC- Disk " << i - 9 << " :" << ssV[3][i].str();
edm::LogInfo("SiStripQualityDQM") << ss.str() << std::endl;
for (int i = 0; i < 4; i++) {
TCanvas c1("c1");
ME[i]->getTH1()->Draw();
std::string name(ME[i]->getTitle());
name += ".png";
c1.Print(name.c_str());
}
}
void SiStripQualityDQM::SetBadComponents(int i, int component, SiStripQuality::BadComponent &BC) {
int napv = reader->getNumberOfApvsAndStripLength(BC.detid).first;
ssV[i][component] << "\n\t\t " << BC.detid << " \t " << BC.BadModule << " \t " << ((BC.BadFibers) & 0x1) << " ";
if (napv == 4)
ssV[i][component] << "x " << ((BC.BadFibers >> 1) & 0x1);
if (napv == 6)
ssV[i][component] << ((BC.BadFibers >> 1) & 0x1) << " " << ((BC.BadFibers >> 2) & 0x1);
ssV[i][component] << " \t " << ((BC.BadApvs) & 0x1) << " " << ((BC.BadApvs >> 1) & 0x1) << " ";
if (napv == 4)
ssV[i][component] << "x x " << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1);
if (napv == 6)
ssV[i][component] << ((BC.BadApvs >> 2) & 0x1) << " " << ((BC.BadApvs >> 3) & 0x1) << " "
<< ((BC.BadApvs >> 4) & 0x1) << " " << ((BC.BadApvs >> 5) & 0x1) << " ";
if (BC.BadApvs) {
NBadComponent[i][0][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) + ((BC.BadApvs >> 3) & 0x1) +
((BC.BadApvs >> 2) & 0x1) + ((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
NBadComponent[i][component][2] += ((BC.BadApvs >> 5) & 0x1) + ((BC.BadApvs >> 4) & 0x1) +
((BC.BadApvs >> 3) & 0x1) + ((BC.BadApvs >> 2) & 0x1) +
((BC.BadApvs >> 1) & 0x1) + ((BC.BadApvs) & 0x1);
// tkMap->fillc(BC.detid,0xff0000);
}
if (BC.BadFibers) {
NBadComponent[i][0][1] += ((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
NBadComponent[i][component][1] +=
((BC.BadFibers >> 2) & 0x1) + ((BC.BadFibers >> 1) & 0x1) + ((BC.BadFibers) & 0x1);
// tkMap->fillc(BC.detid,0x0000ff);
}
if (BC.BadModule) {
NBadComponent[i][0][0]++;
NBadComponent[i][component][0]++;
// tkMap->fillc(BC.detid,0x0);
}
}