CMS 3D CMS Logo

EcalChannelStatusHandler.cc
Go to the documentation of this file.
1 //
2 //
3 // still missing: * check crystals with occupancy zero - to be cross-checked with what was masked in the DAQ
4 // * info about what is in/out of daq
5 //
6 // ------------------------------------------------------------
7 
8 // analyses:
9 // pedestal runs -> PEDESTAL analysis only (occupancy not available from DB):
10 // laser runs -> LASER analysis only
11 // physics runs -> PEDESTAL ONLINE + PEDESTAL (from calib sequence) + OCCUPANCY + LASER (from calib sequence) analysis
12 
13 // pedestal / pedestal online analysis:
14 // a) if one crystal is dead or noisy at least in one gain is recorded
15 // b) cuts: * pedestal value within 100-300
16 // * pedestal RMS above 2 (EB) or 2.5 (EE)
17 // * pedestal RMS not zero
18 // * channel working at all gains [in local pedestal runs]
19 // * channel not stuck at G0 [ stuck = at gain zero in more than 1000 events ]
20 
21 // laser analysis:
22 // a) a light module is ON if at least TWO crystals have amplitude>100. The analysis is done on light modules which are on.
23 // b) cuts: * APD > 400 in EB
24 // * APD > 100 in EE
25 
26 // occupancy analysis:
27 // cuts:
28 // a) a channel in EB (EE) is noisy if it has > 1 permill of total events above high threshold in EB (EE)
29 
30 // cosmics/physics runs analysis: combine pedestal online + laser + occupancy analyses
31 
33 
35 
37 
38 #include "TProfile2D.h"
39 #include "TTree.h"
40 #include "TFile.h"
41 #include "TLine.h"
42 #include "TStyle.h"
43 #include "TCanvas.h"
44 #include "TGaxis.h"
45 #include "TColor.h"
46 
48  std::cout << "EcalChannelStatus Source handler constructor\n" << std::endl;
49 
50  m_firstRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("firstRun").c_str()));
51  m_lastRun = static_cast<unsigned int>(atoi(ps.getParameter<std::string>("lastRun").c_str()));
52  m_sid = ps.getParameter<std::string>("OnlineDBSID");
53  m_user = ps.getParameter<std::string>("OnlineDBUser");
54  m_pass = ps.getParameter<std::string>("OnlineDBPassword");
55  m_locationsource = ps.getParameter<std::string>("LocationSource");
56  m_location = ps.getParameter<std::string>("Location");
57  m_gentag = ps.getParameter<std::string>("GenTag");
58  m_runtype = ps.getParameter<std::string>("RunType");
59  m_name = ps.getUntrackedParameter<std::string>("name", "EcalChannelStatusHandler");
60 
61  std::cout << m_sid << "/" << m_user << "/" << m_pass << "/" << m_location << "/" << m_gentag << std::endl;
62 }
63 
65 
66 // ------------------------------------------------
67 // START PEDESTALS ROUTINES
68 
69 // return pedestal values at gain 12
71  float result = item->mean_x12;
72  return result;
73 }
74 
75 // return pedestal values at gain 6 - pedestal runs
77  float result = item->mean_x6;
78  return result;
79 }
80 
81 // return pedestal values at gain 1 - pedestal runs
83  float result = item->mean_x1;
84  return result;
85 }
86 
87 // return pedestal RMS at gain 12
89  float result = item->rms_x12;
90  return result;
91 }
92 
93 // return pedestal RMS at gain 6 - pedestal runs
95  float result = item->rms_x6;
96  return result;
97 }
98 
99 // return pedestal RMS at gain 1 - pedestal runs
101  float result = item->rms_x1;
102  return result;
103 }
104 
105 // ------------------------------------------------
106 // START LASER ROUTINES
107 
108 // choose 'good' EB and EE light modules. Based on DQM infos
109 void popcon::EcalChannelStatusHandler::nBadLaserModules(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon) {
110  // NB: EcalLogicId, sm_num = ecid_xt.getID1() --> for barrel is 1->18 = EB+; 19->36 = EB-
111  // NB: EcalLogicId, sm_num = ecid_xt.getID1() --> for endcap is 1=Z+, -1=Z- ;
112 
113  // good and bad light modules and reference crystals in EB
114  // theLM=0 -> L-shaped ( TTs: 1,2,3,4; 7-8; 11-12 ... )
115  // theLM=1 -> not L-shaped ( TTs: 5-6,9-10 ... )
116  for (int theSm = 0; theSm < 36; theSm++) {
117  for (int theLM = 0; theLM < 2; theLM++) {
118  isEBRef1[theSm][theLM] = false;
119  isEBRef2[theSm][theLM] = false;
120  isGoodLaserEBSm[theSm][theLM] = false;
121  }
122  }
123 
124  // good and bad light modules and reference crystals in EE [NB: only in EE-5 and EE+5 we need 2 LM... redundant]
125  // theLM=0 -> light module A (ix<=50)
126  // theLM=1 -> light module B (ix>50)
127  for (int theSector = 0; theSector < 18; theSector++) {
128  for (int theLM = 0; theLM < 2; theLM++) {
129  isEERef1[theSector][theLM] = false;
130  isEERef2[theSector][theLM] = false;
131  isGoodLaserEESm[theSector][theLM] = false;
132  }
133  }
134 
135  typedef std::map<EcalLogicID, MonLaserBlueDat>::const_iterator CImon;
136  EcalLogicID ecid_xt;
137  MonLaserBlueDat rd_blue;
138 
139  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
140  ecid_xt = p->first;
141  int sm_num = ecid_xt.getID1();
142  int xt_num = ecid_xt.getID2();
143  int yt_num = ecid_xt.getID3();
144 
145  // in which Fed/triggerTower/sectorSide I am
146  int theFed = -100;
147  int theTT = -100;
148  int theIx = -100;
149  if (ecid_xt.getName() == "EB_crystal_number") {
150  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
151  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
152  theFed = 600 + elecId.dccId();
153  theTT = elecId.towerId();
154  }
155  if (ecid_xt.getName() == "EE_crystal_number") {
156  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
157  EEDetId eedetid(xt_num, yt_num, sm_num);
158  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
159  theFed = 600 + elecId.dccId();
160  theIx = eedetid.ix();
161  }
162  }
163 
164  // to have numbers from 0 to 17 for the EE feds and 0-36 for EB
165  // 0 = EE-7; 1 = EE-8; 2 = EE-9; 3 = EE-1; 4 = EE-2; 5 = EE-3; 6 = EE-4; 7 = EE-5; 8 = EE-6;
166  // 9 = EE+7; 10 = EE+8; 11 = EE+9; 12 = EE+1; 13 = EE+2; 14 = EE+3; 15 = EE+4; 16 = EE+5; 17 = EE+6
167  // 0 = EB-1 --> 17 = EB-18; 18 = EB+1 --> 35 = EB+18
168  int thisFed = -100;
169  if (ecid_xt.getName() == "EE_crystal_number") {
170  if (theFed > 600 && theFed < 610)
171  thisFed = theFed - 601;
172  if (theFed > 645 && theFed < 655)
173  thisFed = theFed - 646 + 9;
174  }
175  if (ecid_xt.getName() == "EB_crystal_number") {
176  thisFed = theFed - 610;
177  }
178 
179  // in which light module I am
180  int theTTieta = -100;
181  int theTTiphi = -100;
182  int theLM = -100;
183  if (ecid_xt.getName() == "EB_crystal_number") {
184  theTTieta = (theTT - 1) / 4 + 1;
185  theTTiphi = (theTT - 1) % 4 + 1;
186  if (theTTieta == 1 || theTTiphi == 3 || theTTiphi == 4)
187  theLM = 0; // L-shaped
188  if (theTTieta > 1 && (theTTiphi == 1 || theTTiphi == 2))
189  theLM = 1; // not L-shaped
190  }
191  if ((ecid_xt.getName() == "EE_crystal_number") && (thisFed == 7 || thisFed == 16)) {
192  if (theIx <= 50)
193  theLM = 0;
194  if (theIx > 50)
195  theLM = 1;
196  }
197 
198  // taking laser infos
199  rd_blue = p->second;
200  float myApdMean = rd_blue.getAPDMean();
201 
202  // barrel: is there at least one crystal on in this LM?
203  if (ecid_xt.getName() == "EB_crystal_number") {
204  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
205  if (!isEBRef1[thisFed][theLM] && !isEBRef2[thisFed][theLM] && myApdMean > 100)
206  isEBRef1[thisFed][theLM] = true;
207  if (isEBRef1[thisFed][theLM] && !isEBRef2[thisFed][theLM] && myApdMean > 100)
208  isEBRef2[thisFed][theLM] = true;
209  }
210 
211  // endcap: is there at least one crystal on in this LM?
212  if (ecid_xt.getName() == "EE_crystal_number") {
213  EEDetId eedetid(xt_num, yt_num, sm_num);
214 
215  // just 1 LM per Fed
216  if (thisFed != 7 && thisFed != 16) {
217  if (!isEERef1[thisFed][0] && !isEERef2[thisFed][0] && myApdMean > 100) {
218  isEERef1[thisFed][0] = true;
219  isEERef1[thisFed][1] = true;
220  }
221  if (isEERef1[thisFed][0] && !isEERef2[thisFed][0] && myApdMean > 100) {
222  isEERef2[thisFed][0] = true;
223  isEERef2[thisFed][1] = true;
224  }
225  }
226 
227  // 2 LMs per Fed
228  if (thisFed == 7 || thisFed == 16) {
229  if (!isEERef1[thisFed][theLM] && !isEERef2[thisFed][theLM] && myApdMean > 100)
230  isEERef1[thisFed][theLM] = true;
231  if (isEERef1[thisFed][theLM] && !isEERef2[thisFed][theLM] && myApdMean > 100)
232  isEERef2[thisFed][theLM] = true;
233  }
234  }
235  }
236 
237  // check if the light module is on: at least two crystals must be on
238  for (int theSm = 0; theSm < 36; theSm++) {
239  for (int theLM = 0; theLM < 2; theLM++) {
240  if (isEBRef1[theSm][theLM] && isEBRef2[theSm][theLM])
241  isGoodLaserEBSm[theSm][theLM] = true;
242  // std::cout << "Barrel: SM " << theSm << ", LM " << theLM << ": good = " << isGoodLaserEBSm[theSm][theLM] << std::endl;
243  }
244  }
245 
246  for (int theSector = 0; theSector < 18; theSector++) {
247  for (int theLM = 0; theLM < 2; theLM++) {
248  if (isEERef1[theSector][theLM] && isEERef2[theSector][theLM])
249  isGoodLaserEESm[theSector][theLM] = true;
250  // std::cout << "Endcap: SM " << theSector << ", LM " << theLM << ": good = " << isGoodLaserEESm[theSector][theLM] << std::endl;
251  }
252  }
253 }
254 
255 // ----------------------------------------------------------
256 // START MASKING ROUTINES
258  uint64_t bits03 = 0;
259  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_ONLINE_HIGH_GAIN_MEAN_WARNING");
260  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_ONLINE_HIGH_GAIN_RMS_WARNING");
261  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_ONLINE_HIGH_GAIN_MEAN_ERROR");
262  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_ONLINE_HIGH_GAIN_RMS_ERROR");
263 
264  std::map<EcalLogicID, RunCrystalErrorsDat> theMask;
265  EcalErrorMask::fetchDataSet(&theMask);
266 
267  if (!theMask.empty()) {
268  std::map<EcalLogicID, RunCrystalErrorsDat>::const_iterator m;
269  for (m = theMask.begin(); m != theMask.end(); m++) {
270  EcalLogicID ecid_xt = m->first;
271  int sm_num = ecid_xt.getID1();
272  int xt_num = ecid_xt.getID2();
273  int yt_num = ecid_xt.getID3();
274 
275  if ((m->second).getErrorBits() & bits03) {
276  if (ecid_xt.getName() == "EB_crystal_number") {
277  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
278  maskedOnlinePedEB.insert(std::pair<DetId, float>(ebdetid, 9999.));
279  } else {
280  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
281  EEDetId eedetid(xt_num, yt_num, sm_num);
282  maskedOnlinePedEE.insert(std::pair<DetId, float>(eedetid, 9999.));
283  }
284  }
285  }
286  }
287  }
288 }
289 
291  uint64_t bits03 = 0;
292  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_MEAN_WARNING");
293  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_MEAN_WARNING");
294  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_MEAN_WARNING");
295  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_MEAN_ERROR");
296  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_MEAN_ERROR");
297  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_MEAN_ERROR");
298  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_RMS_WARNING");
299  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_RMS_WARNING");
300  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_RMS_WARNING");
301  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_LOW_GAIN_RMS_ERROR");
302  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_MIDDLE_GAIN_RMS_ERROR");
303  bits03 |= EcalErrorDictionary::getMask("PEDESTAL_HIGH_GAIN_RMS_ERROR");
304 
305  std::map<EcalLogicID, RunCrystalErrorsDat> theMask;
306  EcalErrorMask::fetchDataSet(&theMask);
307 
308  if (!theMask.empty()) {
309  std::map<EcalLogicID, RunCrystalErrorsDat>::const_iterator m;
310  for (m = theMask.begin(); m != theMask.end(); m++) {
311  EcalLogicID ecid_xt = m->first;
312  int sm_num = ecid_xt.getID1();
313  int xt_num = ecid_xt.getID2();
314  int yt_num = ecid_xt.getID3();
315 
316  if ((m->second).getErrorBits() & bits03) {
317  if (ecid_xt.getName() == "EB_crystal_number") {
318  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
319  maskedPedEB.insert(std::pair<DetId, float>(ebdetid, 9999.));
320  } else {
321  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
322  EEDetId eedetid(xt_num, yt_num, sm_num);
323  maskedPedEE.insert(std::pair<DetId, float>(eedetid, 9999.));
324  }
325  }
326  }
327  }
328  }
329 }
330 
332  uint64_t bits03 = 0;
333  bits03 |= EcalErrorDictionary::getMask("LASER_MEAN_WARNING");
334  bits03 |= EcalErrorDictionary::getMask("LASER_RMS_WARNING");
335  bits03 |= EcalErrorDictionary::getMask("LASER_MEAN_OVER_PN_WARNING");
336  bits03 |= EcalErrorDictionary::getMask("LASER_RMS_OVER_PN_WARNING");
337  bits03 |= EcalErrorDictionary::getMask("LASER_MEAN_TIMING_WARNING");
338  bits03 |= EcalErrorDictionary::getMask("LASER_RMS_TIMING_WARNING");
339 
340  std::map<EcalLogicID, RunCrystalErrorsDat> theMask;
341  EcalErrorMask::fetchDataSet(&theMask);
342 
343  if (!theMask.empty()) {
344  std::map<EcalLogicID, RunCrystalErrorsDat>::const_iterator m;
345  for (m = theMask.begin(); m != theMask.end(); m++) {
346  EcalLogicID ecid_xt = m->first;
347  int sm_num = ecid_xt.getID1();
348  int xt_num = ecid_xt.getID2();
349  int yt_num = ecid_xt.getID3();
350 
351  if ((m->second).getErrorBits() & bits03) {
352  if (ecid_xt.getName() == "EB_crystal_number") {
353  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
354  maskedLaserEB.insert(std::pair<DetId, float>(ebdetid, 9999.));
355  } else {
356  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
357  EEDetId eedetid(xt_num, yt_num, sm_num);
358  maskedLaserEE.insert(std::pair<DetId, float>(eedetid, 9999.));
359  }
360  }
361  }
362  }
363  }
364 }
365 
367  uint64_t bits03 = 0;
368  bits03 |= EcalErrorDictionary::getMask("PHYSICS_BAD_CHANNEL_WARNING");
369  bits03 |= EcalErrorDictionary::getMask("PHYSICS_BAD_CHANNEL_ERROR");
370 
371  std::map<EcalLogicID, RunCrystalErrorsDat> theMask;
372  EcalErrorMask::fetchDataSet(&theMask);
373 
374  if (!theMask.empty()) {
375  std::map<EcalLogicID, RunCrystalErrorsDat>::const_iterator m;
376  for (m = theMask.begin(); m != theMask.end(); m++) {
377  EcalLogicID ecid_xt = m->first;
378  int sm_num = ecid_xt.getID1();
379  int xt_num = ecid_xt.getID2();
380  int yt_num = ecid_xt.getID3();
381 
382  if ((m->second).getErrorBits() & bits03) {
383  if (ecid_xt.getName() == "EB_crystal_number") {
384  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
385  maskedPhysicsEB.insert(std::pair<DetId, float>(ebdetid, 9999.));
386  } else {
387  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
388  EEDetId eedetid(xt_num, yt_num, sm_num);
389  maskedPhysicsEE.insert(std::pair<DetId, float>(eedetid, 9999.));
390  }
391  }
392  }
393  }
394  }
395 }
396 
397 // ----------------------------------------------------------
398 // START DAQ EXCLUDED FEDs ROUTINES
400  RunIOV myRun = _myRun;
401  std::map<EcalLogicID, RunFEConfigDat> feconfig;
402  econn->fetchDataSet(&feconfig, &myRun);
403 
404  typedef std::map<EcalLogicID, RunFEConfigDat>::const_iterator feConfIter;
405  EcalLogicID ecid_xt;
406  RunFEConfigDat rd_fe;
407 
408  int fe_conf_id = 0;
409  for (feConfIter p = feconfig.begin(); p != feconfig.end(); p++) {
410  ecid_xt = p->first;
411  rd_fe = p->second;
412  fe_conf_id = rd_fe.getConfigId();
413  }
414 
415  // reading this configuration
416  ODFEDAQConfig myconfig;
417  myconfig.setId(fe_conf_id);
418  econn->fetchConfigSet(&myconfig);
419 
420  // list of bad channels
421  int myTT = myconfig.getBadTTId();
422  ODBadTTInfo mybadTT;
423  mybadTT.setId(myTT);
424  econn->fetchConfigSet(&mybadTT);
425 
426  std::vector<ODBadTTDat> badTT_dat;
427  econn->fetchConfigDataSet(&badTT_dat, &mybadTT);
428 
429  for (size_t iTT = 0; iTT < badTT_dat.size(); iTT++) {
430  int fed_id = badTT_dat[iTT].getFedId();
431  int tt_id = badTT_dat[iTT].getTTId();
432  if (tt_id < 69)
433  *daqFile << fed_id << " " << tt_id << std::endl;
434 
435  // taking the channel list for towers out of daq
436  if ((fed_id <= 609 || fed_id >= 646) && tt_id < 69) { // endcap
437 
438  // moving from cms fed to db fed convention
439  //int db_fedId = -999;
440  //if (fed_id>=604 && fed_id<=609) db_fedId = fed_id - 603 + 9;
441  //if (fed_id>=601 && fed_id<=603) db_fedId = fed_id - 600 + 15;
442  //if (fed_id>=649 && fed_id<=654) db_fedId = fed_id - 648;
443  //if (fed_id>=646 && fed_id<=648) db_fedId = fed_id - 645 + 6;
444  // db_fedId = fed_id; // fixme: do we need 1-18 or 6XX?
445 
446  std::vector<EcalLogicID> badCrystals;
447  badCrystals = econn->getEcalLogicIDSet("EE_readout_tower",
448  fed_id,
449  fed_id,
450  tt_id,
451  tt_id,
454  "EE_crystal_number");
455 
456  for (size_t mycrys = 0; mycrys < badCrystals.size(); mycrys++) {
457  EcalLogicID ecid_xt = badCrystals[mycrys];
458  int zSide = 999;
459  int log_id = ecid_xt.getLogicID();
460  int yt2 = log_id % 1000; // EE_crystal_number: 2010100060 -> z=-1, x=100, y=60
461  int xt2 = (log_id % 1000000) / 1000; // EE_crystal_number: 2012020085 -> z=+1, x=20, y=85
462  int zt2 = (log_id / 1000000) % 10;
463  if (zt2 == 0)
464  zSide = -1;
465  if (zt2 == 2)
466  zSide = 1;
467  *daqFile2 << xt2 << " " << yt2 << " " << zSide << std::endl;
468  }
469  }
470 
471  if (fed_id >= 610 && fed_id <= 645 && tt_id < 69) { // barrel
472 
473  // moving from cms fed to db fed convention
474  int db_fedId = -999;
475  if (fed_id >= 610 && fed_id <= 627)
476  db_fedId = fed_id - 609 + 18;
477  if (fed_id >= 628 && fed_id <= 645)
478  db_fedId = fed_id - 627;
479 
480  std::vector<EcalLogicID> badCrystals;
481  badCrystals = econn->getEcalLogicIDSet("EB_trigger_tower",
482  db_fedId,
483  db_fedId,
484  tt_id,
485  tt_id,
488  "EB_crystal_number");
489 
490  for (size_t mycrys = 0; mycrys < badCrystals.size(); mycrys++) {
491  EcalLogicID ecid_xt = badCrystals[mycrys];
492  int sm_num = ecid_xt.getID1();
493  int log_id = ecid_xt.getLogicID();
494  int xt2_num = log_id % 10000;
495  EBDetId ebdetid(sm_num, xt2_num, EBDetId::SMCRYSTALMODE);
496  *daqFile2 << ebdetid.hashedIndex() << std::endl;
497  }
498  }
499  }
500 }
501 
502 // ----------------------------------------------------------
503 //
504 // ANALYSIS
505 //
506 // ----------------------------------------------------------
507 
508 // ----------------------------------------------------------
509 // LOCAL pedestal runs
510 
511 void popcon::EcalChannelStatusHandler::pedAnalysis(std::map<EcalLogicID, MonPedestalsDat> dataset_mon,
512  std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon) {
513  // to take the list of masked crystals
514  pedMasking();
515 
516  // to iterate
517  std::map<DetId, float>::const_iterator theIter;
518 
519  // logic id
520  EcalLogicID ecid_xt;
521 
522  // to check all problems except gain zero
523  typedef std::map<EcalLogicID, MonPedestalsDat>::const_iterator CImon;
524  MonPedestalsDat rd_ped;
525 
526  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
527  uint16_t status_now = 0;
528  ecid_xt = p->first;
529  rd_ped = p->second;
530  int sm_num = ecid_xt.getID1();
531  int xt_num = ecid_xt.getID2();
532  int yt_num = ecid_xt.getID3();
533 
534  EcalPedestals::Item ped_item;
535  ped_item.mean_x1 = rd_ped.getPedMeanG1();
536  ped_item.mean_x6 = rd_ped.getPedMeanG6();
537  ped_item.mean_x12 = rd_ped.getPedMeanG12();
538  ped_item.rms_x1 = rd_ped.getPedRMSG1();
539  ped_item.rms_x6 = rd_ped.getPedRMSG6();
540  ped_item.rms_x12 = rd_ped.getPedRMSG12();
541 
542  // check if pedestal RMS is bad at least at 1 gain -> noisy or very noisy channel
543  float lowerCut = 999.;
544  if (ecid_xt.getName() == "EB_crystal_number") {
545  lowerCut = 2.0;
546  }
547  if (ecid_xt.getName() == "EE_crystal_number") {
548  lowerCut = 2.5;
549  }
550  if ((checkPedestalRMSGain12(&ped_item) > lowerCut) || (checkPedestalRMSGain6(&ped_item) > lowerCut) ||
551  (checkPedestalRMSGain1(&ped_item) > lowerCut))
552  status_now = 3;
553 
554  // check if pedestal value is bad at least at 1 gain -> problem in dac settings
555  if ((checkPedestalValueGain12(&ped_item) > 300 || checkPedestalValueGain12(&ped_item) < 100) ||
556  (checkPedestalValueGain6(&ped_item) > 300 || checkPedestalValueGain6(&ped_item) < 100) ||
557  (checkPedestalValueGain1(&ped_item) > 300 || checkPedestalValueGain1(&ped_item) < 100))
558  status_now = 1;
559 
560  // check if pedestal rms is zero at least at 1 gain -> dead at that channel
561  if (checkPedestalRMSGain12(&ped_item) == 0 || checkPedestalRMSGain6(&ped_item) == 0 ||
562  checkPedestalRMSGain1(&ped_item) == 0)
563  status_now = 11;
564 
565  // check if the channel is fixed at G1
566  if (checkPedestalValueGain12(&ped_item) < 0 && checkPedestalValueGain6(&ped_item) < 0 &&
567  checkPedestalValueGain1(&ped_item) > 0)
568  status_now = 9;
569 
570  // check if the channel is fixed at G6
571  if (checkPedestalValueGain12(&ped_item) < 0 && checkPedestalValueGain6(&ped_item) > 0 &&
572  checkPedestalValueGain1(&ped_item) < 0)
573  status_now = 8;
574 
575  // check if the channel is not working at G12
576  if (checkPedestalValueGain12(&ped_item) < 0 && checkPedestalValueGain6(&ped_item) > 0 &&
577  checkPedestalValueGain1(&ped_item) > 0)
578  status_now = 8;
579 
580  // output in case of problems:
581  if (status_now > 0) {
582  if (ecid_xt.getName() == "EB_crystal_number") {
583  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
584  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
585  int thisFed = 600 + elecId.dccId();
586 
587  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t"
588  << ped_item.mean_x12 << "\t\t" << ped_item.rms_x12 << "\t\t" << ped_item.mean_x6 << "\t\t"
589  << ped_item.rms_x6 << "\t\t" << ped_item.mean_x1 << "\t\t" << ped_item.rms_x1 << std::endl;
590 
591  // file with new problems only
592  bool isOld = false;
593  for (theIter = maskedPedEB.begin(); theIter != maskedPedEB.end(); ++theIter) {
594  if ((*theIter).first == ebdetid)
595  isOld = true;
596  }
597  if (!isOld) {
598  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t"
599  << ped_item.mean_x12 << "\t\t" << ped_item.rms_x12 << "\t\t" << ped_item.mean_x6 << "\t\t"
600  << ped_item.rms_x6 << "\t\t" << ped_item.mean_x1 << "\t\t" << ped_item.rms_x1 << std::endl;
601  }
602 
603  } else {
604  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
605  EEDetId eedetid(xt_num, yt_num, sm_num);
606  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
607  int thisFed = 600 + elecId.dccId();
608  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
609  << "\t\t" << eedetid.hashedIndex() << "\t\t" << ped_item.mean_x12 << "\t\t" << ped_item.rms_x12
610  << "\t\t" << ped_item.mean_x6 << "\t\t" << ped_item.rms_x6 << "\t\t" << ped_item.mean_x1 << "\t\t"
611  << ped_item.rms_x1 << std::endl;
612 
613  bool isOld = false;
614  for (theIter = maskedPedEE.begin(); theIter != maskedPedEE.end(); ++theIter) {
615  if ((*theIter).first == eedetid)
616  isOld = true;
617  }
618  if (!isOld) {
619  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
620  << "\t\t" << eedetid.hashedIndex() << "\t\t" << ped_item.mean_x12 << "\t\t"
621  << ped_item.rms_x12 << "\t\t" << ped_item.mean_x6 << "\t\t" << ped_item.rms_x6 << "\t\t"
622  << ped_item.mean_x1 << "\t\t" << ped_item.rms_x1 << std::endl;
623  }
624  }
625  }
626  }
627  }
628 
629  // to check if a crystal is at gain zero in at least 1000 events (which is not the best! fixme)
630  typedef std::map<EcalLogicID, MonCrystalConsistencyDat>::const_iterator WGmonIter;
631  MonCrystalConsistencyDat rd_wgain;
632 
633  for (WGmonIter p = wrongGain_mon.begin(); p != wrongGain_mon.end(); p++) {
634  ecid_xt = p->first;
635  rd_wgain = p->second;
636  int sm_num = ecid_xt.getID1();
637  int xt_num = ecid_xt.getID2();
638  int yt_num = ecid_xt.getID3();
639 
640  // output if problematic
641  if (rd_wgain.getProblemsGainZero() > 1000) {
642  if (ecid_xt.getName() == "EB_crystal_number") {
643  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
644  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
645  int thisFed = 600 + elecId.dccId();
646  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t"
647  << "at gain zero" << std::endl;
648 
649  // file with new problems only
650  bool isOld = false;
651  for (theIter = maskedPedEB.begin(); theIter != maskedPedEB.end(); ++theIter) {
652  if ((*theIter).first == ebdetid)
653  isOld = true;
654  }
655  if (!isOld) {
656  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t"
657  << "at gain zero" << std::endl;
658  }
659 
660  } else {
661  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
662  EEDetId eedetid(xt_num, yt_num, sm_num);
663  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
664  int thisFed = 600 + elecId.dccId();
665  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
666  << "\t\t" << eedetid.hashedIndex() << "\t\t"
667  << "at gain zero" << std::endl;
668 
669  bool isOld = false;
670  for (theIter = maskedPedEE.begin(); theIter != maskedPedEE.end(); ++theIter) {
671  if ((*theIter).first == eedetid)
672  isOld = true;
673  }
674  if (!isOld) {
675  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
676  << "\t\t" << eedetid.hashedIndex() << "\t\t"
677  << "at gain zero" << std::endl;
678  }
679  }
680  }
681  }
682  }
683 }
684 
685 // ------------------------------------------------------------
686 //
687 // LOCAL laser runs
688 
689 void popcon::EcalChannelStatusHandler::laserAnalysis(std::map<EcalLogicID, MonLaserBlueDat> dataset_mon) {
690  // to take the list of masked crystals
691  laserMasking();
692 
693  // to iterate
694  std::map<DetId, float>::const_iterator theIter;
695 
696  typedef std::map<EcalLogicID, MonLaserBlueDat>::const_iterator CImon;
697  EcalLogicID ecid_xt;
698  MonLaserBlueDat rd_blue;
699 
700  for (CImon p = dataset_mon.begin(); p != dataset_mon.end(); p++) {
701  ecid_xt = p->first;
702  int sm_num = ecid_xt.getID1();
703  int xt_num = ecid_xt.getID2();
704  int yt_num = ecid_xt.getID3();
705 
706  // in which Fed/triggerTower/sectorSide I am
707  int theFed = -100;
708  int theTT = -100;
709  int theIx = -100;
710  if (ecid_xt.getName() == "EB_crystal_number") {
711  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
712  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
713  theFed = 600 + elecId.dccId();
714  theTT = elecId.towerId();
715  }
716  if (ecid_xt.getName() == "EE_crystal_number") {
717  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
718  EEDetId eedetid(xt_num, yt_num, sm_num);
719  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
720  theFed = 600 + elecId.dccId();
721  theIx = eedetid.ix();
722  }
723  }
724 
725  // to have numbers from 0 to 17 for the EE feds and 0-36 for EB
726  int thisFed = -100;
727  if (ecid_xt.getName() == "EE_crystal_number") {
728  if (theFed > 600 && theFed < 610)
729  thisFed = theFed - 601;
730  if (theFed > 645 && theFed < 655)
731  thisFed = theFed - 646 + 9;
732  }
733  if (ecid_xt.getName() == "EB_crystal_number") {
734  thisFed = theFed - 610;
735  }
736 
737  // in which light module I am
738  int theTTieta = -100;
739  int theTTiphi = -100;
740  int theLM = -100;
741  if (ecid_xt.getName() == "EB_crystal_number") {
742  theTTieta = (theTT - 1) / 4 + 1;
743  theTTiphi = (theTT - 1) % 4 + 1;
744  if (theTTieta == 1 || theTTiphi == 3 || theTTiphi == 4)
745  theLM = 0; // L-shaped
746  if (theTTieta > 1 && (theTTiphi == 1 || theTTiphi == 2))
747  theLM = 1; // not L-shaped
748  }
749  if ((ecid_xt.getName() == "EE_crystal_number") && (thisFed == 7 || thisFed == 16)) {
750  if (theIx <= 50)
751  theLM = 0;
752  if (theIx > 50)
753  theLM = 1;
754  }
755 
756  // check if APD mean is bad
757  uint16_t status_now = 0;
758  rd_blue = p->second;
759  float myApdMean = rd_blue.getAPDMean();
760 
761  if (ecid_xt.getName() == "EB_crystal_number") {
762  if ((myApdMean < 400) && isGoodLaserEBSm[thisFed][theLM])
763  status_now = 2;
764  }
765 
766  if (ecid_xt.getName() == "EE_crystal_number") {
767  if (myApdMean < 100) {
768  if (thisFed != 7 && thisFed != 16 && isGoodLaserEESm[thisFed][0])
769  status_now = 2;
770  if ((thisFed == 7 || thisFed == 16) && isGoodLaserEESm[thisFed][theLM])
771  status_now = 2;
772  }
773  }
774 
775  // output if problematic
776  if (status_now > 0) {
777  if (ecid_xt.getName() == "EB_crystal_number") {
778  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
779  *ResFileEB << theFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << myApdMean
780  << std::endl;
781 
782  // file with new problems only
783  bool isOld = false;
784  for (theIter = maskedLaserEB.begin(); theIter != maskedLaserEB.end(); ++theIter) {
785  if ((*theIter).first == ebdetid)
786  isOld = true;
787  }
788  if (!isOld) {
789  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << myApdMean
790  << std::endl;
791  }
792 
793  } else {
794  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
795  EEDetId eedetid(xt_num, yt_num, sm_num);
796  *ResFileEE << theFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
797  << "\t\t" << eedetid.hashedIndex() << "\t\t" << myApdMean << std::endl;
798 
799  // file with new problems only
800  bool isOld = false;
801  for (theIter = maskedLaserEE.begin(); theIter != maskedLaserEE.end(); ++theIter) {
802  if ((*theIter).first == eedetid)
803  isOld = true;
804  }
805  if (!isOld) {
806  *ResFileEE << theFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
807  << "\t\t" << eedetid.hashedIndex() << "\t\t" << myApdMean << std::endl;
808  }
809  }
810  }
811  }
812  }
813 }
814 
815 // ------------------------------------------------------------
816 //
817 // COSMICS/PHYSICS ANALYSIS: infos from pedestal online, laser and occupancy analysis
818 
819 void popcon::EcalChannelStatusHandler::cosmicsAnalysis(std::map<EcalLogicID, MonPedestalsOnlineDat> pedestalO_mon,
820  std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon,
821  std::map<EcalLogicID, MonLaserBlueDat> laser_mon,
822  std::map<EcalLogicID, MonOccupancyDat> occupancy_mon) {
823  // to take the list of masked crystals for the diffrent analyses
824  pedOnlineMasking();
825  laserMasking();
826  physicsMasking();
827 
828  std::map<DetId, float>::const_iterator theIter;
829  std::map<DetId, float> badPedOnEB, badPedOnEE;
830  std::map<DetId, float> badPedOnRmsEB, badPedOnRmsEE;
831  std::map<DetId, float> badGainEB, badGainEE;
832  std::map<DetId, float> badLaserEB, badLaserEE;
833  std::map<DetId, float> badOccHighEB, badOccHighEE;
834 
835  typedef std::map<EcalLogicID, MonPedestalsOnlineDat>::const_iterator CImonPedO;
836  typedef std::map<EcalLogicID, MonCrystalConsistencyDat>::const_iterator CImonCons;
837  typedef std::map<EcalLogicID, MonOccupancyDat>::const_iterator CImonOcc;
838  typedef std::map<EcalLogicID, MonLaserBlueDat>::const_iterator CImonLaser;
839  MonPedestalsOnlineDat rd_ped0;
840  MonCrystalConsistencyDat rd_wgain;
841  MonOccupancyDat rd_occ;
842  MonLaserBlueDat rd_blue;
843 
844  // logic id
845  EcalLogicID ecid_xt;
846 
847  // to be used after: total number of entries above high threshold
848  float totEntriesAboveHighThrEB = 0.;
849  float totEntriesAboveHighThrEE = 0.;
850  for (CImonOcc p = occupancy_mon.begin(); p != occupancy_mon.end(); p++) {
851  ecid_xt = p->first;
852  rd_occ = p->second;
853  float highOcc = rd_occ.getEventsOverHighThreshold();
854  if (ecid_xt.getName() == "EB_crystal_number" && highOcc > -1)
855  totEntriesAboveHighThrEB = totEntriesAboveHighThrEB + highOcc;
856  if (ecid_xt.getName() == "EE_crystal_number" && highOcc > -1)
857  totEntriesAboveHighThrEE = totEntriesAboveHighThrEE + highOcc;
858  }
859 
860  // A) creating the list of all bad channels: searching for problems based on pedestal online except gain zero
861  for (CImonPedO p = pedestalO_mon.begin(); p != pedestalO_mon.end(); p++) {
862  bool isWrong = false;
863  ecid_xt = p->first;
864  rd_ped0 = p->second;
865  int sm_num = ecid_xt.getID1();
866  int xt_num = ecid_xt.getID2();
867  int yt_num = ecid_xt.getID3();
868 
869  EcalPedestals::Item ped_item;
870  ped_item.mean_x12 = rd_ped0.getADCMeanG12();
871  ped_item.rms_x12 = rd_ped0.getADCRMSG12();
872 
873  float lowerCut = 999.;
874  if (ecid_xt.getName() == "EB_crystal_number") {
875  lowerCut = 2.0;
876  }
877  if (ecid_xt.getName() == "EE_crystal_number") {
878  lowerCut = 2.5;
879  }
880  if (checkPedestalRMSGain12(&ped_item) > lowerCut)
881  isWrong = true;
882  if (checkPedestalValueGain12(&ped_item) > 300)
883  isWrong = true;
884  if (checkPedestalValueGain12(&ped_item) < 100)
885  isWrong = true;
886  if (checkPedestalRMSGain12(&ped_item) == 0)
887  isWrong = true;
888 
889  // is this channel already in the list?
890  if (isWrong) {
891  if (ecid_xt.getName() == "EB_crystal_number") {
892  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
893  theIter = badPedOnEB.find(ebdetid);
894  if (theIter == badPedOnEB.end()) {
895  badPedOnEB.insert(std::pair<DetId, float>(ebdetid, rd_ped0.getADCMeanG12()));
896  badPedOnRmsEB.insert(std::pair<DetId, float>(ebdetid, rd_ped0.getADCRMSG12()));
897  }
898  } else {
899  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
900  EEDetId eedetid(xt_num, yt_num, sm_num);
901  theIter = badPedOnEE.find(eedetid);
902  if (theIter == badPedOnEE.end()) {
903  badPedOnEE.insert(std::pair<DetId, float>(eedetid, rd_ped0.getADCMeanG12()));
904  badPedOnRmsEE.insert(std::pair<DetId, float>(eedetid, rd_ped0.getADCRMSG12()));
905  }
906  }
907  }
908  }
909  }
910 
911  // B) creating the list of all bad channels: searching for channels at gain zero at least in 100 events
912  for (CImonCons p = wrongGain_mon.begin(); p != wrongGain_mon.end(); p++) {
913  bool isWrong = false;
914  ecid_xt = p->first;
915  rd_wgain = p->second;
916  int sm_num = ecid_xt.getID1();
917  int xt_num = ecid_xt.getID2();
918  int yt_num = ecid_xt.getID3();
919 
920  if (rd_wgain.getProblemsGainZero() > 1000) {
921  isWrong = true;
922  }
923 
924  if (isWrong) {
925  if (ecid_xt.getName() == "EB_crystal_number") {
926  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
927  theIter = badGainEB.find(ebdetid);
928  if (theIter == badGainEB.end())
929  badGainEB.insert(std::pair<DetId, float>(ebdetid, 999.));
930  } else {
931  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
932  EEDetId eedetid(xt_num, yt_num, sm_num);
933  theIter = badGainEE.find(eedetid);
934  if (theIter == badGainEE.end())
935  badGainEE.insert(std::pair<DetId, float>(eedetid, 999.));
936  }
937  }
938  }
939  }
940 
941  // C) creating the list of all bad channels: searching for channels with bad occupancy [ too high ]
942  for (CImonOcc p = occupancy_mon.begin(); p != occupancy_mon.end(); p++) {
943  // logic id
944  ecid_xt = p->first;
945  int sm_num = ecid_xt.getID1();
946  int xt_num = ecid_xt.getID2();
947  int yt_num = ecid_xt.getID3();
948 
949  // occupancy
950  rd_occ = p->second;
951 
952  bool isWrong = false;
953  float occAvg = -999.;
954  if (ecid_xt.getName() == "EB_crystal_number") {
955  occAvg = rd_occ.getEventsOverHighThreshold() / totEntriesAboveHighThrEB;
956  if (occAvg > 0.001)
957  isWrong = true;
958  }
959  if (ecid_xt.getName() == "EE_crystal_number") {
960  occAvg = rd_occ.getEventsOverHighThreshold() / totEntriesAboveHighThrEE;
961  if (occAvg > 0.001)
962  isWrong = true;
963  }
964 
965  if (isWrong) {
966  if (ecid_xt.getName() == "EB_crystal_number") {
967  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
968  theIter = badOccHighEB.find(ebdetid);
969  if (theIter == badOccHighEB.end())
970  badOccHighEB.insert(std::pair<DetId, float>(ebdetid, occAvg));
971  } else {
972  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
973  EEDetId eedetid(xt_num, yt_num, sm_num);
974  theIter = badOccHighEE.find(eedetid);
975  if (theIter == badOccHighEE.end())
976  badOccHighEE.insert(std::pair<DetId, float>(eedetid, occAvg));
977  }
978  }
979  }
980  }
981 
982  // D) creating the list of all bad channels: searching for channels with bad laser amplitude [among those covered by the calibration sequence]
983  for (CImonLaser p = laser_mon.begin(); p != laser_mon.end(); p++) {
984  // logic id
985  ecid_xt = p->first;
986  int sm_num = ecid_xt.getID1();
987  int xt_num = ecid_xt.getID2();
988  int yt_num = ecid_xt.getID3();
989 
990  // in which Fed/triggerTower/sectorSide I am
991  int theFed = -100;
992  int theTT = -100;
993  int theIx = -100;
994  if (ecid_xt.getName() == "EB_crystal_number") {
995  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
996  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
997  theFed = 600 + elecId.dccId();
998  theTT = elecId.towerId();
999  }
1000  if (ecid_xt.getName() == "EE_crystal_number") {
1001  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
1002  EEDetId eedetid(xt_num, yt_num, sm_num);
1003  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
1004  theFed = 600 + elecId.dccId();
1005  theIx = eedetid.ix();
1006  }
1007  }
1008 
1009  // to have numbers from 0 to 17 for the EE feds and 0-36 for EB
1010  int thisFed = -100;
1011  if (ecid_xt.getName() == "EE_crystal_number") {
1012  if (theFed > 600 && theFed < 610)
1013  thisFed = theFed - 601;
1014  if (theFed > 645 && theFed < 655)
1015  thisFed = theFed - 646 + 9;
1016  }
1017  if (ecid_xt.getName() == "EB_crystal_number") {
1018  thisFed = theFed - 610;
1019  }
1020 
1021  // in which light module I am
1022  int theTTieta = -100;
1023  int theTTiphi = -100;
1024  int theLM = -100;
1025  if (ecid_xt.getName() == "EB_crystal_number") {
1026  theTTieta = (theTT - 1) / 4 + 1;
1027  theTTiphi = (theTT - 1) % 4 + 1;
1028  if (theTTieta == 1 || theTTiphi == 3 || theTTiphi == 4)
1029  theLM = 0; // L-shaped
1030  if (theTTieta > 1 && (theTTiphi == 1 || theTTiphi == 2))
1031  theLM = 1; // not L-shaped
1032  }
1033  if ((ecid_xt.getName() == "EE_crystal_number") && (thisFed == 7 || thisFed == 16)) {
1034  if (theIx <= 50)
1035  theLM = 0;
1036  if (theIx > 50)
1037  theLM = 1;
1038  }
1039 
1040  // APD mean value
1041  rd_blue = p->second;
1042  float myApdMean = rd_blue.getAPDMean();
1043 
1044  bool isWrong = false;
1045  if (ecid_xt.getName() == "EB_crystal_number") {
1046  if ((myApdMean < 400) && isGoodLaserEBSm[thisFed][theLM])
1047  isWrong = true;
1048  }
1049  if (ecid_xt.getName() == "EE_crystal_number") {
1050  if (myApdMean < 100) {
1051  if (thisFed != 7 && thisFed != 16 && isGoodLaserEESm[thisFed][0])
1052  isWrong = true;
1053  if ((thisFed == 7 || thisFed == 16) && isGoodLaserEESm[thisFed][theLM])
1054  isWrong = true;
1055  }
1056  }
1057 
1058  if (isWrong) {
1059  if (ecid_xt.getName() == "EB_crystal_number") {
1060  EBDetId ebdetid(sm_num, xt_num, EBDetId::SMCRYSTALMODE);
1061  theIter = badLaserEB.find(ebdetid);
1062  if (theIter == badLaserEB.end())
1063  badLaserEB.insert(std::pair<DetId, float>(ebdetid, myApdMean));
1064  } else {
1065  if (EEDetId::validDetId(xt_num, yt_num, sm_num)) {
1066  EEDetId eedetid(xt_num, yt_num, sm_num);
1067  theIter = badLaserEE.find(eedetid);
1068  if (theIter == badLaserEE.end())
1069  badLaserEE.insert(std::pair<DetId, float>(eedetid, myApdMean));
1070  }
1071  }
1072  }
1073  }
1074 
1075  // check if the crystal is in the vector and fill the summary file
1076  std::map<DetId, float>::const_iterator theIterPedOn;
1077  std::map<DetId, float>::const_iterator theIterPedOnRms;
1078  std::map<DetId, float>::const_iterator theIterGain;
1079  std::map<DetId, float>::const_iterator theIterLaser;
1080  std::map<DetId, float>::const_iterator theIterOccHigh;
1081 
1082  // EB, first check - loop over pedestal online
1083  for (theIterPedOn = badPedOnEB.begin(); theIterPedOn != badPedOnEB.end(); ++theIterPedOn) {
1084  float thePedOn = (*theIterPedOn).second;
1085  float thePedOnRms = 9999.;
1086  float theGain = 9999.;
1087  float theLaser = 9999.;
1088  float theOccHigh = 9999.;
1089 
1090  theIterPedOnRms = badPedOnRmsEB.find((*theIterPedOn).first);
1091  theIterGain = badGainEB.find((*theIterPedOn).first);
1092  theIterLaser = badLaserEB.find((*theIterPedOn).first);
1093  theIterOccHigh = badOccHighEB.find((*theIterPedOn).first);
1094 
1095  if (theIterPedOnRms != badPedOnRmsEB.end())
1096  thePedOnRms = (*theIterPedOnRms).second;
1097  if (theIterLaser != badLaserEB.end())
1098  theLaser = (*theIterLaser).second;
1099  if (theIterOccHigh != badOccHighEB.end())
1100  theOccHigh = (*theIterOccHigh).second;
1101 
1102  int thisFed = -100;
1103  EBDetId ebdetid((*theIterPedOn).first);
1104  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
1105  thisFed = 600 + elecId.dccId();
1106 
1107  // new problems only
1108  bool isNew = false;
1109  bool isNewPed = true;
1110  bool isNewLaser = true;
1111  bool isNewPhysics = true;
1112  for (theIter = maskedOnlinePedEB.begin(); theIter != maskedOnlinePedEB.end(); ++theIter) {
1113  if ((*theIter).first == ebdetid)
1114  isNewPed = false;
1115  }
1116 
1117  for (theIter = maskedLaserEB.begin(); theIter != maskedLaserEB.end(); ++theIter) {
1118  if ((*theIter).first == ebdetid)
1119  isNewLaser = false;
1120  }
1121 
1122  for (theIter = maskedPhysicsEB.begin(); theIter != maskedPhysicsEB.end(); ++theIter) {
1123  if ((*theIter).first == ebdetid)
1124  isNewPhysics = false;
1125  }
1126 
1127  if (isNewPed || (theLaser != 9999 && isNewLaser) || (theOccHigh != 9999 && isNewPhysics))
1128  isNew = true;
1129 
1130  if (theIterGain != badGainEB.end()) {
1131  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1132  << thePedOnRms << "\t\t"
1133  << "gainZero"
1134  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1135 
1136  if (isNew) {
1137  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1138  << "\t\t" << thePedOnRms << "\t\t"
1139  << "gainZero"
1140  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1141 
1142  float thisEtaFill = float(0);
1143  if (ebdetid.ieta() > 0)
1144  thisEtaFill = ebdetid.ieta() - 0.5;
1145  if (ebdetid.ieta() < 0)
1146  thisEtaFill = ebdetid.ieta();
1147  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1148  }
1149  } else {
1150  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1151  << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1152 
1153  if (isNew) {
1154  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1155  << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh
1156  << std::endl;
1157 
1158  float thisEtaFill = float(0);
1159  if (ebdetid.ieta() > 0)
1160  thisEtaFill = ebdetid.ieta() - 0.5;
1161  if (ebdetid.ieta() < 0)
1162  thisEtaFill = ebdetid.ieta();
1163  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1164  }
1165  }
1166  }
1167 
1168  // EB, second check - loop over laser
1169  for (theIterLaser = badLaserEB.begin(); theIterLaser != badLaserEB.end(); ++theIterLaser) {
1170  // remove already included channels
1171  theIterPedOnRms = badPedOnRmsEB.find((*theIterLaser).first);
1172  if (theIterPedOnRms != badPedOnRmsEB.end())
1173  continue;
1174 
1175  float thePedOn = 9999.;
1176  float thePedOnRms = 9999.;
1177  float theGain = 9999.;
1178  float theLaser = (*theIterLaser).second;
1179  float theOccHigh = 9999.;
1180 
1181  theIterGain = badGainEB.find((*theIterLaser).first);
1182  theIterOccHigh = badOccHighEB.find((*theIterLaser).first);
1183  if (theIterOccHigh != badOccHighEB.end())
1184  theOccHigh = (*theIterOccHigh).second;
1185 
1186  int thisFed = -100;
1187  EBDetId ebdetid((*theIterLaser).first);
1188  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
1189  thisFed = 600 + elecId.dccId();
1190 
1191  // new problems only
1192  bool isNew = false;
1193  bool isNewPed = true;
1194  bool isNewLaser = true;
1195  bool isNewPhysics = true;
1196  for (theIter = maskedOnlinePedEB.begin(); theIter != maskedOnlinePedEB.end(); ++theIter) {
1197  if ((*theIter).first == ebdetid)
1198  isNewPed = false;
1199  }
1200 
1201  for (theIter = maskedLaserEB.begin(); theIter != maskedLaserEB.end(); ++theIter) {
1202  if ((*theIter).first == ebdetid)
1203  isNewLaser = false;
1204  }
1205 
1206  for (theIter = maskedPhysicsEB.begin(); theIter != maskedPhysicsEB.end(); ++theIter) {
1207  if ((*theIter).first == ebdetid)
1208  isNewPhysics = false;
1209  }
1210 
1211  if ((isNewPed && theIterGain != badGainEB.end()) || (isNewLaser) || (theOccHigh != 9999 && isNewPhysics))
1212  isNew = true;
1213 
1214  if (theIterGain != badGainEB.end()) {
1215  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1216  << thePedOnRms << "\t\t"
1217  << "gainZero"
1218  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1219 
1220  if (isNew) {
1221  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1222  << "\t\t" << thePedOnRms << "\t\t"
1223  << "gainZero"
1224  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1225 
1226  float thisEtaFill = float(0);
1227  if (ebdetid.ieta() > 0)
1228  thisEtaFill = ebdetid.ieta() - 0.5;
1229  if (ebdetid.ieta() < 0)
1230  thisEtaFill = ebdetid.ieta();
1231  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1232  }
1233  } else {
1234  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1235  << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1236 
1237  if (isNew) {
1238  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1239  << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh
1240  << std::endl;
1241 
1242  float thisEtaFill = float(0);
1243  if (ebdetid.ieta() > 0)
1244  thisEtaFill = ebdetid.ieta() - 0.5;
1245  if (ebdetid.ieta() < 0)
1246  thisEtaFill = ebdetid.ieta();
1247  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1248  }
1249  }
1250  }
1251 
1252  // EB, third check: loop over occupancy
1253  for (theIterOccHigh = badOccHighEB.begin(); theIterOccHigh != badOccHighEB.end(); ++theIterOccHigh) {
1254  // remove already included channels
1255  theIterPedOnRms = badPedOnRmsEB.find((*theIterOccHigh).first);
1256  theIterLaser = badLaserEB.find((*theIterOccHigh).first);
1257  if (theIterPedOnRms != badPedOnRmsEB.end())
1258  continue;
1259  if (theIterLaser != badLaserEB.end())
1260  continue;
1261 
1262  float thePedOn = 9999.;
1263  float thePedOnRms = 9999.;
1264  float theGain = 9999.;
1265  float theLaser = 9999.;
1266  float theOccHigh = (*theIterOccHigh).second;
1267  theIterGain = badGainEB.find((*theIterOccHigh).first);
1268 
1269  int thisFed = -100;
1270  EBDetId ebdetid((*theIterOccHigh).first);
1271  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
1272  thisFed = 600 + elecId.dccId();
1273 
1274  // new problems only
1275  bool isNew = false;
1276  bool isNewPed = true;
1277  bool isNewPhysics = true;
1278  for (theIter = maskedOnlinePedEB.begin(); theIter != maskedOnlinePedEB.end(); ++theIter) {
1279  if ((*theIter).first == ebdetid)
1280  isNewPed = false;
1281  }
1282 
1283  for (theIter = maskedPhysicsEB.begin(); theIter != maskedPhysicsEB.end(); ++theIter) {
1284  if ((*theIter).first == ebdetid)
1285  isNewPhysics = false;
1286  }
1287 
1288  if ((isNewPed && theIterGain != badGainEB.end()) || (isNewPhysics))
1289  isNew = true;
1290 
1291  if (theIterGain != badGainEB.end()) {
1292  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1293  << thePedOnRms << "\t\t"
1294  << "gainZero"
1295  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1296 
1297  if (isNew) {
1298  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1299  << "\t\t" << thePedOnRms << "\t\t"
1300  << "gainZero"
1301  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1302 
1303  float thisEtaFill = float(0);
1304  if (ebdetid.ieta() > 0)
1305  thisEtaFill = ebdetid.ieta() - 0.5;
1306  if (ebdetid.ieta() < 0)
1307  thisEtaFill = ebdetid.ieta();
1308  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1309  }
1310  } else {
1311  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1312  << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1313 
1314  if (isNew) {
1315  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1316  << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh
1317  << std::endl;
1318 
1319  float thisEtaFill = float(0);
1320  if (ebdetid.ieta() > 0)
1321  thisEtaFill = ebdetid.ieta() - 0.5;
1322  if (ebdetid.ieta() < 0)
1323  thisEtaFill = ebdetid.ieta();
1324  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1325  }
1326  }
1327  }
1328 
1329  // EB, fourth check: loop over consistency
1330  for (theIterGain = badGainEB.begin(); theIterGain != badGainEB.end(); ++theIterGain) {
1331  // remove already included channels
1332  theIterPedOnRms = badPedOnRmsEB.find((*theIterGain).first);
1333  theIterLaser = badLaserEB.find((*theIterGain).first);
1334  theIterOccHigh = badOccHighEB.find((*theIterGain).first);
1335  if (theIterPedOnRms != badPedOnRmsEB.end())
1336  continue;
1337  if (theIterLaser != badLaserEB.end())
1338  continue;
1339  if (theIterOccHigh != badOccHighEB.end())
1340  continue;
1341 
1342  float thePedOn = 9999.;
1343  float thePedOnRms = 9999.;
1344  float theLaser = 9999.;
1345  float theOccHigh = 9999.;
1346 
1347  int thisFed = -100;
1348  EBDetId ebdetid((*theIterGain).first);
1349  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(ebdetid);
1350  thisFed = 600 + elecId.dccId();
1351 
1352  // new problems only
1353  bool isNew = false;
1354  bool isNewPed = true;
1355  for (theIter = maskedOnlinePedEB.begin(); theIter != maskedOnlinePedEB.end(); ++theIter) {
1356  if ((*theIter).first == ebdetid)
1357  isNewPed = false;
1358  }
1359 
1360  if (isNewPed && theIterGain != badGainEB.end())
1361  isNew = true;
1362 
1363  *ResFileEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn << "\t\t"
1364  << thePedOnRms << "\t\t"
1365  << "gainZero"
1366  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1367 
1368  if (isNew) {
1369  *ResFileNewEB << thisFed << "\t\t" << ebdetid.ic() << "\t\t" << ebdetid.hashedIndex() << "\t\t" << thePedOn
1370  << "\t\t" << thePedOnRms << "\t\t"
1371  << "gainZero"
1372  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1373 
1374  float thisEtaFill = float(0);
1375  if (ebdetid.ieta() > 0)
1376  thisEtaFill = ebdetid.ieta() - 0.5;
1377  if (ebdetid.ieta() < 0)
1378  thisEtaFill = ebdetid.ieta();
1379  newBadEB_->Fill((ebdetid.iphi() - 0.5), thisEtaFill, 2);
1380  }
1381  }
1382 
1383  // EE, first check: loop over pedestal online
1384  for (theIterPedOn = badPedOnEE.begin(); theIterPedOn != badPedOnEE.end(); ++theIterPedOn) {
1385  float thePedOn = (*theIterPedOn).second;
1386  float thePedOnRms = 9999.;
1387  float theGain = 9999.;
1388  float theLaser = 9999.;
1389  float theOccHigh = 9999.;
1390 
1391  theIterPedOnRms = badPedOnRmsEE.find((*theIterPedOn).first);
1392  theIterGain = badGainEE.find((*theIterPedOn).first);
1393  theIterLaser = badLaserEE.find((*theIterPedOn).first);
1394  theIterOccHigh = badOccHighEE.find((*theIterPedOn).first);
1395 
1396  if (theIterPedOnRms != badPedOnRmsEE.end())
1397  thePedOnRms = (*theIterPedOnRms).second;
1398  if (theIterLaser != badLaserEE.end())
1399  theLaser = (*theIterLaser).second;
1400  if (theIterOccHigh != badOccHighEE.end())
1401  theOccHigh = (*theIterOccHigh).second;
1402 
1403  int thisFed = -100;
1404  EEDetId eedetid((*theIterPedOn).first);
1405  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
1406  thisFed = 600 + elecId.dccId();
1407 
1408  // new problems only
1409  bool isNew = false;
1410  bool isNewPed = true;
1411  bool isNewLaser = true;
1412  bool isNewPhysics = true;
1413  for (theIter = maskedOnlinePedEE.begin(); theIter != maskedOnlinePedEE.end(); ++theIter) {
1414  if ((*theIter).first == eedetid)
1415  isNewPed = false;
1416  }
1417 
1418  for (theIter = maskedLaserEE.begin(); theIter != maskedLaserEE.end(); ++theIter) {
1419  if ((*theIter).first == eedetid)
1420  isNewLaser = false;
1421  }
1422 
1423  for (theIter = maskedPhysicsEE.begin(); theIter != maskedPhysicsEE.end(); ++theIter) {
1424  if ((*theIter).first == eedetid)
1425  isNewPhysics = false;
1426  }
1427 
1428  if (isNewPed || (theLaser != 9999 && isNewLaser) || (theOccHigh != 9999 && isNewPhysics))
1429  isNew = true;
1430 
1431  if (theIterGain != badGainEE.end()) {
1432  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1433  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1434  << "gainZero"
1435  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1436 
1437  if (isNew) {
1438  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1439  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1440  << "gainZero"
1441  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1442 
1443  if (eedetid.zside() > 0)
1444  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1445  if (eedetid.zside() < 0)
1446  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1447  }
1448  } else {
1449  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1450  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t"
1451  << theLaser << "\t\t" << theOccHigh << std::endl;
1452 
1453  if (isNew) {
1454  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1455  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1456  << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1457 
1458  if (eedetid.zside() > 0)
1459  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1460  if (eedetid.zside() < 0)
1461  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1462  }
1463  }
1464  }
1465 
1466  // EE, second check: loop over laser
1467  for (theIterLaser = badLaserEE.begin(); theIterLaser != badLaserEE.end(); ++theIterLaser) {
1468  // remove already included channels
1469  theIterPedOnRms = badPedOnRmsEE.find((*theIterLaser).first);
1470  if (theIterPedOnRms != badPedOnRmsEE.end())
1471  continue;
1472 
1473  float thePedOn = 9999.;
1474  float thePedOnRms = 9999.;
1475  float theGain = 9999.;
1476  float theLaser = (*theIterLaser).second;
1477  float theOccHigh = 9999.;
1478 
1479  theIterGain = badGainEE.find((*theIterLaser).first);
1480  theIterOccHigh = badOccHighEE.find((*theIterLaser).first);
1481  if (theIterOccHigh != badOccHighEE.end())
1482  theOccHigh = (*theIterOccHigh).second;
1483 
1484  int thisFed = -100;
1485  EEDetId eedetid((*theIterLaser).first);
1486  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
1487  thisFed = 600 + elecId.dccId();
1488 
1489  // new problems only
1490  bool isNew = false;
1491  bool isNewPed = true;
1492  bool isNewLaser = true;
1493  bool isNewPhysics = true;
1494  for (theIter = maskedOnlinePedEE.begin(); theIter != maskedOnlinePedEE.end(); ++theIter) {
1495  if ((*theIter).first == eedetid)
1496  isNewPed = false;
1497  }
1498 
1499  for (theIter = maskedLaserEE.begin(); theIter != maskedLaserEE.end(); ++theIter) {
1500  if ((*theIter).first == eedetid)
1501  isNewLaser = false;
1502  }
1503 
1504  for (theIter = maskedPhysicsEE.begin(); theIter != maskedPhysicsEE.end(); ++theIter) {
1505  if ((*theIter).first == eedetid)
1506  isNewPhysics = false;
1507  }
1508 
1509  if ((isNewPed && theIterGain != badGainEE.end()) || (isNewLaser) || (theOccHigh != 9999 && isNewPhysics))
1510  isNew = true;
1511 
1512  if (theIterGain != badGainEE.end()) {
1513  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1514  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1515  << "gainZero"
1516  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1517 
1518  if (isNew) {
1519  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1520  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1521  << "gainZero"
1522  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1523 
1524  if (eedetid.zside() > 0)
1525  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1526  if (eedetid.zside() < 0)
1527  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1528  }
1529  } else {
1530  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1531  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t"
1532  << theLaser << "\t\t" << theOccHigh << std::endl;
1533 
1534  if (isNew) {
1535  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1536  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1537  << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1538 
1539  if (eedetid.zside() > 0)
1540  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1541  if (eedetid.zside() < 0)
1542  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1543  }
1544  }
1545  }
1546 
1547  // third check: loop over occupancy
1548  for (theIterOccHigh = badOccHighEE.begin(); theIterOccHigh != badOccHighEE.end(); ++theIterOccHigh) {
1549  // remove already included channels
1550  theIterPedOnRms = badPedOnRmsEE.find((*theIterOccHigh).first);
1551  theIterLaser = badLaserEE.find((*theIterOccHigh).first);
1552  if (theIterPedOnRms != badPedOnRmsEE.end())
1553  continue;
1554  if (theIterLaser != badLaserEE.end())
1555  continue;
1556 
1557  float thePedOn = 9999.;
1558  float thePedOnRms = 9999.;
1559  float theGain = 9999.;
1560  float theLaser = 9999.;
1561  float theOccHigh = (*theIterOccHigh).second;
1562  theIterGain = badGainEE.find((*theIterOccHigh).first);
1563 
1564  int thisFed = -100;
1565  EEDetId eedetid((*theIterOccHigh).first);
1566  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
1567  thisFed = 600 + elecId.dccId();
1568 
1569  // new problems only
1570  bool isNew = false;
1571  bool isNewPed = true;
1572  bool isNewPhysics = true;
1573  for (theIter = maskedOnlinePedEE.begin(); theIter != maskedOnlinePedEE.end(); ++theIter) {
1574  if ((*theIter).first == eedetid)
1575  isNewPed = false;
1576  }
1577 
1578  for (theIter = maskedPhysicsEE.begin(); theIter != maskedPhysicsEE.end(); ++theIter) {
1579  if ((*theIter).first == eedetid)
1580  isNewPhysics = false;
1581  }
1582 
1583  if ((isNewPed && theIterGain != badGainEE.end()) || (isNewPhysics))
1584  isNew = true;
1585 
1586  if (theIterGain != badGainEE.end()) {
1587  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1588  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1589  << "gainZero"
1590  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1591 
1592  if (isNew) {
1593  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1594  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1595  << "gainZero"
1596  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1597 
1598  if (eedetid.zside() > 0)
1599  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1600  if (eedetid.zside() < 0)
1601  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1602  }
1603  } else {
1604  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1605  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t" << theGain << "\t\t"
1606  << theLaser << "\t\t" << theOccHigh << std::endl;
1607 
1608  if (isNew) {
1609  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1610  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1611  << theGain << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1612 
1613  if (eedetid.zside() > 0)
1614  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1615  if (eedetid.zside() < 0)
1616  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1617  }
1618  }
1619  }
1620 
1621  // EE, fourth check: loop over consistency
1622  for (theIterGain = badGainEE.begin(); theIterGain != badGainEE.end(); ++theIterGain) {
1623  // remove already included channels
1624  theIterPedOnRms = badPedOnRmsEE.find((*theIterGain).first);
1625  theIterLaser = badLaserEE.find((*theIterGain).first);
1626  theIterOccHigh = badOccHighEE.find((*theIterGain).first);
1627  if (theIterPedOnRms != badPedOnRmsEE.end())
1628  continue;
1629  if (theIterLaser != badLaserEE.end())
1630  continue;
1631  if (theIterOccHigh != badOccHighEE.end())
1632  continue;
1633  float thePedOn = 9999.;
1634  float thePedOnRms = 9999.;
1635  float theLaser = 9999.;
1636  float theOccHigh = 9999.;
1637 
1638  int thisFed = -100;
1639  EEDetId eedetid((*theIterGain).first);
1640  EcalElectronicsId elecId = ecalElectronicsMap_.getElectronicsId(eedetid);
1641  thisFed = 600 + elecId.dccId();
1642 
1643  // new problems only
1644  bool isNew = false;
1645  bool isNewPed = true;
1646  for (theIter = maskedOnlinePedEE.begin(); theIter != maskedOnlinePedEE.end(); ++theIter) {
1647  if ((*theIter).first == eedetid)
1648  isNewPed = false;
1649  }
1650 
1651  if (isNewPed && theIterGain != badGainEE.end())
1652  isNew = true;
1653 
1654  *ResFileEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside() << "\t\t"
1655  << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1656  << "gainZero"
1657  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1658 
1659  if (isNew) {
1660  *ResFileNewEE << thisFed << "\t\t" << eedetid.ix() << "\t\t" << eedetid.iy() << "\t\t" << eedetid.zside()
1661  << "\t\t" << eedetid.hashedIndex() << "\t\t" << thePedOn << "\t\t" << thePedOnRms << "\t\t"
1662  << "gainZero"
1663  << "\t\t" << theLaser << "\t\t" << theOccHigh << std::endl;
1664 
1665  if (eedetid.zside() > 0)
1666  newBadEEP_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1667  if (eedetid.zside() < 0)
1668  newBadEEM_->Fill((eedetid.ix() - 0.5), (eedetid.iy() - 0.5), 4);
1669  }
1670  }
1671 }
1672 
1673 // core of the work = analyzing runs
1675  std::ostringstream ss;
1676  ss << "ECAL ";
1677 
1678  // here we retrieve all the runs of a given type after the last from online DB
1679  unsigned int max_since = 0;
1680  max_since = static_cast<unsigned int>(tagInfo().lastInterval.since);
1681  std::cout << "max_since : " << max_since << std::endl;
1682 
1683  std::cout << "Retrieving run list from ONLINE DB ... " << std::endl;
1684  econn = new EcalCondDBInterface(m_sid, m_user, m_pass);
1685  std::cout << "Connection done" << std::endl;
1686 
1687  if (!econn) {
1688  std::cout << " Problem with OMDS: connection parameters " << m_sid << "/" << m_user << "/" << m_pass << std::endl;
1689  throw cms::Exception("OMDS not available");
1690  }
1691 
1692  // histos
1693  newBadEB_ = new TProfile2D("newBadEB_", "new bad channels, EB", 360, 0., 360., 170, -85., 85.);
1694  newBadEEP_ = new TProfile2D("newBad_EEP_", "new bad channels, EE+", 100, 0., 100., 100, 0., 100.);
1695  newBadEEM_ = new TProfile2D("newBad_EEM_", "new bad channels, EE-", 100, 0., 100., 100, 0., 100.);
1696 
1697  // these are the online conditions DB classes
1698  RunList my_runlist;
1699  RunTag my_runtag;
1702  my_locdef.setLocation(m_location);
1703  my_rundef.setRunType(m_runtype);
1704  my_runtag.setLocationDef(my_locdef);
1705  my_runtag.setRunTypeDef(my_rundef);
1706  my_runtag.setGeneralTag(m_gentag);
1707 
1708  // range of validity
1709  unsigned int min_run = 0;
1710  if (m_firstRun < max_since) {
1711  min_run = max_since + 1; // we have to add 1 to the last transferred one
1712  } else {
1713  min_run = m_firstRun;
1714  }
1715  unsigned int max_run = m_lastRun;
1716 
1717  // here we retrieve the Monitoring run records
1718  MonVersionDef monverdef;
1719  monverdef.setMonitoringVersion("test01");
1720  MonRunTag mon_tag;
1721  // if (m_runtype=="PEDESTAL") mon_tag.setGeneralTag("CMSSW");
1722  // if (m_runtype=="LASER") mon_tag.setGeneralTag("CMSSW");
1723  // if (m_runtype=="COSMIC" || m_runtype=="BEAM" || m_runtype=="PHYSICS" || m_runtype=="HALO" || m_runtype=="GLOBAL_COSMICS" ) mon_tag.setGeneralTag("CMSSW-online");
1724  if (m_runtype == "PEDESTAL")
1725  mon_tag.setGeneralTag("CMSSW-offline-private");
1726  if (m_runtype == "LASER")
1727  mon_tag.setGeneralTag("CMSSW-offline-private");
1728  if (m_runtype == "COSMIC" || m_runtype == "BEAM" || m_runtype == "PHYSICS" || m_runtype == "HALO" ||
1729  m_runtype == "GLOBAL_COSMICS")
1730  mon_tag.setGeneralTag("CMSSW-online-private");
1731  mon_tag.setMonVersionDef(monverdef);
1732  MonRunList mon_list;
1733  mon_list.setMonRunTag(mon_tag);
1734  mon_list.setRunTag(my_runtag);
1735  mon_list = econn->fetchMonRunList(my_runtag, mon_tag, min_run, max_run);
1736 
1737  // ----------------------------------------------------------------
1738  // preparing the output files
1739  char outfile[800];
1740  sprintf(outfile, "BadChannelsEB_run%d.txt", min_run);
1741  ResFileEB = new std::ofstream(outfile, std::ios::out);
1742  sprintf(outfile, "BadChannelsEE_run%d.txt", min_run);
1743  ResFileEE = new std::ofstream(outfile, std::ios::out);
1744  sprintf(outfile, "BadNewChannelsEB_run%d.txt", min_run);
1745  ResFileNewEB = new std::ofstream(outfile, std::ios::out);
1746  sprintf(outfile, "BadNewChannelsEE_run%d.txt", min_run);
1747  ResFileNewEE = new std::ofstream(outfile, std::ios::out);
1748  sprintf(outfile, "DaqConfig_run%d.txt", min_run);
1749  daqFile = new std::ofstream(outfile, std::ios::out);
1750  sprintf(outfile, "DaqConfig_channels_run%d.txt", min_run);
1751  daqFile2 = new std::ofstream(outfile, std::ios::out);
1752 
1753  *daqFile << "fed"
1754  << "\t\t"
1755  << "tower" << std::endl;
1756 
1757  if (m_runtype == "PEDESTAL") {
1758  *ResFileEB << "Fed"
1759  << "\t\t"
1760  << "Ic"
1761  << "\t\t"
1762  << "hIndex"
1763  << "\t\t"
1764  << "MeanG12"
1765  << "\t\t"
1766  << "RmsG12"
1767  << "\t\t"
1768  << "MeanG6"
1769  << "\t\t"
1770  << "RmsG6"
1771  << "\t\t"
1772  << "MeanG1"
1773  << "\t\t"
1774  << "RmsG1" << std::endl;
1775 
1776  *ResFileEE << "Fed"
1777  << "\t\t"
1778  << "Ix"
1779  << "\t\t"
1780  << "Iy"
1781  << "\t\t"
1782  << "Iz"
1783  << "\t\t"
1784  << "hIndex"
1785  << "\t\t"
1786  << "MeanG12"
1787  << "\t\t"
1788  << "RmsG12"
1789  << "\t\t"
1790  << "MeanG6"
1791  << "\t\t"
1792  << "RmsG6"
1793  << "\t\t"
1794  << "MeanG1"
1795  << "\t\t"
1796  << "RmsG1" << std::endl;
1797 
1798  *ResFileNewEB << "Fed"
1799  << "\t\t"
1800  << "Ic"
1801  << "\t\t"
1802  << "hIndex"
1803  << "\t\t"
1804  << "MeanG12"
1805  << "\t\t"
1806  << "RmsG12"
1807  << "\t\t"
1808  << "MeanG6"
1809  << "\t\t"
1810  << "RmsG6"
1811  << "\t\t"
1812  << "MeanG1"
1813  << "\t\t"
1814  << "RmsG1" << std::endl;
1815 
1816  *ResFileNewEE << "Fed"
1817  << "\t\t"
1818  << "Ix"
1819  << "\t\t"
1820  << "Iy"
1821  << "\t\t"
1822  << "Iz"
1823  << "\t\t"
1824  << "hIndex"
1825  << "\t\t"
1826  << "MeanG12"
1827  << "\t\t"
1828  << "RmsG12"
1829  << "\t\t"
1830  << "MeanG6"
1831  << "\t\t"
1832  << "RmsG6"
1833  << "\t\t"
1834  << "MeanG1"
1835  << "\t\t"
1836  << "RmsG1" << std::endl;
1837  }
1838 
1839  if (m_runtype == "LASER") {
1840  *ResFileEB << "Fed"
1841  << "\t\t"
1842  << "Ic"
1843  << "\t\t"
1844  << "hIndex"
1845  << "\t\t"
1846  << "apd" << std::endl;
1847  *ResFileEE << "Fed"
1848  << "\t\t"
1849  << "Ix"
1850  << "\t\t"
1851  << "Iy"
1852  << "\t\t"
1853  << "Iz"
1854  << "\t\t"
1855  << "hIndex"
1856  << "\t\t"
1857  << "apd" << std::endl;
1858  *ResFileNewEB << "Fed"
1859  << "\t\t"
1860  << "Ic"
1861  << "\t\t"
1862  << "hIndex"
1863  << "\t\t"
1864  << "apd" << std::endl;
1865  *ResFileNewEE << "Fed"
1866  << "\t\t"
1867  << "Ix"
1868  << "\t\t"
1869  << "Iy"
1870  << "\t\t"
1871  << "Iz"
1872  << "\t\t"
1873  << "hIndex"
1874  << "\t\t"
1875  << "apd" << std::endl;
1876  }
1877 
1878  if (m_runtype == "COSMIC" || m_runtype == "BEAM" || m_runtype == "PHYSICS" || m_runtype == "HALO" ||
1879  m_runtype == "GLOBAL_COSMICS") {
1880  *ResFileEB << "Fed"
1881  << "\t\t"
1882  << "Ic"
1883  << "\t\t"
1884  << "hIndex"
1885  << "\t\t"
1886  << "pedOnline"
1887  << "\t\t"
1888  << "pedOnlineRMS "
1889  << "\t\t"
1890  << "gain0"
1891  << "\t\t"
1892  << "apd"
1893  << "\t\t"
1894  << "highThrOcc"
1895  << "\t\t" << std::endl;
1896 
1897  *ResFileEE << "Fed"
1898  << "\t\t"
1899  << "Ix"
1900  << "Iy"
1901  << "\t\t"
1902  << "Iz"
1903  << "\t\t"
1904  << "hIndex"
1905  << "\t\t"
1906  << "pedOnline"
1907  << "\t\t"
1908  << "pedOnlineRMS "
1909  << "\t\t"
1910  << "gain0"
1911  << "\t\t"
1912  << "apd"
1913  << "\t\t"
1914  << "highThrOcc"
1915  << "\t\t" << std::endl;
1916 
1917  *ResFileNewEB << "Fed"
1918  << "\t\t"
1919  << "Ic"
1920  << "\t\t"
1921  << "hIndex"
1922  << "\t\t"
1923  << "pedOnline"
1924  << "\t\t"
1925  << "pedOnlineRMS "
1926  << "\t\t"
1927  << "gain0"
1928  << "\t\t"
1929  << "apd"
1930  << "\t\t"
1931  << "highThrOcc"
1932  << "\t\t" << std::endl;
1933 
1934  *ResFileNewEE << "Fed"
1935  << "\t\t"
1936  << "Ix"
1937  << "Iy"
1938  << "\t\t"
1939  << "Iz"
1940  << "\t\t"
1941  << "hIndex"
1942  << "\t\t"
1943  << "pedOnline"
1944  << "\t\t"
1945  << "pedOnlineRMS "
1946  << "\t\t"
1947  << "gain0"
1948  << "\t\t"
1949  << "apd"
1950  << "\t\t"
1951  << "highThrOcc"
1952  << "\t\t" << std::endl;
1953  }
1954 
1955  // -------------------------------------------------------------------
1956  // analysis for the wanted runs
1957  std::vector<MonRunIOV> mon_run_vec = mon_list.getRuns();
1958  int mon_runs = mon_run_vec.size();
1959  std::cout << "number of Mon runs is " << mon_runs << std::endl;
1960  if (mon_runs == 0)
1961  std::cout << "PROBLEM! 0 runs analyzed by DQM" << std::endl;
1962  if (mon_runs == 0)
1963  ss << "PROBLEM! 0 runs analyzed by DQM" << std::endl;
1964 
1965  // initialize std::maps with masked channels
1966  maskedOnlinePedEB.clear();
1967  maskedOnlinePedEE.clear();
1968  maskedPedEB.clear();
1969  maskedPedEE.clear();
1970  maskedLaserEB.clear();
1971  maskedLaserEE.clear();
1972  maskedPhysicsEB.clear();
1973  maskedPhysicsEE.clear();
1974 
1975  // to iterate
1976  std::map<DetId, float>::const_iterator theIter;
1977 
1978  // using db info written by DQM
1979  if (mon_runs > 0) {
1980  for (int dqmRun = 0; dqmRun < mon_runs; dqmRun++) {
1981  unsigned long iDqmRun = (unsigned long)mon_run_vec[dqmRun].getRunIOV().getRunNumber();
1982 
1983  std::cout << "retrieve the DQM data for run number: " << iDqmRun
1984  << ", subrun number: " << mon_run_vec[dqmRun].getSubRunNumber() << std::endl;
1985 
1986  if (mon_run_vec[dqmRun].getSubRunNumber() ==
1987  mon_runs) { // fixme: check it still works after DMQ soft reset modifications
1988 
1989  // retrieve daq configuration for this run
1990  RunIOV myRun;
1991  myRun = mon_run_vec[dqmRun].getRunIOV();
1992  daqOut(myRun);
1993 
1994  // retrieve the data for a given run
1995  RunIOV runiov_prime = mon_run_vec[dqmRun].getRunIOV();
1996 
1997  // here we read the list of masked channel in the DB for this run and create masked channels std::maps
1998  std::cout << "Fetching masked channels from DB" << std::endl;
1999  EcalErrorMask::readDB(econn, &runiov_prime);
2000 
2001  // -----------------------------------------------------------------------------------
2002  // here we do all the different types of analyses
2003 
2004  // PEDESTAL ANALYSIS for local runs: check pedestals only
2005  if (m_runtype == "PEDESTAL") {
2006  // retrieve the pedestals from OMDS for this run
2007  std::map<EcalLogicID, MonPedestalsDat> dataset_mon;
2008  econn->fetchDataSet(&dataset_mon, &mon_run_vec[dqmRun]);
2009  std::cout << "running pedestal analysis" << std::endl;
2010  std::cout << "OMDS record for pedestals, run " << iDqmRun << " is made of " << dataset_mon.size()
2011  << " entries" << std::endl;
2012 
2013  // retrieve the crystal consistency from OMDS for this run
2014  std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon;
2015  econn->fetchDataSet(&wrongGain_mon, &mon_run_vec[dqmRun]);
2016  std::cout << "OMDS record for consistency, run " << iDqmRun << " is made of " << wrongGain_mon.size()
2017  << " entries" << std::endl;
2018 
2019  // check if enough data and perform analysis
2020  if (!dataset_mon.empty()) {
2021  pedAnalysis(dataset_mon, wrongGain_mon);
2022  } else {
2023  std::cout << "Not enought data for pedestal analysis" << std::endl;
2024  ss << "Not enought data for pedestal analysis" << std::endl;
2025  }
2026  }
2027 
2028  // LASER ANALYSIS for local runs: check APD values only
2029  if (m_runtype == "LASER") {
2030  // retrieve the APD / PNs from OMDS for this run
2031  std::map<EcalLogicID, MonLaserBlueDat> dataset_mon;
2032  econn->fetchDataSet(&dataset_mon, &mon_run_vec[dqmRun]);
2033  std::cout << "running the laser analysis based on DQM data" << std::endl;
2034  std::cout << "OMDS record for run " << iDqmRun << " is made of " << dataset_mon.size() << " records"
2035  << std::endl;
2036 
2037  // check if enough data and select good light modules / perform analysis
2038  if (!dataset_mon.empty()) {
2039  nBadLaserModules(dataset_mon);
2040  laserAnalysis(dataset_mon);
2041  } else {
2042  std::cout << "Not enought data for dqm-based laser analysis" << std::endl;
2043  ss << "Not enought data for dqm-based laser analysis" << std::endl;
2044  }
2045  }
2046 
2047  // global analysis for global runs
2048  if (m_runtype == "COSMIC" || m_runtype == "BEAM" || m_runtype == "PHYSICS" || m_runtype == "HALO" ||
2049  m_runtype == "GLOBAL_COSMICS") {
2050  // retrieve the pedestal online from OMDS for this run
2051  std::map<EcalLogicID, MonPedestalsOnlineDat> pedonline_mon;
2052  econn->fetchDataSet(&pedonline_mon, &mon_run_vec[dqmRun]);
2053  std::cout << "running pedestal online analysis" << std::endl;
2054  std::cout << "OMDS record for pedestals, run " << iDqmRun << " is made of " << pedonline_mon.size()
2055  << std::endl;
2056 
2057  // retrieve the crystal consistency from OMDS for this run
2058  std::map<EcalLogicID, MonCrystalConsistencyDat> wrongGain_mon;
2059  econn->fetchDataSet(&wrongGain_mon, &mon_run_vec[dqmRun]);
2060  std::cout << "OMDS record for consistency, run " << iDqmRun << " is made of " << wrongGain_mon.size()
2061  << " entries" << std::endl;
2062 
2063  // retrieve the occupancy info from OMDS for this run
2064  std::map<EcalLogicID, MonOccupancyDat> occupancy_mon;
2065  econn->fetchDataSet(&occupancy_mon, &mon_run_vec[dqmRun]);
2066  std::cout << "OMDS record for occupancy, run " << iDqmRun << " is made of " << occupancy_mon.size()
2067  << std::endl;
2068 
2069  // retrieve the APD / PNs from OMDS for this run
2070  std::map<EcalLogicID, MonLaserBlueDat> laser_mon;
2071  econn->fetchDataSet(&laser_mon, &mon_run_vec[dqmRun]);
2072  std::cout << "running laser analysis" << std::endl;
2073  std::cout << "OMDS record for laser, run " << iDqmRun << " is made of " << laser_mon.size() << " records"
2074  << std::endl;
2075 
2076  // check if enough data in all the categories and do the analysis
2077  if (pedonline_mon.empty()) {
2078  std::cout << "Not enought data for pedestal online analysis" << std::endl;
2079  ss << "Not enought data for pedestal online analysis" << std::endl;
2080  }
2081  if (occupancy_mon.empty()) {
2082  std::cout << "Not enought data for occupancy analysis" << std::endl;
2083  ss << "Not enought data for occupancy analysis" << std::endl;
2084  }
2085  if (laser_mon.empty()) {
2086  std::cout << "Not enought data for laser analysis" << std::endl;
2087  ss << "Not enought data for laser analysis" << std::endl;
2088  }
2089  if (!pedonline_mon.empty() || !occupancy_mon.empty() || !wrongGain_mon.empty() || !laser_mon.empty()) {
2090  nBadLaserModules(laser_mon);
2091  cosmicsAnalysis(pedonline_mon, wrongGain_mon, laser_mon, occupancy_mon);
2092  }
2093 
2094  // plotting histos with new bad channels
2095  int iLineEB = 0;
2096  TLine lEB;
2097  gStyle->SetPalette(1);
2098  gStyle->SetOptStat(0);
2099  TCanvas c("c", "c", 1);
2100  newBadEB_->SetMaximum(11);
2101  newBadEB_->Draw("colz");
2102  iLineEB = 0;
2103  lEB.DrawLine(0, 0, 360, 0);
2104  while (iLineEB < 18) {
2105  lEB.DrawLine(iLineEB * 20, -85, iLineEB * 20, 85);
2106  iLineEB++;
2107  }
2108  c.SaveAs("newBadEB_.png");
2109 
2110  TLine lEE;
2111  lEE.SetLineWidth(1);
2112  int ixSectorsEE[202] = {
2113  61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43, 43, 42, 42, 41, 41, 40, 40, 39,
2114  39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61,
2115  0, 100, 100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85, 80, 80, 75, 75, 65, 65, 60, 60, 40, 40,
2116  35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3, 0, 0, 3, 3, 5, 5, 8,
2117  8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 60, 60, 65, 65, 75, 75, 80, 80, 85, 85,
2118  87, 87, 92, 92, 95, 95, 97, 97, 100, 100, 0, 61, 65, 65, 70, 70, 80, 80, 90, 90, 92, 0, 61,
2119  65, 65, 90, 90, 97, 0, 57, 60, 60, 65, 65, 70, 70, 75, 75, 80, 80, 0, 50, 50, 0, 43, 40,
2120  40, 35, 35, 30, 30, 25, 25, 20, 20, 0, 39, 35, 35, 10, 10, 3, 0, 39, 35, 35, 30, 30, 20,
2121  20, 10, 10, 8, 0, 45, 45, 40, 40, 35, 35, 0, 55, 55, 60, 60, 65, 65};
2122  int iySectorsEE[202] = {
2123  50, 55, 55, 57, 57, 58, 58, 59, 59, 60, 60, 61, 61, 60, 60, 59, 59, 58, 58, 57, 57, 55, 55, 45, 45, 43,
2124  43, 42, 42, 41, 41, 40, 40, 39, 39, 40, 40, 41, 41, 42, 42, 43, 43, 45, 45, 50, 0, 50, 60, 60, 65, 65,
2125  75, 75, 80, 80, 85, 85, 87, 87, 92, 92, 95, 95, 97, 97, 100, 100, 97, 97, 95, 95, 92, 92, 87, 87, 85, 85,
2126  80, 80, 75, 75, 65, 65, 60, 60, 40, 40, 35, 35, 25, 25, 20, 20, 15, 15, 13, 13, 8, 8, 5, 5, 3, 3,
2127  0, 0, 3, 3, 5, 5, 8, 8, 13, 13, 15, 15, 20, 20, 25, 25, 35, 35, 40, 40, 50, 0, 45, 45, 40, 40,
2128  35, 35, 30, 30, 25, 25, 0, 50, 50, 55, 55, 60, 60, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0,
2129  61, 100, 0, 60, 60, 65, 65, 70, 70, 75, 75, 85, 85, 87, 0, 50, 50, 55, 55, 60, 60, 0, 45, 45, 40, 40,
2130  35, 35, 30, 30, 25, 25, 0, 39, 30, 30, 15, 15, 5, 0, 39, 30, 30, 15, 15, 5};
2131 
2132  newBadEEP_->SetMaximum(11);
2133  newBadEEP_->Draw("colz");
2134  for (int iLineEEP = 0; iLineEEP < 201; iLineEEP = iLineEEP + 1) {
2135  if ((ixSectorsEE[iLineEEP] != 0 || iySectorsEE[iLineEEP] != 0) &&
2136  (ixSectorsEE[iLineEEP + 1] != 0 || iySectorsEE[iLineEEP + 1] != 0)) {
2137  lEE.DrawLine(
2138  ixSectorsEE[iLineEEP], iySectorsEE[iLineEEP], ixSectorsEE[iLineEEP + 1], iySectorsEE[iLineEEP + 1]);
2139  }
2140  }
2141  c.SaveAs("newBadEEP_.png");
2142 
2143  newBadEEM_->SetMaximum(11);
2144  newBadEEM_->Draw("colz");
2145  for (int iLineEEP = 0; iLineEEP < 201; iLineEEP = iLineEEP + 1) {
2146  if ((ixSectorsEE[iLineEEP] != 0 || iySectorsEE[iLineEEP] != 0) &&
2147  (ixSectorsEE[iLineEEP + 1] != 0 || iySectorsEE[iLineEEP + 1] != 0)) {
2148  lEE.DrawLine(
2149  ixSectorsEE[iLineEEP], iySectorsEE[iLineEEP], ixSectorsEE[iLineEEP + 1], iySectorsEE[iLineEEP + 1]);
2150  }
2151  }
2152  c.SaveAs("newBadEEM_.png");
2153 
2154  } // cosmics analysis
2155 
2156  } // subruns
2157  } // runs loop
2158  } // we have the DQM info
2159 
2160  delete econn;
2161  std::cout << "Ecal - > end of getNewObjects -----------\n";
2162 }
2163 
2165  ecalElectronicsMap_ = (*theEcalElectronicsMap);
2166 }
MonRunList::setRunTag
void setRunTag(const RunTag &tag)
Definition: MonRunList.cc:18
EBDetId::hashedIndex
int hashedIndex() const
get a compact index for arrays
Definition: EBDetId.h:82
EcalCondDBInterface
Definition: EcalCondDBInterface.h:37
EcalElectronicsMapping
Definition: EcalElectronicsMapping.h:28
MonPedestalsDat::getPedMeanG1
float getPedMeanG1() const
Definition: MonPedestalsDat.h:21
RunIOV
Definition: RunIOV.h:13
popcon::EcalChannelStatusHandler::m_lastRun
unsigned int m_lastRun
Definition: EcalChannelStatusHandler.h:110
EBDetId::ieta
int ieta() const
get the crystal ieta
Definition: EBDetId.h:49
popcon::EcalChannelStatusHandler::physicsMasking
void physicsMasking()
Definition: EcalChannelStatusHandler.cc:366
MonVersionDef::setMonitoringVersion
void setMonitoringVersion(std::string ver)
Definition: MonVersionDef.cc:21
dqmMemoryStats.float
float
Definition: dqmMemoryStats.py:127
MonPedestalsOnlineDat::getADCRMSG12
float getADCRMSG12() const
Definition: MonPedestalsOnlineDat.h:25
MonRunList
Definition: MonRunList.h:16
MonLaserBlueDat
Definition: MonLaserBlueDat.h:12
popcon::EcalChannelStatusHandler::m_sid
std::string m_sid
Definition: EcalChannelStatusHandler.h:115
popcon::EcalChannelStatusHandler::checkPedestalValueGain6
float checkPedestalValueGain6(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:76
RunList
Definition: RunList.h:16
EBDetId::ic
int ic() const
get ECAL/crystal number inside SM
Definition: EBDetId.cc:41
MonCrystalConsistencyDat::getProblemsGainZero
int getProblemsGainZero() const
Definition: MonCrystalConsistencyDat.h:31
EBDetId
Definition: EBDetId.h:17
RunTag
Definition: RunTag.h:13
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
gather_cfg.cout
cout
Definition: gather_cfg.py:144
MonPedestalsDat
Definition: MonPedestalsDat.h:11
EcalLogicID::getName
std::string getName() const
Definition: EcalLogicID.cc:26
test_db_connect.econn
econn
Definition: test_db_connect.py:10
LocationDef
Definition: LocationDef.h:12
popcon::EcalChannelStatusHandler::~EcalChannelStatusHandler
~EcalChannelStatusHandler() override
Definition: EcalChannelStatusHandler.cc:64
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
EcalElectronicsId::dccId
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
Definition: EcalElectronicsId.h:31
EcalLogicID::getID1
int getID1() const
Definition: EcalLogicID.cc:30
EcalLogicID::getLogicID
int getLogicID() const
Definition: EcalLogicID.cc:28
EEDetId::ix
int ix() const
Definition: EEDetId.h:77
MonRunTag::setGeneralTag
void setGeneralTag(std::string tag)
Definition: MonRunTag.cc:21
EcalLaserHandler.h
MonPedestalsDat::getPedRMSG6
float getPedRMSG6() const
Definition: MonPedestalsDat.h:33
EcalElectronicsId::towerId
int towerId() const
get the tower id
Definition: EcalElectronicsId.h:33
EcalErrorMask::fetchDataSet
static void fetchDataSet(std::map< EcalLogicID, RunCrystalErrorsDat > *fillMap)
Definition: EcalErrorMask.cc:79
EcalPedestal::mean_x1
float mean_x1
Definition: EcalPedestals.h:23
EcalLogicID::getID2
int getID2() const
Definition: EcalLogicID.cc:32
contentValuesCheck.ss
ss
Definition: contentValuesCheck.py:33
popcon::EcalChannelStatusHandler::EcalChannelStatusHandler
EcalChannelStatusHandler(edm::ParameterSet const &)
Definition: EcalChannelStatusHandler.cc:47
ODBadTTInfo::setId
void setId(int id)
Definition: ODBadTTInfo.h:18
popcon::EcalChannelStatusHandler::m_pass
std::string m_pass
Definition: EcalChannelStatusHandler.h:117
popcon::EcalChannelStatusHandler::checkPedestalRMSGain12
float checkPedestalRMSGain12(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:88
popcon::EcalChannelStatusHandler::m_firstRun
unsigned int m_firstRun
Definition: EcalChannelStatusHandler.h:109
RunTag::setGeneralTag
void setGeneralTag(std::string tag)
Definition: RunTag.cc:24
ODFEDAQConfig::setId
void setId(int id)
Definition: ODFEDAQConfig.h:18
test_db_connect.my_rundef
my_rundef
Definition: test_db_connect.py:13
ODFEDAQConfig::getBadTTId
int getBadTTId() const
Definition: ODFEDAQConfig.h:36
EcalPedestal::mean_x12
float mean_x12
Definition: EcalPedestals.h:19
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
MonOccupancyDat::getEventsOverHighThreshold
int getEventsOverHighThreshold() const
Definition: MonOccupancyDat.h:25
MonPedestalsDat::getPedMeanG6
float getPedMeanG6() const
Definition: MonPedestalsDat.h:24
popcon::EcalChannelStatusHandler::nBadLaserModules
void nBadLaserModules(std::map< EcalLogicID, MonLaserBlueDat > dataset_mon)
Definition: EcalChannelStatusHandler.cc:109
EcalLogicID
Definition: EcalLogicID.h:7
MonVersionDef
Definition: MonVersionDef.h:12
EEDetId::zside
int zside() const
Definition: EEDetId.h:71
EcalElectronicsId
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
Definition: EcalElectronicsId.h:18
EEDetId
Definition: EEDetId.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
RunTypeDef
Definition: RunTypeDef.h:12
EcalErrorMask::readDB
static void readDB(EcalCondDBInterface *eConn, RunIOV *runIOV) noexcept(false)
Definition: EcalErrorMask.cc:26
test_db_connect.my_locdef
my_locdef
Definition: test_db_connect.py:11
popcon::EcalChannelStatusHandler::m_runtype
std::string m_runtype
Definition: EcalChannelStatusHandler.h:114
popcon::EcalChannelStatusHandler::laserMasking
void laserMasking()
Definition: EcalChannelStatusHandler.cc:331
MonPedestalsDat::getPedRMSG1
float getPedRMSG1() const
Definition: MonPedestalsDat.h:30
EcalErrorDictionary::getMask
static uint64_t getMask(std::string shortDesc)
Definition: EcalErrorDictionary.h:25
ODBadTTInfo
Definition: ODBadTTInfo.h:9
popcon::EcalChannelStatusHandler::m_locationsource
std::string m_locationsource
Definition: EcalChannelStatusHandler.h:118
popcon::EcalChannelStatusHandler::checkPedestalRMSGain1
float checkPedestalRMSGain1(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:100
edm::ParameterSet
Definition: ParameterSet.h:36
EcalCondObjectContainer< EcalPedestal >::Item
EcalPedestal Item
Definition: EcalCondObjectContainer.h:15
popcon::EcalChannelStatusHandler::m_name
std::string m_name
Definition: EcalChannelStatusHandler.h:119
RunFEConfigDat
Definition: RunFEConfigDat.h:12
popcon::EcalChannelStatusHandler::cosmicsAnalysis
void cosmicsAnalysis(std::map< EcalLogicID, MonPedestalsOnlineDat > pedestalO_mon, std::map< EcalLogicID, MonCrystalConsistencyDat > wrongGain_mon, std::map< EcalLogicID, MonLaserBlueDat > laser_mon, std::map< EcalLogicID, MonOccupancyDat > occupancy_mon)
Definition: EcalChannelStatusHandler.cc:819
EEDetId::hashedIndex
int hashedIndex() const
Definition: EEDetId.h:183
popcon::EcalChannelStatusHandler::checkPedestalRMSGain6
float checkPedestalRMSGain6(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:94
MonPedestalsOnlineDat
Definition: MonPedestalsOnlineDat.h:12
MonLaserBlueDat::getAPDMean
float getAPDMean() const
Definition: MonLaserBlueDat.h:22
B2GTnPMonitor_cfi.item
item
Definition: B2GTnPMonitor_cfi.py:147
MonRunTag
Definition: MonRunTag.h:13
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
EEDetId::iy
int iy() const
Definition: EEDetId.h:83
popcon::EcalChannelStatusHandler::getNewObjects
void getNewObjects() override
Definition: EcalChannelStatusHandler.cc:1674
popcon::EcalChannelStatusHandler::setElectronicsMap
void setElectronicsMap(const EcalElectronicsMapping *)
Definition: EcalChannelStatusHandler.cc:2164
MonPedestalsDat::getPedRMSG12
float getPedRMSG12() const
Definition: MonPedestalsDat.h:36
popcon::EcalChannelStatusHandler::m_user
std::string m_user
Definition: EcalChannelStatusHandler.h:116
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
EcalLogicID::NULLID
static const int NULLID
Definition: EcalLogicID.h:35
EcalChannelStatusHandler.h
RunTag::setLocationDef
void setLocationDef(const LocationDef &locDef)
Definition: RunTag.cc:33
RunFEConfigDat::getConfigId
int getConfigId() const
Definition: RunFEConfigDat.h:21
MonCrystalConsistencyDat
Definition: MonCrystalConsistencyDat.h:12
ODFEDAQConfig
Definition: ODFEDAQConfig.h:9
popcon::EcalChannelStatusHandler::checkPedestalValueGain1
float checkPedestalValueGain1(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:82
popcon::EcalChannelStatusHandler::m_gentag
std::string m_gentag
Definition: EcalChannelStatusHandler.h:113
Exception
Definition: hltDiff.cc:246
popcon::EcalChannelStatusHandler::laserAnalysis
void laserAnalysis(std::map< EcalLogicID, MonLaserBlueDat > dataset_mon)
Definition: EcalChannelStatusHandler.cc:689
MonPedestalsDat::getPedMeanG12
float getPedMeanG12() const
Definition: MonPedestalsDat.h:27
popcon::EcalChannelStatusHandler::pedMasking
void pedMasking()
Definition: EcalChannelStatusHandler.cc:290
ParameterSetfwd.h
EcalLogicID::getID3
int getID3() const
Definition: EcalLogicID.cc:34
dumpRecoGeometry_cfg.tagInfo
tagInfo
Definition: dumpRecoGeometry_cfg.py:194
MonRunList::setMonRunTag
void setMonRunTag(const MonRunTag &tag)
Definition: MonRunList.cc:23
EEDetId::validDetId
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
Definition: EEDetId.h:248
popcon::EcalChannelStatusHandler::pedAnalysis
void pedAnalysis(std::map< EcalLogicID, MonPedestalsDat > dataset_mon, std::map< EcalLogicID, MonCrystalConsistencyDat > wrongGain_mon)
Definition: EcalChannelStatusHandler.cc:511
popcon::EcalChannelStatusHandler::pedOnlineMasking
void pedOnlineMasking()
Definition: EcalChannelStatusHandler.cc:257
cond::uint64_t
unsigned long long uint64_t
Definition: Time.h:13
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
RunTag::setRunTypeDef
void setRunTypeDef(const RunTypeDef &runTypeDef)
Definition: RunTag.cc:42
EBDetId::iphi
int iphi() const
get the crystal iphi
Definition: EBDetId.h:51
mps_fire.result
result
Definition: mps_fire.py:303
timingPdfMaker.outfile
outfile
Definition: timingPdfMaker.py:351
popcon::EcalChannelStatusHandler::m_location
std::string m_location
Definition: EcalChannelStatusHandler.h:112
MonRunTag::setMonVersionDef
void setMonVersionDef(const MonVersionDef &ver)
Definition: MonRunTag.cc:30
MonOccupancyDat
Definition: MonOccupancyDat.h:12
EBDetId::SMCRYSTALMODE
static const int SMCRYSTALMODE
Definition: EBDetId.h:159
MonPedestalsOnlineDat::getADCMeanG12
float getADCMeanG12() const
Definition: MonPedestalsOnlineDat.h:22
popcon::EcalChannelStatusHandler::checkPedestalValueGain12
float checkPedestalValueGain12(EcalPedestals::Item *item)
Definition: EcalChannelStatusHandler.cc:70
popcon::EcalChannelStatusHandler::daqOut
void daqOut(const RunIOV &myRun)
Definition: EcalChannelStatusHandler.cc:399
MonRunList::getRuns
std::vector< MonRunIOV > getRuns()
Definition: MonRunList.cc:32