CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SiPixelFrameConverter.cc
Go to the documentation of this file.
3 
6 
8 
9 #include <sstream>
10 
11 using namespace std;
12 using namespace sipixelobjects;
13 
15  : theFedId(fedId), theMap(map)
16 { }
17 
18 
19 bool SiPixelFrameConverter::hasDetUnit(uint32_t rawId) const
20 {
21  std::vector<CablingPathToDetUnit> paths = theMap->pathToDetUnit(rawId);
22  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
23  for (IT it=paths.begin(); it!=paths.end();++it) {
24  if(it->fed==static_cast<unsigned int>(theFedId)) return true;
25  }
26  return false;
27 }
28 
29 
30 int SiPixelFrameConverter::toDetector(const ElectronicIndex & cabling, DetectorIndex & detector) const
31 {
32  CablingPathToDetUnit path = {static_cast<unsigned int>(theFedId),
33  static_cast<unsigned int>(cabling.link),
34  static_cast<unsigned int>(cabling.roc)};
35  const PixelROC * roc = theMap->findItem(path);
36  if (!roc){
37  stringstream stm;
38  stm << "Map shows no fed="<<theFedId
39  <<", link="<<cabling.link
40  <<", roc="<<cabling.roc;
41  edm::LogWarning("SiPixelFrameConverter") << stm.str();
42  return 2;
43  }
44  LocalPixel::DcolPxid local = { cabling.dcol, cabling.pxid };
45  if (!local.valid()) return 3;
46 
47  GlobalPixel global = roc->toGlobal( LocalPixel(local) );
48  detector.rawId = roc->rawId();
49  detector.row = global.row;
50  detector.col = global.col;
51 
52  return 0;
53 
54 
55 }
56 
57 
59  ElectronicIndex & cabling, const DetectorIndex & detector) const
60 {
61  std::vector<CablingPathToDetUnit> path = theMap->pathToDetUnit(detector.rawId);
62  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
63  for (IT it = path.begin(); it != path.end(); ++it) {
64  const PixelROC * roc = theMap->findItem(*it);
65  if (!roc) return 2;
66  if (! roc->rawId() == detector.rawId) return 3;
67 
68  GlobalPixel global = {detector.row, detector.col};
69  //LogTrace("")<<"GLOBAL PIXEL: row=" << global.row <<" col="<< global.col;
70 
71  LocalPixel local = roc->toLocal(global);
72  // LogTrace("")<<"LOCAL PIXEL: dcol ="
73  //<< local.dcol()<<" pxid="<< local.pxid()<<" inside: " <<local.valid();
74 
75  if(!local.valid()) continue;
76  ElectronicIndex cabIdx = {static_cast<int>(it->link),
77  static_cast<int>(it->roc), local.dcol(), local.pxid()};
78  cabling = cabIdx;
79  return 0;
80  }
81  return 1;
82 }
83 
GlobalPixel toGlobal(const LocalPixel &loc) const
Definition: PixelROC.cc:44
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
virtual std::vector< sipixelobjects::CablingPathToDetUnit > pathToDetUnit(uint32_t rawDetId) const =0
SiPixelFrameConverter(const SiPixelFedCabling *map, int fedId)
identify pixel inside single ROC
Definition: LocalPixel.h:7
dictionary map
Definition: Association.py:205
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
LocalPixel toLocal(const GlobalPixel &gp) const
Definition: PixelROC.cc:54
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:40
std::vector< LinkConnSpec >::const_iterator IT
double collumn and pixel ID in double collumn representation
Definition: LocalPixel.h:22
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
const SiPixelFedCabling * theMap
bool hasDetUnit(uint32_t radId) const
int toDetector(const sipixelobjects::ElectronicIndex &cabling, sipixelobjects::DetectorIndex &detector) const