Go to the documentation of this file.00001
00002
00003
00004
00005
00006
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
00033
00034
00035
00037
00039
00040
00041
00042
00043
00044
00045
00047
00048
00049
00050 void SiPixelQuality::addDisabledModule(std::vector<SiPixelQuality::disabledModuleType> & idVector) {
00051 theDisabledModules.insert(theDisabledModules.end(),
00052 idVector.begin(),
00053 idVector.end());
00054
00055 }
00056
00057 void SiPixelQuality::add(const SiStripDetVOff* Voff) {
00058
00059
00060 std::vector<uint32_t> vdets;
00061 Voff->getDetIds(vdets);
00062
00063 std::vector<uint32_t>::const_iterator iter=vdets.begin();
00064 std::vector<uint32_t>::const_iterator iterEnd=vdets.end();
00065
00066 for(;iter!=iterEnd;++iter){
00067 SiPixelQuality::disabledModuleType BadModule;
00068 BadModule.DetID = *iter;
00069 BadModule.errorType = 0;
00070 BadModule.BadRocs = 65535;
00071 if(IsModuleUsable(BadModule.DetID))
00072 addDisabledModule(BadModule);
00073
00074 }
00075 }
00076
00077
00078
00079
00080
00081
00082
00083
00084
00085
00086
00087 bool SiPixelQuality::IsModuleUsable(const uint32_t& detid) const {
00088 if(IsFedBad(detid))
00089 return true;
00090 std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00091 std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00092 std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00093 if (iter != disabledModules.end() && iter->DetID==detid && iter->errorType ==0)
00094 return false;
00095 return true;
00096 }
00097
00098 int SiPixelQuality::BadModuleNumber() {
00099 std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00100
00101 return disabledModules.size();
00102 }
00103
00104
00105 bool SiPixelQuality::IsModuleBad(const uint32_t & detid) const {
00106 if(IsFedBad(detid))
00107 return true;
00108 std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00109 std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00110 std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00111 if (iter != disabledModules.end() && iter->DetID==detid && iter->errorType == 0)
00112 return true;
00113 return false;
00114 }
00115
00116
00117 bool SiPixelQuality::IsRocBad(const uint32_t& detid, const short& rocNb) const {
00118 if(IsModuleBad(detid))
00119 return true;
00120 std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00121 std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00122 std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00123 if (iter != disabledModules.end() && iter->DetID == detid){
00124 return ((iter->BadRocs >> rocNb)&0x1);}
00125 return false;
00126 }
00127
00128 bool SiPixelQuality::IsAreaBad(uint32_t detid, sipixelobjects::GlobalPixel global, const edm::EventSetup& es, const SiPixelFedCabling* map ) const {
00129
00130 SiPixelFrameReverter reverter(es,map);
00131 int rocfromarea = -1;
00132 rocfromarea = reverter.findRocInDet(detid, global);
00133
00134 return SiPixelQuality::IsRocBad(detid, rocfromarea);
00135 return false;
00136 }
00137
00138
00139
00140
00141 short SiPixelQuality::getBadRocs(const uint32_t& detid) const{
00142 std::vector<SiPixelQuality::disabledModuleType>disabledModules = theDisabledModules;
00143 std::sort(disabledModules.begin(),disabledModules.end(),SiPixelQuality::BadComponentStrictWeakOrdering());
00144 std::vector<disabledModuleType>::const_iterator iter = std::lower_bound(disabledModules.begin(),disabledModules.end(),detid,SiPixelQuality::BadComponentStrictWeakOrdering());
00145 if (iter != disabledModules.end() && iter->DetID==detid)
00146 return iter->BadRocs;
00147 return 0;
00148 }
00149
00150 const std::vector<LocalPoint> SiPixelQuality::getBadRocPositions(const uint32_t & detid, const TrackerGeometry& theTracker, const SiPixelFedCabling* map) const{
00151 std::vector<LocalPoint> badrocpositions (0);
00152 std::pair<uint8_t, uint8_t> coord(1,1);
00153 for(unsigned int i = 0; i < 16; i++){
00154 if (IsRocBad(detid, i) == true){
00155 std::vector<CablingPathToDetUnit> path = map->pathToDetUnit(detid);
00156 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00157 for (IT it = path.begin(); it != path.end(); ++it) {
00158 const PixelROC * myroc = map->findItem(*it);
00159 if( myroc->idInDetUnit() == i) {
00160 LocalPixel::RocRowCol local = { 39, 25};
00161 GlobalPixel global = myroc->toGlobal( LocalPixel(local) );
00162
00163
00164
00165 const PixelGeomDetUnit * theGeomDet = dynamic_cast<const PixelGeomDetUnit*> (theTracker.idToDet(detid) );
00166
00167 PixelTopology const * topology = &(theGeomDet->specificTopology());
00168
00169 MeasurementPoint thepoint(global.row, global.col);
00170 LocalPoint localpoint = topology->localPosition(thepoint);
00171 badrocpositions.push_back(localpoint);
00172 break;
00173 }
00174 }
00175 }
00176 }
00177 return badrocpositions;
00178 }
00179
00180
00181 bool SiPixelQuality::IsFedBad(const uint32_t & detid) const{
00182 return false;
00183 }
00184
00185
00186