File indexing completed on 2024-09-07 04:35:07
0001
0002 #include "CalibTracker/SiPixelQuality/interface/SiPixelTopoFinder.h"
0003
0004 #include "Geometry/CommonDetUnit/interface/PixelGeomDetUnit.h"
0005 #include "Geometry/CommonTopologies/interface/PixelTopology.h"
0006 #include "DataFormats/TrackerCommon/interface/PixelBarrelName.h"
0007 #include "DataFormats/TrackerCommon/interface/PixelEndcapName.h"
0008 #include "DataFormats/FEDRawData/interface/FEDNumbering.h"
0009 #include "CondFormats/SiPixelObjects/interface/SiPixelFrameConverter.h"
0010
0011 SiPixelTopoFinder::SiPixelTopoFinder() {}
0012
0013 SiPixelTopoFinder::~SiPixelTopoFinder() {}
0014
0015 void SiPixelTopoFinder::init(const TrackerGeometry* trackerGeometry,
0016 const TrackerTopology* trackerTopology,
0017 const SiPixelFedCablingMap* siPixelFedCablingMap) {
0018 phase_ = -1;
0019
0020 tkGeom_ = trackerGeometry;
0021 tkTopo_ = trackerTopology;
0022 cablingMap_ = siPixelFedCablingMap;
0023
0024 fFedIds_ = cablingMap_->det2fedMap();
0025
0026
0027 fDetIds_.clear();
0028 fSensors_.clear();
0029 fSensorLayout_.clear();
0030 fRocIds_.clear();
0031
0032
0033 for (TrackerGeometry::DetContainer::const_iterator it = tkGeom_->dets().begin(); it != tkGeom_->dets().end();
0034 it++) {
0035
0036 const PixelGeomDetUnit* pgdu = dynamic_cast<const PixelGeomDetUnit*>((*it));
0037 if (pgdu == nullptr)
0038 continue;
0039
0040 DetId detId = (*it)->geographicalId();
0041 int detid = detId.rawId();
0042 fDetIds_.push_back(detid);
0043
0044
0045 const PixelTopology* topo = static_cast<const PixelTopology*>(&pgdu->specificTopology());
0046 int rowsperroc = topo->rowsperroc();
0047 int colsperroc = topo->colsperroc();
0048
0049 int nROCrows = pgdu->specificTopology().nrows() / rowsperroc;
0050 int nROCcolumns = pgdu->specificTopology().ncolumns() / colsperroc;
0051
0052 fSensors_[detid] = std::make_pair(rowsperroc, colsperroc);
0053 fSensorLayout_[detid] = std::make_pair(nROCrows, nROCcolumns);
0054
0055 std::map<int, int> rocIdMap;
0056 for (int irow = 0; irow < nROCrows; irow++) {
0057 for (int icol = 0; icol < nROCcolumns; icol++) {
0058 int dummyOfflineRow = (rowsperroc / 2 - 1) + irow * rowsperroc;
0059 int dummeOfflineColumn = (colsperroc / 2 - 1) + icol * colsperroc;
0060 int fedId = fFedIds_[detId.rawId()];
0061
0062 int roc(-1), rocR(-1), rocC(-1);
0063 SiPixelTopoFinder::onlineRocColRow(
0064 detId, cablingMap_, fedId, dummyOfflineRow, dummeOfflineColumn, roc, rocR, rocC);
0065
0066
0067 int key = SiPixelTopoFinder::indexROC(irow, icol, nROCcolumns);
0068 int value = roc;
0069 rocIdMap[key] = value;
0070 }
0071 }
0072
0073 fRocIds_[detid] = rocIdMap;
0074
0075 }
0076 }
0077
0078 void SiPixelTopoFinder::onlineRocColRow(const DetId& detId,
0079 const SiPixelFedCablingMap* cablingMap,
0080 int fedId,
0081 int offlineRow,
0082 int offlineCol,
0083 int& roc,
0084 int& row,
0085 int& col) {
0086
0087 sipixelobjects::ElectronicIndex cabling;
0088 sipixelobjects::DetectorIndex detector;
0089 detector.rawId = detId.rawId();
0090 detector.row = offlineRow;
0091 detector.col = offlineCol;
0092
0093 SiPixelFrameConverter converter(cablingMap, fedId);
0094 converter.toCabling(cabling, detector);
0095
0096
0097 sipixelobjects::LocalPixel::DcolPxid loc;
0098 loc.dcol = cabling.dcol;
0099 loc.pxid = cabling.pxid;
0100
0101 sipixelobjects::LocalPixel locpixel(loc);
0102 col = locpixel.rocCol();
0103 row = locpixel.rocRow();
0104
0105
0106 const sipixelobjects::PixelROC* theRoc = converter.toRoc(cabling.link, cabling.roc);
0107 roc = theRoc->idInDetUnit();
0108
0109
0110
0111 if (detId.subdetId() == PixelSubdetector::PixelBarrel && SiPixelTopoFinder::side(detId) == 1 &&
0112 SiPixelTopoFinder::half(detId)) {
0113 roc += 8;
0114 }
0115 }
0116
0117 int SiPixelTopoFinder::indexROC(int irow, int icol, int nROCcolumns) {
0118 return int(icol + irow * nROCcolumns);
0119
0120
0121
0122
0123 }
0124
0125
0126 int SiPixelTopoFinder::quadrant(const DetId& detid) {
0127 if (detid.subdetId() == PixelSubdetector::PixelBarrel)
0128 return PixelBarrelName(detid, tkTopo_, phase_).shell();
0129 else if (detid.subdetId() == PixelSubdetector::PixelEndcap)
0130 return PixelEndcapName(detid, tkTopo_, phase_).halfCylinder();
0131 else
0132 return -9999;
0133 }
0134
0135 int SiPixelTopoFinder::side(const DetId& detid) {
0136 if (detid.subdetId() == PixelSubdetector::PixelBarrel)
0137 return 1 + (SiPixelTopoFinder::quadrant(detid) > 2);
0138 else if (detid.subdetId() == PixelSubdetector::PixelEndcap)
0139 return tkTopo_->pxfSide(detid);
0140 else
0141 return -9999;
0142 }
0143
0144 int SiPixelTopoFinder::half(const DetId& detid) {
0145 if (detid.subdetId() == PixelSubdetector::PixelBarrel)
0146 return PixelBarrelName(detid, tkTopo_, phase_).isHalfModule();
0147 else
0148 return -9999;
0149 }