00001 #ifndef PSCALIB_SEGGEOMETRYMATRIXV1_H 00002 #define PSCALIB_SEGGEOMETRYMATRIXV1_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: SegGeometryMatrixV1.h 12308 2016-07-20 20:52:38Z dubrovin@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class SegGeometryMatrixV1 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 00017 //---------------------- 00018 // Base Class Headers -- 00019 //---------------------- 00020 #include "PSCalib/SegGeometry.h" 00021 #include <string> 00022 00023 //------------------------------- 00024 // Collaborating Class Headers -- 00025 //------------------------------- 00026 00027 //------------------------------------ 00028 // Collaborating Class Declarations -- 00029 //------------------------------------ 00030 //#include "psddl_psana/pnccd.ddl.h" 00031 00032 // --------------------- 00033 // -- Class Interface -- 00034 // --------------------- 00035 00036 namespace PSCalib { 00037 00038 00039 /// @addtogroup PSCalib 00040 00041 /** 00042 * @ingroup PSCalib 00043 * 00044 * @brief Class SegGeometryMatrixV1 defines the matrix V1 (pnCCD, 512x512) sensor pixel coordinates in its local frame. 00045 * 00046 * Default constructor parameters are set for pnCCD; 512x512 pixels with 75x75um pixel size. 00047 * 00048 * 00049 * MatrixV1 sensor coordinate frame has a matrix-style coordinate system: 00050 * 00051 * @code 00052 * (Xmin,Ymin) (Xmin,Ymax) 00053 * (0,0) (0,512) 00054 * +-----------------+----> Y 00055 * | | 00056 * | | 00057 * | | 00058 * | | 00059 * | | 00060 * | | 00061 * | | 00062 * | | 00063 * +-----------------+ 00064 * | 00065 * X V 00066 * (512,0) (512,512) 00067 * (Xmax,Ymin) (Xmax,Ymax) 00068 * @endcode 00069 * 00070 * Pixel (r,c)=(0,0) is in the top left corner of the matrix which has coordinates (Xmin,Ymin) - is in origin. 00071 * Here we assume that sensor has 512 rows and 512 columns. 00072 * 00073 * @anchor interface 00074 * @par<interface> Interface Description 00075 * 00076 * @li Include and typedef 00077 * @code 00078 * #include "PSCalib/SegGeometryMatrixV1.h" 00079 * typedef PSCalib::SegGeometryMatrixV1 SG; 00080 * @endcode 00081 * 00082 * @li Instatiation 00083 * @code 00084 * SG *seg_geom = new SG(); 00085 * or 00086 * bool use_wide_pix_center = true; 00087 * SG *seg_geom = new SG(use_wide_pix_center); 00088 * @endcode 00089 * 00090 * @li Print info 00091 * @code 00092 * unsigned pbits=0377; // 1-member data; 2-coordinate arrays; 4-min/max coordinate values 00093 * seg_geom -> print_seg_info(pbits); 00094 * @endcode 00095 * 00096 * @li Access methods 00097 * @code 00098 * // scalar values 00099 * const size_t array_size = seg_geom -> size(); // 512*512 00100 * const size_t number_of_rows = seg_geom -> rows(); // 512 00101 * const size_t number_of_cols = seg_geom -> cols(); // 512 00102 * const pixel_coord_t pixel_scale_size = seg_geom -> pixel_scale_size(); // 75.00 00103 * const pixel_coord_t pixel_coord_min = seg_geom -> pixel_coord_min(SG::AXIS_Z); 00104 * const pixel_coord_t pixel_coord_max = seg_geom -> pixel_coord_max(SG::AXIS_X); 00105 * 00106 * // pointer to arrays with size equal to array_size 00107 * const size_t* p_array_shape = seg_geom -> shape(); // {512, 512} 00108 * const pixel_area_t* p_pixel_area = seg_geom -> pixel_area_array(); // array of 1-for regular or 2.5-for long pixels 00109 * const pixel_coord_t* p_pixel_size_arr = seg_geom -> pixel_size_array(SG::AXIS_X); 00110 * const pixel_coord_t* p_pixel_coord_arr = seg_geom -> pixel_coord_array(SG::AXIS_Y); 00111 * 00112 * unsigned mbits=0377; // 1-edges; 2-wide central cols; 4-non-bound; 8-non-bound neighbours 00113 * const pixel_mask_t* p_mask_arr = seg_geom -> pixel_mask_array(mbits); 00114 * @endcode 00115 * 00116 * This software was developed for the LCLS project. If you use all or 00117 * part of it, please give an appropriate acknowledgment. 00118 * 00119 * 00120 * @version \$Id: SegGeometryMatrixV1.h 12308 2016-07-20 20:52:38Z dubrovin@SLAC.STANFORD.EDU $ 00121 * 00122 * @author Mikhail S. Dubrovin 00123 */ 00124 00125 /** 00126 * @brief Splits the string segname like MTRX:384:384:100:100 and returns values 00127 * @param[in] segname - string like MTRX:384:384:100:100; 00128 * @param[out] rows - number of rows 00129 * @param[out] cols - number of columnss 00130 * @param[out] pix_size_rows - pixel size along axis counting rows 00131 * @param[out] pix_size_cols - pixel size along axis counting cols 00132 */ 00133 bool matrix_pars( const std::string& segname 00134 , size_t& rows 00135 , size_t& cols 00136 , float& pix_size_rows 00137 , float& pix_size_cols); 00138 00139 00140 class SegGeometryMatrixV1 : public PSCalib::SegGeometry { 00141 public: 00142 00143 /// Number of pixel rows in segment 00144 //static const size_t ROWS = 512; 00145 00146 /// Number of pixel columnss in segment 00147 //static const size_t COLS = 512; 00148 00149 /// Number of pixels in segment 00150 //static const size_t SIZE = COLS*ROWS; 00151 00152 /// Number of corners 00153 static const size_t NCORNERS = 4; 00154 00155 /// Pixel scale size [um] for indexing 00156 static const pixel_coord_t PIX_SCALE_SIZE_DEF = 12345; 00157 00158 /// Pixel size [um] in column direction 00159 static const pixel_coord_t PIX_SIZE_COLS_DEF = 75; // for pnccd 00160 00161 /// Pixel size [um] in row direction 00162 static const pixel_coord_t PIX_SIZE_ROWS_DEF = 75; // for pnccd 00163 00164 /// Pixel size [um] in depth 00165 static const pixel_coord_t PIX_SIZE_DEPTH_DEF = 400; // for pnccd 00166 00167 /// Conversion factor between um and pix 00168 //static const double UM_TO_PIX; // = 1./75; 00169 00170 // Constructor 00171 00172 /** 00173 * @brief Fills-in the map of perfect segment coordinates, defined through the chip geometry. 00174 * @param[in] rows - number of rows 00175 * @param[in] cols - number of columns 00176 * @param[in] pix_size_rows - pixel size in rows in micrometers [um] 00177 * @param[in] pix_size_cols - pixel size in columns in micrometers [um] 00178 * @param[in] pix_size_depth - pixel size in depth in micrometers [um] 00179 * @param[in] pix_scale_size - pixel size parameter taken as a 2-d image grid parameter 00180 */ 00181 SegGeometryMatrixV1 ( const size_t& rows = 512 00182 , const size_t& cols = 512 00183 , const float& pix_size_rows = PIX_SIZE_ROWS_DEF 00184 , const float& pix_size_cols = PIX_SIZE_COLS_DEF 00185 , const float& pix_size_depth = PIX_SIZE_DEPTH_DEF 00186 , const float& pix_scale_size = PIX_SCALE_SIZE_DEF 00187 ); 00188 /// Destructor 00189 virtual ~SegGeometryMatrixV1 (); 00190 00191 /// Implementation of interface methods 00192 00193 /// Prints segment info for selected bits 00194 virtual void print_seg_info(const unsigned& pbits=0); 00195 00196 /// Returns size of the coordinate arrays 00197 virtual const size_t size() { return SIZE; } 00198 00199 /// Returns number of rows in segment 00200 virtual const size_t rows() { return ROWS; } 00201 00202 /// Returns number of cols in segment 00203 virtual const size_t cols() { return COLS; } 00204 00205 /// Returns shape of the segment {rows, cols} 00206 virtual const size_t* shape() { return &ARR_SHAPE[0]; } 00207 00208 /// Returns pixel size in um for indexing 00209 virtual const pixel_coord_t pixel_scale_size() { return PIX_SCALE_SIZE; } 00210 00211 /// Returns pointer to the array of pixel areas 00212 virtual const pixel_area_t* pixel_area_array(); 00213 00214 /** 00215 * @brief Returns pointer to the array of pixel size in um for AXIS 00216 * @param[in] axis Axis from the enumerated list for X, Y, and Z axes 00217 */ 00218 virtual const pixel_coord_t* pixel_size_array(AXIS axis); 00219 00220 /// Returns pointer to the array of segment pixel coordinates in um for AXIS 00221 virtual const pixel_coord_t* pixel_coord_array(AXIS axis); 00222 00223 /// Returns minimal value in the array of segment pixel coordinates in um for AXIS 00224 virtual const pixel_coord_t pixel_coord_min(AXIS axis); 00225 00226 /// Returns maximal value in the array of segment pixel coordinates in um for AXIS 00227 virtual const pixel_coord_t pixel_coord_max(AXIS axis); 00228 00229 /** 00230 * @brief Returns pointer to the array of pixel mask: 1/0 = ok/masked 00231 * @param[in] mbits - mask control bits; 00232 * + 1 - mask edges, 00233 */ 00234 virtual const pixel_mask_t* pixel_mask_array(const unsigned& mbits = 0377); 00235 00236 private: 00237 00238 /// Generator of the pixel coordinate arrays. 00239 void make_pixel_coord_arrs (); 00240 00241 /// Generator of the pixel size and area arrays. 00242 void make_pixel_size_arrs (); 00243 00244 /// Prints class member data 00245 void print_member_data (); 00246 00247 /// Prints segment pixel coordinates 00248 void print_coord_arrs(); 00249 00250 /// Prints minimal and maximal values of the segment coordinates for X, Y, and Z axes 00251 void print_min_max_coords(); 00252 00253 /// Number of pixel rows in segment 00254 size_t ROWS; 00255 /// Number of pixel columnss in segment 00256 size_t COLS; 00257 /// Number of pixels in segment SIZE = COLS*ROWS 00258 size_t SIZE; 00259 00260 size_t IND_CORNER[NCORNERS]; 00261 size_t ARR_SHAPE[2]; 00262 00263 /// Pixel scale size [um] for indexing 00264 pixel_coord_t PIX_SCALE_SIZE; // = 75; 00265 00266 /// Pixel size [um] in column direction 00267 pixel_coord_t PIX_SIZE_COLS; // = 75; 00268 00269 /// Pixel size [um] in row direction 00270 pixel_coord_t PIX_SIZE_ROWS; // = 75; 00271 00272 /// Pixel size [um] in depth 00273 pixel_coord_t PIX_SIZE_DEPTH; // = 400.; 00274 00275 /// Conversion factor between um and pix 00276 double UM_TO_PIX; // = 1./75; 00277 00278 /// switch between two options of the wide pixel row center 00279 bool m_use_wide_pix_center; 00280 00281 /// done bits 00282 unsigned m_done_bits; 00283 00284 /// 1-d pixel coordinates of rows and cols 00285 pixel_coord_t* m_x_arr_um; 00286 pixel_coord_t* m_y_arr_um; 00287 00288 /// 2-d pixel coordinate arrays 00289 pixel_coord_t* m_x_pix_coord_um; 00290 pixel_coord_t* m_y_pix_coord_um; 00291 pixel_coord_t* m_z_pix_coord_um; 00292 00293 /// 2-d pixel size arrays 00294 pixel_coord_t* m_x_pix_size_um; 00295 pixel_coord_t* m_y_pix_size_um; 00296 pixel_coord_t* m_z_pix_size_um; 00297 00298 /// 2-d pixel area arrays 00299 pixel_area_t* m_pix_area_arr; 00300 00301 /// 2-d pixel mask arrays 00302 pixel_mask_t* m_pix_mask_arr; 00303 00304 // Copy constructor and assignment are disabled by default 00305 SegGeometryMatrixV1 ( const SegGeometryMatrixV1& ) ; 00306 SegGeometryMatrixV1& operator = ( const SegGeometryMatrixV1& ) ; 00307 }; 00308 00309 } // namespace PSCalib 00310 00311 #endif // PSCALIB_SEGGEOMETRYMATRIXV1_H