CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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)
28 {
29  // Build map
30  buildStructure(iSetup);
31 }
32 
33 
35 {
36 
37  // Create map connecting each detId to appropriate SiPixelFrameConverter
38 
40  iSetup.get<TrackerDigiGeometryRecord>().get( pDD );
41 
42  for(auto it = pDD->dets().begin(); it != pDD->dets().end(); it++){
43 
44  if(dynamic_cast<PixelGeomDetUnit const *>((*it))!=0){
45 
46  DetId detId = (*it)->geographicalId();
47  uint32_t id = detId();
48  std::vector<CablingPathToDetUnit> paths = map_->pathToDetUnit(id);
49  DetToFedMap.insert(pair< uint32_t,std::vector<CablingPathToDetUnit> > (id,paths));
50 
51  }
52  } // for(TrackerGeometry::DetContainer::const_iterator
53 } // end buildStructure
54 
55 
57  sipixelobjects::ElectronicIndex & cabling, const sipixelobjects::DetectorIndex & detector) const
58 {
59  if(!hasDetUnit(detector.rawId)) return -1;
60  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detector.rawId)->second;
61  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
62  for (IT it = path.begin(); it != path.end(); ++it) {
63  const PixelROC * roc = map_->findItem(*it);
64  if (!roc) return -3;
65  if (! roc->rawId() == detector.rawId) return -4;
66 
67  GlobalPixel global = {detector.row, detector.col};
68  LocalPixel local = roc->toLocal(global);
69  if(!local.valid()) continue;
70  ElectronicIndex cabIdx = {static_cast<int>(it->link), static_cast<int>(it->roc), local.dcol(), local.pxid()};
71  cabling = cabIdx;
72 
73  return it->fed;
74  }
75  return -2;
76 }
77 
78 
80 {
81  if(!hasDetUnit(detId)) return -1;
82  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
83  int fedId = (int) path[0].fed;
84  return fedId;
85 }
86 
87 
88 short SiPixelFrameReverter::findLinkInFed(uint32_t detId, GlobalPixel global)
89 {
90  if(!hasDetUnit(detId)) return -1;
91  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
92  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
93  for (IT it = path.begin(); it != path.end(); ++it) {
94  const PixelROC * roc = map_->findItem(*it);
95  if (!roc) continue;
96 
97  LocalPixel local = roc->toLocal(global);
98 
99  if(!local.valid()) continue;
100  short link = (short) it->link;
101  return link;
102  }
103  return -1;
104 }
105 
106 
108 {
109  if(!hasDetUnit(detId)) 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) continue;
115 
116  LocalPixel local = roc->toLocal(global);
117 
118  if(!local.valid()) continue;
119  short rocInLink = (short) roc->idInLink();
120  return rocInLink;
121  }
122  return -1;
123 }
124 
125 
126 short SiPixelFrameReverter::findRocInDet(uint32_t detId, GlobalPixel global)
127 {
128  if(!hasDetUnit(detId)) return -1;
129  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
130  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
131  for (IT it = path.begin(); it != path.end(); ++it) {
132  const PixelROC * roc = map_->findItem(*it);
133  if (!roc) continue;
134 
135  LocalPixel local = roc->toLocal(global);
136 
137  if(!local.valid()) continue;
138  short rocInDet = (short) roc->idInDetUnit();
139  return rocInDet;
140  }
141  return -1;
142 }
143 
144 
146 {
147  if(!hasDetUnit(detId)) {
148  LocalPixel::RocRowCol pixel = {-1,-1};
149  LocalPixel local(pixel);
150  return local;
151  }
152  std::vector<CablingPathToDetUnit> path = DetToFedMap.find(detId)->second;
153  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
154  for (IT it = path.begin(); it != path.end(); ++it) {
155  const PixelROC * roc = map_->findItem(*it);
156  if (!roc) continue;
157 
158  LocalPixel local = roc->toLocal(global);
159 
160  if(!local.valid()) continue;
161  return local;
162  }
163  LocalPixel::RocRowCol pixel = {-1,-1};
164  LocalPixel local(pixel);
165  return local;
166 }
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
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:42
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)
std::string link(std::string &nm, std::string &ns)
Definition: hierarchy.cc:24
LocalPixel toLocal(const GlobalPixel &glo) const
Definition: PixelROC.h:47
tuple path
else: Piece not in the list, fine.
int findFedId(uint32_t detId)
unsigned int idInDetUnit() const
id of this ROC in DetUnit etermined by token path
Definition: PixelROC.h:39
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:36
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:18
const SiPixelFedCabling * map_
const T & get() const
Definition: EventSetup.h:55
std::map< uint32_t, std::vector< sipixelobjects::CablingPathToDetUnit > > DetToFedMap
row and collumn in ROC representation
Definition: LocalPixel.h:15
sipixelobjects::LocalPixel findPixelInRoc(uint32_t detId, sipixelobjects::GlobalPixel global)
short findLinkInFed(uint32_t detId, sipixelobjects::GlobalPixel global)