CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/CondFormats/SiPixelObjects/src/SiPixelQuality.cc

Go to the documentation of this file.
00001 // SiPixelQuality.cc
00002 //
00003 // class implementation to hold a list of disabled pixel modules
00004 //
00005 // M. Eads
00006 // Apr 2008
00007 
00008 #include "CondFormats/SiPixelObjects/interface/SiPixelQuality.h"
00009 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
00010 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
00011 #include "DataFormats/Common/interface/Handle.h"
00012 #include "FWCore/Framework/interface/ESHandle.h"
00013 #include "FWCore/Framework/interface/ESWatcher.h"
00014 #include "CondFormats/DataRecord/interface/SiPixelFedCablingMapRcd.h"
00015 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingMap.h"
00016 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCablingTree.h"
00017 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
00018 #include "CondFormats/SiPixelObjects/interface/LocalPixel.h"
00019 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00020 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00021 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00022 
00023 
00024 #include <algorithm>
00025 #include <iostream>
00026 
00027 
00028 using namespace sipixelobjects;
00029 
00030 
00032       //  errortype "whole" = int 0 in DB //
00033       //  errortype "tbmA" = int 1 in DB  //
00034       //  errortype "tbmB" = int 2 in DB  //
00035       //  errortype "none" = int 3 in DB  //
00037     
00039       //each bad roc correspond to a bit to 1: num=  //
00040       // 0 <-> all good rocs                         //
00041       // 1 <-> only roc 0 bad                        //
00042       // 2<-> only roc 1 bad                         //
00043       // 3<->  roc 0 and 1 bad                       //
00044       // 4 <-> only roc 2 bad                        //
00045       //  ...                                        //
00047 
00048 
00049 // add a list of modules to the vector of disabled modules
00050 void SiPixelQuality::addDisabledModule(std::vector<SiPixelQuality::disabledModuleType> & idVector) {
00051   theDisabledModules.insert(theDisabledModules.end(),
00052                             idVector.begin(),
00053                             idVector.end());
00054 
00055 } 
00056 
00057 
00058 // bool SiPixelQuality::removeDisabledModule(const uint32_t & detid){
00059 //   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(theDisabledModules.begin(),theDisabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00060 //   if (iter != theDisabledModules.end() && iter->DetID==detid){
00061 //     theDisabledModules.erase(iter);
00062 //     return true;
00063 //   }
00064 //   return false;
00065 // }
00066 
00067 // ask if module is OK
00068 bool SiPixelQuality::IsModuleUsable(const uint32_t& detid) const {
00069    if(IsFedBad(detid))
00070      return true;
00071    std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00072    std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00073    std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00074    if (iter != disabledModules.end() && iter->DetID==detid && iter->errorType ==0)
00075     return false;
00076   return true;
00077 }
00078 
00079 //ask if module is bad
00080  bool SiPixelQuality::IsModuleBad(const uint32_t & detid) const {
00081    if(IsFedBad(detid))
00082      return true;
00083    std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00084    std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00085    std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00086    if (iter != disabledModules.end() && iter->DetID==detid && iter->errorType == 0) //errorType 0 corresponds to "whole" dead module
00087       return true;
00088    return false;
00089 }
00090 
00091 //ask if roc is bad
00092 bool SiPixelQuality::IsRocBad(const uint32_t& detid, const short& rocNb) const {
00093   if(IsModuleBad(detid))
00094     return true;
00095    std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00096    std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00097    std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00098    if (iter != disabledModules.end() && iter->DetID == detid){
00099      return ((iter->BadRocs >> rocNb)&0x1);}
00100   return false;
00101 }
00102 
00103 bool SiPixelQuality::IsAreaBad(uint32_t detid, sipixelobjects::GlobalPixel global, const edm::EventSetup& es, const SiPixelFedCabling* map ) const {
00104  
00105   SiPixelFrameReverter reverter(es,map);
00106   int rocfromarea = -1;  
00107   rocfromarea = reverter.findRocInDet(detid, global);
00108 
00109   return SiPixelQuality::IsRocBad(detid, rocfromarea);
00110   return false;
00111 }
00112 
00113 //ask for bad ROCS
00114 
00115 
00116 short SiPixelQuality::getBadRocs(const uint32_t& detid) const{
00117   std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00118   std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00119   std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00120   if (iter != disabledModules.end() && iter->DetID==detid)
00121     return iter->BadRocs;
00122   return 0;
00123 }
00124 
00125 const std::vector<LocalPoint> SiPixelQuality::getBadRocPositions(const uint32_t & detid, const TrackerGeometry& theTracker, const SiPixelFedCabling* map) const{
00126   std::vector<LocalPoint> badrocpositions (0);
00127   std::pair<uint8_t, uint8_t> coord(1,1);
00128    for(unsigned int i = 0; i < 16; i++){
00129      if (IsRocBad(detid, i) == true){
00130     std::vector<CablingPathToDetUnit> path = map->pathToDetUnit(detid);
00131     typedef  std::vector<CablingPathToDetUnit>::const_iterator IT;
00132        for  (IT it = path.begin(); it != path.end(); ++it) {
00133           const PixelROC * myroc = map->findItem(*it);
00134           if( myroc->idInDetUnit() == i) {
00135               LocalPixel::RocRowCol  local = { 39, 25};   //corresponding to center of ROC row, col
00136               GlobalPixel global = myroc->toGlobal( LocalPixel(local) );
00137               //       edm::ESHandle<TrackerGeometry> geom;
00138               //     es.get<TrackerDigiGeometryRecord>().get( geom );
00139               //    const TrackerGeometry& theTracker(*geom);
00140               const PixelGeomDetUnit * theGeomDet = dynamic_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detid) );
00141 
00142               PixelTopology const * topology = &(theGeomDet->specificTopology());
00143 
00144               MeasurementPoint thepoint(global.row, global.col);
00145               LocalPoint localpoint = topology->localPosition(thepoint);
00146               badrocpositions.push_back(localpoint);
00147          break;
00148           }
00149        }
00150      }
00151    }
00152   return badrocpositions;
00153 }
00154 
00155 
00156 bool SiPixelQuality::IsFedBad(const uint32_t & detid) const{
00157   return false;
00158 }
00159 
00160 
00161