1 #ifndef TP_PIXELINDICES_H
2 #define TP_PIXELINDICES_H
24 const int maxROCsInX = 2;
26 const int maxROCsInY = 8;
28 const int DColsPerROC = 26;
30 const int ROCSizeInX = 80;
31 const int ROCSizeInY = 52;
33 const int defaultDetSizeInX = 160;
34 const int defaultDetSizeInY = 416;
37 const bool TP_CHECK_LIMITS =
true;
48 if (TP_CHECK_LIMITS) {
49 if (theChipsInX < 1 || theChipsInX > maxROCsInX)
52 if (theChipsInY < 1 || theChipsInY > maxROCsInY)
69 std::cout <<
" Rows in one chip " << ROCSizeInX <<
" and columns " << ROCSizeInY << std::endl;
70 std::cout <<
" Double columns per ROC " << DColsPerROC << std::endl;
80 inline static int convertDcolToCol(
const int dcol,
const int pix,
int& colROC,
int& rowROC) {
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;
91 int colEvenOdd = pix % 2;
93 colROC = dcol * 2 + colEvenOdd;
94 rowROC =
abs(
int(pix / 2) - 80);
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
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;
123 if (rocId >= 0 && rocId < 8) {
126 col = (8 - rocId) * ROCSizeInY - colROC - 1;
127 }
else if (rocId >= 8 && rocId < 16) {
130 col = (rocId - 8) * ROCSizeInY + colROC;
132 std::cout <<
"PixelIndices: wrong ROC ID " << rocId << std::endl;
135 if (TP_CHECK_LIMITS) {
137 std::cout <<
"PixelIndices: wrong index " <<
col <<
" " << row << std::endl;
150 if (TP_CHECK_LIMITS) {
152 std::cout <<
"PixelIndices: wrong index 3 " << std::endl;
158 int chipX = row / ROCSizeInX;
159 int chipY =
col / ROCSizeInY;
163 if (TP_CHECK_LIMITS && (rocId < 0 || rocId >= 16)) {
164 std::cout <<
"PixelIndices: wrong roc index " << rocId << std::endl;
168 rowROC = (row % ROCSizeInX);
169 colROC = (
col % ROCSizeInY);
172 colROC = 51 - colROC;
173 rowROC = 79 - rowROC;
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;
189 inline static int rocIndex(
const int chipX,
const int chipY) {
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;
202 if (TP_CHECK_LIMITS) {
203 if (rocId < 0 || rocId >= (maxROCsInX * maxROCsInY)) {
204 std::cout <<
"PixelIndices: Error in ROC index " << rocId << std::endl;
214 int dColumnId = (colROC) / 2;
215 if (TP_CHECK_LIMITS) {
216 if (dColumnId < 0 || dColumnId >= 26) {
217 std::cout <<
"PixelIndices: wrong dcol index " << dColumnId <<
" " << colROC << std::endl;
227 int dcolInMod = dcol + chipIndex * 26;
234 return (rowROC << 6) | colROC;
237 int rowROC = (
chan >> 6) & 0x7F;
238 int colROC =
chan & 0x3F;
239 return std::pair<int, int>(rowROC, colROC);