00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017 #include "PSCalib/CSPadCalibPars.h"
00018 #include "CSPadPixCoords/CSPadConfigPars.h"
00019 #include "CSPadPixCoords/PixCoordsCSPadV2.h"
00020 #include "CSPadPixCoords/Image2D.h"
00021
00022 #include "ndarray/ndarray.h"
00023
00024 #include <string>
00025 #include <iostream>
00026 #include <time.h>
00027
00028
00029
00030
00031 using namespace std;
00032
00033 typedef PSCalib::CSPadCalibPars CALIB;
00034 typedef CSPadPixCoords::CSPadConfigPars CONFIG;
00035 typedef CSPadPixCoords::PixCoordsCSPadV2 PC;
00036
00037
00038
00039 void test01()
00040 {
00041 PC *pix_coords = new PC();
00042 pix_coords -> printXYLimits();
00043 }
00044
00045
00046
00047 void test02()
00048 {
00049 PC *pix_coords = new PC();
00050 pix_coords -> printXYLimits();
00051
00052
00053 unsigned NX = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00054 unsigned NY = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00055 double* img_arr = new double[NX*NY];
00056 std::fill_n(img_arr, int(NX*NY), double(0));
00057
00058
00059 for (unsigned s=0; s<PC::N2X1_IN_DET; s++){
00060 for (unsigned r=0; r<PC::ROWS2X1; r++){
00061 for (unsigned c=0; c<PC::COLS2X1; c++){
00062
00063 int ix = int (pix_coords -> getPixCoor_pix(PC::AXIS_X, s, r, c) + 0.1);
00064 int iy = int (pix_coords -> getPixCoor_pix(PC::AXIS_Y, s, r, c) + 0.1);
00065
00066
00067 img_arr[ix + iy*NX] = ix;
00068 }
00069 }
00070 }
00071
00072 CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(img_arr,NY,NX);
00073 img2d -> saveImageInFile("test-img.txt",0);
00074 }
00075
00076
00077
00078
00079 void test03()
00080 {
00081
00082 const std::string calibDir = "/reg/d/psdm/cxi/cxitut13/calib";
00083 const std::string groupName = "CsPad::CalibV1";
00084 const std::string source = "CxiDs1.0:Cspad.0";
00085 unsigned runNumber = 10;
00086 CALIB *calibpars = new CALIB(calibDir, groupName, source, runNumber);
00087 calibpars->printCalibPars();
00088
00089 PC *pix_coords = new PC(calibpars);
00090 pix_coords -> printXYLimits();
00091
00092
00093
00094 unsigned NX = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00095 unsigned NY = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00096 double* img_arr = new double[NX*NY];
00097 std::fill_n(img_arr, int(NX*NY), double(0));
00098
00099
00100 for (unsigned s=0; s<PC::N2X1_IN_DET; s++){
00101 for (unsigned r=0; r<PC::ROWS2X1; r++){
00102 for (unsigned c=0; c<PC::COLS2X1; c++){
00103
00104 int ix = int (pix_coords -> getPixCoor_pix(PC::AXIS_X, s, r, c) + 0.1);
00105 int iy = int (pix_coords -> getPixCoor_pix(PC::AXIS_Y, s, r, c) + 0.1);
00106
00107 img_arr[ix + iy*NX] = r+c;
00108 }
00109 }
00110 }
00111
00112 CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(img_arr,NY,NX);
00113 img2d -> saveImageInFile("test-img.txt",0);
00114 }
00115
00116
00117
00118
00119 void test04()
00120 {
00121
00122 const std::string calibDir = "/reg/d/psdm/cxi/cxitut13/calib";
00123 const std::string groupName = "CsPad::CalibV1";
00124 const std::string source = "CxiDs1.0:Cspad.0";
00125 unsigned runNumber = 10;
00126 CALIB *calibpars = new CALIB(calibDir, groupName, source, runNumber);
00127 calibpars->printCalibPars();
00128
00129 PC *pix_coords = new PC(calibpars);
00130 pix_coords -> printXYLimits();
00131
00132 uint32_t numQuads = 4;
00133 uint32_t quadNumber[] = {0,1,2,3};
00134 uint32_t roiMask[] = {0375,0337,0177,0376};
00135 CONFIG *config = new CONFIG( numQuads, quadNumber, roiMask );
00136 config -> printCSPadConfigPars();
00137
00138
00139
00140 unsigned NX = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00141 unsigned NY = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);
00142 double* img_arr = new double[NX*NY];
00143 std::fill_n(img_arr, int(NX*NY), double(0));
00144
00145
00146 ndarray<double,3> nda_pix_coord_x = pix_coords -> getPixCoorNDArrShapedAsData_um (PC::AXIS_X, config);
00147 ndarray<double,3> nda_pix_coord_y = pix_coords -> getPixCoorNDArrShapedAsData_um (PC::AXIS_Y, config);
00148
00149
00150
00151
00152
00153
00154
00155
00156
00157
00158
00159
00160
00161
00162
00163
00164
00165
00166
00167 int ix, iy;
00168 ndarray<double, 3>::iterator xit;
00169 ndarray<double, 3>::iterator yit;
00170 for(xit=nda_pix_coord_x.begin(), yit=nda_pix_coord_y.begin(); xit!=nda_pix_coord_x.end(); ++xit, ++yit) {
00171 ix = int ( *xit * PC::UM_TO_PIX + 0.1);
00172 iy = int ( *yit * PC::UM_TO_PIX + 0.1);
00173 img_arr[ix + iy*NX] = ix+iy;
00174 }
00175
00176
00177 CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(img_arr,NY,NX);
00178 img2d -> saveImageInFile("test-img.txt",0);
00179 }
00180
00181
00182
00183 int main (int argc, char* argv[])
00184 {
00185 cout << "Number of input arguments = " << argc << endl;
00186
00187 if (argc == 1) {test03();}
00188 else if (argc == 2 && atoi(argv[1])==1) {test01();}
00189 else if (argc == 2 && atoi(argv[1])==2) {test02();}
00190 else if (argc == 2 && atoi(argv[1])==3) {test03();}
00191 else if (argc == 2 && atoi(argv[1])==4) {test04();}
00192 else {
00193 cout << "WARNING!!! Unexpected input arguments, argc=" << argc << endl;
00194 for(int i = 0; i < argc; i++)
00195 cout << "argv[" << i << "] = " << argv[i] << endl;
00196 cout << "Use command: " << argv[0] << " N, where N stands for test number 1,2,3,...\n";
00197 }
00198 return 0;
00199 }
00200
00201
00202