CMS 3D CMS Logo

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