Go to the documentation of this file.00001 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameReverter.h"
00002 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCabling.h"
00003 #include "CondFormats/SiPixelObjects/interface/CablingPathToDetUnit.h"
00004 #include "CondFormats/SiPixelObjects/interface/PixelFEDCabling.h"
00005 #include "CondFormats/SiPixelObjects/interface/PixelFEDLink.h"
00006 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
00007
00008 #include "DataFormats/DetId/interface/DetId.h"
00009 #include "DataFormats/SiPixelDetId/interface/PixelSubdetector.h"
00010 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
00011 #include "DataFormats/SiPixelDetId/interface/PixelBarrelName.h"
00012 #include "DataFormats/SiPixelDetId/interface/PixelEndcapName.h"
00013
00014 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00015 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00016 #include "Geometry/TrackerGeometryBuilder/interface/PixelGeomDetUnit.h"
00017 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
00018
00019 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00020
00021 #include <sstream>
00022
00023 using namespace std;
00024 using namespace sipixelobjects;
00025
00026 SiPixelFrameReverter::SiPixelFrameReverter(const edm::EventSetup& iSetup, const SiPixelFedCabling* map)
00027 : map_(map)
00028 {
00029
00030 buildStructure(iSetup);
00031 }
00032
00033
00034 void SiPixelFrameReverter::buildStructure(const edm::EventSetup& iSetup)
00035 {
00036
00037
00038
00039 edm::ESHandle<TrackerGeometry> pDD;
00040 iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
00041
00042 for(TrackerGeometry::DetContainer::const_iterator it = pDD->dets().begin(); it != pDD->dets().end(); it++){
00043
00044 if(dynamic_cast<PixelGeomDetUnit*>((*it))!=0){
00045
00046 DetId detId = (*it)->geographicalId();
00047 uint32_t id = detId();
00048 std::vector<CablingPathToDetUnit> paths = map_->pathToDetUnit(id);
00049 DetToFedMap.insert(pair< uint32_t,std::vector<CablingPathToDetUnit> > (id,paths));
00050
00051 }
00052 }
00053 }
00054
00055
00056 int SiPixelFrameReverter::findFedId(uint32_t detId)
00057 {
00058 std::vector<CablingPathToDetUnit> path = DetToFedMap[detId];
00059 int fedId = (int) path[0].fed;
00060 return fedId;
00061 }
00062
00063
00064 short SiPixelFrameReverter::findLinkInFed(uint32_t detId, GlobalPixel global)
00065 {
00066 std::vector<CablingPathToDetUnit> path = map_->pathToDetUnit(detId);
00067 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00068 for (IT it = path.begin(); it != path.end(); ++it) {
00069 const PixelROC * roc = map_->findItem(*it);
00070 if (!roc) continue;
00071
00072 LocalPixel local = roc->toLocal(global);
00073
00074 if(!local.valid()) continue;
00075 short link = (short) it->link;
00076 return link;
00077 }
00078 return -1;
00079 }
00080
00081
00082 short SiPixelFrameReverter::findRocInLink(uint32_t detId, GlobalPixel global)
00083 {
00084 std::vector<CablingPathToDetUnit> path = map_->pathToDetUnit(detId);
00085 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00086 for (IT it = path.begin(); it != path.end(); ++it) {
00087 const PixelROC * roc = map_->findItem(*it);
00088 if (!roc) continue;
00089
00090 LocalPixel local = roc->toLocal(global);
00091
00092 if(!local.valid()) continue;
00093 short rocInLink = (short) roc->idInLink();
00094 return rocInLink;
00095 }
00096 return -1;
00097 }
00098
00099
00100 short SiPixelFrameReverter::findRocInDet(uint32_t detId, GlobalPixel global)
00101 {
00102 std::vector<CablingPathToDetUnit> path = map_->pathToDetUnit(detId);
00103 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00104 for (IT it = path.begin(); it != path.end(); ++it) {
00105 const PixelROC * roc = map_->findItem(*it);
00106 if (!roc) continue;
00107
00108 LocalPixel local = roc->toLocal(global);
00109
00110 if(!local.valid()) continue;
00111 short rocInDet = (short) roc->idInDetUnit();
00112 return rocInDet;
00113 }
00114 return -1;
00115 }
00116
00117
00118 LocalPixel SiPixelFrameReverter::findPixelInRoc(uint32_t detId, GlobalPixel global)
00119 {
00120 std::vector<CablingPathToDetUnit> path = map_->pathToDetUnit(detId);
00121 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00122 for (IT it = path.begin(); it != path.end(); ++it) {
00123 const PixelROC * roc = map_->findItem(*it);
00124 if (!roc) continue;
00125
00126 LocalPixel local = roc->toLocal(global);
00127
00128 if(!local.valid()) continue;
00129 return local;
00130 }
00131 LocalPixel::RocRowCol pixel = {-1,-1};
00132 LocalPixel local(pixel);
00133 return local;
00134 }