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;
53 if(theChipsInX<1 || theChipsInX>maxROCsInX)
54 std::cout <<
" PixelIndices: Error in ROCsInX "
56 if(theChipsInY<1 || theChipsInY>maxROCsInY)
57 std::cout <<
" PixelIndices: Error in ROCsInY "
76 std::cout <<
" Rows in one chip " << ROCSizeInX <<
" and columns "
77 << ROCSizeInY << std::endl;
78 std::cout <<
" Double columns per ROC " << DColsPerROC << std::endl;
89 int & colROC,
int & rowROC) {
92 if(dcol<0||dcol>=DColsPerROC||pix<2||pix>161) {
93 std::cout<<
"PixelIndices: wrong dcol or pix "<<dcol<<
" "<<pix<<std::endl;
101 int colEvenOdd = pix%2;
103 colROC = dcol * 2 + colEvenOdd;
104 rowROC =
abs(
int(pix/2) - 80);
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;
126 int &
col,
int & row )
const {
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;
136 if(rocId>=0 && rocId<8) {
139 col = (8-rocId)*ROCSizeInY - colROC - 1;
140 }
else if(rocId>=8 && rocId<16) {
143 col = (rocId-8)*ROCSizeInY + colROC;
145 std::cout<<
"PixelIndices: wrong ROC ID "<<rocId<<std::endl;
148 if(TP_CHECK_LIMITS) {
149 if(col<0 || col>=(ROCSizeInY*
theChipsInY) || row<0 ||
151 std::cout<<
"PixelIndices: wrong index "<<col<<
" "<<row<<std::endl;
164 int & rocId,
int & colROC,
int & rowROC )
const {
166 if(TP_CHECK_LIMITS) {
167 if(col<0 || col>=(ROCSizeInY*
theChipsInY) || row<0 ||
169 std::cout<<
"PixelIndices: wrong index 3 "<<std::endl;
175 int chipX = row / ROCSizeInX;
176 int chipY = col / ROCSizeInY;
180 if(TP_CHECK_LIMITS && (rocId<0 || rocId>=16) ) {
181 std::cout<<
"PixelIndices: wrong roc index "<<rocId<<std::endl;
185 rowROC = (row%ROCSizeInX);
186 colROC = (col%ROCSizeInY);
189 colROC = 51 - colROC;
190 rowROC = 79 - rowROC;
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;
206 inline static int rocIndex(
const int chipX,
const int chipY) {
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;
215 if(chipX==0) rocId = chipY + 8;
216 else if(chipX==1) rocId = 7 - chipY;
218 if(TP_CHECK_LIMITS) {
219 if(rocId < 0 || rocId >= (maxROCsInX*maxROCsInY) ) {
220 std::cout <<
"PixelIndices: Error in ROC index " << rocId << std::endl;
231 int dColumnId = (colROC)/2;
232 if(TP_CHECK_LIMITS) {
233 if(dColumnId<0 || dColumnId>=26) {
234 std::cout<<
"PixelIndices: wrong dcol index "<<dColumnId<<
" "<<colROC<<std::endl;
244 int dcolInMod = dcol + chipIndex * 26;
251 return (rowROC<<6) | colROC;
254 int rowROC = (chan >> 6) & 0x7F;
255 int colROC = chan & 0x3F;
256 return std::pair<int,int>(rowROC,colROC);
int numberOfROCsInY(void)
static int DColumn(const int colROC)
int transformToROC(const int col, const int row, int &rocId, int &colROC, int &rowROC) const
static int rocIndex(const int chipX, const int chipY)
PixelIndices(const int colsInDet, const int rowsInDet)
int numberOfROCsInX(void)
static int pixelToChannelROC(const int rowROC, const int colROC)
static int convertDcolToCol(const int dcol, const int pix, int &colROC, int &rowROC)
static std::pair< int, int > channelToPixelROC(const int chan)
static int DColumnInModule(const int dcol, const int chipIndex)
int transformToModule(const int colROC, const int rowROC, const int rocId, int &col, int &row) const