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 // Pixel geometry and cabling map
28 // Condition Format
32 // LHCinfo
33 //#include "CondFormats/RunInfo/interface/LHCInfo.h"
34 //#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"
35 
36 // CondOutput
38 // Dataformat of SiPixel status in ALCAPROMPT data
40 //#include "CondCore/Utilities/bin/cmscond_export_iov.cpp"
41 //#include "CondCore/Utilities/interface/Utilities.h"
42 // harvest helper class
44 // header file
46 
47 // output format
48 #include "TH1.h"
49 #include "TTree.h"
50 #include "TString.h"
51 
52 #include <iostream>
53 #include <cstring>
54 
55 using namespace edm;
56 //class MonitorElement;
57 
58 //--------------------------------------------------------------------------------------------------
60  HistogramManagerHolder(iConfig),
61  thresholdL1_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdL1")),
62  thresholdL2_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdL2")),
63  thresholdL3_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdL3")),
64  thresholdL4_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdL4")),
65  thresholdRNG1_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdRNG1")),
66  thresholdRNG2_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<double>("thresholdRNG2")),
67  outputBase_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("outputBase")),
68  aveDigiOcc_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("aveDigiOcc")),
69  nLumi_(iConfig.getParameter<edm::ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<int>("resetEveryNLumi")),
70  moduleName_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("moduleName")),
71  label_(iConfig.getParameter<ParameterSet>("SiPixelStatusManagerParameters").getUntrackedParameter<std::string>("label")){
72 
73  SiPixelStatusManager* siPixelStatusManager = new SiPixelStatusManager(iConfig, consumesCollector());
74  siPixelStatusManager_ = *siPixelStatusManager;
75  debug_ = iConfig.getUntrackedParameter<bool>("debug");
76  recordName_ = iConfig.getUntrackedParameter<std::string>("recordName", "SiPixelQualityFromDbRcd");
77 
78  sensorSize_.clear();
79  pixelO2O_.clear();
80 
82  endLumiBlock_ = 0;
83  countLumi_ = 0;
84 
85 }
86 
87 //--------------------------------------------------------------------------------------------------
89 
90 //--------------------------------------------------------------------------------------------------
92 }
93 
94 //--------------------------------------------------------------------------------------------------
96 }
97 
98 //--------------------------------------------------------------------------------------------------
100 
101  for( auto& histoman : histo ){
102  histoman.book( iBooker, iSetup );
103  }
104 
105 }
106 
107 //--------------------------------------------------------------------------------------------------
109 
110 //--------------------------------------------------------------------------------------------------
112 
113  // tracker geometry and cabling map to convert offline row/column (module) to online row/column
114  edm::ESHandle<TrackerGeometry> tmpTkGeometry;
115  iSetup.get<TrackerDigiGeometryRecord>().get(tmpTkGeometry);
116  trackerGeometry_ = tmpTkGeometry.product();
117 
119  iSetup.get<SiPixelFedCablingMapRcd>().get(pixelCabling);
120  cablingMap_ = pixelCabling.product();
121 
122  // Pixel Phase-1 helper class
123  coord_.init(iSetup);
124 
125  for (TrackerGeometry::DetContainer::const_iterator it = trackerGeometry_->dets().begin(); it != trackerGeometry_->dets().end(); it++){
126 
127  const PixelGeomDetUnit *pgdu = dynamic_cast<const PixelGeomDetUnit*>((*it));
128  if (pgdu == nullptr) continue;
129  DetId detId = (*it)->geographicalId();
130  int detid = detId.rawId();
131 
132  const PixelTopology* topo = static_cast<const PixelTopology*>(&pgdu->specificTopology());
133  // number of row/columns for a given module
134  int rowsperroc = topo->rowsperroc();
135  int colsperroc = topo->colsperroc();
136 
137  int nROCrows = pgdu->specificTopology().nrows()/rowsperroc;
138  int nROCcolumns = pgdu->specificTopology().ncolumns()/colsperroc;
139  unsigned int nrocs = nROCrows*nROCcolumns;
140  sensorSize_[detid] = nrocs;
141 
142  std::map<int, std::pair<int,int> > rocToOfflinePixel;
143 
144  std::vector<sipixelobjects::CablingPathToDetUnit> path = (cablingMap_->det2PathMap()).find(detId.rawId())->second;
145  typedef std::vector<sipixelobjects::CablingPathToDetUnit>::const_iterator IT;
146  for(IT it = path.begin(); it != path.end(); ++it) {
147  // Pixel ROC building from path in cabling map
148  const sipixelobjects::PixelROC *roc = cablingMap_->findItem(*it);
149  int idInDetUnit = (int) roc->idInDetUnit();
150 
151  // local to global conversion
152  sipixelobjects::LocalPixel::RocRowCol local = {rowsperroc/2, colsperroc/2};
154 
155  rocToOfflinePixel[idInDetUnit] = std::pair<int,int>(global.row, global.col);
156 
157  }
158 
159  pixelO2O_[detid] = rocToOfflinePixel;
160  }
161 
162  // Permananent bad components
163  edm::ESHandle<SiPixelQuality> qualityInfo;
164  iSetup.get<SiPixelQualityFromDbRcd>().get( qualityInfo );
165  badPixelInfo_ = qualityInfo.product();
166 
167  // read in SiPixel occupancy data in ALCARECO/ALCAPROMPT
169  std::map<edm::LuminosityBlockNumber_t,std::map<int,std::vector<int>> > FEDerror25Map = siPixelStatusManager_.getFEDerror25Rocs();
170  std::map<edm::LuminosityBlockNumber_t,SiPixelDetectorStatus> siPixelStatusMap = siPixelStatusManager_.getBadComponents();
171 
172  // DB service
174 
175  if(poolDbService.isAvailable() ) {// if(poolDbService.isAvailable() )
176 
177  // start producing tag for permanent component removed
178  SiPixelQuality *siPixelQualityPermBad = new SiPixelQuality();
179  const std::vector<SiPixelQuality::disabledModuleType> badComponentList = badPixelInfo_->getBadComponentList();
180  for(unsigned int i = 0; i<badComponentList.size();i++){
181 
182  siPixelQualityPermBad->addDisabledModule(badComponentList[i]);
183 
184  uint32_t detId = badComponentList[i].DetID;
185  int detid = int(detId);
186  unsigned int nroc = sensorSize_[detid];
187 
188  for(int iroc = 0; iroc<int(nroc); iroc++){
189  if(badPixelInfo_->IsRocBad(detId, short(iroc)) ){
190  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
191  int row = rocToOfflinePixel[iroc].first;
192  int column = rocToOfflinePixel[iroc].second;
193  histo[PERMANENTBADROC].fill(detId, nullptr, column, row);
194  }
195  }
196 
197  }
198  if(debug_==true){ // only produced for debugging reason
199  cond::Time_t thisIOV = (cond::Time_t) iRun.id().run();
200  poolDbService->writeOne<SiPixelQuality>(siPixelQualityPermBad, thisIOV, recordName_+"_permanentBad");
201  }
202 
203  // IOV for final payloads. FEDerror25 and pcl
204  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> finalIOV;
205  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> fedError25IOV;
206  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t> pclIOV;
207 
208  // container for SiPixelQuality for the whole run
209  std::map<int, SiPixelQuality*> siPixelQualityStuckTBM_Tag;
210 
211  // stuckTBM tag from FED error 25 with permanent component removed
212  for(SiPixelStatusManager::FEDerror25Map_iterator it=FEDerror25Map.begin(); it!=FEDerror25Map.end();it++){
213 
214  cond::Time_t thisIOV = 1;
215  edm::LuminosityBlockID lu(iRun.id().run(),it->first);
216  thisIOV = (cond::Time_t)(lu.value());
217 
218  int interval = 0;
219  // interval is the number of lumi sections in the IOV
221  if(nextIt!=FEDerror25Map.end()) interval = int(nextIt->first - it->first);
222  else interval = int(endLumiBlock_ - it->first + 1); // +1 because need to include the last lumi section
223 
224  SiPixelQuality *siPixelQuality_stuckTBM = new SiPixelQuality();
225  SiPixelQuality *siPixelQuality_FEDerror25 = new SiPixelQuality();
226 
227  std::map<int, std::vector<int> > tmpFEDerror25 = it->second;
228  for(std::map<int, std::vector<int> >::iterator ilist = tmpFEDerror25.begin(); ilist!=tmpFEDerror25.end();ilist++){
229 
230  int detid = ilist->first;
231  uint32_t detId = uint32_t(detid);
232 
233  SiPixelQuality::disabledModuleType BadModule_stuckTBM, BadModule_FEDerror25;
234 
235  BadModule_stuckTBM.DetID = uint32_t(detid); BadModule_FEDerror25.DetID = uint32_t(detid);
236  BadModule_stuckTBM.errorType = 3; BadModule_FEDerror25.errorType = 3;
237 
238  BadModule_stuckTBM.BadRocs = 0; BadModule_FEDerror25.BadRocs = 0;
239  std::vector<uint32_t> BadRocList_stuckTBM, BadRocList_FEDerror25;
240  std::vector<int> list = ilist->second;
241 
242  for(unsigned int i=0; i<list.size();i++){
243 
244  int iroc = list[i];
245  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
246  int row = rocToOfflinePixel[iroc].first;
247  int column = rocToOfflinePixel[iroc].second;
248 
249  BadRocList_FEDerror25.push_back(uint32_t(iroc));
250  for (int iLumi = 0; iLumi<interval;iLumi++){
251  histo[FEDERRORROC].fill(detId, nullptr, column, row);// 1.0/nLumiBlock_);
252  }
253 
254  // only include rocs that are not permanent known bad
255  if(!badPixelInfo_->IsRocBad(detId, short(iroc))){ // stuckTBM = FEDerror25 - permanent bad
256  BadRocList_stuckTBM.push_back(uint32_t(iroc));
257  for (int iLumi = 0; iLumi<interval;iLumi++){
258  histo[STUCKTBMROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
259  }
260  }
261 
262  }
263 
264  // change module error type if all ROCs are bad
265  if(BadRocList_stuckTBM.size()==sensorSize_[detid])
266  BadModule_stuckTBM.errorType = 0;
267 
268  short badrocs_stuckTBM = 0;
269  for(std::vector<uint32_t>::iterator iter = BadRocList_stuckTBM.begin(); iter != BadRocList_stuckTBM.end(); ++iter){
270  badrocs_stuckTBM += 1 << *iter; // 1 << *iter = 2^{*iter} using bitwise shift
271  }
272  // fill the badmodule only if there is(are) bad ROC(s) in it
273  if(badrocs_stuckTBM!=0){
274  BadModule_stuckTBM.BadRocs = badrocs_stuckTBM;
275  siPixelQuality_stuckTBM->addDisabledModule(BadModule_stuckTBM);
276  }
277 
278  // change module error type if all ROCs are bad
279  if(BadRocList_FEDerror25.size()==sensorSize_[detid])
280  BadModule_FEDerror25.errorType = 0;
281 
282  short badrocs_FEDerror25 = 0;
283  for(std::vector<uint32_t>::iterator iter = BadRocList_FEDerror25.begin(); iter != BadRocList_FEDerror25.end(); ++iter){
284  badrocs_FEDerror25 += 1 << *iter; // 1 << *iter = 2^{*iter} using bitwise shift
285  }
286  // fill the badmodule only if there is(are) bad ROC(s) in it
287  if(badrocs_FEDerror25!=0){
288  BadModule_FEDerror25.BadRocs = badrocs_FEDerror25;
289  siPixelQuality_FEDerror25->addDisabledModule(BadModule_FEDerror25);
290  }
291 
292  } // loop over modules
293 
294  siPixelQualityStuckTBM_Tag[it->first] = siPixelQuality_stuckTBM;
295 
296  finalIOV[it->first] = it->first;
297  fedError25IOV[it->first] = it->first;
298 
299  if(debug_==true) // only produced for debugging reason
300  poolDbService->writeOne<SiPixelQuality>(siPixelQuality_FEDerror25, thisIOV, recordName_+"_FEDerror25");
301 
302  delete siPixelQuality_FEDerror25;
303 
304  }
305 
306  // IOV for PCL output tags that "combines" permanent bad/stuckTBM/other
307  for(SiPixelStatusManager::siPixelStatusMap_iterator it=siPixelStatusMap.begin(); it!=siPixelStatusMap.end();it++){
308  finalIOV[it->first] = it->first;
309  pclIOV[it->first] = it->first;
310  }
311 
312  // loop over final IOV
313  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator itIOV;
314 
315  // container for SiPixelQuality for the whole run
316  std::map<int, SiPixelQuality*> siPixelQualityPCL_Tag;
317  std::map<int, SiPixelQuality*> siPixelQualityPrompt_Tag;
318  std::map<int, SiPixelQuality*> siPixelQualityOther_Tag;
319 
320  for(itIOV=finalIOV.begin();itIOV!=finalIOV.end();itIOV++){
321 
322  int interval = 0;
323  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator nextItIOV = std::next(itIOV);
324  if(nextItIOV!=finalIOV.end()) interval = int(nextItIOV->first - itIOV->first);
325  else interval = int(endLumiBlock_ - itIOV->first + 1);
326 
327  edm::LuminosityBlockNumber_t lumiFEDerror25 = SiPixelStatusHarvester::stepIOV(itIOV->first,fedError25IOV);
328  edm::LuminosityBlockNumber_t lumiPCL = SiPixelStatusHarvester::stepIOV(itIOV->first,pclIOV);
329 
330  // get badROC list due to FEDerror25 = stuckTBM + permanent bad components
331  std::map<int, std::vector<int> > tmpFEDerror25 = FEDerror25Map[lumiFEDerror25];
332  // get SiPixelDetectorStatus
333  SiPixelDetectorStatus tmpSiPixelStatus = siPixelStatusMap[lumiPCL];
334  double DetAverage = tmpSiPixelStatus.perRocDigiOcc();
335 
336  // For the IOV of which the statistics is too low, for e.g., a cosmic run
337  // When using dynamicLumibased harvester or runbased harvester
338  // this only happens when the full run is lack of statistics
339  if(DetAverage<aveDigiOcc_) {
340 
341  edm::LogInfo("SiPixelStatusHarvester")
342  << "Tag requested for prompt in low statistics IOV in the "<<outputBase_<<" harvester"<< std::endl;
343  siPixelQualityPCL_Tag[itIOV->first] = siPixelQualityPermBad;
344  siPixelQualityPrompt_Tag[itIOV->first] = siPixelQualityPermBad;
345 
346  // loop over modules to fill the PROMPT DQM plots with permanent bad components
347  std::map<int, SiPixelModuleStatus> detectorStatus = tmpSiPixelStatus.getDetectorStatus();
348  std::map<int, SiPixelModuleStatus>::iterator itModEnd = detectorStatus.end();
349  for (std::map<int, SiPixelModuleStatus>::iterator itMod = detectorStatus.begin(); itMod != itModEnd; ++itMod) {
350 
351  int detid = itMod->first;
352  uint32_t detId = uint32_t(detid);
353  SiPixelModuleStatus modStatus = itMod->second;
354 
355  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
356 
357  if(badPixelInfo_->IsRocBad(detId, short(iroc))){
358  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
359  int row = rocToOfflinePixel[iroc].first;
360  int column = rocToOfflinePixel[iroc].second;
361  for (int iLumi = 0; iLumi<interval;iLumi++){
362  histo[PROMPTBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
363  histo[PERMANENTBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
364  }
365 
366  } // if permanent BAD
367 
368  } // loop over ROCs
369 
370  } // loop over modules
371 
372  // add empty bad components to "other" tag
373  edm::LogInfo("SiPixelStatusHarvester")
374  << "Tag requested for other in low statistics IOV in the "<<outputBase_<<" harvester"<< std::endl;
375  siPixelQualityOther_Tag[itIOV->first] = new SiPixelQuality();
376 
377  continue;
378 
379  }
380 
381  // create the DB object
382  // payload including all : PCL = permanent bad (low DIGI ROC) + other + stuckTBM
383  SiPixelQuality *siPixelQualityPCL = new SiPixelQuality();
384  SiPixelQuality *siPixelQualityOther = new SiPixelQuality();
385  // Prompt = permanent bad(low DIGI + low eff/damaged ROCs + other)
386  SiPixelQuality *siPixelQualityPrompt = new SiPixelQuality();
387 
388  // loop over modules
389  std::map<int, SiPixelModuleStatus> detectorStatus = tmpSiPixelStatus.getDetectorStatus();
390  std::map<int, SiPixelModuleStatus>::iterator itModEnd = detectorStatus.end();
391  for (std::map<int, SiPixelModuleStatus>::iterator itMod = detectorStatus.begin(); itMod != itModEnd; ++itMod) {
392 
393  // create the bad module list for PCL and other
394  SiPixelQuality::disabledModuleType BadModulePCL, BadModuleOther;
395 
396  int detid = itMod->first;
397  uint32_t detId = uint32_t(detid);
398 
399  double DetAverage_local = SiPixelStatusHarvester::perLayerRingAverage(detid,tmpSiPixelStatus);
400  double local_threshold = 0.0;
401 
402  int layer = coord_.layer(DetId(detid));
403  int ring = coord_.ring(DetId(detid));
404 
405  if(layer==1) local_threshold = thresholdL1_;
406  if(layer==2) local_threshold = thresholdL2_;
407  if(layer==3) local_threshold = thresholdL3_;
408  if(layer==4) local_threshold = thresholdL4_;
409 
410  if(ring==1) local_threshold = thresholdRNG1_;
411  if(ring==2) local_threshold = thresholdRNG2_;
412 
413  BadModulePCL.DetID = uint32_t(detid); BadModuleOther.DetID = uint32_t(detid);
414  BadModulePCL.errorType = 3; BadModuleOther.errorType = 3;
415  BadModulePCL.BadRocs = 0; BadModuleOther.BadRocs = 0;
416 
417  std::vector<uint32_t> BadRocListPCL, BadRocListOther;
418 
419  // module status and FEDerror25 status for module with DetId detId
420  SiPixelModuleStatus modStatus = itMod->second;
421  std::vector<int> listFEDerror25 = tmpFEDerror25[detid];
422 
423  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
424  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
425 
426  unsigned int rocOccupancy = modStatus.digiOccROC(iroc);
427 
428  int row = rocToOfflinePixel[iroc].first;
429  int column = rocToOfflinePixel[iroc].second;
430 
431  // Bad ROC are from low DIGI Occ ROCs
432  if(rocOccupancy<local_threshold*DetAverage_local){ // if BAD
433 
434  //PCL bad roc list
435  BadRocListPCL.push_back(uint32_t(iroc));
436  for (int iLumi = 0; iLumi<interval;iLumi++){
437  histo[BADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
438  }
439 
440  //FEDerror25 list
441  std::vector<int>::iterator it = std::find(listFEDerror25.begin(), listFEDerror25.end(),iroc);
442 
443  // other source of bad components = PCL bad - FEDerror25 - permanent bad
444  if(it==listFEDerror25.end() && !(badPixelInfo_->IsRocBad(detId, short(iroc)))){
445  // if neither permanent nor FEDerror25
446  BadRocListOther.push_back(uint32_t(iroc));
447  for (int iLumi = 0; iLumi<interval;iLumi++){
448  histo[OTHERBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
449  }
450  }
451 
452  }// if BAD
453 
454  } // loop over ROCs
455 
456  // errorType 0 means the full module is bad
457  if(BadRocListPCL.size()==sensorSize_[detid]) BadModulePCL.errorType = 0;
458  if(BadRocListOther.size()==sensorSize_[detid]) BadModuleOther.errorType = 0;
459 
460  // PCL
461  short badrocsPCL = 0;
462  for(std::vector<uint32_t>::iterator iterPCL = BadRocListPCL.begin(); iterPCL != BadRocListPCL.end(); ++iterPCL){
463  badrocsPCL += 1 << *iterPCL; // 1 << *iter = 2^{*iter} using bitwise shift
464  }
465  if(badrocsPCL!=0){
466  BadModulePCL.BadRocs = badrocsPCL;
467  siPixelQualityPCL->addDisabledModule(BadModulePCL);
468  }
469 
470  // Other
471  short badrocsOther = 0;
472  for(std::vector<uint32_t>::iterator iterOther = BadRocListOther.begin(); iterOther != BadRocListOther.end(); ++iterOther){
473  badrocsOther += 1 << *iterOther; // 1 << *iter = 2^{*iter} using bitwise shift
474  }
475  if(badrocsOther!=0){
476  BadModuleOther.BadRocs = badrocsOther;
477  siPixelQualityOther->addDisabledModule(BadModuleOther);
478  }
479 
480  // start constructing bad components for prompt = "other" + permanent
481  SiPixelQuality::disabledModuleType BadModulePrompt;
482  BadModulePrompt.DetID = uint32_t(detid);
483  BadModulePrompt.errorType = 3;
484  BadModulePrompt.BadRocs = 0;
485 
486  std::vector<uint32_t> BadRocListPrompt;
487  for (int iroc = 0; iroc < modStatus.nrocs(); ++iroc) {
488  // if in permannet bad tag or is in other tag
489  if(badPixelInfo_->IsRocBad(detId, short(iroc))|| ((badrocsOther >> short(iroc))&0x1)){
490  BadRocListPrompt.push_back(uint32_t(iroc));
491 
492  std::map<int, std::pair<int,int> > rocToOfflinePixel = pixelO2O_[detid];
493  int row = rocToOfflinePixel[iroc].first;
494  int column = rocToOfflinePixel[iroc].second;
495  for (int iLumi = 0; iLumi<interval;iLumi++){
496  histo[PROMPTBADROC].fill(detId, nullptr, column, row);//, 1.0/nLumiBlock_);
497  }
498  } // if bad
499  } // loop over all ROCs
500 
501  // errorType 0 means the full module is bad
502  if(BadRocListPrompt.size()==sensorSize_[detid]) BadModulePrompt.errorType = 0;
503 
504  short badrocsPrompt = 0;
505  for(std::vector<uint32_t>::iterator iterPrompt = BadRocListPrompt.begin(); iterPrompt != BadRocListPrompt.end(); ++iterPrompt)
506  {
507  badrocsPrompt += 1 << *iterPrompt; // 1 << *iter = 2^{*iter} using bitwise shift
508  }
509  if(badrocsPrompt!=0){
510  BadModulePrompt.BadRocs = badrocsPrompt;
511  siPixelQualityPrompt->addDisabledModule(BadModulePrompt);
512  }
513 
514  } // end module loop
515 
516  // PCL
517  siPixelQualityPCL_Tag[itIOV->first] = siPixelQualityPCL;
518  // Prompt
519  siPixelQualityPrompt_Tag[itIOV->first] = siPixelQualityPrompt;
520  // Other
521  siPixelQualityOther_Tag[itIOV->first] = siPixelQualityOther;
522 
523  }// loop over IOV
524 
525  // Now construct the tags made of payloads
526  // and only append newIOV if this payload differs wrt last
527 
528  //PCL
529  if(debug_==true)// only produced for debugging reason
530  SiPixelStatusHarvester::constructTag(siPixelQualityPCL_Tag, poolDbService, "PCL", iRun);
531  // other
532  SiPixelStatusHarvester::constructTag(siPixelQualityOther_Tag, poolDbService, "other", iRun);
533  // prompt
534  SiPixelStatusHarvester::constructTag(siPixelQualityPrompt_Tag, poolDbService, "prompt", iRun);
535  // stuckTBM
536  SiPixelStatusHarvester::constructTag(siPixelQualityStuckTBM_Tag, poolDbService, "stuckTBM", iRun);
537 
538  // Add a dummy IOV starting from last lumisection+1 to close the tag for the run
539  if((outputBase_ == "nLumibased" || outputBase_ == "dynamicLumibased") && !finalIOV.empty()){
540 
541  itIOV=std::prev(finalIOV.end()); // go to last element in the pixel quality tag
542  SiPixelQuality* lastPrompt = siPixelQualityPrompt_Tag[itIOV->first];
543  SiPixelQuality* lastOther = siPixelQualityOther_Tag[itIOV->first];
544 
545  // add permanent bad components to last lumi+1 IF AND ONLY IF the last payload of prompt is not equal to permanent bad components
547  cond::Time_t thisIOV = (cond::Time_t)(lu.value());
548  if(!SiPixelStatusHarvester::equal(lastPrompt,siPixelQualityPermBad))
549  poolDbService->writeOne<SiPixelQuality>(siPixelQualityPermBad, thisIOV, recordName_+"_prompt");
550 
551  // add empty bad components to last lumi+1 IF AND ONLY IF the last payload of other is not equal to empty
552  SiPixelQuality* siPixelQualityDummy = new SiPixelQuality();
553  if(!SiPixelStatusHarvester::equal(lastOther,siPixelQualityDummy))
554  poolDbService->writeOne<SiPixelQuality>(siPixelQualityDummy, thisIOV, recordName_+"_other");
555 
556  delete siPixelQualityDummy;
557  }
558 
559  delete siPixelQualityPermBad;
560 
561 
562  } // end of if(poolDbService.isAvailable() )
563 
564 }
565 
566 //--------------------------------------------------------------------------------------------------
568  countLumi_++;
569 }
570 
571 
572 //--------------------------------------------------------------------------------------------------
574 
576  // update endLumiBlock_ by current lumi block
577  if(endLumiBlock_<iLumi.luminosityBlock())
578  endLumiBlock_ = iLumi.luminosityBlock();
579 
580 }
581 
582 // step function for IOV
583 edm::LuminosityBlockNumber_t SiPixelStatusHarvester::stepIOV(edm::LuminosityBlockNumber_t pin, std::map<edm::LuminosityBlockNumber_t,edm::LuminosityBlockNumber_t> IOV){
584 
585  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator itIOV;
586  for(itIOV=IOV.begin();itIOV!=IOV.end();itIOV++){
587  std::map<edm::LuminosityBlockNumber_t, edm::LuminosityBlockNumber_t>::iterator nextItIOV;
588  nextItIOV = itIOV; nextItIOV++;
589 
590  if(nextItIOV!=IOV.end()){
591  if(pin>=itIOV->first && pin<nextItIOV->first){
592  return itIOV->first;
593  }
594  }
595  else{
596  if(pin>=itIOV->first){
597  return itIOV->first;
598  }
599  }
600 
601  }
602 
603  // return the firstIOV in case all above fail
604  return (IOV.begin())->first;
605 
606 }
607 
608 //--------------------------------------------------------------------------------------------------
610 
611  std::vector<SiPixelQuality::disabledModuleType> badRocListA;
612  std::vector<SiPixelQuality::disabledModuleType> badRocListB;
613 
614  for(unsigned int ia = 0; ia < (a->getBadComponentList()).size();ia++){
615  badRocListA.push_back((a->getBadComponentList())[ia]);
616  }
617  for(unsigned int ib = 0; ib < (b->getBadComponentList()).size();ib++){
618  badRocListB.push_back((b->getBadComponentList())[ib]);
619  }
620 
621  if(badRocListA.size()!=badRocListB.size()) return false;
622 
623  // ordering ROCs by DetId
624  std::sort(badRocListA.begin(),badRocListA.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
625  std::sort(badRocListB.begin(),badRocListB.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
626 
627  for(unsigned int i = 0; i<badRocListA.size();i++){
628 
629  uint32_t detIdA = badRocListA[i].DetID;
630  uint32_t detIdB = badRocListB[i].DetID;
631  if(detIdA!=detIdB) return false;
632  else{
633  unsigned short BadRocsA = badRocListA[i].BadRocs;
634  unsigned short BadRocsB = badRocListB[i].BadRocs;
635  if(BadRocsA!=BadRocsB) return false;
636  }
637 
638  }
639 
640  //if the module list is the same, and for each module, roc list is the same
641  //the two SiPixelQualitys are equal
642  return true;
643 
644 
645 }
646 
647 //--------------------------------------------------------------------------------------------------
648 void SiPixelStatusHarvester::constructTag(std::map<int,SiPixelQuality*>siPixelQualityTag, edm::Service<cond::service::PoolDBOutputService>& poolDbService, std::string tagName,edm::Run& iRun){
649 
650  for (std::map<int, SiPixelQuality*>::iterator qIt = siPixelQualityTag.begin(); qIt != siPixelQualityTag.end(); ++qIt) {
651 
652  edm::LuminosityBlockID lu(iRun.id().run(),qIt->first);
653  cond::Time_t thisIOV = (cond::Time_t)(lu.value());
654 
655  SiPixelQuality* thisPayload = qIt->second;
656  if(qIt==siPixelQualityTag.begin())
657  poolDbService->writeOne<SiPixelQuality>(thisPayload, thisIOV, recordName_+"_"+tagName);
658  else{
659  SiPixelQuality* prevPayload = (std::prev(qIt))->second;
660  if(!SiPixelStatusHarvester::equal(thisPayload,prevPayload)) // only append newIOV if this payload differs wrt last
661  poolDbService->writeOne<SiPixelQuality>(thisPayload, thisIOV, recordName_+"_"+tagName);
662  }
663  }
664 
665 }
666 
667 //--------------------------------------------------------------------------------------------------------
669 
670  unsigned long int ave(0);
671  int nrocs(0);
672 
673  int layer = coord_.layer(DetId(detid));
674  int ring = coord_.ring(DetId(detid));
675 
676  std::map<int, SiPixelModuleStatus> detectorStatus = tmpSiPixelStatus.getDetectorStatus();
677  std::map<int, SiPixelModuleStatus>::iterator itModEnd = detectorStatus.end();
678  for (std::map<int, SiPixelModuleStatus>::iterator itMod = detectorStatus.begin(); itMod != itModEnd; ++itMod) {
679 
680  if( layer != coord_.layer(DetId(itMod->first)) ) continue;
681  if( ring != coord_.ring(DetId(itMod->first)) ) continue;
682  unsigned long int inc = itMod->second.digiOccMOD();
683  ave += inc;
684  nrocs += itMod->second.nrocs();
685  }
686 
687  if(nrocs>0)
688  return ave*1.0/nrocs;
689  else return 0.0;
690 
691 }
692 
694 
696  int layer = coord_.layer(DetId(detid));
697 
698  if(layer>0){
699  std::string L = std::to_string(layer);
700  substructure = "BpixLYR";
701  substructure += L;
702  }
703  else{
704  substructure = "FpixRNG";
705  int ring = coord_.ring(DetId(detid));
706  std::string R = std::to_string(ring);
707  substructure += R;
708  }
709 
710  return substructure;
711 }
712 
713 
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_
RunNumber_t run() const
Definition: RunID.h:39
void init(edm::EventSetup const &)
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
int ring(const DetId &)
void constructTag(std::map< int, SiPixelQuality * > siPixelQualityTag, edm::Service< cond::service::PoolDBOutputService > &poolDbService, std::string tagName, edm::Run &iRun)
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
int layer(const DetId &)
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
std::string substructure(int detid)
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
double perLayerRingAverage(int detid, SiPixelDetectorStatus tmpSiPixelStatus)
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