00001 #ifndef CSPADPIXCOORDS_PIXCOORDS2X1V2_H 00002 #define CSPADPIXCOORDS_PIXCOORDS2X1V2_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: PixCoords2x1V2.h 8646 2014-07-16 00:09:51Z dubrovin@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class PixCoords2x1V2. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 00017 //---------------------- 00018 // Base Class Headers -- 00019 //---------------------- 00020 00021 //------------------------------- 00022 // Collaborating Class Headers -- 00023 //------------------------------- 00024 00025 //------------------------------------ 00026 // Collaborating Class Declarations -- 00027 //------------------------------------ 00028 #include "psddl_psana/cspad.ddl.h" 00029 00030 // --------------------- 00031 // -- Class Interface -- 00032 // --------------------- 00033 00034 namespace CSPadPixCoords { 00035 00036 00037 /** 00038 * @defgroup CSPadPixCoords CSPadPixCoords package 00039 * @brief Package CSPadPixCoords helps to access CSPAD pixel coordinates 00040 * 00041 * Detailed description. 00042 * 00043 * CSPAD is a detector composed of a set of tiles (AKA sensors, sectors, segments, 2x1, etc...). 00044 * Sensor pixels' geometry is precisely defined by the silicon wafer production process. Relative 00045 * sensor relative position is not so well defined and may have a few pixel size offset from expected position. 00046 * Geometry calibration parameters allows to get precise pixel location. 00047 * At data collection time some sensors may be turned on or off, 00048 * as it is defined in configuration parameters and affects the data array shape. 00049 * 00050 * CSPAD precise pixel geometry can be provided based on three components: 00051 * @li description of the ideal sensor geometry 00052 * @li geometry calibration parameters 00053 * @li detector configuration parameters 00054 * 00055 * 00056 * @li Set of modules for CSPAD 00057 * \n PSCalib/CSPadCalibPars 00058 * \n CSPadPixCoords/CSPadConfigPars 00059 * \n CSPadPixCoords/PixCoordsV2 00060 * \n CSPadPixCoords/PixCoordsCSPadV2 00061 * 00062 * 00063 * @li Set of modules for CSPAD2x2 00064 * \n PSCalib/CSPad2x2CalibPars 00065 * \n CSPadPixCoords/PixCoords2x1V2 00066 * \n CSPadPixCoords/PixCoordsCSPad2x2V2 00067 */ 00068 00069 00070 00071 /// @addtogroup CSPadPixCoords 00072 00073 /** 00074 * @ingroup CSPadPixCoords 00075 * 00076 * @brief PixCoords2x1V2 class defines the 2x1 sensor pixel coordinates in its local frame. V2 stands for latest version. 00077 * 00078 * 2x1 sensor coordinate frame: 00079 * 00080 * @code 00081 * (Xmin,Ymax) ^ Y (Xmax,Ymax) 00082 * (0,0) | (0,387) 00083 * ------------------------------ 00084 * | | | 00085 * | | | 00086 * | | | 00087 * --|-------------+--------------|----> X 00088 * | | | 00089 * | | | 00090 * | | | 00091 * ------------------------------ 00092 * (184,0) | (184,387) 00093 * (Xmin,Ymin) (Xmax,Ymin) 00094 * @endcode 00095 * 00096 * The (r,c)=(0,0) is in the top left corner of the matrix which has coordinates (Xmin,Ymax) 00097 * Here we assume that 2x1 has 185 rows and 388 columns. 00098 * This assumption differs from the DAQ map, where rows and cols are interchanged: 00099 * /reg/g/psdm/sw/external/lusi-xtc/2.12.0a/x86_64-rhel5-gcc41-opt/pdsdata/cspad/ElementIterator.hh, 00100 * Detector.hh 00101 * 00102 * @anchor interface 00103 * @par<interface> Interface Description 00104 * 00105 * @li Include and typedef 00106 * @code 00107 * #include "CSPadPixCoords/PixCoords2x1V2.h" 00108 * typedef CSPadPixCoords::PixCoords2x1V2 PC2X1; 00109 * @endcode 00110 * 00111 * @li Instatiation 00112 * @code 00113 * PC2X1 *pix_coords_2x1 = new PC2X1(); 00114 * or 00115 * bool use_wide_pix_center = true; 00116 * PC2X1 *pix_coords_2x1 = new PC2X1(use_wide_pix_center); 00117 * @endcode 00118 * 00119 * @li Printing methods 00120 * @code 00121 * pix_coords_2x1 -> print_member_data(); 00122 * pix_coords_2x1 -> print_coord_arrs_2x1(); 00123 * 00124 * double angle = 5; 00125 * pix_coords_2x1 -> print_map_min_max(PC2X1::PIX); 00126 * pix_coords_2x1 -> print_map_min_max(PC2X1::PIX, angle); 00127 * pix_coords_2x1 -> print_map_min_max(PC2X1::UM); 00128 * pix_coords_2x1 -> print_map_min_max(PC2X1::UM, angle); 00129 * @endcode 00130 * 00131 * @li Access methods 00132 * @code 00133 * double* x_arr = pix_coords_2x1 -> get_x_map_2x1_pix (); 00134 * double* y_arr = pix_coords_2x1 -> get_y_map_2x1_pix (); 00135 * double* z_arr = pix_coords_2x1 -> get_z_map_2x1_pix (); // returns 0-s 00136 * or 00137 * double* x_arr = pix_coords_2x1 -> get_coord_map_2x1 (PC2X1::AXIS_X, PC2X1::UM, angle); 00138 * double* y_arr = pix_coords_2x1 -> get_coord_map_2x1 (PC2X1::AXIS_Y, PC2X1::UM, angle); 00139 * double* z_arr = pix_coords_2x1 -> get_coord_map_2x1 (PC2X1::AXIS_Z, PC2X1::UM, angle); // returns 0-s 00140 * 00141 * double x_min_um = pix_coords_2x1 -> get_min_of_coord_map_2x1 (PC2X1::AXIS_X, PC2X1::UM, angle); 00142 * double y_min_um = pix_coords_2x1 -> get_min_of_coord_map_2x1 (PC2X1::AXIS_Y, PC2X1::UM, angle); 00143 * double z_min_um = pix_coords_2x1 -> get_min_of_coord_map_2x1 (PC2X1::AXIS_Z, PC2X1::UM, angle); 00144 * double y_max_pix = pix_coords_2x1 -> get_max_of_coord_map_2x1 (PC2X1::AXIS_Y, PC2X1::PIX, angle); 00145 * @endcode 00146 * 00147 * This software was developed for the LCLS project. If you use all or 00148 * part of it, please give an appropriate acknowledgment. 00149 * 00150 * 00151 * @version \$Id: PixCoords2x1V2.h 8646 2014-07-16 00:09:51Z dubrovin@SLAC.STANFORD.EDU $ 00152 * 00153 * @author Mikhail S. Dubrovin 00154 */ 00155 00156 // * @see CSPadImageProducer, PixCoordsTest 00157 00158 00159 class PixCoords2x1V2 { 00160 public: 00161 00162 /// Enumerator for X, Y, and Z axes 00163 enum AXIS { AXIS_X=0, 00164 AXIS_Y, 00165 AXIS_Z }; 00166 00167 /// Enumerator for scales, coordinates in micrometers or pixels 00168 enum UNITS { UM=0, 00169 PIX }; 00170 00171 /// Number of pixel rows in 2x1 00172 const static unsigned ROWS2X1 = 185; 00173 00174 /// Number of pixel columnss in 2x1 00175 const static unsigned COLS2X1 = 388; 00176 00177 /// Half number of pixel columnss in 2x1 00178 const static unsigned COLS2X1HALF = 194; 00179 00180 /// Number of pixels in 2x1 00181 const static unsigned SIZE2X1 = COLS2X1*ROWS2X1; 00182 00183 /// Number of corners... 00184 const static unsigned NCORNERS = 4; 00185 00186 /// Pixel size [um] in column direction 00187 const static double PIX_SIZE_COLS = 109.92; 00188 00189 /// Pixel size [um] in row direction 00190 const static double PIX_SIZE_ROWS = 109.92; 00191 00192 /// Wide pixel length [um] 00193 const static double PIX_SIZE_WIDE = 274.80; 00194 00195 /// Pixel size [um] 00196 const static double PIX_SIZE_UM = 109.92; 00197 00198 /// Conversion factor between um and pix 00199 const static double UM_TO_PIX = 1./109.92; 00200 00201 // Constructor 00202 00203 /** 00204 * @brief Fills-in the map of perfect 2x1 coordinates, defined through the chip geometry. 00205 * @param[in] use_wide_pix_center Optional parameter can be used if the wide-pixel row coordinate is prefered to be in the raw center. 00206 */ 00207 PixCoords2x1V2 (bool use_wide_pix_center=false); 00208 00209 /// Destructor 00210 virtual ~PixCoords2x1V2 (); 00211 00212 /// Prints 2x1 pixel coordinates 00213 void print_coord_arrs_2x1(); 00214 00215 00216 /// Prints class member data 00217 void print_member_data (); 00218 00219 /** 00220 * @brief Prints minimal and maximal values of the 2x1 coordinate map 00221 * @param[in] units Units [UM] or [PIX] from the enumerated list 00222 * @param[in] angle_deg 2x1 rotation angle [degree] 00223 */ 00224 void print_map_min_max(UNITS units, const double& angle_deg); 00225 00226 // Access methods 00227 00228 /// Returns pointer to the 2x1 pixel map of x-coordinate [um] 00229 double* get_x_map_2x1_um () { return &m_x_map_2x1_um[0][0]; } 00230 00231 /// Returns pointer to the 2x1 pixel map of y-coordinate [um] 00232 double* get_y_map_2x1_um () { return &m_y_map_2x1_um[0][0]; } 00233 00234 /// Returns pointer to the 2x1 pixel map of z-coordinate [um] 00235 double* get_z_map_2x1_um () { return &m_z_map_2x1[0][0]; } 00236 00237 /// Returns pointer to the 2x1 pixel map of x-coordinate [pix] 00238 double* get_x_map_2x1_pix () { return &m_x_map_2x1_pix[0][0]; } 00239 00240 /// Returns pointer to the 2x1 pixel map of y-coordinate [pix] 00241 double* get_y_map_2x1_pix () { return &m_y_map_2x1_pix[0][0]; } 00242 00243 /// Returns pointer to the 2x1 pixel map of z-coordinate [pix] 00244 double* get_z_map_2x1_pix () { return &m_z_map_2x1[0][0]; } 00245 00246 /// Returns sizee of the coordinate arrays 00247 const unsigned get_size() {return unsigned(SIZE2X1);} 00248 00249 /** 00250 * @brief Returns pointer to the 2x1 pixel map for specified parameters 00251 * @param[in] axis Axis from the enumerated list for X, Y, and Z 00252 * @param[in] units Units [UM] or [PIX] from the enumerated list 00253 * @param[in] angle_deg 2x1 rotation angle [degree] 00254 */ 00255 double* get_coord_map_2x1 (AXIS axis, UNITS units, const double& angle_deg=0); 00256 00257 /// Returns minimal value of the 2x1 pixel coordinate for specified parameters 00258 double get_min_of_coord_map_2x1 (AXIS axis, UNITS units, const double& angle_deg=0); 00259 00260 /// Returns miximal value of the 2x1 pixel coordinate for specified parameters 00261 double get_max_of_coord_map_2x1 (AXIS axis, UNITS units, const double& angle_deg=0); 00262 00263 00264 protected: 00265 00266 /// Generator of the 2x1 pixel coordinate map. 00267 void make_maps_of_2x1_pix_coordinates (); 00268 00269 00270 private: 00271 00272 bool m_use_wide_pix_center; /// switch between two options of the wide pixel row center 00273 double m_angle_deg; /// 2x1 rotation angle [degree] 00274 UNITS m_units; /// Units [UM] or [PIX] from the enumerated list 00275 00276 // Cols and rows are interchanged in order to have an order of arrays like in ONLINE. 00277 double m_x_rhs[COLS2X1HALF]; 00278 00279 double m_x_arr_um [COLS2X1]; 00280 double m_y_arr_um [ROWS2X1]; 00281 double m_x_arr_pix[COLS2X1]; 00282 double m_y_arr_pix[ROWS2X1]; 00283 00284 const static unsigned IND_CORNER[NCORNERS]; 00285 00286 double m_z_map_2x1 [ROWS2X1][COLS2X1]; // contains 0-s and works for all - _um, _pix, and _rot 00287 double m_x_map_2x1_um [ROWS2X1][COLS2X1]; 00288 double m_y_map_2x1_um [ROWS2X1][COLS2X1]; 00289 double m_x_map_2x1_pix[ROWS2X1][COLS2X1]; 00290 double m_y_map_2x1_pix[ROWS2X1][COLS2X1]; 00291 double m_x_map_2x1_rot[ROWS2X1][COLS2X1]; 00292 double m_y_map_2x1_rot[ROWS2X1][COLS2X1]; 00293 00294 // Copy constructor and assignment are disabled by default 00295 PixCoords2x1V2 ( const PixCoords2x1V2& ) ; 00296 PixCoords2x1V2& operator = ( const PixCoords2x1V2& ) ; 00297 }; 00298 00299 const static double DEG_TO_RAD = 3.141592653589793238463 / 180; 00300 00301 /// Global method for x and y arrays rotation 00302 void rotation(const double* x, const double* y, unsigned size, double angle_deg, double* xrot, double* yrot); 00303 /// Global method for x and y arrays rotation 00304 void rotation(const double* x, const double* y, unsigned size, double C, double S, double* xrot, double* yrot); 00305 /// Global method, returns minimal value of the array of specified length 00306 double min_of_array(const double* arr, unsigned size); 00307 /// Global method, returns maximal value of the array of specified length 00308 double max_of_array(const double* arr, unsigned size); 00309 00310 } // namespace CSPadPixCoords 00311 00312 #endif // CSPADPIXCOORDS_PIXCOORDS2X1V2_H