CMS 3D CMS Logo

SiPixelStatusHarvester.cc
Go to the documentation of this file.
1 
2 /*
3  * See header file for a description of this class.
4  *
5  * author
6  */
7 
8 // CMSSW FW
21 
22 // Pixel geometry and cabling map
29 
30 // Condition Format
34 // CondOutput
36 
37 // Dataformat of SiPixel status in ALCAPROMPT data
39 //#include "CondCore/Utilities/bin/cmscond_export_iov.cpp"
40 //#include "CondCore/Utilities/interface/Utilities.h"
41 
42 // harvest helper class
44 // header file
46 
47 #include <iostream>
48 #include <cstring>
49 
50 using namespace edm;
51 
52 //--------------------------------------------------------------------------------------------------
54  HistogramManagerHolder(iConfig),
55  outputBase_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("outputBase")),
56  aveDigiOcc_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("aveDigiOcc")),
57  nLumi_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("resetEveryNLumi")),
58  moduleName_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("moduleName")),
59  label_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("label")){
60 
61  SiPixelStatusManager* siPixelStatusManager = new SiPixelStatusManager(iConfig, consumesCollector());
62  siPixelStatusManager_ = *siPixelStatusManager;
63  debug_ = iConfig.getUntrackedParameter<bool>("debug");
64  recordName_ = iConfig.getUntrackedParameter<std::string>("recordName", "SiPixelQualityFromDbRcd");
65 
66  sensorSize_.clear();
67  pixelO2O_.clear();
68 
70  endLumiBlock_ = 0;
71  countLumi_ = 0;
72 
73 }
74 
75 //--------------------------------------------------------------------------------------------------
77 
78 //--------------------------------------------------------------------------------------------------
80 
81 //--------------------------------------------------------------------------------------------------
83 
84 //--------------------------------------------------------------------------------------------------
85 void
87 {
88  for( auto& histoman : histo ){
89  histoman.book( iBooker, iSetup );
90  }
91 }
92 //--------------------------------------------------------------------------------------------------
94 
95 //--------------------------------------------------------------------------------------------------
97 
98  // tracker geometry and cabling map to convert offline row/column (module) to online row/column
99  edm::ESHandle<TrackerGeometry> tmpTkGeometry;
100  iSetup.get<TrackerDigiGeometryRecord>().get(tmpTkGeometry);
101  trackerGeometry_ = tmpTkGeometry.product();
102 
104  iSetup.get<SiPixelFedCablingMapRcd>().get(pixelCabling);
105  cablingMap_ = pixelCabling.product();
106 
107  for (TrackerGeometry::DetContainer::const_iterator it = trackerGeometry_->dets().begin(); it != trackerGeometry_->dets().end(); it++){
108 
109  const PixelGeomDetUnit *pgdu = dynamic_cast<const PixelGeomDetUnit*>((*it));
110  if (pgdu == nullptr) continue;
111  DetId detId = (*it)->geographicalId();
112  int detid = detId.rawId();
113 
114  const PixelTopology* topo = static_cast<const PixelTopology*>(&pgdu->specificTopology());
115  // number of row/columns for a given module
116  int rowsperroc = topo->rowsperroc();
117  int colsperroc = topo->colsperroc();
118 
119  int nROCrows = pgdu->specificTopology().nrows()/rowsperroc;
120  int nROCcolumns = pgdu->specificTopology().ncolumns()/colsperroc;
121  unsigned int nrocs = nROCrows*nROCcolumns;
122  sensorSize_[detid] = nrocs;
123 
124  std::map<int, std::pair<int,int> > rocToOfflinePixel;
125 
126  std::vector<sipixelobjects::CablingPathToDetUnit> path = (cablingMap_->det2PathMap()).find(detId.rawId())->second;
127  typedef std::vector<sipixelobjects::CablingPathToDetUnit>::const_iterator IT;
128  for(IT it = path.begin(); it != path.end(); ++it) {
129  // Pixel ROC building from path in cabling map
130  const sipixelobjects::PixelROC *roc = cablingMap_->findItem(*it);
131  int idInDetUnit = (int) roc->idInDetUnit();
132 
133  // local to global conversion
134  sipixelobjects::LocalPixel::RocRowCol local = {rowsperroc/2, colsperroc/2};
136 
137  rocToOfflinePixel[idInDetUnit] = std::pair<int,int>(global.row, global.col);
138 
139  }
140 
141  pixelO2O_[detid] = rocToOfflinePixel;
142  }
143 
144  // Permananent bad components
145  edm::ESHandle<SiPixelQuality> qualityInfo;
146  iSetup.get<SiPixelQualityFromDbRcd>().get( qualityInfo );
147  badPixelInfo_ = qualityInfo.product();
148 
149  // read in SiPixel occupancy data in ALCARECO/ALCAPROMPT
151  std::map<edm::LuminosityBlockNumber_t,std::map<int,std::vector<int>> > FEDerror25Map = siPixelStatusManager_.getFEDerror25Rocs();
152  std::map<edm::LuminosityBlockNumber_t,SiPixelDetectorStatus> siPixelStatusMap = siPixelStatusManager_.getBadComponents();
153 
154  // DB service
156 
157  if(poolDbService.isAvailable() ) {// if(poolDbService.isAvailable() )
158 
159  std::vector<int> vDetId;
160  // start producing tag for permanent component removed
161  SiPixelQuality *siPixelQualityPermBad = new SiPixelQuality();
162  const std::vector<SiPixelQuality::disabledModuleType> badComponentList = badPixelInfo_->getBadComponentList();
163  for(unsigned int i = 0; i<badComponentList.size();i++){
164 
165  siPixelQualityPermBad->addDisabledModule(badComponentList[i]);
166 
167  uint32_t detId = badComponentList[i].DetID;
168  int detid = int(detId);
169  unsigned int nroc = sensorSize_[detid];
170 
171  for(int iroc = 0; iroc<int(nroc); iroc++){
172  if(badPixelInfo_->IsRocBad(detId, short(iroc)) ){
173  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
174  int row = rocToOfflinePixel[iroc].first;
175  int column = rocToOfflinePixel[iroc].second;
176  histo[PERMANENTBADROC].fill(detId, nullptr, column, row);
177  }
178  }
179 
180  }
181  if(debug_==true){ // only produced for debugging reason
182  cond::Time_t thisIOV = (cond::Time_t) iRun.id().run();
183  poolDbService->writeOne<SiPixelQuality>(siPixelQualityPermBad, thisIOV, recordName_+"_permanentBad");
184  }
185 
186  // IOV for final payloads. FEDerror25 and pcl
187  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> finalIOV;
188  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> fedError25IOV;
189  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> pclIOV;
190 
191  //int nLumiBlock_ = countLumi_-FEDerror25Map.begin()->first+1;
192 
193  // container for SiPixelQuality for the whole run
194  std::map<int, SiPixelQuality*> siPixelQualityStuckTBM_Tag;
195 
196  // stuckTBM tag from FED error 25 with permanent component removed
197  for(SiPixelStatusManager::FEDerror25Map_iterator it=FEDerror25Map.begin(); it!=FEDerror25Map.end();it++){
198 
199  cond::Time_t thisIOV = 1;
200  edm::LuminosityBlockID lu(iRun.id().run(),it->first);
201  thisIOV = (cond::Time_t)(lu.value());
202 
203  int interval = 0;
204  // interval is the number of lumi sections in the IOV
206  if(nextIt!=FEDerror25Map.end()) interval = int(nextIt->first - it->first);
207  else interval = int(endLumiBlock_ - it->first + 1);
208 
209  SiPixelQuality *siPixelQuality_stuckTBM = new SiPixelQuality();
210  SiPixelQuality *siPixelQuality_FEDerror25 = new SiPixelQuality();
211 
212  std::map<int, std::vector<int> > tmpFEDerror25 = it->second;
213  for(std::map<int, std::vector<int> >::iterator ilist = tmpFEDerror25.begin(); ilist!=tmpFEDerror25.end();ilist++){
214 
215  int detid = ilist->first;
216  uint32_t detId = uint32_t(detid);
217 
218  SiPixelQuality::disabledModuleType BadModule_stuckTBM, BadModule_FEDerror25;
219 
220  BadModule_stuckTBM.DetID = uint32_t(detid); BadModule_FEDerror25.DetID = uint32_t(detid);
221  BadModule_stuckTBM.errorType = 3; BadModule_FEDerror25.errorType = 3;
222 
223  BadModule_stuckTBM.BadRocs = 0; BadModule_FEDerror25.BadRocs = 0;
224  std::vector<uint32_t> BadRocList_stuckTBM, BadRocList_FEDerror25;
225  std::vector<int> list = ilist->second;
226 
227  for(unsigned int i=0; i<list.size();i++){
228 
229  int iroc = list[i];
230  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
231  int row = rocToOfflinePixel[iroc].first;
232  int column = rocToOfflinePixel[iroc].second;
233 
234  BadRocList_FEDerror25.push_back(uint32_t(iroc));
235  for (int iLumi = 0; iLumi<interval;iLumi++){
236  histo[FEDERRORROC].fill(detId, nullptr, column, row);// 1.0/nLumiBlock_);
237  }
238 
239  // only include rocs that are not permanent known bad
240  if(!badPixelInfo_->IsRocBad(detId, short(iroc))){ // stuckTBM = FEDerror25 - permanent bad
241  BadRocList_stuckTBM.push_back(uint32_t(iroc));
242  for (int iLumi = 0; iLumi<interval;iLumi++){
243  histo[STUCKTBMROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
244  }
245  }
246 
247  }
248 
249  // change module error type if all ROCs are bad
250  if(BadRocList_stuckTBM.size()==sensorSize_[detid])
251  BadModule_stuckTBM.errorType = 0;
252 
253  short badrocs_stuckTBM = 0;
254  for(std::vector<uint32_t>::iterator iter = BadRocList_stuckTBM.begin(); iter != BadRocList_stuckTBM.end(); ++iter){
255  badrocs_stuckTBM += 1 << *iter; // 1 << *iter = 2^{*iter} using bitwise shift
256  }
257  // fill the badmodule only if there is(are) bad ROC(s) in it
258  if(badrocs_stuckTBM!=0){
259  BadModule_stuckTBM.BadRocs = badrocs_stuckTBM;
260  siPixelQuality_stuckTBM->addDisabledModule(BadModule_stuckTBM);
261  }
262 
263  // change module error type if all ROCs are bad
264  if(BadRocList_FEDerror25.size()==sensorSize_[detid])
265  BadModule_FEDerror25.errorType = 0;
266 
267  short badrocs_FEDerror25 = 0;
268  for(std::vector<uint32_t>::iterator iter = BadRocList_FEDerror25.begin(); iter != BadRocList_FEDerror25.end(); ++iter){
269  badrocs_FEDerror25 += 1 << *iter; // 1 << *iter = 2^{*iter} using bitwise shift
270  }
271  // fill the badmodule only if there is(are) bad ROC(s) in it
272  if(badrocs_FEDerror25!=0){
273  BadModule_FEDerror25.BadRocs = badrocs_FEDerror25;
274  siPixelQuality_FEDerror25->addDisabledModule(BadModule_FEDerror25);
275  }
276 
277  } // loop over modules
278 
279  siPixelQualityStuckTBM_Tag[it->first] = siPixelQuality_stuckTBM;
280 
281  finalIOV[it->first] = it->first;
282  fedError25IOV[it->first] = it->first;
283 
284  if(debug_==true) // only produced for debugging reason
285  poolDbService->writeOne<SiPixelQuality>(siPixelQuality_FEDerror25, thisIOV, recordName_+"_FEDerror25");
286 
287  delete siPixelQuality_FEDerror25;
288 
289  }
290 
291  // IOV for PCL output tags that "combines" permanent bad/stuckTBM/other
292  for(SiPixelStatusManager::siPixelStatusMap_iterator it=siPixelStatusMap.begin(); it!=siPixelStatusMap.end();it++){
293  finalIOV[it->first] = it->first;
294  pclIOV[it->first] = it->first;
295  }
296 
297  // loop over final IOV
298  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator itIOV;
299 
300  // container for SiPixelQuality for the whole run
301  std::map<int, SiPixelQuality*> siPixelQualityPCL_Tag;
302  std::map<int, SiPixelQuality*> siPixelQualityPrompt_Tag;
303  std::map<int, SiPixelQuality*> siPixelQualityOther_Tag;
304 
305  for(itIOV=finalIOV.begin();itIOV!=finalIOV.end();itIOV++){
306 
307  int interval = 0;
308  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator nextItIOV = std::next(itIOV);
309  if(nextItIOV!=finalIOV.end()) interval = int(nextItIOV->first - itIOV->first);
310  else interval = int(endLumiBlock_ - itIOV->first + 1);
311 
312  edm::LuminosityBlockNumber_t lumiFEDerror25 = SiPixelStatusHarvester::stepIOV(itIOV->first,fedError25IOV);
313  edm::LuminosityBlockNumber_t lumiPCL = SiPixelStatusHarvester::stepIOV(itIOV->first,pclIOV);
314 
315  // get badROC list due to FEDerror25 = stuckTBM + permanent bad components
316  std::map<int, std::vector<int> > tmpFEDerror25 = FEDerror25Map[lumiFEDerror25];
317  // get SiPixelDetectorStatus
318  SiPixelDetectorStatus tmpSiPixelStatus = siPixelStatusMap[lumiPCL];
319  double DetAverage = tmpSiPixelStatus.perRocDigiOcc();
320 
321  // For the IOV of which the statistics is too low, for e.g., a cosmic run
322  // When using dynamicLumibased harvester or runbased harvester
323  // this only happens when the full run is lack of statistics
324  if(DetAverage<aveDigiOcc_) {
325 
326  edm::LogInfo("SiPixelStatusHarvester")
327  << "Tag requested for prompt in low statistics IOV in the "<<outputBase_<<" harvester"<< std::endl;
328  siPixelQualityPCL_Tag[itIOV->first] = siPixelQualityPermBad;
329  siPixelQualityPrompt_Tag[itIOV->first] = siPixelQualityPermBad;
330 
331  // loop over modules to fill the PROMPT DQM plots with permanent bad components
332  std::map<int, SiPixelModuleStatus> detectorStatus = tmpSiPixelStatus.getDetectorStatus();
333  std::map<int, SiPixelModuleStatus>::iterator itModEnd = detectorStatus.end();
334  for (std::map<int, SiPixelModuleStatus>::iterator itMod = detectorStatus.begin(); itMod != itModEnd; ++itMod) {
335 
336  int detid = itMod->first;
337  uint32_t detId = uint32_t(detid);
338  SiPixelModuleStatus modStatus = itMod->second;
339 
340  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
341 
342  if(badPixelInfo_->IsRocBad(detId, short(iroc))){
343  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
344  int row = rocToOfflinePixel[iroc].first;
345  int column = rocToOfflinePixel[iroc].second; for (int iLumi = 0; iLumi<interval;iLumi++){
346  histo[PROMPTBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
347  }
348 
349  } // if permanent BAD
350 
351  } // loop over ROCs
352 
353  } // loop over modules
354 
355  // add empty bad components to "other" tag
356  edm::LogInfo("SiPixelStatusHarvester")
357  << "Tag requested for other in low statistics IOV in the "<<outputBase_<<" harvester"<< std::endl;
358  siPixelQualityOther_Tag[itIOV->first] = new SiPixelQuality();
359 
360  continue;
361 
362  }
363 
365 
366  // create the DB object
367  // payload including all : PCL = permanent bad (low DIGI ROC) + other + stuckTBM
368  SiPixelQuality *siPixelQualityPCL = new SiPixelQuality();
369  SiPixelQuality *siPixelQualityOther = new SiPixelQuality();
370  // Prompt = permanent bad(low DIGI + low eff/damaged ROCs + other)
371  SiPixelQuality *siPixelQualityPrompt = new SiPixelQuality();
372 
373  // loop over modules
374  std::map<int, SiPixelModuleStatus> detectorStatus = tmpSiPixelStatus.getDetectorStatus();
375  std::map<int, SiPixelModuleStatus>::iterator itModEnd = detectorStatus.end();
376  for (std::map<int, SiPixelModuleStatus>::iterator itMod = detectorStatus.begin(); itMod != itModEnd; ++itMod) {
377 
378  // create the bad module list for PCL and other
379  SiPixelQuality::disabledModuleType BadModulePCL, BadModuleOther;
380 
381  int detid = itMod->first;
382  uint32_t detId = uint32_t(detid);
383 
384  BadModulePCL.DetID = uint32_t(detid); BadModuleOther.DetID = uint32_t(detid);
385  BadModulePCL.errorType = 3; BadModuleOther.errorType = 3;
386  BadModulePCL.BadRocs = 0; BadModuleOther.BadRocs = 0;
387 
388  std::vector<uint32_t> BadRocListPCL, BadRocListOther;
389 
390  // module status and FEDerror25 status for module with DetId detId
391  SiPixelModuleStatus modStatus = itMod->second;
392  std::vector<int> listFEDerror25 = tmpFEDerror25[detid];
393 
394  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
395 
396  unsigned int rocOccupancy = modStatus.digiOccROC(iroc);
397 
398  // Bad ROC are from low DIGI Occ ROCs
399  if(rocOccupancy<1.e-4*DetAverage){ // if BAD
400 
401  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
402  int row = rocToOfflinePixel[iroc].first;
403  int column = rocToOfflinePixel[iroc].second;
404 
405  //PCL bad roc list
406  BadRocListPCL.push_back(uint32_t(iroc));
407  for (int iLumi = 0; iLumi<interval;iLumi++){
408  histo[BADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
409  }
410 
411  //FEDerror25 list
412  std::vector<int>::iterator it = std::find(listFEDerror25.begin(), listFEDerror25.end(),iroc);
413 
414  // other source of bad components = PCL bad - FEDerror25 - permanent bad
415  if(it==listFEDerror25.end() && !(badPixelInfo_->IsRocBad(detId, short(iroc)))){
416  // if neither permanent nor FEDerror25
417  BadRocListOther.push_back(uint32_t(iroc));
418  for (int iLumi = 0; iLumi<interval;iLumi++){
419  histo[OTHERBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
420  }
421  }
422 
423  }// if BAD
424 
425  } // loop over ROCs
426 
427  // errorType 0 means the full module is bad
428  if(BadRocListPCL.size()==sensorSize_[detid]) BadModulePCL.errorType = 0;
429  if(BadRocListOther.size()==sensorSize_[detid]) BadModuleOther.errorType = 0;
430 
431  // PCL
432  short badrocsPCL = 0;
433  for(std::vector<uint32_t>::iterator iterPCL = BadRocListPCL.begin(); iterPCL != BadRocListPCL.end(); ++iterPCL){
434  badrocsPCL += 1 << *iterPCL; // 1 << *iter = 2^{*iter} using bitwise shift
435  }
436  if(badrocsPCL!=0){
437  BadModulePCL.BadRocs = badrocsPCL;
438  siPixelQualityPCL->addDisabledModule(BadModulePCL);
439  }
440 
441  // Other
442  short badrocsOther = 0;
443  for(std::vector<uint32_t>::iterator iterOther = BadRocListOther.begin(); iterOther != BadRocListOther.end(); ++iterOther){
444  badrocsOther += 1 << *iterOther; // 1 << *iter = 2^{*iter} using bitwise shift
445  }
446  if(badrocsOther!=0){
447  BadModuleOther.BadRocs = badrocsOther;
448  siPixelQualityOther->addDisabledModule(BadModuleOther);
449  }
450 
451  // start constructing bad components for prompt = "other" + permanent
452  SiPixelQuality::disabledModuleType BadModulePrompt;
453  BadModulePrompt.DetID = uint32_t(detid);
454  BadModulePrompt.errorType = 3;
455  BadModulePrompt.BadRocs = 0;
456 
457  std::vector<uint32_t> BadRocListPrompt;
458  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
459  // if in permannet bad tag or is in other tag
460  if(badPixelInfo_->IsRocBad(detId, short(iroc))|| ((badrocsOther >> short(iroc))&0x1)){
461  BadRocListPrompt.push_back(uint32_t(iroc));
462 
463  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
464  int row = rocToOfflinePixel[iroc].first;
465  int column = rocToOfflinePixel[iroc].second;
466  for (int iLumi = 0; iLumi<interval;iLumi++){
467  histo[PROMPTBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
468  }
469  } // if bad
470  } // loop over all ROCs
471 
472  // errorType 0 means the full module is bad
473  if(BadRocListPrompt.size()==sensorSize_[detid]) BadModulePrompt.errorType = 0;
474 
475  short badrocsPrompt = 0;
476  for(std::vector<uint32_t>::iterator iterPrompt = BadRocListPrompt.begin(); iterPrompt != BadRocListPrompt.end(); ++iterPrompt){
477  badrocsPrompt += 1 << *iterPrompt; // 1 << *iter = 2^{*iter} using bitwise shift
478  }
479  if(badrocsPrompt!=0){
480  BadModulePrompt.BadRocs = badrocsPrompt;
481  siPixelQualityPrompt->addDisabledModule(BadModulePrompt);
482  }
483 
484  } // end module loop
485 
486  // PCL
487  siPixelQualityPCL_Tag[itIOV->first] = siPixelQualityPCL;
488  // Prompt
489  siPixelQualityPrompt_Tag[itIOV->first] = siPixelQualityPrompt;
490  // Other
491  siPixelQualityOther_Tag[itIOV->first] = siPixelQualityOther;
492 
493  }// loop over IOV
494 
495  // Now construct the tags made of payloads
496  // and only append newIOV if this payload differs wrt last
497 
498  //PCL
499  if(debug_==true)// only produced for debugging reason
500  SiPixelStatusHarvester::constructTag(siPixelQualityPCL_Tag, poolDbService, "PCL", iRun);
501  // other
502  SiPixelStatusHarvester::constructTag(siPixelQualityOther_Tag, poolDbService, "other", iRun);
503  // prompt
504  SiPixelStatusHarvester::constructTag(siPixelQualityPrompt_Tag, poolDbService, "prompt", iRun);
505  // stuckTBM
506  SiPixelStatusHarvester::constructTag(siPixelQualityStuckTBM_Tag, poolDbService, "stuckTBM", iRun);
507 
508  // Add a dummy IOV starting from last lumisection+1 to close the tag for the run
509  if(outputBase_ == "nLumibased" || outputBase_ == "dynamicLumibased"){
510 
512  cond::Time_t thisIOV = (cond::Time_t)(lu.value());
513  poolDbService->writeOne<SiPixelQuality>(siPixelQualityPermBad, thisIOV, recordName_+"_prompt");
514 
515  // add empty bad components to "other" tag
516  SiPixelQuality* siPixelQualityDummy = new SiPixelQuality();
517  poolDbService->writeOne<SiPixelQuality>(siPixelQualityDummy, thisIOV, recordName_+"_other");
518  delete siPixelQualityDummy;
519  }
520 
521  delete siPixelQualityPermBad;
522 
523  } // end of if(poolDbService.isAvailable() )
524 
525 }
526 
527 //--------------------------------------------------------------------------------------------------
529  countLumi_++;
530 }
531 
532 
533 //--------------------------------------------------------------------------------------------------
535 
537  // update endLumiBlock_ by current lumi block
538  if(endLumiBlock_<iLumi.luminosityBlock())
539  endLumiBlock_ = iLumi.luminosityBlock();
540 
541 }
542 
543 // step function for IOV
544 edm::LuminosityBlockNumber_t SiPixelStatusHarvester::stepIOV(edm::LuminosityBlockNumber_t pin, std::map<edm::LuminosityBlockNumber_t,edm::LuminosityBlockNumber_t> IOV){
545 
546  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator itIOV;
547  for(itIOV=IOV.begin();itIOV!=IOV.end();itIOV++){
548  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator nextItIOV;
549  nextItIOV = itIOV; nextItIOV++;
550 
551  if(nextItIOV!=IOV.end()){
552  if(pin>=itIOV->first && pin<nextItIOV->first){
553  return itIOV->first;
554  }
555  }
556  else{
557  if(pin>=itIOV->first){
558  return itIOV->first;
559  }
560  }
561 
562  }
563 
564  // return the firstIOV in case all above fail
565  return (IOV.begin())->first;
566 
567 }
568 
570 
571  std::vector<SiPixelQuality::disabledModuleType> badRocListA;
572  std::vector<SiPixelQuality::disabledModuleType> badRocListB;
573 
574  for(unsigned int ia = 0; ia < (a->getBadComponentList()).size();ia++){
575  badRocListA.push_back((a->getBadComponentList())[ia]);
576  }
577  for(unsigned int ib = 0; ib < (b->getBadComponentList()).size();ib++){
578  badRocListB.push_back((b->getBadComponentList())[ib]);
579  }
580 
581  if(badRocListA.size()!=badRocListB.size()) return false;
582 
583  // ordering ROCs by DetId
584  std::sort(badRocListA.begin(),badRocListA.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
585  std::sort(badRocListB.begin(),badRocListB.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
586 
587  for(unsigned int i = 0; i<badRocListA.size();i++){
588 
589  uint32_t detIdA = badRocListA[i].DetID;
590  uint32_t detIdB = badRocListB[i].DetID;
591  if(detIdA!=detIdB) return false;
592  else{
593  unsigned short BadRocsA = badRocListA[i].BadRocs;
594  unsigned short BadRocsB = badRocListB[i].BadRocs;
595  if(BadRocsA!=BadRocsB) return false;
596  }
597 
598  }
599 
600  //if the module list is the same, and for each module, roc list is the same
601  //the two SiPixelQualitys are equal
602  return true;
603 
604 
605 }
606 
607 void SiPixelStatusHarvester::constructTag(std::map<int,SiPixelQuality*>siPixelQualityTag, edm::Service<cond::service::PoolDBOutputService>& poolDbService, std::string tagName,edm::Run& iRun){
608 
609  for (std::map<int, SiPixelQuality*>::iterator qIt = siPixelQualityTag.begin(); qIt != siPixelQualityTag.end(); ++qIt) {
610 
611  edm::LuminosityBlockID lu(iRun.id().run(),qIt->first);
612  cond::Time_t thisIOV = (cond::Time_t)(lu.value());
613 
614  SiPixelQuality* thisPayload = qIt->second;
615  if(qIt==siPixelQualityTag.begin())
616  poolDbService->writeOne<SiPixelQuality>(thisPayload, thisIOV, recordName_+"_"+tagName);
617  else{
618  SiPixelQuality* prevPayload = (std::prev(qIt))->second;
619  if(!SiPixelStatusHarvester::equal(thisPayload,prevPayload)) // only append newIOV if this payload differs wrt last
620  poolDbService->writeOne<SiPixelQuality>(thisPayload, thisIOV, recordName_+"_"+tagName);
621  }
622  }
623 
624 }
625 
void endLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
size
Write out results.
void addDisabledModule(disabledModuleType module)
T getUntrackedParameter(std::string const &, T const &) const
virtual int nrows() const =0
virtual int rowsperroc() const =0
RunID const & id() const
Definition: RunBase.h:39
bool equal(SiPixelQuality *a, SiPixelQuality *b)
std::map< int, unsigned int > sensorSize_
void constructTag(std::map< int, SiPixelQuality * >siPixelQualityTag, edm::Service< cond::service::PoolDBOutputService > &poolDbService, std::string tagName, edm::Run &iRun)
RunNumber_t run() const
Definition: RunID.h:39
const std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > > & getFEDerror25Rocs()
edm::LuminosityBlockNumber_t endLumiBlock_
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
virtual std::map< uint32_t, std::vector< sipixelobjects::CablingPathToDetUnit > > det2PathMap() const =0
bool IsRocBad(const uint32_t &detid, const short &rocNb) const
edm::LuminosityBlockNumber_t stepIOV(edm::LuminosityBlockNumber_t pin, std::map< edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t > IOV)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:20
unsigned int LuminosityBlockNumber_t
SiPixelStatusManager siPixelStatusManager_
identify pixel inside single ROC
Definition: LocalPixel.h:7
void bookHistograms(DQMStore::IBooker &iBooker, edm::Run const &, edm::EventSetup const &iSetup) final
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
LuminosityBlockNumber_t luminosityBlock() const
U second(std::pair< T, U > const &p)
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
int iEvent
Definition: GenABIO.cc:224
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
unsigned long long Time_t
Definition: Time.h:16
virtual int colsperroc() const =0
const SiPixelQuality * badPixelInfo_
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:40
bool isAvailable() const
Definition: Service.h:40
void writeOne(T *payload, Time_t time, const std::string &recordName, bool withlogging=false)
const std::vector< disabledModuleType > getBadComponentList() const
const SiPixelFedCabling * cablingMap_
std::vector< LinkConnSpec >::const_iterator IT
const TrackerGeometry * trackerGeometry_
void endRunProduce(edm::Run &, const edm::EventSetup &) final
std::map< int, SiPixelModuleStatus > getDetectorStatus()
std::map< edm::LuminosityBlockNumber_t, std::map< int, std::vector< int > > >::iterator FEDerror25Map_iterator
Definition: DetId.h:18
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
SiPixelStatusHarvester(const edm::ParameterSet &)
virtual const PixelTopology & specificTopology() const
Returns a reference to the pixel proxy topology.
double b
Definition: hdecay.h:120
row and collumn in ROC representation
Definition: LocalPixel.h:15
std::map< int, std::map< int, std::pair< int, int > > > pixelO2O_
std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus >::iterator siPixelStatusMap_iterator
void beginLuminosityBlock(const edm::LuminosityBlock &, const edm::EventSetup &) final
std::vector< HistogramManager > histo
HLT enums.
virtual int ncolumns() const =0
double a
Definition: hdecay.h:121
T get() const
Definition: EventSetup.h:71
unsigned int digiOccROC(int iroc)
return ROC status (= hits on ROC iroc)
void readLumi(const edm::LuminosityBlock &)
const std::map< edm::LuminosityBlockNumber_t, SiPixelDetectorStatus > & getBadComponents()
T const * product() const
Definition: ESHandle.h:86
void analyze(const edm::Event &iEvent, const edm::EventSetup &iSetup) final
Definition: Run.h:45
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
ib
Definition: cuy.py:662
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.h:59