CMS 3D CMS Logo

List of all members | Public Member Functions | Static Public Member Functions | Private Attributes
PixelIndices Class Reference

#include <PixelIndices.h>

Public Member Functions

int numberOfROCsInX (void)
 
int numberOfROCsInY (void)
 
 PixelIndices (const int colsInDet, const int rowsInDet)
 
void print (void) const
 
int transformToModule (const int colROC, const int rowROC, const int rocId, int &col, int &row) const
 
int transformToROC (const int col, const int row, int &rocId, int &colROC, int &rowROC) const
 
 ~PixelIndices ()
 

Static Public Member Functions

static std::pair< int, int > channelToPixelROC (const int chan)
 
static int convertDcolToCol (const int dcol, const int pix, int &colROC, int &rowROC)
 
static int DColumn (const int colROC)
 
static int DColumnInModule (const int dcol, const int chipIndex)
 
static int pixelToChannelROC (const int rowROC, const int colROC)
 
static int rocIndex (const int chipX, const int chipY)
 

Private Attributes

int theChipsInX
 
int theChipsInY
 
int theColsInDet
 
int theRowsInDet
 

Detailed Description

Definition at line 40 of file PixelIndices.h.

Constructor & Destructor Documentation

◆ PixelIndices()

PixelIndices::PixelIndices ( const int  colsInDet,
const int  rowsInDet 
)
inline

Definition at line 44 of file PixelIndices.h.

44  : theColsInDet(colsInDet), theRowsInDet(rowsInDet) {
45  theChipsInX = theRowsInDet / ROCSizeInX; // number of ROCs in X
46  theChipsInY = theColsInDet / ROCSizeInY; // number of ROCs in Y
47 
48  if (TP_CHECK_LIMITS) {
49  if (theChipsInX < 1 || theChipsInX > maxROCsInX)
50  std::cout << " PixelIndices: Error in ROCsInX " << theChipsInX << " " << theRowsInDet << " " << ROCSizeInX
51  << std::endl;
52  if (theChipsInY < 1 || theChipsInY > maxROCsInY)
53  std::cout << " PixelIndices: Error in ROCsInY " << theChipsInY << " " << theColsInDet << " " << ROCSizeInY
54  << std::endl;
55  }
56  }

References gather_cfg::cout, theChipsInX, theChipsInY, theColsInDet, and theRowsInDet.

◆ ~PixelIndices()

PixelIndices::~PixelIndices ( )
inline

Definition at line 58 of file PixelIndices.h.

58 {}

Member Function Documentation

◆ channelToPixelROC()

static std::pair<int, int> PixelIndices::channelToPixelROC ( const int  chan)
inlinestatic

Definition at line 236 of file PixelIndices.h.

236  {
237  int rowROC = (chan >> 6) & 0x7F; // reserve 7 bits for row ROC index 0-79
238  int colROC = chan & 0x3F;
239  return std::pair<int, int>(rowROC, colROC);
240  }

References officialStyle::chan.

Referenced by SiPixelDigitizerAlgorithm::initCal().

◆ convertDcolToCol()

static int PixelIndices::convertDcolToCol ( const int  dcol,
const int  pix,
int &  colROC,
int &  rowROC 
)
inlinestatic

Definition at line 80 of file PixelIndices.h.

80  {
81  if (TP_CHECK_LIMITS) {
82  if (dcol < 0 || dcol >= DColsPerROC || pix < 2 || pix > 161) {
83  std::cout << "PixelIndices: wrong dcol or pix " << dcol << " " << pix << std::endl;
84  rowROC = -1; // dummy row Address
85  colROC = -1; // dummy col Address
86  return -1; // Signal error
87  }
88  }
89 
90  // First find if we are in the first or 2nd col of a dcol.
91  int colEvenOdd = pix % 2; // module(2), 0-1st sol, 1-2nd col.
92  // Transform
93  colROC = dcol * 2 + colEvenOdd; // col address, starts from 0
94  rowROC = abs(int(pix / 2) - 80); // row addres, starts from 0
95 
96  if (TP_CHECK_LIMITS) {
97  if (colROC < 0 || colROC >= ROCSizeInY || rowROC < 0 || rowROC >= ROCSizeInX) {
98  std::cout << "PixelIndices: wrong col or row " << colROC << " " << rowROC << " " << dcol << " " << pix
99  << std::endl;
100  rowROC = -1; // dummy row Address
101  colROC = -1; // dummy col Address
102  return -1;
103  }
104  }
105  return 0;
106  }

References funct::abs(), and gather_cfg::cout.

◆ DColumn()

static int PixelIndices::DColumn ( const int  colROC)
inlinestatic

Definition at line 213 of file PixelIndices.h.

213  {
214  int dColumnId = (colROC) / 2; // double column 0-25
215  if (TP_CHECK_LIMITS) {
216  if (dColumnId < 0 || dColumnId >= 26) {
217  std::cout << "PixelIndices: wrong dcol index " << dColumnId << " " << colROC << std::endl;
218  return -1;
219  }
220  }
221  return dColumnId;
222  }

References gather_cfg::cout.

◆ DColumnInModule()

static int PixelIndices::DColumnInModule ( const int  dcol,
const int  chipIndex 
)
inlinestatic

Definition at line 226 of file PixelIndices.h.

226  {
227  int dcolInMod = dcol + chipIndex * 26;
228  return dcolInMod;
229  }

◆ numberOfROCsInX()

int PixelIndices::numberOfROCsInX ( void  )
inline

Definition at line 61 of file PixelIndices.h.

61 { return theChipsInX; }

References theChipsInX.

◆ numberOfROCsInY()

int PixelIndices::numberOfROCsInY ( void  )
inline

Definition at line 62 of file PixelIndices.h.

62 { return theChipsInY; }

References theChipsInY.

◆ pixelToChannelROC()

static int PixelIndices::pixelToChannelROC ( const int  rowROC,
const int  colROC 
)
inlinestatic

Definition at line 233 of file PixelIndices.h.

233  {
234  return (rowROC << 6) | colROC; // reserve 6 bit for col ROC index 0-52
235  }

Referenced by SiPixelDigitizerAlgorithm::initCal().

◆ print()

void PixelIndices::print ( void  ) const
inline

Definition at line 66 of file PixelIndices.h.

66  {
67  std::cout << " Pixel det with " << theChipsInX << " chips in x and " << theChipsInY << " in y " << std::endl;
68  std::cout << " Pixel rows " << theRowsInDet << " and columns " << theColsInDet << std::endl;
69  std::cout << " Rows in one chip " << ROCSizeInX << " and columns " << ROCSizeInY << std::endl;
70  std::cout << " Double columns per ROC " << DColsPerROC << std::endl;
71  }

References gather_cfg::cout, theChipsInX, theChipsInY, theColsInDet, and theRowsInDet.

◆ rocIndex()

static int PixelIndices::rocIndex ( const int  chipX,
const int  chipY 
)
inlinestatic

Definition at line 189 of file PixelIndices.h.

189  {
190  int rocId = -1;
191  if (TP_CHECK_LIMITS) {
192  if (chipX < 0 || chipX >= 2 || chipY < 0 || chipY >= 8) {
193  std::cout << "PixelChipIndices: wrong index " << chipX << " " << chipY << std::endl;
194  return -1;
195  }
196  }
197  if (chipX == 0)
198  rocId = chipY + 8; // should be 8-15
199  else if (chipX == 1)
200  rocId = 7 - chipY; // should be 0-7
201 
202  if (TP_CHECK_LIMITS) {
203  if (rocId < 0 || rocId >= (maxROCsInX * maxROCsInY)) {
204  std::cout << "PixelIndices: Error in ROC index " << rocId << std::endl;
205  return -1;
206  }
207  }
208  return rocId;
209  }

References gather_cfg::cout.

Referenced by transformToROC().

◆ transformToModule()

int PixelIndices::transformToModule ( const int  colROC,
const int  rowROC,
const int  rocId,
int &  col,
int &  row 
) const
inline

Definition at line 114 of file PixelIndices.h.

114  {
115  if (TP_CHECK_LIMITS) {
116  if (colROC < 0 || colROC >= ROCSizeInY || rowROC < 0 || rowROC >= ROCSizeInX) {
117  std::cout << "PixelIndices: wrong index " << colROC << " " << rowROC << std::endl;
118  return -1;
119  }
120  }
121 
122  // The transformation depends on the ROC-ID
123  if (rocId >= 0 && rocId < 8) {
124  row = 159 - rowROC;
125  //col = rocId*52 + colROC;
126  col = (8 - rocId) * ROCSizeInY - colROC - 1;
127  } else if (rocId >= 8 && rocId < 16) {
128  row = rowROC;
129  //col = (16-rocId)*52 - colROC - 1;
130  col = (rocId - 8) * ROCSizeInY + colROC;
131  } else {
132  std::cout << "PixelIndices: wrong ROC ID " << rocId << std::endl;
133  return -1;
134  }
135  if (TP_CHECK_LIMITS) {
136  if (col < 0 || col >= (ROCSizeInY * theChipsInY) || row < 0 || row >= (ROCSizeInX * theChipsInX)) {
137  std::cout << "PixelIndices: wrong index " << col << " " << row << std::endl;
138  return -1;
139  }
140  }
141 
142  return 0;
143  }

References cuy::col, gather_cfg::cout, theChipsInX, and theChipsInY.

◆ transformToROC()

int PixelIndices::transformToROC ( const int  col,
const int  row,
int &  rocId,
int &  colROC,
int &  rowROC 
) const
inline

Definition at line 149 of file PixelIndices.h.

149  {
150  if (TP_CHECK_LIMITS) {
151  if (col < 0 || col >= (ROCSizeInY * theChipsInY) || row < 0 || row >= (ROCSizeInX * theChipsInX)) {
152  std::cout << "PixelIndices: wrong index 3 " << std::endl;
153  return -1;
154  }
155  }
156 
157  // Get the 2d ROC coordinate
158  int chipX = row / ROCSizeInX; // row index of the chip 0-1
159  int chipY = col / ROCSizeInY; // col index of the chip 0-7
160 
161  // Get the ROC id from the 2D index
162  rocId = rocIndex(chipX, chipY);
163  if (TP_CHECK_LIMITS && (rocId < 0 || rocId >= 16)) {
164  std::cout << "PixelIndices: wrong roc index " << rocId << std::endl;
165  return -1;
166  }
167  // get the local ROC coordinates
168  rowROC = (row % ROCSizeInX); // row in chip
169  colROC = (col % ROCSizeInY); // col in chip
170 
171  if (rocId < 8) { // For lower 8 ROCs the coordinates are reversed
172  colROC = 51 - colROC;
173  rowROC = 79 - rowROC;
174  }
175 
176  if (TP_CHECK_LIMITS) {
177  if (colROC < 0 || colROC >= ROCSizeInY || rowROC < 0 || rowROC >= ROCSizeInX) {
178  std::cout << "PixelIndices: wrong index " << colROC << " " << rowROC << std::endl;
179  return -1;
180  }
181  }
182 
183  return 0;
184  }

References cuy::col, gather_cfg::cout, rocIndex(), theChipsInX, and theChipsInY.

Member Data Documentation

◆ theChipsInX

int PixelIndices::theChipsInX
private

◆ theChipsInY

int PixelIndices::theChipsInY
private

◆ theColsInDet

int PixelIndices::theColsInDet
private

Definition at line 244 of file PixelIndices.h.

Referenced by PixelIndices(), and print().

◆ theRowsInDet

int PixelIndices::theRowsInDet
private

Definition at line 245 of file PixelIndices.h.

Referenced by PixelIndices(), and print().

cuy.col
col
Definition: cuy.py:1009
gather_cfg.cout
cout
Definition: gather_cfg.py:144
PixelIndices::theChipsInX
int theChipsInX
Definition: PixelIndices.h:246
PixelIndices::theChipsInY
int theChipsInY
Definition: PixelIndices.h:247
PixelIndices::theRowsInDet
int theRowsInDet
Definition: PixelIndices.h:245
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
PixelIndices::rocIndex
static int rocIndex(const int chipX, const int chipY)
Definition: PixelIndices.h:189
PixelIndices::theColsInDet
int theColsInDet
Definition: PixelIndices.h:244