Go to the documentation of this file.00001 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
00002 #include "CondFormats/SiPixelObjects/interface/SiPixelFedCabling.h"
00003
00004 #include "CondFormats/SiPixelObjects/interface/PixelROC.h"
00005 #include "CondFormats/SiPixelObjects/interface/CablingPathToDetUnit.h"
00006
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 #include <sstream>
00010
00011 using namespace std;
00012 using namespace sipixelobjects;
00013
00014 SiPixelFrameConverter::SiPixelFrameConverter(const SiPixelFedCabling* map, int fedId)
00015 : theFedId(fedId), theMap(map)
00016 { }
00017
00018
00019 bool SiPixelFrameConverter::hasDetUnit(uint32_t rawId) const
00020 {
00021 std::vector<CablingPathToDetUnit> paths = theMap->pathToDetUnit(rawId);
00022 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00023 for (IT it=paths.begin(); it!=paths.end();++it) {
00024 if(it->fed==static_cast<unsigned int>(theFedId)) return true;
00025 }
00026 return false;
00027 }
00028
00029
00030 int SiPixelFrameConverter::toDetector(const ElectronicIndex & cabling, DetectorIndex & detector) const
00031 {
00032 CablingPathToDetUnit path = {static_cast<unsigned int>(theFedId),
00033 static_cast<unsigned int>(cabling.link),
00034 static_cast<unsigned int>(cabling.roc)};
00035 const PixelROC * roc = theMap->findItem(path);
00036 if (!roc){
00037 stringstream stm;
00038 stm << "Map shows no fed="<<theFedId
00039 <<", link="<<cabling.link
00040 <<", roc="<<cabling.roc;
00041 edm::LogWarning("SiPixelFrameConverter") << stm.str();
00042 return 2;
00043 }
00044 LocalPixel::DcolPxid local = { cabling.dcol, cabling.pxid };
00045 if (!local.valid()) return 3;
00046
00047 GlobalPixel global = roc->toGlobal( LocalPixel(local) );
00048 detector.rawId = roc->rawId();
00049 detector.row = global.row;
00050 detector.col = global.col;
00051
00052 return 0;
00053
00054
00055 }
00056
00057
00058 int SiPixelFrameConverter::toCabling(
00059 ElectronicIndex & cabling, const DetectorIndex & detector) const
00060 {
00061 std::vector<CablingPathToDetUnit> path = theMap->pathToDetUnit(detector.rawId);
00062 typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
00063 for (IT it = path.begin(); it != path.end(); ++it) {
00064 const PixelROC * roc = theMap->findItem(*it);
00065 if (!roc) return 2;
00066 if (! roc->rawId() == detector.rawId) return 3;
00067
00068 GlobalPixel global = {detector.row, detector.col};
00069
00070
00071 LocalPixel local = roc->toLocal(global);
00072
00073
00074
00075 if(!local.valid()) continue;
00076 ElectronicIndex cabIdx = {static_cast<int>(it->link),
00077 static_cast<int>(it->roc), local.dcol(), local.pxid()};
00078 cabling = cabIdx;
00079 return 0;
00080 }
00081 return 1;
00082 }
00083