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  theTree(dynamic_cast<SiPixelFedCablingTree const *>(map)),
17  theFed(theTree ? theTree->fed(fedId) : nullptr)
18 {}
19 
20 bool SiPixelFrameConverter::hasDetUnit(uint32_t rawId) const
21 {
22  std::vector<CablingPathToDetUnit> paths = theMap->pathToDetUnit(rawId);
23  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
24  for (IT it=paths.begin(); it!=paths.end();++it) {
25  if(it->fed==static_cast<unsigned int>(theFedId)) return true;
26  }
27  return false;
28 }
29 
30 
31 PixelROC const * SiPixelFrameConverter::toRoc(int link, int roc) const {
32  CablingPathToDetUnit path = {static_cast<unsigned int>(theFedId),
33  static_cast<unsigned int>(link),
34  static_cast<unsigned int>(roc)};
35  const PixelROC * rocp = (theFed) ? theTree->findItemInFed(path, theFed) : theMap->findItem(path);
36  if unlikely(!rocp){
37  stringstream stm;
38  stm << "Map shows no fed="<<theFedId
39  <<", link="<< link
40  <<", roc="<< roc;
41  edm::LogWarning("SiPixelFrameConverter") << stm.str();
42  }
43  return rocp;
44 }
45 
46 
47 
49  ElectronicIndex & cabling, const DetectorIndex & detector) const
50 {
51  std::vector<CablingPathToDetUnit> path = theMap->pathToDetUnit(detector.rawId);
52  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
53  for (IT it = path.begin(); it != path.end(); ++it) {
54  const PixelROC * roc = theMap->findItem(*it);
55  if (!roc) return 2;
56  if (! roc->rawId() == detector.rawId) return 3;
57 
58  GlobalPixel global = {detector.row, detector.col};
59  //LogTrace("")<<"GLOBAL PIXEL: row=" << global.row <<" col="<< global.col;
60 
61  LocalPixel local = roc->toLocal(global);
62  // LogTrace("")<<"LOCAL PIXEL: dcol ="
63  //<< local.dcol()<<" pxid="<< local.pxid()<<" inside: " <<local.valid();
64 
65  if(!local.valid()) continue;
66  ElectronicIndex cabIdx = {static_cast<int>(it->link),
67  static_cast<int>(it->roc), local.dcol(), local.pxid()};
68  cabling = cabIdx;
69  return 0;
70  }
71  return 1;
72 }
73 
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)
#define nullptr
identify pixel inside single ROC
Definition: LocalPixel.h:7
global coordinates (row and column in DetUnit, as in PixelDigi)
Definition: GlobalPixel.h:6
#define unlikely(x)
LocalPixel toLocal(const GlobalPixel &glo) const
Definition: PixelROC.h:47
tuple path
else: Piece not in the list, fine.
SiPixelFedCablingTree const * theTree
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:36
std::vector< LinkConnSpec >::const_iterator IT
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
const SiPixelFedCabling * theMap
string const
Definition: compareJSON.py:14
sipixelobjects::PixelROC const * toRoc(int link, int roc) const
bool hasDetUnit(uint32_t radId) const
const sipixelobjects::PixelROC * findItemInFed(const sipixelobjects::CablingPathToDetUnit &path, const PixelFEDCabling *aFed) const
const PixelFEDCabling * theFed