CMS 3D CMS Logo

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

#include <CTPPSPixelIndices.h>

Public Member Functions

 CTPPSPixelIndices ()
 
 CTPPSPixelIndices (const int colsInDet, const int rowsInDet)
 
int getDefaultColDetSize () const
 
int getDefaultRowDetSize () const
 
int getROCId (const int col, const int row) const
 
bool isOnEdge (const int col, const int row) const
 
int numberOfROCsInX (void)
 
int numberOfROCsInY (void)
 
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
 
 ~CTPPSPixelIndices ()
 

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 74 of file CTPPSPixelIndices.h.

Constructor & Destructor Documentation

CTPPSPixelIndices::CTPPSPixelIndices ( )
inline

Definition at line 81 of file CTPPSPixelIndices.h.

References theChipsInX, theChipsInY, theColsInDet, and theRowsInDet.

81  :
82  theColsInDet(defaultDetSizeInY), theRowsInDet (defaultDetSizeInX) {
83 
84  theChipsInX = theRowsInDet / ROCSizeInX; // number of ROCs in X
85  theChipsInY = theColsInDet / ROCSizeInY; // number of ROCs in Y
86 
87  if(CTPPS_CHECK_LIMITS) {
88  if(theChipsInX<1 || theChipsInX>maxROCsInX)
89  edm::LogError("RPix") << " CTPPSPixelIndices: Error in ROCsInX "
90  << theChipsInX <<" "<<theRowsInDet<<" "<<ROCSizeInX;
91  if(theChipsInY<1 || theChipsInY>maxROCsInY)
92  edm::LogError("RPix") << " CTPPSPixelIndices: Error in ROCsInY "
93  << theChipsInY <<" "<<theColsInDet<<" "<<ROCSizeInY;
94  }
95  }
CTPPSPixelIndices::CTPPSPixelIndices ( const int  colsInDet,
const int  rowsInDet 
)
inline

Definition at line 97 of file CTPPSPixelIndices.h.

References theChipsInX, theChipsInY, theColsInDet, and theRowsInDet.

97  :
98  theColsInDet(colsInDet), theRowsInDet (rowsInDet) {
99 
100  theChipsInX = theRowsInDet / ROCSizeInX; // number of ROCs in X
101  theChipsInY = theColsInDet / ROCSizeInY; // number of ROCs in Y
102 
103  if(CTPPS_CHECK_LIMITS) {
104  if(theChipsInX<1 || theChipsInX>maxROCsInX)
105  edm::LogError("RPix") << " CTPPSPixelIndices: Error in ROCsInX "
106  << theChipsInX <<" "<<theRowsInDet<<" "<<ROCSizeInX;
107  if(theChipsInY<1 || theChipsInY>maxROCsInY)
108  edm::LogError("RPix") << " CTPPSPixelIndices: Error in ROCsInY "
109  << theChipsInY <<" "<<theColsInDet<<" "<<ROCSizeInY;
110  }
111  }
CTPPSPixelIndices::~CTPPSPixelIndices ( )
inline

Definition at line 113 of file CTPPSPixelIndices.h.

113 {}

Member Function Documentation

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

Definition at line 339 of file CTPPSPixelIndices.h.

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

Definition at line 136 of file CTPPSPixelIndices.h.

References funct::abs().

Referenced by CTPPSPixelROC::toGlobalfromDcol().

137  {
138 
139  if(CTPPS_CHECK_LIMITS) {
140  if(dcol<0||dcol>=DColsPerROC||pix<2||pix>161) {
141  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong dcol or pix "<<dcol<<" "<<pix;
142  rowROC = -1; // dummy row Address
143  colROC = -1; // dummy col Address
144  return -1; // Signal error
145  }
146  }
147 
148  // First find if we are in the first or 2nd col of a dcol.
149  int colEvenOdd = pix%2; // module(2), 0-1st sol, 1-2nd col.
150  // Transform
151  colROC = dcol * 2 + colEvenOdd; // col address, starts from 0
152  rowROC = abs( int(pix/2) - 80); // row addres, starts from 0
153 
154  if(CTPPS_CHECK_LIMITS) {
155  if(colROC<0||colROC>=ROCSizeInY||rowROC<0||rowROC>=ROCSizeInX ) {
156  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong col or row "<<colROC<<" "<<rowROC<<" "
157  <<dcol<<" "<<pix;
158  rowROC = -1; // dummy row Address
159  colROC = -1; // dummy col Address
160  return -1;
161  }
162  }
163  return 0;
164  }
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static int CTPPSPixelIndices::DColumn ( const int  colROC)
inlinestatic

Definition at line 315 of file CTPPSPixelIndices.h.

315  {
316 
317  int dColumnId = (colROC)/2; // double column 0-25
318  if(CTPPS_CHECK_LIMITS) {
319  if(dColumnId<0 || dColumnId>=26) {
320  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong dcol index "<<dColumnId<<" "<<colROC;
321  return -1;
322  }
323  }
324  return dColumnId;
325  }
static int CTPPSPixelIndices::DColumnInModule ( const int  dcol,
const int  chipIndex 
)
inlinestatic

Definition at line 329 of file CTPPSPixelIndices.h.

329  {
330  int dcolInMod = dcol + chipIndex * 26;
331  return dcolInMod;
332  }
int CTPPSPixelIndices::getDefaultColDetSize ( ) const
inline

Definition at line 346 of file CTPPSPixelIndices.h.

Referenced by CTPPSPixelDQMSource::dqmBeginRun(), and RPixClusterToHit::make_hit().

346 { return defaultDetSizeInY;}
int CTPPSPixelIndices::getDefaultRowDetSize ( ) const
inline

Definition at line 345 of file CTPPSPixelIndices.h.

Referenced by CTPPSPixelDQMSource::dqmBeginRun(), and RPixClusterToHit::make_hit().

345 { return defaultDetSizeInX;}
int CTPPSPixelIndices::getROCId ( const int  col,
const int  row 
) const
inline

Definition at line 252 of file CTPPSPixelIndices.h.

References rocIndex(), theChipsInX, and theChipsInY.

Referenced by RPixClusterToHit::make_hit().

252  {
253 
254  int rocId = -1;
255 
256  if(CTPPS_CHECK_LIMITS) {
257  if(col<0 || col>=(ROCSizeInY*theChipsInY) || row<0 ||
258  row>=(ROCSizeInX*theChipsInX)) {
259  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong index ";
260  return -1;
261  }
262  }
263 
264  // Get the 2d ROC coordinate
265  int chipX = row / ROCSizeInX; // row index of the chip 0-1
266  int chipY = col / ROCSizeInY; // col index of the chip 0-2
267 
268  // Get the ROC id from the 2D index
269  rocId = rocIndex(chipX,chipY);
270  if(CTPPS_CHECK_LIMITS && (rocId<0 || rocId>=6) ) {
271  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong roc index "<<rocId;
272  return -1;
273  }
274 
275  return rocId;
276  }
static int rocIndex(const int chipX, const int chipY)
col
Definition: cuy.py:1009
bool CTPPSPixelIndices::isOnEdge ( const int  col,
const int  row 
) const
inline

Definition at line 281 of file CTPPSPixelIndices.h.

281  {
282  if(col == 0 || row == 0 || col == (defaultDetSizeInY-1) || row == (defaultDetSizeInX-1)) return true;
283  return false;
284  }
col
Definition: cuy.py:1009
int CTPPSPixelIndices::numberOfROCsInX ( void  )
inline

Definition at line 115 of file CTPPSPixelIndices.h.

References theChipsInX.

115 {return theChipsInX;}
int CTPPSPixelIndices::numberOfROCsInY ( void  )
inline

Definition at line 116 of file CTPPSPixelIndices.h.

References theChipsInY.

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

Definition at line 336 of file CTPPSPixelIndices.h.

336  {
337  return (rowROC<<6) | colROC; // reserve 6 bit for col ROC index 0-52
338  }
void CTPPSPixelIndices::print ( void  ) const
inline

Definition at line 118 of file CTPPSPixelIndices.h.

References theChipsInX, theChipsInY, theColsInDet, and theRowsInDet.

118  {
119 
120  edm::LogInfo("RPix") << " Pixel det with " << theChipsInX << " chips in x and "
121  << theChipsInY << " in y " ;
122  edm::LogInfo("RPix") << " Pixel rows " << theRowsInDet << " and columns "
123  << theColsInDet ;
124  edm::LogInfo("RPix") << " Rows in one chip " << ROCSizeInX << " and columns "
125  << ROCSizeInY ;
126  edm::LogInfo("RPix") << " Double columns per ROC " << DColsPerROC ;
127  }
static int CTPPSPixelIndices::rocIndex ( const int  chipX,
const int  chipY 
)
inlinestatic

Definition at line 292 of file CTPPSPixelIndices.h.

Referenced by getROCId(), and transformToROC().

292  {
293 
294  int rocId = -1;
295  if(CTPPS_CHECK_LIMITS) {
296  if(chipX<0 || chipX>=2 ||chipY<0 || chipY>=3) {
297  edm::LogError("RPix")<<"PixelChipIndices: wrong index "<<chipX<<" "<<chipY;
298  return -1;
299  }
300  }
301  if(chipX==0) rocId = 5 - chipY; // should be 3-5
302  else if(chipX==1) rocId = chipY; // should be 0-2
303 
304  if(CTPPS_CHECK_LIMITS) {
305  if(rocId < 0 || rocId >= (maxROCsInX*maxROCsInY) ) {
306  edm::LogError("RPix") << "CTPPSPixelIndices: Error in ROC index " << rocId ;
307  return -1;
308  }
309  }
310  return rocId;
311  }
int CTPPSPixelIndices::transformToModule ( const int  colROC,
const int  rowROC,
const int  rocId,
int &  col,
int &  row 
) const
inline

Definition at line 172 of file CTPPSPixelIndices.h.

References theChipsInX, and theChipsInY.

Referenced by CTPPSPixelROC::toGlobal(), and CTPPSPixelROC::toGlobalfromDcol().

174  {
175  if(CTPPS_CHECK_LIMITS) {
176  if(colROC<0 || colROC>=ROCSizeInY || rowROC<0 ||rowROC>=ROCSizeInX) {
177  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong index "<<colROC<<" "<<rowROC;
178  return -1;
179  }
180  }
181 
182 // The transformation depends on the ROC-ID
183  if(rocId>=0 && rocId<3) {
184  row = 159-rowROC;
185 
186  col = (rocId+1)*ROCSizeInY - colROC - 1 ;
187  } else if(rocId>=3 && rocId<6) {
188  row = rowROC;
189 
190  col = (5-rocId)*ROCSizeInY + colROC;
191  } else {
192  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong ROC ID "<<rocId;
193  return -1;
194  }
195  if(CTPPS_CHECK_LIMITS) {
196  if(col<0 || col>=(ROCSizeInY*theChipsInY) || row<0 ||
197  row>=(ROCSizeInX*theChipsInX)) {
198  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong index "<<col<<" "<<row;
199  return -1;
200  }
201  }
202 
203  return 0;
204 
205  }
col
Definition: cuy.py:1009
int CTPPSPixelIndices::transformToROC ( const int  col,
const int  row,
int &  rocId,
int &  colROC,
int &  rowROC 
) const
inline

Definition at line 211 of file CTPPSPixelIndices.h.

References rocIndex(), theChipsInX, and theChipsInY.

Referenced by CTPPSPixelDQMSource::analyze(), and CTPPSPixelROC::toLocal().

212  {
213  if(CTPPS_CHECK_LIMITS) {
214  if(col<0 || col>=(ROCSizeInY*theChipsInY) || row<0 ||
215  row>=(ROCSizeInX*theChipsInX)) {
216  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong index 3 ";
217  return -1;
218  }
219  }
220 
221 // Get the 2d ROC coordinate
222  int chipX = row / ROCSizeInX; // row index of the chip 0-1
223  int chipY = col / ROCSizeInY; // col index of the chip 0-2
224 
225 // Get the ROC id from the 2D index
226  rocId = rocIndex(chipX,chipY);
227  if(CTPPS_CHECK_LIMITS && (rocId<0 || rocId>=6) ) {
228  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong roc index "<<rocId;
229  return -1;
230  }
231 // get the local ROC coordinates
232  rowROC = (row%ROCSizeInX); // row in chip
233  colROC = (col%ROCSizeInY); // col in chip
234 
235  if(rocId<3) {
236  colROC = 51 - colROC;
237  rowROC = 79 - rowROC;
238  }
239 
240  if(CTPPS_CHECK_LIMITS) {
241  if(colROC<0||colROC>=ROCSizeInY||rowROC<0||rowROC>=ROCSizeInX) {
242  edm::LogError("RPix")<<"CTPPSPixelIndices: wrong index "<<colROC<<" "<<rowROC;
243  return -1;
244  }
245  }
246 
247  return 0;
248  }
static int rocIndex(const int chipX, const int chipY)
col
Definition: cuy.py:1009

Member Data Documentation

int CTPPSPixelIndices::theChipsInX
private
int CTPPSPixelIndices::theChipsInY
private
int CTPPSPixelIndices::theColsInDet
private

Definition at line 352 of file CTPPSPixelIndices.h.

Referenced by CTPPSPixelIndices(), and print().

int CTPPSPixelIndices::theRowsInDet
private

Definition at line 353 of file CTPPSPixelIndices.h.

Referenced by CTPPSPixelIndices(), and print().