Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-06-04 06:14:14

0001 // SiPixelQuality.cc
0002 //
0003 // class implementation to hold a list of disabled pixel modules
0004 //
0005 // M. Eads
0006 // Apr 2008
0007 
0008 #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
0009 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
0010 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
0011 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
0012 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
0013 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
0014 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
0015 #include "CondFormats/SiPixelObjects/interface/LocalPixel.h"
0016 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0017 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
0018 
0019 #include <algorithm>
0020 #include <iostream>
0021 
0022 using namespace sipixelobjects;
0023 
0024 //////////////////////////////////////
0025 //  errortype "whole" = int 0 in DB //
0026 //  errortype "tbmA" = int 1 in DB  //
0027 //  errortype "tbmB" = int 2 in DB  //
0028 //  errortype "none" = int 3 in DB  //
0029 //////////////////////////////////////
0030 
0031 /////////////////////////////////////////////////
0032 //each bad roc correspond to a bit to 1: num=  //
0033 // 0 <-> all good rocs                         //
0034 // 1 <-> only roc 0 bad                        //
0035 // 2<-> only roc 1 bad                         //
0036 // 3<->  roc 0 and 1 bad                       //
0037 // 4 <-> only roc 2 bad                        //
0038 //  ...                                        //
0039 /////////////////////////////////////////////////
0040 
0041 // add a list of modules to the vector of disabled modules
0042 void SiPixelQuality::addDisabledModule(std::vector<SiPixelQuality::disabledModuleType>& idVector) {
0043   theDisabledModules.insert(theDisabledModules.end(), idVector.begin(), idVector.end());
0044 }
0045 
0046 void SiPixelQuality::add(const SiStripDetVOff* Voff) {
0047   //Get vector of Voff dets
0048   std::vector<uint32_t> vdets;
0049   Voff->getDetIds(vdets);
0050 
0051   std::vector<uint32_t>::const_iterator iter = vdets.begin();
0052   std::vector<uint32_t>::const_iterator iterEnd = vdets.end();
0053 
0054   for (; iter != iterEnd; ++iter) {
0055     SiPixelQuality::disabledModuleType BadModule;
0056     BadModule.DetID = *iter;
0057     BadModule.errorType = 0;
0058     BadModule.BadRocs = 65535;  //NOTE: here all module is bad - no difference for half modules
0059     if (IsModuleUsable(BadModule.DetID))
0060       addDisabledModule(BadModule);
0061   }
0062 }
0063 
0064 // bool SiPixelQuality::removeDisabledModule(const uint32_t & detid){
0065 //   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(theDisabledModules.begin(),theDisabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
0066 //   if (iter != theDisabledModules.end() && iter->DetID==detid){
0067 //     theDisabledModules.erase(iter);
0068 //     return true;
0069 //   }
0070 //   return false;
0071 // }
0072 
0073 // ask if module is OK
0074 bool SiPixelQuality::IsModuleUsable(const uint32_t& detid) const {
0075   if (IsFedBad(detid))
0076     return true;
0077   std::vector<SiPixelQuality::disabledModuleType> disabledModules = theDisabledModules;
0078   std::sort(disabledModules.begin(), disabledModules.end(), SiPixelQuality::BadComponentStrictWeakOrdering());
0079   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(
0080       disabledModules.begin(), disabledModules.end(), detid, SiPixelQuality::BadComponentStrictWeakOrdering());
0081   if (iter != disabledModules.end() && iter->DetID == detid && iter->errorType == 0)
0082     return false;
0083   return true;
0084 }
0085 
0086 int SiPixelQuality::BadModuleNumber() {
0087   std::vector<SiPixelQuality::disabledModuleType> disabledModules = theDisabledModules;
0088   //does not distinguish between partially dead or not
0089   return disabledModules.size();
0090 }
0091 
0092 //ask if module is bad
0093 bool SiPixelQuality::IsModuleBad(const uint32_t& detid) const {
0094   if (IsFedBad(detid))
0095     return true;
0096   std::vector<SiPixelQuality::disabledModuleType> disabledModules = theDisabledModules;
0097   std::sort(disabledModules.begin(), disabledModules.end(), SiPixelQuality::BadComponentStrictWeakOrdering());
0098   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(
0099       disabledModules.begin(), disabledModules.end(), detid, SiPixelQuality::BadComponentStrictWeakOrdering());
0100   //errorType 0 corresponds to "whole" dead module
0101   if (iter != disabledModules.end() && iter->DetID == detid && iter->errorType == 0)
0102     return true;
0103   return false;
0104 }
0105 
0106 //ask if roc is bad
0107 bool SiPixelQuality::IsRocBad(const uint32_t& detid, const short& rocNb) const {
0108   if (IsModuleBad(detid))
0109     return true;
0110   std::vector<SiPixelQuality::disabledModuleType> disabledModules = theDisabledModules;
0111   std::sort(disabledModules.begin(), disabledModules.end(), SiPixelQuality::BadComponentStrictWeakOrdering());
0112   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(
0113       disabledModules.begin(), disabledModules.end(), detid, SiPixelQuality::BadComponentStrictWeakOrdering());
0114   if (iter != disabledModules.end() && iter->DetID == detid) {
0115     return ((iter->BadRocs >> rocNb) & 0x1);
0116   }
0117   return false;
0118 }
0119 
0120 //ask for bad ROCS
0121 
0122 short SiPixelQuality::getBadRocs(const uint32_t& detid) const {
0123   std::vector<SiPixelQuality::disabledModuleType> disabledModules = theDisabledModules;
0124   std::sort(disabledModules.begin(), disabledModules.end(), SiPixelQuality::BadComponentStrictWeakOrdering());
0125   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(
0126       disabledModules.begin(), disabledModules.end(), detid, SiPixelQuality::BadComponentStrictWeakOrdering());
0127   if (iter != disabledModules.end() && iter->DetID == detid)
0128     return iter->BadRocs;
0129   return 0;
0130 }
0131 
0132 const std::vector<LocalPoint> SiPixelQuality::getBadRocPositions(const uint32_t& detid,
0133                                                                  const TrackerGeometry& theTracker,
0134                                                                  const SiPixelFedCabling* map) const {
0135   std::vector<LocalPoint> badrocpositions(0);
0136   for (unsigned int i = 0; i < 16; i++) {
0137     if (IsRocBad(detid, i) == true) {
0138       std::vector<CablingPathToDetUnit> path = map->pathToDetUnit(detid);
0139       typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
0140       for (IT it = path.begin(); it != path.end(); ++it) {
0141         const PixelROC* myroc = map->findItem(*it);
0142         if (myroc->idInDetUnit() == i) {
0143           LocalPixel::RocRowCol local = {39, 25};  //corresponding to center of ROC row, col
0144           GlobalPixel global = myroc->toGlobal(LocalPixel(local));
0145           const PixelGeomDetUnit* theGeomDet = dynamic_cast<const PixelGeomDetUnit*>(theTracker.idToDet(detid));
0146 
0147           PixelTopology const* topology = &(theGeomDet->specificTopology());
0148 
0149           MeasurementPoint thepoint(global.row, global.col);
0150           LocalPoint localpoint = topology->localPosition(thepoint);
0151           badrocpositions.push_back(localpoint);
0152           break;
0153         }
0154       }
0155     }
0156   }
0157   return badrocpositions;
0158 }
0159 
0160 bool SiPixelQuality::IsFedBad(const uint32_t& detid) const { return false; }