CSPadPixCoords/test/ex_PixCoordsCSPad2x2V2.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id$
00004 //
00005 // Description:
00006 //      Test class PixCoordsCSPad2x2V2 of the CSPadPixCoords packadge
00007 //
00008 // Author List:
00009 //      Mikhail Dubrovin
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 #include "CSPadPixCoords/PixCoordsCSPad2x2V2.h"
00018 #include "CSPadPixCoords/Image2D.h"
00019 #include "PSCalib/CSPad2x2CalibPars.h"
00020 
00021 #include <string>
00022 #include <iostream>
00023 
00024 //using std::cout;
00025 //using std::endl;
00026 
00027 using namespace std;
00028 
00029 //typedef CSPadPixCoords::PixCoords2x1V2 PC2X1;
00030 typedef CSPadPixCoords::PixCoordsCSPad2x2V2 PC2X2;
00031 typedef PSCalib::CSPad2x2CalibPars CALIB2X2;
00032 
00033 //-----------------
00034 
00035 void test01()
00036 {
00037   PC2X2 *pix_coords_2x2 = new PC2X2();  
00038 
00039   pix_coords_2x2 -> printXYLimits();
00040 }
00041 
00042 //-----------------
00043 
00044 void test02()
00045 {
00046   const unsigned NX=420, NY=420;
00047   double img_arr[NY][NX];
00048   std::fill_n(&img_arr[0][0], int(NX*NY), double(0));
00049 
00050   PC2X2 *pix_coords_2x2 = new PC2X2();  
00051   pix_coords_2x2 -> printXYLimits();
00052 
00053   // Assignment to coordinates
00054 
00055   for (unsigned r=0; r<PC2X2::ROWS2X1; r++){
00056   for (unsigned c=0; c<PC2X2::COLS2X1; c++){
00057   for (unsigned s=0; s<PC2X2::N2X1_IN_DET; s++){
00058 
00059     int ix = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_X, s, r, c) + 0.1);
00060     int iy = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_Y, s, r, c) + 0.1);
00061 
00062     img_arr[ix][iy] = ix;
00063   }
00064   }
00065   }
00066 
00067   CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(&img_arr[0][0],NY,NX);
00068   img2d -> saveImageInFile("test-img.txt",0);
00069 }
00070 
00071 //-----------------
00072 
00073 void test03()
00074 {
00075   const unsigned NX=400, NY=400;
00076   double img_arr[NY][NX];
00077   std::fill_n(&img_arr[0][0], int(NX*NY), double(0));
00078 
00079   //const std::string calibDir  = "/reg/d/psdm/mec/mec73313/calib";
00080   //const std::string groupName = "CsPad2x2::CalibV1";
00081   //const std::string source    = "MecTargetChamber.0:Cspad2x2.3";
00082 
00083   const std::string calibDir  = "/reg/d/psdm/xpp/xpptut13/calib";
00084   const std::string groupName = "CsPad2x2::CalibV1";
00085   const std::string source    = "XppGon.0:Cspad2x2.1";
00086   unsigned          runNumber = 10;
00087   CALIB2X2 *calibpars2x2 = new CALIB2X2(calibDir, groupName, source, runNumber);  
00088   calibpars2x2->printCalibPars();
00089 
00090   PC2X2 *pix_coords_2x2 = new PC2X2(calibpars2x2);  
00091   pix_coords_2x2 -> printXYLimits();
00092 
00093   // Assignment to coordinates
00094 
00095   for (unsigned r=0; r<PC2X2::ROWS2X1; r++){
00096   for (unsigned c=0; c<PC2X2::COLS2X1; c++){
00097   for (unsigned s=0; s<PC2X2::N2X1_IN_DET; s++){
00098 
00099     int ix = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_X, s, r, c) + 0.1);
00100     int iy = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_Y, s, r, c) + 0.1);
00101 
00102     img_arr[ix][iy] = ix+iy;
00103   }
00104   }
00105   }
00106 
00107   CSPadPixCoords::Image2D<double> *img2d = new CSPadPixCoords::Image2D<double>(&img_arr[0][0],NY,NX);
00108   img2d -> saveImageInFile("test-img.txt",0);
00109 }
00110 
00111 //-----------------
00112 
00113 int main ()
00114 {
00115   //test01();
00116   //test02();
00117   test03();
00118 
00119   return 0;
00120 }
00121 
00122 //-----------------
00123 

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7