00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "CSPadPixCoords/PixCoords2x1.h"
00017
00018
00019
00020
00021
00022 #include <iostream>
00023
00024
00025
00026 using namespace std;
00027
00028
00029
00030
00031
00032 #include "PSCalib/CSPadCalibPars.h"
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042 namespace CSPadPixCoords {
00043
00044
00045
00046
00047
00048 PixCoords2x1::PixCoords2x1 ()
00049 {
00050
00051
00052 m_row_size_um = PSCalib::CSPadCalibPars::getRowSize_um();
00053 m_col_size_um = PSCalib::CSPadCalibPars::getColSize_um();
00054 m_gap_size_um = PSCalib::CSPadCalibPars::getGapSize_um();
00055
00056 k_row_um_to_pix = PSCalib::CSPadCalibPars::getRowUmToPix();
00057 k_col_um_to_pix = PSCalib::CSPadCalibPars::getColUmToPix();
00058 k_ort_um_to_pix = PSCalib::CSPadCalibPars::getOrtUmToPix();
00059
00060 k_center_of_rows_um = 0.5 * (m_row_size_um * ((double)NRows2x1-3.0) + 2 * m_gap_size_um) + 1;
00061 k_center_of_cols_um = 0.5 * m_col_size_um * ((double)NCols2x1-1.0) + 1;
00062
00063 k_center_of_rows_pix = k_center_of_rows_um * k_row_um_to_pix;
00064 k_center_of_cols_pix = k_center_of_cols_um * k_col_um_to_pix;
00065
00066 fill_pix_coords_2x1();
00067 }
00068
00069
00070
00071
00072
00073 PixCoords2x1::~PixCoords2x1 ()
00074 {
00075 }
00076
00077
00078
00079 void PixCoords2x1::fill_pix_coords_2x1()
00080 {
00081 for (int col=0; col<NCols2x1; col++) m_coor_col[col] = col * m_col_size_um;
00082 for (int row=0; row<NRows2x1; row++) {
00083 m_coor_row[row] = (row<NRowsASIC) ? row * m_row_size_um : row * m_row_size_um + m_gap_size_um;
00084 for (int col=0; col<NCols2x1; col++) m_coor_ort[col][row] = 0;
00085 }
00086
00087 m_coor_row_max = m_coor_row[NRows2x1-1];
00088 m_coor_col_max = m_coor_col[NCols2x1-1];
00089 }
00090
00091
00092
00093 void PixCoords2x1::print_member_data()
00094 {
00095 cout << "PixCoords2x1::print_member_data():" << endl
00096 << "NRows2x1 " << NRows2x1 << endl
00097 << "NCols2x1 " << NCols2x1 << endl
00098 << "NRowsASIC " << NRowsASIC << endl
00099 << "m_coor_row_max " << m_coor_row_max << endl
00100 << "m_coor_col_max " << m_coor_col_max << endl
00101 << "m_row_size_um " << m_row_size_um << endl
00102 << "m_col_size_um " << m_col_size_um << endl
00103 << "m_gap_size_um " << m_gap_size_um << endl;
00104 }
00105
00106
00107
00108 void PixCoords2x1::print_selected_coords_2x1(ARRAXIS arraxis)
00109 {
00110 string str_coord;
00111 switch (arraxis)
00112 {
00113 case ROW : str_coord = "ROW"; break;
00114 case COL : str_coord = "COL"; break;
00115 case ORT : str_coord = "ORT"; break;
00116 default : return;
00117 }
00118
00119 cout << "\nPixCoords2x1::print_selected_coords_2x1(" << str_coord << ")\n";
00120 for (int row=0; row<NRows2x1; row+=20) {
00121 for (int col=0; col<NCols2x1; col+=20) {
00122
00123 switch (arraxis)
00124 {
00125 case ROW : cout << m_coor_row[row] << " "; break;
00126 case COL : cout << m_coor_col[col] << " "; break;
00127 case ORT : cout << m_coor_ort[col][row] << " "; break;
00128 default : continue;
00129 }
00130 }
00131 cout << endl;
00132 }
00133 }
00134
00135
00136
00137 double PixCoords2x1::getPixCoorRot000_um (COORDINATE icoor, unsigned row, unsigned col)
00138 {
00139 switch (icoor)
00140 {
00141 case X : return m_coor_row[row];
00142 case Y : return m_coor_col_max - m_coor_col[col];
00143 case Z : return m_coor_ort[col][row];
00144 default: return 0;
00145 }
00146 }
00147
00148
00149
00150 double PixCoords2x1::getPixCoorRot090_um (COORDINATE icoor, unsigned row, unsigned col)
00151 {
00152 switch (icoor)
00153 {
00154 case X : return m_coor_col[col];
00155 case Y : return m_coor_row[row];
00156 case Z : return m_coor_ort[col][row];
00157 default: return 0;
00158 }
00159 }
00160
00161
00162
00163 double PixCoords2x1::getPixCoorRot180_um (COORDINATE icoor, unsigned row, unsigned col)
00164 {
00165 switch (icoor)
00166 {
00167 case X : return m_coor_row_max - m_coor_row[row];
00168 case Y : return m_coor_col[col];
00169 case Z : return m_coor_ort[col][row];
00170 default: return 0;
00171 }
00172 }
00173
00174
00175
00176 double PixCoords2x1::getPixCoorRot270_um (COORDINATE icoor, unsigned row, unsigned col)
00177 {
00178 switch (icoor)
00179 {
00180 case X : return m_coor_col_max - m_coor_col[col];
00181 case Y : return m_coor_row_max - m_coor_row[row];
00182 case Z : return m_coor_ort[col][row];
00183 default: return 0;
00184 }
00185 }
00186
00187
00188
00189 double PixCoords2x1::getPixCoorRotN90_um (ORIENTATION n90, COORDINATE icoor, unsigned row, unsigned col)
00190 {
00191 switch (n90)
00192 {
00193 case R000 : return getPixCoorRot000_um (icoor, row, col);
00194 case R090 : return getPixCoorRot090_um (icoor, row, col);
00195 case R180 : return getPixCoorRot180_um (icoor, row, col);
00196 case R270 : return getPixCoorRot270_um (icoor, row, col);
00197 default : return 0;
00198 }
00199 }
00200
00201
00202
00203
00204 double PixCoords2x1::getPixCoorRot000_pix (COORDINATE icoor, unsigned row, unsigned col)
00205 {
00206 switch (icoor)
00207 {
00208 case X : return k_row_um_to_pix * getPixCoorRot000_um (icoor, row, col);
00209 case Y : return k_col_um_to_pix * getPixCoorRot000_um (icoor, row, col);
00210 case Z : return k_ort_um_to_pix * getPixCoorRot000_um (icoor, row, col);
00211 default: return 0;
00212 }
00213 }
00214
00215
00216
00217 double PixCoords2x1::getPixCoorRot090_pix (COORDINATE icoor, unsigned row, unsigned col)
00218 {
00219 switch (icoor)
00220 {
00221 case X : return k_col_um_to_pix * getPixCoorRot090_um (icoor, row, col);
00222 case Y : return k_row_um_to_pix * getPixCoorRot090_um (icoor, row, col);
00223 case Z : return k_ort_um_to_pix * getPixCoorRot090_um (icoor, row, col);
00224 default: return 0;
00225 }
00226 }
00227
00228
00229
00230 double PixCoords2x1::getPixCoorRot180_pix (COORDINATE icoor, unsigned row, unsigned col)
00231 {
00232 switch (icoor)
00233 {
00234 case X : return k_row_um_to_pix * getPixCoorRot180_um (icoor, row, col);
00235 case Y : return k_col_um_to_pix * getPixCoorRot180_um (icoor, row, col);
00236 case Z : return k_ort_um_to_pix * getPixCoorRot180_um (icoor, row, col);
00237 default: return 0;
00238 }
00239 }
00240
00241
00242
00243 double PixCoords2x1::getPixCoorRot270_pix (COORDINATE icoor, unsigned row, unsigned col)
00244 {
00245 switch (icoor)
00246 {
00247 case X : return k_col_um_to_pix * getPixCoorRot270_um (icoor, row, col);
00248 case Y : return k_row_um_to_pix * getPixCoorRot270_um (icoor, row, col);
00249 case Z : return k_ort_um_to_pix * getPixCoorRot270_um (icoor, row, col);
00250 default: return 0;
00251 }
00252 }
00253
00254
00255
00256 double PixCoords2x1::getPixCoorRotN90_pix (ORIENTATION n90, COORDINATE icoor, unsigned row, unsigned col)
00257 {
00258 switch (n90)
00259 {
00260 case R000 : return getPixCoorRot000_pix (icoor, row, col);
00261 case R090 : return getPixCoorRot090_pix (icoor, row, col);
00262 case R180 : return getPixCoorRot180_pix (icoor, row, col);
00263 case R270 : return getPixCoorRot270_pix (icoor, row, col);
00264 default : return 0;
00265 }
00266 }
00267
00268
00269
00270 double PixCoords2x1::getPixCoorRotN90 ( UNITS units, ORIENTATION n90, COORDINATE icoor, unsigned row, unsigned col)
00271 {
00272 switch (units)
00273 {
00274 case UM : return getPixCoorRotN90_um (n90, icoor, row, col);
00275 case PIX : return getPixCoorRotN90_pix (n90, icoor, row, col);
00276 default : return 0;
00277 }
00278 }
00279
00280
00281
00282 PixCoords2x1::ORIENTATION PixCoords2x1::getOrientation(double angle)
00283 {
00284 if(angle == 0.) return R000;
00285 else if(angle == 90.) return R090;
00286 else if(angle == 180.) return R180;
00287 else if(angle == 270.) return R270;
00288 else return R000;
00289 }
00290
00291
00292
00293 size_t PixCoords2x1::getNCols(ORIENTATION n90)
00294 {
00295 switch (n90)
00296 {
00297 case R000 : return NCols2x1;
00298 case R180 : return NCols2x1;
00299 case R090 : return NRows2x1;
00300 case R270 : return NRows2x1;
00301 default : return NCols2x1;
00302 }
00303 }
00304
00305
00306
00307 size_t PixCoords2x1::getNRows(ORIENTATION n90)
00308 {
00309 switch (n90)
00310 {
00311 case R000 : return NRows2x1;
00312 case R180 : return NRows2x1;
00313 case R090 : return NCols2x1;
00314 case R270 : return NCols2x1;
00315 default : return NRows2x1;
00316 }
00317 }
00318
00319
00320
00321 double PixCoords2x1::getXCenterOffset_um(ORIENTATION n90)
00322 {
00323 switch (n90)
00324 {
00325 case R000 : return k_center_of_rows_um;
00326 case R180 : return k_center_of_rows_um;
00327 case R090 : return k_center_of_cols_um;
00328 case R270 : return k_center_of_cols_um;
00329 default : return k_center_of_rows_um;
00330 }
00331 }
00332
00333
00334
00335 double PixCoords2x1::getYCenterOffset_um(ORIENTATION n90)
00336 {
00337 switch (n90)
00338 {
00339 case R000 : return k_center_of_cols_um;
00340 case R180 : return k_center_of_cols_um;
00341 case R090 : return k_center_of_rows_um;
00342 case R270 : return k_center_of_rows_um;
00343 default : return k_center_of_cols_um;
00344 }
00345 }
00346
00347
00348
00349
00350
00351
00352 }
00353
00354