30 kchipCollections_ = consumes<ESLocalRawDataCollection>(ps.
getParameter<
InputTag>(
"ESKChipCollections"));
32 doLumiAnalysis_ = ps.
getParameter<
bool>(
"DoLumiAnalysis");
35 for (
int i = 0;
i < 2; ++
i)
36 for (
int j = 0;
j < 2; ++
j)
37 for (
int k = 0;
k < 40; ++
k)
38 for (
int m = 0;
m < 40; ++
m) {
39 fed_[
i][
j][
k][
m] = -1;
40 kchip_[
i][
j][
k][
m] = -1;
41 fiber_[
i][
j][
k][
m] = -1;
44 int nLines_, z, iz, ip,
ix,
iy, fed, kchip, pace, bundle, fiber, optorx;
46 file.open(lookup_.fullPath().c_str());
50 for (
int i = 0;
i < nLines_; ++
i) {
51 file >> iz >> ip >>
ix >>
iy >> fed >> kchip >> pace >> bundle >> fiber >> optorx;
53 z = (iz == -1) ? 2 : iz;
54 fed_[z - 1][ip - 1][
ix - 1][
iy - 1] = fed;
55 kchip_[z - 1][ip - 1][
ix - 1][
iy - 1] = kchip;
56 fiber_[z - 1][ip - 1][
ix - 1][
iy - 1] = (fiber - 1) + (optorx - 1) * 12;
59 cout <<
"ESIntegrityTask : Look up table file can not be found in " << lookup_.fullPath().c_str() << endl;
72 LogInfo(
"ESIntegrityTask") <<
"analyzed " << ievt_ <<
" events";
74 auto lumiCache = std::make_shared<ESLSCache>();
75 lumiCache->ievtLS_ = 0;
76 if (doLumiAnalysis_) {
77 for (
int iz = 0; iz < 2; ++iz) {
78 for (
int ip = 0; ip < 2; ++ip) {
79 for (
int ix = 0;
ix < 40; ++
ix) {
80 for (
int iy = 0;
iy < 40; ++
iy) {
81 (lumiCache->DIErrorsLS_)[iz][ip][
ix][
iy] = 0;
92 calculateDIFraction(
lumi,
c);
100 sprintf(
histo,
"ES FEDs used for data taking");
103 meFED_->setAxisTitle(
"Num of Events", 2);
105 sprintf(
histo,
"ES Gain used for data taking");
108 meGain_->setAxisTitle(
"Num of Events", 2);
110 sprintf(
histo,
"ES DCC Error codes");
113 meDCCErr_->setAxisTitle(
"ES DCC Error code", 2);
115 sprintf(
histo,
"ES SLink CRC Errors");
118 meSLinkCRCErr_->setAxisTitle(
"Num of Events", 2);
120 sprintf(
histo,
"ES DCC CRC Errors");
121 meDCCCRCErr_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 3, -0.5, 2.5);
123 meDCCCRCErr_->setAxisTitle(
"ES OptoRX", 2);
125 sprintf(
histo,
"ES OptoRX used for data taking");
128 meOptoRX_->setAxisTitle(
"ES OptoRX", 2);
130 sprintf(
histo,
"ES OptoRX BC mismatch");
133 meOptoBC_->setAxisTitle(
"ES OptoRX", 2);
135 sprintf(
histo,
"ES Fiber Bad Status");
136 meFiberBadStatus_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 36, 0.5, 36.5);
138 meFiberBadStatus_->setAxisTitle(
"Fiber Number", 2);
140 sprintf(
histo,
"ES Fiber Error Code");
144 sprintf(
histo,
"ES Fiber Off");
146 meFiberOff_ = iBooker.
book2D(
histo,
histo, 56, 519.5, 575.5, 36, 0.5, 36.5);
148 meFiberOff_->setAxisTitle(
"Fiber Number", 2);
150 sprintf(
histo,
"ES Warning Event Dropped");
153 meEVDR_->setAxisTitle(
"Fiber Number", 2);
155 sprintf(
histo,
"ES KChip Flag 1 Error codes");
158 meKF1_->setAxisTitle(
"ES KChip F1 Error Code ", 2);
160 sprintf(
histo,
"ES KChip Flag 2 Error codes");
163 meKF2_->setAxisTitle(
"ES KChip F1 Error Code ", 2);
165 sprintf(
histo,
"ES KChip BC mismatch with OptoRX");
168 meKBC_->setAxisTitle(
"Num of BC mismatch", 2);
170 sprintf(
histo,
"ES KChip EC mismatch with OptoRX");
173 meKEC_->setAxisTitle(
"Num of EC mismatch", 2);
175 for (
int i = 0;
i < 2; ++
i)
176 for (
int j = 0;
j < 2; ++
j) {
177 int iz = (
i == 0) ? 1 : -1;
178 sprintf(
histo,
"ES Integrity Errors Z %d P %d", iz,
j + 1);
181 meDIErrors_[
i][
j]->setAxisTitle(
"Si Y", 2);
184 if (doLumiAnalysis_) {
185 sprintf(
histo,
"ES Good Channel Fraction");
194 auto lumiCache = luminosityBlockCache(
e.getLuminosityBlock().index());
195 ++(lumiCache->ievtLS_);
201 meDCCErr_->Fill(575, 2, 1);
202 meDCCCRCErr_->Fill(575, 2, 1);
203 meOptoRX_->Fill(575, 2, 1);
204 meOptoBC_->Fill(575, 2, 1);
205 meFiberBadStatus_->Fill(575, 36, 1);
206 meFiberOff_->Fill(575, 36, 1);
207 meEVDR_->Fill(575, 36, 1);
210 Double_t nDIErr[56][36];
211 for (
int i = 0;
i < 56; ++
i)
212 for (
int j = 0;
j < 36; ++
j)
216 vector<int> fiberStatus;
217 if (
e.getByToken(dccCollections_, dccs)) {
221 meFED_->Fill(
dcc.fedId());
223 meDCCErr_->Fill(
dcc.fedId(),
dcc.getDCCErrors());
226 if (
dcc.getDCCErrors() == 101) {
227 meSLinkCRCErr_->Fill(
dcc.fedId());
228 for (
int j = 0;
j < 36; ++
j)
229 nDIErr[
dcc.fedId() - 520][
j]++;
232 if (
dcc.getOptoRX0() == 129) {
233 meOptoRX_->Fill(
dcc.fedId(), 0);
234 if (((
dcc.getOptoBC0() - 15) & 0x0fff) !=
dcc.getBX())
235 meOptoBC_->Fill(
dcc.fedId(), 0);
237 if (
dcc.getOptoRX1() == 129) {
238 meOptoRX_->Fill(
dcc.fedId(), 1);
239 if (((
dcc.getOptoBC1() - 15) & 0x0fff) !=
dcc.getBX())
240 meOptoBC_->Fill(
dcc.fedId(), 1);
242 if (
dcc.getOptoRX2() == 129) {
243 meOptoRX_->Fill(
dcc.fedId(), 2);
244 if (((
dcc.getOptoBC2() - 15) & 0x0fff) !=
dcc.getBX())
245 meOptoBC_->Fill(
dcc.fedId(), 2);
248 if (
dcc.getOptoRX0() == 128) {
249 meDCCCRCErr_->Fill(
dcc.fedId(), 0);
250 for (
int j = 0;
j < 12; ++
j)
251 nDIErr[
dcc.fedId() - 520][
j]++;
253 if (
dcc.getOptoRX1() == 128) {
254 meDCCCRCErr_->Fill(
dcc.fedId(), 1);
255 for (
int j = 12;
j < 24; ++
j)
256 nDIErr[
dcc.fedId() - 520][
j]++;
258 if (
dcc.getOptoRX2() == 128) {
259 meDCCCRCErr_->Fill(
dcc.fedId(), 2);
260 for (
int j = 24;
j < 36; ++
j)
261 nDIErr[
dcc.fedId() - 520][
j]++;
264 fiberStatus =
dcc.getFEChannelStatus();
266 for (
unsigned int i = 0;
i < fiberStatus.size(); ++
i) {
267 if (fiberStatus[
i] == 4 || fiberStatus[
i] == 8 || fiberStatus[
i] == 10 || fiberStatus[
i] == 11 ||
268 fiberStatus[
i] == 12) {
269 meFiberBadStatus_->Fill(
dcc.fedId(),
i + 1, 1);
270 meFiberErrCode_->Fill(fiberStatus[
i]);
271 nDIErr[
dcc.fedId() - 520][
i]++;
273 if (fiberStatus[
i] == 7)
274 meFiberOff_->Fill(
dcc.fedId(),
i + 1, 1);
275 if (fiberStatus[
i] == 6) {
276 meFiberErrCode_->Fill(fiberStatus[
i]);
277 meEVDR_->Fill(
dcc.fedId(),
i + 1, 1);
281 runtype_ =
dcc.getRunType();
282 seqtype_ =
dcc.getSeqType();
285 precision_ =
dcc.getPrecision();
287 meGain_->Fill(
gain_);
290 LogWarning(
"ESIntegrityTask") <<
"dccCollections not available";
294 if (
e.getByToken(kchipCollections_, kchips)) {
301 meKBC_->Fill(kchip.
id());
303 meKEC_->Fill(kchip.
id());
306 LogWarning(
"ESIntegrityTask") <<
"kchipCollections not available";
310 for (
int iz = 0; iz < 2; ++iz)
311 for (
int ip = 0; ip < 2; ++ip)
312 for (
int ix = 0;
ix < 40; ++
ix)
313 for (
int iy = 0;
iy < 40; ++
iy) {
314 if (fed_[iz][ip][
ix][
iy] == -1)
317 if (nDIErr[fed_[iz][ip][
ix][
iy] - 520][fiber_[iz][ip][
ix][
iy]] > 0) {
318 meDIErrors_[iz][ip]->Fill(
ix + 1,
iy + 1, 1);
320 (lumiCache->DIErrorsLS_)[iz][ip][
ix][
iy] += 1;
328 float nValidChannels = 0;
329 float nGlobalErrors = 0;
330 auto lumiCache = luminosityBlockCache(
lumi.index());
332 for (
int i = 0;
i < 2; ++
i) {
333 for (
int j = 0;
j < 2; ++
j) {
334 float nValidChannelsES = 0;
335 float nGlobalErrorsES = 0;
336 float reportSummaryES = -1;
337 for (
int x = 0;
x < 40; ++
x) {
338 for (
int y = 0; y < 40; ++y) {
339 float val = 1.0 * ((lumiCache->DIErrorsLS_)[
i][
j][
x][y]);
340 if (fed_[
i][
j][
x][y] == -1)
342 if ((lumiCache->ievtLS_) != 0)
343 nGlobalErrors +=
val / (lumiCache->ievtLS_);
345 if ((lumiCache->ievtLS_) != 0)
346 nGlobalErrorsES +=
val / (lumiCache->ievtLS_);
350 if (nValidChannelsES != 0)
351 reportSummaryES = 1 - nGlobalErrorsES / nValidChannelsES;
352 meDIFraction_->setBinContent(
i + 1,
j + 1, reportSummaryES);
355 float reportSummary = -1.0;
356 if (nValidChannels != 0)
357 reportSummary = 1.0 - nGlobalErrors / nValidChannels;
358 meDIFraction_->setBinContent(3, 3, reportSummary);
std::shared_ptr< ESLSCache > globalBeginLuminosityBlock(const edm::LuminosityBlock &lumi, const edm::EventSetup &c) const override
Begin Lumi.
T getParameter(std::string const &) const
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)