CMS 3D CMS Logo

SiPixelFrameReverter.cc
Go to the documentation of this file.
6 // DataFormats
12 // Geometry
16 
17 using namespace std;
18 using namespace sipixelobjects;
19 
20 SiPixelFrameReverter::SiPixelFrameReverter(const SiPixelFedCabling* map) : map_(map), DetToFedMap(map->det2PathMap()) {}
21 
23  // Create map connecting each detId to appropriate SiPixelFrameConverter
24  for (auto it = trackerGeometry->dets().begin(); it != trackerGeometry->dets().end(); it++) {
25  if (dynamic_cast<PixelGeomDetUnit const*>((*it)) != nullptr) {
26  DetId detId = (*it)->geographicalId();
27  uint32_t id = detId();
28  std::vector<CablingPathToDetUnit> paths = map_->pathToDetUnit(id);
29  DetToFedMap.insert(pair<uint32_t, std::vector<CablingPathToDetUnit> >(id, paths));
30  }
31  } // for(TrackerGeometry::DetContainer::const_iterator
32 } // end buildStructure
33 
36  if (!hasDetUnit(detector.rawId))
37  return -1;
38  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detector.rawId)->second;
39  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
40  for (IT it = path.begin(); it != path.end(); ++it) {
41  const PixelROC* roc = map_->findItem(*it);
42  if (!roc)
43  return -3;
44  if (roc->rawId() != detector.rawId)
45  return -4;
46 
47  GlobalPixel global = {detector.row, detector.col};
48  LocalPixel local = roc->toLocal(global);
49  if (!local.valid())
50  continue;
51  ElectronicIndex cabIdx = {static_cast<int>(it->link), static_cast<int>(it->roc), local.dcol(), local.pxid()};
52  cabling = cabIdx;
53 
54  return it->fed;
55  }
56  return -2;
57 }
58 
59 int SiPixelFrameReverter::findFedId(uint32_t detId) {
60  if (!hasDetUnit(detId))
61  return -1;
62  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
63  int fedId = (int)path[0].fed;
64  return fedId;
65 }
66 
67 short SiPixelFrameReverter::findLinkInFed(uint32_t detId, GlobalPixel global) {
68  if (!hasDetUnit(detId))
69  return -1;
70  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
71  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
72  for (IT it = path.begin(); it != path.end(); ++it) {
73  const PixelROC* roc = map_->findItem(*it);
74  if (!roc)
75  continue;
76 
77  LocalPixel local = roc->toLocal(global);
78 
79  if (!local.valid())
80  continue;
81  short link = (short)it->link;
82  return link;
83  }
84  return -1;
85 }
86 
87 short SiPixelFrameReverter::findRocInLink(uint32_t detId, GlobalPixel global) {
88  if (!hasDetUnit(detId))
89  return -1;
90  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
91  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
92  for (IT it = path.begin(); it != path.end(); ++it) {
93  const PixelROC* roc = map_->findItem(*it);
94  if (!roc)
95  continue;
96 
97  LocalPixel local = roc->toLocal(global);
98 
99  if (!local.valid())
100  continue;
101  short rocInLink = (short)roc->idInLink();
102  return rocInLink;
103  }
104  return -1;
105 }
106 
107 short SiPixelFrameReverter::findRocInDet(uint32_t detId, GlobalPixel global) {
108  if (!hasDetUnit(detId))
109  return -1;
110  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
111  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
112  for (IT it = path.begin(); it != path.end(); ++it) {
113  const PixelROC* roc = map_->findItem(*it);
114  if (!roc)
115  continue;
116 
117  LocalPixel local = roc->toLocal(global);
118 
119  if (!local.valid())
120  continue;
121  short rocInDet = (short)roc->idInDetUnit();
122  return rocInDet;
123  }
124  return -1;
125 }
126 
128  if (!hasDetUnit(detId)) {
129  LocalPixel::RocRowCol pixel = {-1, -1};
131  return local;
132  }
133  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
134  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
135  for (IT it = path.begin(); it != path.end(); ++it) {
136  const PixelROC* roc = map_->findItem(*it);
137  if (!roc)
138  continue;
139 
140  LocalPixel local = roc->toLocal(global);
141 
142  if (!local.valid())
143  continue;
144  return local;
145  }
146  LocalPixel::RocRowCol pixel = {-1, -1};
148  return local;
149 }
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const =0
const DetContainer & dets() const override
Returm a vector of all GeomDet (including all GeomDetUnits)
identify pixel inside single ROC
Definition: LocalPixel.h:7
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
int findFedId(uint32_t detId)
std::vector< LinkConnSpec >::const_iterator IT
short findRocInLink(uint32_t detId, sipixelobjects::GlobalPixel global)
short findRocInDet(uint32_t detId, sipixelobjects::GlobalPixel global)
Definition: DetId.h:17
std::map< uint32_t, std::vector< sipixelobjects::CablingPathToDetUnit > > DetToFedMap
const SiPixelFedCabling * map_
void buildStructure(const TrackerGeometry *)
SiPixelFrameReverter(const SiPixelFedCabling *map)
row and collumn in ROC representation
Definition: LocalPixel.h:13
bool hasDetUnit(uint32_t detId) const
sipixelobjects::LocalPixel findPixelInRoc(uint32_t detId, sipixelobjects::GlobalPixel global)
short findLinkInFed(uint32_t detId, sipixelobjects::GlobalPixel global)