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 ( const int  colsInDet,
const int  rowsInDet 
)
inline

Definition at line 46 of file PixelIndices.h.

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

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

Definition at line 62 of file PixelIndices.h.

62 {}

Member Function Documentation

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

Definition at line 253 of file PixelIndices.h.

Referenced by SiPixelDigitizerAlgorithm::initCal().

253  {
254  int rowROC = (chan >> 6) & 0x7F; // reserve 7 bits for row ROC index 0-79
255  int colROC = chan & 0x3F;
256  return std::pair<int,int>(rowROC,colROC);
257  }
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi...
static int PixelIndices::convertDcolToCol ( const int  dcol,
const int  pix,
int &  colROC,
int &  rowROC 
)
inlinestatic

Definition at line 88 of file PixelIndices.h.

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

89  {
90 
91  if(TP_CHECK_LIMITS) {
92  if(dcol<0||dcol>=DColsPerROC||pix<2||pix>161) {
93  std::cout<<"PixelIndices: wrong dcol or pix "<<dcol<<" "<<pix<<std::endl;
94  rowROC = -1; // dummy row Address
95  colROC = -1; // dummy col Address
96  return -1; // Signal error
97  }
98  }
99 
100  // First find if we are in the first or 2nd col of a dcol.
101  int colEvenOdd = pix%2; // module(2), 0-1st sol, 1-2nd col.
102  // Transform
103  colROC = dcol * 2 + colEvenOdd; // col address, starts from 0
104  rowROC = abs( int(pix/2) - 80); // row addres, starts from 0
105 
106  if(TP_CHECK_LIMITS) {
107  if(colROC<0||colROC>=ROCSizeInY||rowROC<0||rowROC>=ROCSizeInX ) {
108  std::cout<<"PixelIndices: wrong col or row "<<colROC<<" "<<rowROC<<" "
109  <<dcol<<" "<<pix<<std::endl;
110  rowROC = -1; // dummy row Address
111  colROC = -1; // dummy col Address
112  return -1;
113  }
114  }
115  return 0;
116  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static int PixelIndices::DColumn ( const int  colROC)
inlinestatic

Definition at line 229 of file PixelIndices.h.

References gather_cfg::cout.

229  {
230 
231  int dColumnId = (colROC)/2; // double column 0-25
232  if(TP_CHECK_LIMITS) {
233  if(dColumnId<0 || dColumnId>=26) {
234  std::cout<<"PixelIndices: wrong dcol index "<<dColumnId<<" "<<colROC<<std::endl;
235  return -1;
236  }
237  }
238  return dColumnId;
239  }
static int PixelIndices::DColumnInModule ( const int  dcol,
const int  chipIndex 
)
inlinestatic

Definition at line 243 of file PixelIndices.h.

243  {
244  int dcolInMod = dcol + chipIndex * 26;
245  return dcolInMod;
246  }
int PixelIndices::numberOfROCsInX ( void  )
inline

Definition at line 65 of file PixelIndices.h.

References theChipsInX.

65 {return theChipsInX;}
int PixelIndices::numberOfROCsInY ( void  )
inline

Definition at line 66 of file PixelIndices.h.

References theChipsInY.

66 {return theChipsInY;}
static int PixelIndices::pixelToChannelROC ( const int  rowROC,
const int  colROC 
)
inlinestatic

Definition at line 250 of file PixelIndices.h.

Referenced by SiPixelDigitizerAlgorithm::initCal().

250  {
251  return (rowROC<<6) | colROC; // reserve 6 bit for col ROC index 0-52
252  }
void PixelIndices::print ( void  ) const
inline

Definition at line 70 of file PixelIndices.h.

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

70  {
71 
72  std::cout << " Pixel det with " << theChipsInX << " chips in x and "
73  << theChipsInY << " in y " << std::endl;
74  std::cout << " Pixel rows " << theRowsInDet << " and columns "
75  << theColsInDet << std::endl;
76  std::cout << " Rows in one chip " << ROCSizeInX << " and columns "
77  << ROCSizeInY << std::endl;
78  std::cout << " Double columns per ROC " << DColsPerROC << std::endl;
79  }
static int PixelIndices::rocIndex ( const int  chipX,
const int  chipY 
)
inlinestatic

Definition at line 206 of file PixelIndices.h.

References gather_cfg::cout.

Referenced by transformToROC().

206  {
207 
208  int rocId = -1;
209  if(TP_CHECK_LIMITS) {
210  if(chipX<0 || chipX>=2 ||chipY<0 || chipY>=8) {
211  std::cout<<"PixelChipIndices: wrong index "<<chipX<<" "<<chipY<<std::endl;
212  return -1;
213  }
214  }
215  if(chipX==0) rocId = chipY + 8; // should be 8-15
216  else if(chipX==1) rocId = 7 - chipY; // should be 0-7
217 
218  if(TP_CHECK_LIMITS) {
219  if(rocId < 0 || rocId >= (maxROCsInX*maxROCsInY) ) {
220  std::cout << "PixelIndices: Error in ROC index " << rocId << std::endl;
221  return -1;
222  }
223  }
224  return rocId;
225  }
int PixelIndices::transformToModule ( const int  colROC,
const int  rowROC,
const int  rocId,
int &  col,
int &  row 
) const
inline

Definition at line 124 of file PixelIndices.h.

References gather_cfg::cout, theChipsInX, and theChipsInY.

126  {
127 
128  if(TP_CHECK_LIMITS) {
129  if(colROC<0 || colROC>=ROCSizeInY || rowROC<0 ||rowROC>=ROCSizeInX) {
130  std::cout<<"PixelIndices: wrong index "<<colROC<<" "<<rowROC<<std::endl;
131  return -1;
132  }
133  }
134 
135  // The transformation depends on the ROC-ID
136  if(rocId>=0 && rocId<8) {
137  row = 159-rowROC;
138  //col = rocId*52 + colROC;
139  col = (8-rocId)*ROCSizeInY - colROC - 1;
140  } else if(rocId>=8 && rocId<16) {
141  row = rowROC;
142  //col = (16-rocId)*52 - colROC - 1;
143  col = (rocId-8)*ROCSizeInY + colROC;
144  } else {
145  std::cout<<"PixelIndices: wrong ROC ID "<<rocId<<std::endl;
146  return -1;
147  }
148  if(TP_CHECK_LIMITS) {
149  if(col<0 || col>=(ROCSizeInY*theChipsInY) || row<0 ||
150  row>=(ROCSizeInX*theChipsInX)) {
151  std::cout<<"PixelIndices: wrong index "<<col<<" "<<row<<std::endl;
152  return -1;
153  }
154  }
155 
156  return 0;
157  }
col
Definition: cuy.py:1010
int PixelIndices::transformToROC ( const int  col,
const int  row,
int &  rocId,
int &  colROC,
int &  rowROC 
) const
inline

Definition at line 163 of file PixelIndices.h.

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

164  {
165 
166  if(TP_CHECK_LIMITS) {
167  if(col<0 || col>=(ROCSizeInY*theChipsInY) || row<0 ||
168  row>=(ROCSizeInX*theChipsInX)) {
169  std::cout<<"PixelIndices: wrong index 3 "<<std::endl;
170  return -1;
171  }
172  }
173 
174  // Get the 2d ROC coordinate
175  int chipX = row / ROCSizeInX; // row index of the chip 0-1
176  int chipY = col / ROCSizeInY; // col index of the chip 0-7
177 
178  // Get the ROC id from the 2D index
179  rocId = rocIndex(chipX,chipY);
180  if(TP_CHECK_LIMITS && (rocId<0 || rocId>=16) ) {
181  std::cout<<"PixelIndices: wrong roc index "<<rocId<<std::endl;
182  return -1;
183  }
184  // get the local ROC coordinates
185  rowROC = (row%ROCSizeInX); // row in chip
186  colROC = (col%ROCSizeInY); // col in chip
187 
188  if(rocId<8) { // For lower 8 ROCs the coordinates are reversed
189  colROC = 51 - colROC;
190  rowROC = 79 - rowROC;
191  }
192 
193  if(TP_CHECK_LIMITS) {
194  if(colROC<0||colROC>=ROCSizeInY||rowROC<0||rowROC>=ROCSizeInX) {
195  std::cout<<"PixelIndices: wrong index "<<colROC<<" "<<rowROC<<std::endl;
196  return -1;
197  }
198  }
199 
200  return 0;
201  }
static int rocIndex(const int chipX, const int chipY)
Definition: PixelIndices.h:206
col
Definition: cuy.py:1010

Member Data Documentation

int PixelIndices::theChipsInX
private
int PixelIndices::theChipsInY
private
int PixelIndices::theColsInDet
private

Definition at line 263 of file PixelIndices.h.

Referenced by PixelIndices(), and print().

int PixelIndices::theRowsInDet
private

Definition at line 264 of file PixelIndices.h.

Referenced by PixelIndices(), and print().