CMS 3D CMS Logo

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  return theMap->pathToDetUnitHasDetUnit(rawId, static_cast<unsigned int>(theFedId));
23 }
24 
25 
26 PixelROC const * SiPixelFrameConverter::toRoc(int link, int roc) const {
27  CablingPathToDetUnit path = {static_cast<unsigned int>(theFedId),
28  static_cast<unsigned int>(link),
29  static_cast<unsigned int>(roc)};
30  const PixelROC * rocp = (theFed) ? theTree->findItemInFed(path, theFed) : theMap->findItem(path);
31  if UNLIKELY(!rocp){
32  stringstream stm;
33  stm << "Map shows no fed="<<theFedId
34  <<", link="<< link
35  <<", roc="<< roc;
36  edm::LogWarning("SiPixelFrameConverter") << stm.str();
37  }
38  return rocp;
39 }
40 
41 
42 
44  ElectronicIndex & cabling, const DetectorIndex & detector) const
45 {
46  std::vector<CablingPathToDetUnit> path = theMap->pathToDetUnit(detector.rawId);
47  typedef std::vector<CablingPathToDetUnit>::const_iterator IT;
48  for (IT it = path.begin(); it != path.end(); ++it) {
49  const PixelROC * roc = theMap->findItem(*it);
50  if (!roc) return 2;
51  if (roc->rawId() != detector.rawId) return 3;
52 
53  GlobalPixel global = {detector.row, detector.col};
54  //LogTrace("")<<"GLOBAL PIXEL: row=" << global.row <<" col="<< global.col;
55 
56  LocalPixel local = roc->toLocal(global);
57  // LogTrace("")<<"LOCAL PIXEL: dcol ="
58  //<< local.dcol()<<" pxid="<< local.pxid()<<" inside: " <<local.valid();
59 
60  if(!local.valid()) continue;
61  ElectronicIndex cabIdx = {static_cast<int>(it->link),
62  static_cast<int>(it->roc), local.dcol(), local.pxid()};
63  cabling = cabIdx;
64  return 0;
65  }
66  return 1;
67 }
68 
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
LocalPixel toLocal(const GlobalPixel &glo) const
Definition: PixelROC.h:48
SiPixelFedCablingTree const * theTree
uint32_t rawId() const
return the DetUnit to which this ROC belongs to.
Definition: PixelROC.h:37
std::vector< LinkConnSpec >::const_iterator IT
virtual bool pathToDetUnitHasDetUnit(uint32_t rawDetId, unsigned int fedId) const =0
virtual const sipixelobjects::PixelROC * findItem(const sipixelobjects::CablingPathToDetUnit &) const =0
int toCabling(sipixelobjects::ElectronicIndex &cabling, const sipixelobjects::DetectorIndex &detector) const
const SiPixelFedCabling * theMap
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
#define UNLIKELY(x)