CSPadPixCoords/include/PixCoordsCSPadV2.h

Go to the documentation of this file.
00001 #ifndef CSPADPIXCOORDS_PIXCOORDSCSPADV2_H
00002 #define CSPADPIXCOORDS_PIXCOORDSCSPADV2_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: PixCoordsCSPadV2.h 8040 2014-04-19 01:00:36Z dubrovin@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class PixCoordsCSPadV2.
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 //----------------------
00018 // Base Class Headers --
00019 //----------------------
00020 
00021 //-------------------------------
00022 // Collaborating Class Headers --
00023 //-------------------------------
00024 #include "CSPadPixCoords/PixCoords2x1V2.h"
00025 #include "CSPadPixCoords/CSPadConfigPars.h"
00026 #include "PSCalib/CSPadCalibPars.h"
00027 #include "ndarray/ndarray.h"
00028 
00029 //------------------------------------
00030 // Collaborating Class Declarations --
00031 //------------------------------------
00032 
00033 //              ---------------------
00034 //              -- Class Interface --
00035 //              ---------------------
00036 
00037 namespace CSPadPixCoords {
00038 
00039 /// @addtogroup CSPadPixCoords
00040 
00041 /**
00042  *  @ingroup CSPadPixCoords
00043  *
00044  *  @brief PixCoordsCSPadV2 class defines the CSPad pixel coordinates in the detector.
00045  *
00046  *  Use the same frame like in optical measurement, but in "matrix style" geometry:
00047  *  X axis goes along rows (from top to bottom)
00048  *  Y axis goes along columns (from left to right)
00049  *
00050  *  This software was developed for the LCLS project.  If you use all or 
00051  *  part of it, please give an appropriate acknowledgment.
00052  *
00053  *  @see CSPadImageProducer, PixCoordsTest
00054  *
00055  *  @version $Id: PixCoordsCSPadV2.h 8040 2014-04-19 01:00:36Z dubrovin@SLAC.STANFORD.EDU $
00056  *
00057  *  @author Mikhail S. Dubrovin
00058  */
00059 
00060 
00061 
00062 /**   
00063  *  <h1>Interface Description</h1>
00064  *   
00065  *  @li  Includes and typedefs
00066  *  @code
00067  *  #include "PSCalib/CSPadCalibPars.h"
00068  *  #include "CSPadPixCoords/CSPadConfigPars.h"
00069  *  #include "CSPadPixCoords/PixCoordsCSPadV2.h"
00070  *
00071  *  typedef PSCalib::CSPadCalibPars CALIB;
00072  *  typedef CSPadPixCoords::CSPadConfigPars CONFIG;
00073  *  typedef CSPadPixCoords::PixCoordsCSPadV2 PC;
00074  *  @endcode
00075  *  
00076  *  @li  Instatiation\n
00077  *  Default constructor does not provide correct CSPAD geometry, but can be used for test or when precise geometry is not important:
00078  *  @code
00079  *        PC *pix_coords = new PC();  
00080  *  @endcode
00081  *  Precise geometry can be obtained using pointer to the store of calibration parameters:
00082  *  @code
00083  *        PC *pix_coords = new PC(calibpars);  
00084  *  @endcode
00085  *  Instatiation of calibration parameters can be done by different ways. For example:
00086  *  @code
00087  *        const std::string calibDir  = "/reg/d/psdm/cxi/cxitut13/calib";
00088  *        const std::string groupName = "CsPad::CalibV1";
00089  *        const std::string source    = "CxiDs1.0:Cspad.0";
00090  *        unsigned          runNumber = 10;
00091  *        CALIB *calibpars = new CALIB(calibDir, groupName, source, runNumber);  
00092  *        calibpars->printCalibPars();
00093  *  @endcode
00094  *  
00095  *  @li  Printing methods\n
00096  *  @code
00097  *        pix_coords -> printXYLimits();
00098  *        pix_coords -> printConstants();
00099  *        unsigned row_begin=15, row_end=20, col_begin=40, col_end=50;
00100  *        pix_coords -> printCoordArray(row_begin, row_end, col_begin, col_end);
00101  *  @endcode
00102  * 
00103  *  @li  Access methods\n
00104  *  Get pixel coordinate for specified axis, section, row, and column numbers
00105  *  @code
00106  *         unsigned s=23, r=123, c=235;
00107  *         double ix = pix_coords -> getPixCoor_pix(PC::AXIS_X, s, r, c);
00108  *         double iy = pix_coords -> getPixCoor_pix(PC::AXIS_Y, s, r, c);
00109  *  @endcode
00110  *  \n
00111  *  Example of how to compose image of pixel coordinates:\n
00112  *  @code
00113  *        // Reservation of memory for image array
00114  *        unsigned NX = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1); 
00115  *        unsigned NY = (unsigned)(pix_coords -> get_x_max() * PC::UM_TO_PIX + 1);   
00116  *        double* img_arr = new double[NX*NY];
00117  *        std::fill_n(img_arr, int(NX*NY), double(0));
00118  *
00119  *        // Assignment to coordinates
00120  *        for (unsigned s=0; s<PC::N2X1_IN_DET; s++){
00121  *        for (unsigned r=0; r<PC::ROWS2X1; r++){
00122  *        for (unsigned c=0; c<PC::COLS2X1; c++){
00123  *
00124  *          int ix = int (pix_coords -> getPixCoor_pix(PC::AXIS_X, s, r, c) + 0.1);
00125  *          int iy = int (pix_coords -> getPixCoor_pix(PC::AXIS_Y, s, r, c) + 0.1);
00126  *
00127  *          img_arr[ix + iy*NX] = r+c;
00128  *        }
00129  *        }
00130  *        }
00131  *  @endcode
00132  *  \n
00133  *  Access to ndarray of pixel coordinates, taking into account CSPAD configuration parameters:
00134  *  @code
00135  *        ndarray<double,3> nda_pix_coord_x = pix_coords -> getPixCoorNDArrShapedAsData_um (PC::AXIS_X, config);
00136  *        ndarray<double,3> nda_pix_coord_y = pix_coords -> getPixCoorNDArrShapedAsData_um (PC::AXIS_Y, config);
00137  *  @endcode
00138  *  where the configuration parameters can be defined by different ways, for example:
00139  *  @code
00140  *        uint32_t numQuads         = 4;                     // 4; 
00141  *        uint32_t quadNumber[]     = {0,1,2,3};             // {0,1,2,3};
00142  *        uint32_t roiMask[]        = {0375,0337,0177,0376}; // {0377,0377,0377,0377};
00143  *        CONFIG *config = new CONFIG( numQuads, quadNumber, roiMask );  
00144  *        config -> printCSPadConfigPars();
00145  *  @endcode
00146  *  \n     
00147  *  Example of how to compose image of pixel coordinates using ndarray:
00148  *  @code
00149  *        // Assignment to coordinates for entire array
00150  *        int ix, iy;
00151  *        ndarray<double, 3>::iterator xit;
00152  *        ndarray<double, 3>::iterator yit;
00153  *        for(xit=nda_pix_coord_x.begin(), yit=nda_pix_coord_y.begin(); xit!=nda_pix_coord_x.end(); ++xit, ++yit) { 
00154  *          ix = int ( *xit * PC::UM_TO_PIX + 0.1);
00155  *          iy = int ( *yit * PC::UM_TO_PIX + 0.1);
00156  *          img_arr[ix + iy*NX] = ix+iy;
00157  *        }
00158  *  @endcode
00159  *  
00160  */
00161 
00162 
00163 class PixCoordsCSPadV2 : public PixCoords2x1V2 {
00164 public:
00165   /// Number of 2x1s in the entire detector
00166   const static unsigned N2X1_IN_DET = 32;
00167  
00168   // Default constructor
00169   /**
00170    *  @brief PixCoordsCSPadV2 class fills and provides access to the CSPad pixel coordinates.
00171    *  
00172    *  Fills/holds/provides access to the array of the quad coordinates, indexed by the quad, section, row, and column.
00173    *  @param[in] cspad_calibpars - pointer to the store of CSPAD calibration parameters
00174    *  @param[in] tiltIsApplied - boolean key indicating if the tilt angle correction for 2x1 in the detector is applied.
00175    *  @param[in] use_wide_pix_center - boolean parameter defining coordinate of the wide pixel; true-use wide pixel center as its coordinate, false-use ASIC-uniform pixel coordinate.
00176    */
00177   PixCoordsCSPadV2 ( PSCalib::CSPadCalibPars *cspad_calibpars = new PSCalib::CSPadCalibPars(), 
00178                      bool tiltIsApplied = true, 
00179                      bool use_wide_pix_center = false );
00180 
00181   /// Destructor
00182   virtual ~PixCoordsCSPadV2 () ;
00183 
00184   /// Protected method for filling pixel coordinate array in constructor
00185   void fillPixelCoordinateArrays();
00186 
00187   /// Protected method for filling pixel coordinate array for specified sensor
00188   void fillOneSectionInDet(uint32_t sect, double xcenter, double ycenter, double zcenter, double rotation);
00189 
00190   /// Protected method which resets the origin of the pixel coordinate map to (0,0)
00191   void resetXYOriginAndMinMax();
00192 
00193   /// Prints X and Y limits of the pixel coordinate map
00194   void printXYLimits();
00195 
00196   /// Prints member data and partial coordinate map
00197   void printConstants();
00198 
00199   /// Prints the part of the 2-D coordinate array in the specified ranges of rows and columns
00200   void printCoordArray(unsigned r1=10, unsigned r2=21, unsigned c1=15, unsigned c2=18);
00201 
00202 
00203   /**
00204    *  @brief Returns coordimate of the pixel in [um](micrometers) for specified axis, section, row, and column
00205    *  @param[in] axis - enomerated axes, can be PC2X2::AXIS_X or PC2X2::AXIS_Y
00206    *  @param[in] sect - section index [0,1]
00207    *  @param[in] row - row index [0,184]
00208    *  @param[in] col - column index [0,387]
00209    */
00210   double getPixCoor_um    (AXIS axis, unsigned sect, unsigned row, unsigned col) ;
00211 
00212 
00213   /**
00214    *  @brief Returns coordimate of the pixel in [pix](pixel size) for specified axis, section, row, and column
00215    *  @param[in] axis - enumerated axes, can be set to PC2X2::AXIS_X or PC2X2::AXIS_Y
00216    *  @param[in] sect - section index [0,1] (two 2x1 sensors in CSPAD2x2)
00217    *  @param[in] row - row index [0,184]
00218    *  @param[in] col - column index [0,387]
00219    */
00220   double getPixCoor_pix   (AXIS axis, unsigned sect, unsigned row, unsigned col) ;
00221 
00222 
00223   /**
00224    *  @brief Returns pointer to the pixel coordimate array of entire CSPAD in [um](micrometers)
00225    */
00226   double* getPixCoorArr_um (AXIS axis) ;
00227 
00228 /** Returns the ndarray with data for specified axis and configuration parameters
00229   *  @param[in] axis - enumerated axis
00230   *  @param[in] cspad_configpars - pointer to the store of CSPAD configuration parameters
00231   */
00232   ndarray<double,3> getPixCoorNDArrShapedAsData_um(AXIS axis, CSPadConfigPars *cspad_configpars = new CSPadConfigPars());
00233 
00234   /// Returns minimal x coordinate of the pixel in [um]
00235   double get_x_min() { return m_coor_x_min; };
00236 
00237   /// Returns maximal x coordinate of the pixel in [um]
00238   double get_x_max() { return m_coor_x_max; };
00239 
00240   /// Returns minimal y coordinate of the pixel in [um]
00241   double get_y_min() { return m_coor_y_min; };
00242 
00243   /// Returns maximal y coordinate of the pixel in [um]
00244   double get_y_max() { return m_coor_y_max; };
00245 
00246   /// Returns minimal z coordinate of the pixel in [um]
00247   double get_z_min() { return m_coor_z_min; };
00248 
00249   /// Returns maximal z coordinate of the pixel in [um]
00250   double get_z_max() { return m_coor_z_max; };
00251 
00252 protected:
00253 
00254 private:
00255   /// Pointer to the store of calibration parameters
00256   PSCalib::CSPadCalibPars *m_cspad_calibpars;
00257 
00258   /// Flag showing whether tilt angle needs to be applied.
00259   bool                     m_tiltIsApplied;
00260 
00261   /// Array of x pixel coordinates in [um] 
00262   double m_coor_x[N2X1_IN_DET][ROWS2X1][COLS2X1];
00263 
00264   /// Array of y pixel coordinates in [um]
00265   double m_coor_y[N2X1_IN_DET][ROWS2X1][COLS2X1];
00266 
00267   /// Array of z pixel coordinates in [um]
00268  
00269   double m_coor_z[N2X1_IN_DET][ROWS2X1][COLS2X1];
00270 
00271   /// Minimal x coordinate of the pixel in [um]
00272   double m_coor_x_min;
00273 
00274   /// Maximal x coordinate of the pixel in [um]
00275   double m_coor_x_max;
00276 
00277   /// Minimal y coordinate of the pixel in [um] 
00278   double m_coor_y_min;
00279 
00280   /// Maximal y coordinate of the pixel in [um]
00281   double m_coor_y_max;
00282 
00283   /// Minimal z coordinate of the pixel in [um]
00284   double m_coor_z_min;
00285 
00286   /// Maximal z coordinate of the pixel in [um]
00287   double m_coor_z_max;
00288 
00289   /// Copy constructor
00290   PixCoordsCSPadV2 ( const PixCoordsCSPadV2& ) ;
00291 
00292   /// Assignment constructor
00293   PixCoordsCSPadV2& operator = ( const PixCoordsCSPadV2& ) ;
00294 };
00295 
00296 } // namespace CSPadPixCoords
00297 
00298 #endif // CSPADPIXCOORDS_PIXCOORDSCSPADV2_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7