test
CMS 3D CMS Logo

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