30 kchipCollections_ = consumes<ESLocalRawDataCollection>(ps.
getParameter<
InputTag>(
"ESKChipCollections"));
33 for (
int i = 0;
i < 2; ++
i)
34 for (
int j = 0;
j < 2; ++
j)
35 for (
int k = 0;
k < 40; ++
k)
36 for (
int m = 0;
m < 40; ++
m) {
37 fed_[
i][
j][
k][
m] = -1;
38 kchip_[
i][
j][
k][
m] = -1;
39 fiber_[
i][
j][
k][
m] = -1;
42 int nLines_, z, iz, ip,
ix,
iy, fed, kchip, pace, bundle,
fiber, optorx;
44 file.open(lookup_.fullPath().c_str());
48 for (
int i = 0;
i < nLines_; ++
i) {
49 file >> iz >> ip >>
ix >>
iy >> fed >> kchip >> pace >> bundle >>
fiber >> optorx;
51 z = (iz == -1) ? 2 : iz;
52 fed_[z - 1][ip - 1][
ix - 1][
iy - 1] = fed;
53 kchip_[z - 1][ip - 1][
ix - 1][
iy - 1] = kchip;
54 fiber_[z - 1][ip - 1][
ix - 1][
iy - 1] = (
fiber - 1) + (optorx - 1) * 12;
57 cout <<
"ESIntegrityTask : Look up table file can not be found in " << lookup_.fullPath().c_str() << endl;
70 LogInfo(
"ESIntegrityTask") <<
"analyzed " << ievt_ <<
" events";
72 auto lumiCache = std::make_shared<ESIntLSCache>();
73 lumiCache->ievtLS_ = 0;
75 for (
int iz = 0; iz < 2; ++iz) {
76 for (
int ip = 0; ip < 2; ++ip) {
77 meDIErrorsByLS_[iz][ip]->Reset();
78 for (
int ix = 0;
ix < 40; ++
ix) {
79 for (
int iy = 0;
iy < 40; ++
iy) {
80 (lumiCache->DIErrorsByLS_)[iz][ip][
ix][
iy] = 0;
86 meDCCCRCErrByLS_->Reset();
87 meFiberErrCodeByLS_->Reset();
88 meFiberOffByLS_->Reset();
89 meOptoBCByLS_->Reset();
90 meSLinkCRCErrByLS_->Reset();
96 calculateDIFraction(
lumi,
c);
104 sprintf(
histo,
"ES FEDs used for data taking");
107 meFED_->setAxisTitle(
"Num of Events", 2);
109 sprintf(
histo,
"ES Gain used for data taking");
112 meGain_->setAxisTitle(
"Num of Events", 2);
114 sprintf(
histo,
"ES DCC Error codes");
117 meDCCErr_->setAxisTitle(
"ES DCC Error code", 2);
119 sprintf(
histo,
"ES SLink CRC Errors");
122 meSLinkCRCErr_->setAxisTitle(
"Num of Events", 2);
124 sprintf(
histo,
"ES DCC CRC Errors");
125 meDCCCRCErr_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 3, -0.5, 2.5);
127 meDCCCRCErr_->setAxisTitle(
"ES OptoRX", 2);
129 sprintf(
histo,
"ES OptoRX used for data taking");
132 meOptoRX_->setAxisTitle(
"ES OptoRX", 2);
134 sprintf(
histo,
"ES OptoRX BC mismatch");
137 meOptoBC_->setAxisTitle(
"ES OptoRX", 2);
139 sprintf(
histo,
"ES Fiber Bad Status");
140 meFiberBadStatus_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 36, 0.5, 36.5);
142 meFiberBadStatus_->setAxisTitle(
"Fiber Number", 2);
144 sprintf(
histo,
"ES Fiber Error Code");
148 sprintf(
histo,
"ES Fiber Off");
150 meFiberOff_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 36, 0.5, 36.5);
152 meFiberOff_->setAxisTitle(
"Fiber Number", 2);
154 sprintf(
histo,
"ES Warning Event Dropped");
157 meEVDR_->setAxisTitle(
"Fiber Number", 2);
159 sprintf(
histo,
"ES KChip Flag 1 Error codes");
162 meKF1_->setAxisTitle(
"ES KChip F1 Error Code ", 2);
164 sprintf(
histo,
"ES KChip Flag 2 Error codes");
167 meKF2_->setAxisTitle(
"ES KChip F1 Error Code ", 2);
169 sprintf(
histo,
"ES KChip BC mismatch with OptoRX");
172 meKBC_->setAxisTitle(
"Num of BC mismatch", 2);
174 sprintf(
histo,
"ES KChip EC mismatch with OptoRX");
177 meKEC_->setAxisTitle(
"Num of EC mismatch", 2);
179 for (
int i = 0;
i < 2; ++
i)
180 for (
int j = 0;
j < 2; ++
j) {
181 int iz = (
i == 0) ? 1 : -1;
182 sprintf(
histo,
"ES Integrity Errors Z %d P %d", iz,
j + 1);
185 meDIErrors_[
i][
j]->setAxisTitle(
"Si Y", 2);
189 sprintf(
histo,
"ES Good Channel Fraction");
194 sprintf(
histo,
"ES SLink CRC Errors");
197 meSLinkCRCErrByLS_->setAxisTitle(
"Num of Events", 2);
199 sprintf(
histo,
"ES DCC CRC Errors");
200 meDCCCRCErrByLS_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 3, -0.5, 2.5);
202 meDCCCRCErrByLS_->setAxisTitle(
"ES OptoRX", 2);
204 sprintf(
histo,
"ES OptoRX BC mismatch");
205 meOptoBCByLS_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 3, -0.5, 2.5);
207 meOptoBCByLS_->setAxisTitle(
"ES OptoRX", 2);
209 sprintf(
histo,
"ES Fiber Error Code");
211 meFiberErrCodeByLS_->
setAxisTitle(
"Fiber Error Code", 1);
213 sprintf(
histo,
"ES Fiber Off");
214 meFiberOffByLS_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 36, 0.5, 36.5);
216 meFiberOffByLS_->setAxisTitle(
"Fiber Number", 2);
218 for (
int i = 0;
i < 2; ++
i) {
219 for (
int j = 0;
j < 2; ++
j) {
220 int iz = (
i == 0) ? 1 : -1;
221 sprintf(
histo,
"ES Integrity Errors Z %d P %d", iz,
j + 1);
224 meDIErrorsByLS_[
i][
j]->setAxisTitle(
"Si Y", 2);
233 auto lumiCache = luminosityBlockCache(
e.getLuminosityBlock().index());
234 ++(lumiCache->ievtLS_);
240 meDCCErr_->Fill(575, 2, 1);
241 meDCCCRCErr_->Fill(575, 2, 1);
242 meDCCCRCErrByLS_->Fill(575, 2, 1);
243 meOptoRX_->Fill(575, 2, 1);
244 meOptoBC_->Fill(575, 2, 1);
245 meOptoBCByLS_->Fill(575, 2, 1);
246 meFiberBadStatus_->Fill(575, 36, 1);
247 meFiberOff_->Fill(575, 36, 1);
248 meFiberOffByLS_->Fill(575, 36, 1);
249 meEVDR_->Fill(575, 36, 1);
252 Double_t nDIErr[56][36];
253 for (
int i = 0;
i < 56; ++
i)
254 for (
int j = 0;
j < 36; ++
j)
258 vector<int> fiberStatus;
259 if (
e.getByToken(dccCollections_, dccs)) {
263 meFED_->Fill(
dcc.fedId());
265 meDCCErr_->Fill(
dcc.fedId(),
dcc.getDCCErrors());
268 if (
dcc.getDCCErrors() == 101) {
269 meSLinkCRCErr_->Fill(
dcc.fedId());
270 meSLinkCRCErrByLS_->Fill(
dcc.fedId());
271 for (
int j = 0;
j < 36; ++
j)
272 nDIErr[
dcc.fedId() - 520][
j]++;
275 if (
dcc.getOptoRX0() == 129) {
276 meOptoRX_->Fill(
dcc.fedId(), 0);
277 if (((
dcc.getOptoBC0() - 15) & 0x0fff) !=
dcc.getBX()) {
278 meOptoBC_->Fill(
dcc.fedId(), 0);
279 meOptoBCByLS_->Fill(
dcc.fedId(), 0);
282 if (
dcc.getOptoRX1() == 129) {
283 meOptoRX_->Fill(
dcc.fedId(), 1);
284 if (((
dcc.getOptoBC1() - 15) & 0x0fff) !=
dcc.getBX()) {
285 meOptoBC_->Fill(
dcc.fedId(), 1);
286 meOptoBCByLS_->Fill(
dcc.fedId(), 1);
289 if (
dcc.getOptoRX2() == 129) {
290 meOptoRX_->Fill(
dcc.fedId(), 2);
291 if (((
dcc.getOptoBC2() - 15) & 0x0fff) !=
dcc.getBX()) {
292 meOptoBC_->Fill(
dcc.fedId(), 2);
293 meOptoBCByLS_->Fill(
dcc.fedId(), 2);
297 if (
dcc.getOptoRX0() == 128) {
298 meDCCCRCErr_->Fill(
dcc.fedId(), 0);
299 meDCCCRCErrByLS_->Fill(
dcc.fedId(), 0);
300 for (
int j = 0;
j < 12; ++
j)
301 nDIErr[
dcc.fedId() - 520][
j]++;
303 if (
dcc.getOptoRX1() == 128) {
304 meDCCCRCErr_->Fill(
dcc.fedId(), 1);
305 meDCCCRCErrByLS_->Fill(
dcc.fedId(), 1);
306 for (
int j = 12;
j < 24; ++
j)
307 nDIErr[
dcc.fedId() - 520][
j]++;
309 if (
dcc.getOptoRX2() == 128) {
310 meDCCCRCErr_->Fill(
dcc.fedId(), 2);
311 meDCCCRCErrByLS_->Fill(
dcc.fedId(), 2);
312 for (
int j = 24;
j < 36; ++
j)
313 nDIErr[
dcc.fedId() - 520][
j]++;
316 fiberStatus =
dcc.getFEChannelStatus();
318 for (
unsigned int i = 0;
i < fiberStatus.size(); ++
i) {
319 if (fiberStatus[
i] == 4 || fiberStatus[
i] == 8 || fiberStatus[
i] == 10 || fiberStatus[
i] == 11 ||
320 fiberStatus[
i] == 12) {
321 meFiberBadStatus_->Fill(
dcc.fedId(),
i + 1, 1);
322 meFiberErrCode_->Fill(fiberStatus[
i]);
323 meFiberErrCodeByLS_->Fill(fiberStatus[
i]);
324 nDIErr[
dcc.fedId() - 520][
i]++;
326 if (fiberStatus[
i] == 7) {
327 meFiberOff_->Fill(
dcc.fedId(),
i + 1, 1);
328 meFiberOffByLS_->Fill(
dcc.fedId(),
i + 1, 1);
330 if (fiberStatus[
i] == 6) {
331 meFiberErrCode_->Fill(fiberStatus[
i]);
332 meFiberErrCodeByLS_->Fill(fiberStatus[
i]);
333 meEVDR_->Fill(
dcc.fedId(),
i + 1, 1);
337 runtype_ =
dcc.getRunType();
338 seqtype_ =
dcc.getSeqType();
341 precision_ =
dcc.getPrecision();
343 meGain_->Fill(
gain_);
346 LogWarning(
"ESIntegrityTask") <<
"dccCollections not available";
350 if (
e.getByToken(kchipCollections_, kchips)) {
357 meKBC_->Fill(kchip.
id());
359 meKEC_->Fill(kchip.
id());
362 LogWarning(
"ESIntegrityTask") <<
"kchipCollections not available";
366 for (
int iz = 0; iz < 2; ++iz)
367 for (
int ip = 0; ip < 2; ++ip)
368 for (
int ix = 0;
ix < 40; ++
ix)
369 for (
int iy = 0;
iy < 40; ++
iy) {
370 if (fed_[iz][ip][
ix][
iy] == -1)
373 if (nDIErr[fed_[iz][ip][
ix][
iy] - 520][fiber_[iz][ip][
ix][
iy]] > 0) {
374 meDIErrors_[iz][ip]->Fill(
ix + 1,
iy + 1, 1);
375 (lumiCache->DIErrorsByLS_)[iz][ip][
ix][
iy] += 1;
376 meDIErrorsByLS_[iz][ip]->Fill(
ix + 1,
iy + 1, 1);
384 float nValidChannels = 0;
385 float nGlobalErrors = 0;
386 auto lumiCache = luminosityBlockCache(
lumi.index());
388 for (
int i = 0;
i < 2; ++
i) {
389 for (
int j = 0;
j < 2; ++
j) {
390 float nValidChannelsES = 0;
391 float nGlobalErrorsES = 0;
392 float reportSummaryES = -1;
393 for (
int x = 0;
x < 40; ++
x) {
394 for (
int y = 0; y < 40; ++y) {
395 float val = 1.0 * ((lumiCache->DIErrorsByLS_)[
i][
j][
x][y]);
396 if (fed_[
i][
j][
x][y] == -1)
398 if ((lumiCache->ievtLS_) != 0)
399 nGlobalErrors +=
val / (lumiCache->ievtLS_);
401 if ((lumiCache->ievtLS_) != 0)
402 nGlobalErrorsES +=
val / (lumiCache->ievtLS_);
406 if (nValidChannelsES != 0)
407 reportSummaryES = 1 - nGlobalErrorsES / nValidChannelsES;
408 meDIFraction_->setBinContent(
i + 1,
j + 1, reportSummaryES);
411 float reportSummary = -1.0;
412 if (nValidChannels != 0)
413 reportSummary = 1.0 - nGlobalErrors / nValidChannels;
414 meDIFraction_->setBinContent(3, 3, reportSummary);
T getParameter(std::string const &) const
std::shared_ptr< ESIntLSCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &c) const override
Begin Lumi.
ALPAKA_FN_ACC int dcc(int ieta, int iphi)
virtual void setCurrentFolder(std::string const &fullpath)
std::vector< T >::const_iterator const_iterator
void dqmEndRun(const edm::Run &r, const edm::EventSetup &c) override
EndRun.
T getUntrackedParameter(std::string const &, T const &) const
void calculateDIFraction(const edm::LuminosityBlock &lumi, const edm::EventSetup &c)
Calculate Data Integrity Fraction.
#define DEFINE_FWK_MODULE(type)
const_iterator begin() const
Namespace of DDCMS conversion namespace.
const_iterator end() const
Log< level::Info, false > LogInfo
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t ix(uint32_t id)
void endJob(void) override
EndJob.
MonitorElement * book2D(TString const &name, TString const &title, int nchX, double lowX, double highX, int nchY, double lowY, double highY, FUNC onbooking=NOOP())
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
ALPAKA_FN_ACC ALPAKA_FN_INLINE uint32_t iy(uint32_t id)
ESIntegrityTask(const edm::ParameterSet &ps)
Log< level::Warning, false > LogWarning
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
void analyze(const edm::Event &e, const edm::EventSetup &c) override
Analyze.
void globalEndLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &c) override
End Lumi.
virtual void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)