PSCalib/include/SegGeometryCspad2x1V1.h

Go to the documentation of this file.
00001 #ifndef PSCALIB_SEGGEOMETRYCSPAD2X1V1_H
00002 #define PSCALIB_SEGGEOMETRYCSPAD2X1V1_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: SegGeometryCspad2x1V1.h 10053 2015-05-11 22:27:46Z dubrovin@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class SegGeometryCspad2x1V1
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------
00014 // C/C++ Headers --
00015 //-----------------
00016 
00017 //----------------------
00018 // Base Class Headers --
00019 //----------------------
00020 #include "PSCalib/SegGeometry.h"
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 
00026 //------------------------------------
00027 // Collaborating Class Declarations --
00028 //------------------------------------
00029 //#include "psddl_psana/cspad.ddl.h"
00030 
00031 //              ---------------------
00032 //              -- Class Interface --
00033 //              ---------------------
00034 
00035 namespace PSCalib {
00036 
00037 
00038 /// @addtogroup PSCalib
00039 
00040 /**
00041  *  @ingroup PSCalib
00042  *
00043  *  @brief Class SegGeometryCspad2x1V1 defines the cspad 2x1 V1 sensor pixel coordinates in its local frame.
00044  *
00045  *
00046  *  2x1 sensor coordinate frame:
00047  * 
00048  *  @code
00049  *    (Xmin,Ymax)      ^ Y          (Xmax,Ymax)
00050  *    (0,0)            |            (0,387)
00051  *       +----------------------------+
00052  *       |             |              |
00053  *       |             |              |
00054  *       |             |              |
00055  *     --|-------------+--------------|----> X
00056  *       |             |              |
00057  *       |             |              |
00058  *       |             |              |
00059  *       +----------------------------+
00060  *    (184,0)          |           (184,387)
00061  *    (Xmin,Ymin)                  (Xmax,Ymin)
00062  *  @endcode
00063  *
00064  *  Pixel (r,c)=(0,0) is in the top left corner of the matrix which has coordinates (Xmin,Ymax)
00065  *  Here we assume that 2x1 has 185 rows and 388 columns.
00066  *  This assumption differs from the DAQ map, where rows and cols are interchanged:
00067  *  /reg/g/psdm/sw/external/lusi-xtc/2.12.0a/x86_64-rhel5-gcc41-opt/pdsdata/cspad/ElementIterator.hh,
00068  *  Detector.hh
00069  *   
00070  *  @anchor interface
00071  *  @par<interface> Interface Description
00072  * 
00073  *  @li  Include and typedef
00074  *  @code
00075  *  #include "PSCalib/SegGeometryCspad2x1V1.h"
00076  *  typedef PSCalib::SegGeometryCspad2x1V1 SG2X1;
00077  *  @endcode
00078  *
00079  *  @li  Instatiation
00080  *  @code
00081  *       SG2X1 *seg_geom_2x1 = new SG2X1();  
00082  *  or
00083  *       bool use_wide_pix_center = true;
00084  *       SG2X1 *seg_geom_2x1 = new SG2X1(use_wide_pix_center);  
00085  *  @endcode
00086  *
00087  *  @li  Print info
00088  *  @code
00089  *       unsigned pbits=0377; // 1-member data; 2-coordinate arrays; 4-min/max coordinate values
00090  *       seg_geom_2x1 -> print_seg_info(pbits);
00091  *  @endcode
00092  *
00093  *  @li  Access methods
00094  *  @code
00095  *        // scalar values
00096  *        const size_t         array_size        = seg_geom_2x1 -> size(); // 185*388
00097  *        const size_t         number_of_rows    = seg_geom_2x1 -> rows(); // 185
00098  *        const size_t         number_of_cols    = seg_geom_2x1 -> cols(); // 388
00099  *        const pixel_coord_t  pixel_scale_size  = seg_geom_2x1 -> pixel_scale_size();             // 109.92 
00100  *        const pixel_coord_t  pixel_coord_min   = seg_geom_2x1 -> pixel_coord_min(SG2X1::AXIS_Z);
00101  *        const pixel_coord_t  pixel_coord_max   = seg_geom_2x1 -> pixel_coord_max(SG2X1::AXIS_X);
00102  * 
00103  *        // pointer to arrays with size equal to array_size
00104  *        const size_t*        p_array_shape     = seg_geom_2x1 -> shape();                        // {185, 388}
00105  *        const pixel_area_t*  p_pixel_area      = seg_geom_2x1 -> pixel_area_array(); // array of 1-for regular or 2.5-for long pixels
00106  *        const pixel_coord_t* p_pixel_size_arr  = seg_geom_2x1 -> pixel_size_array(SG2X1::AXIS_X);
00107  *        const pixel_coord_t* p_pixel_coord_arr = seg_geom_2x1 -> pixel_coord_array(SG2X1::AXIS_Y);
00108  *
00109  *        unsigned mbits=0377; // 1-edges; 2-wide central cols; 4-non-bound; 8-non-bound neighbours
00110  *        const pixel_mask_t*  p_mask_arr = seg_geom_2x1 -> pixel_mask_array(mbits);
00111  *  @endcode
00112  *  
00113  *  This software was developed for the LCLS project.  If you use all or 
00114  *  part of it, please give an appropriate acknowledgment.
00115  *
00116  *
00117  *  @version \$Id: SegGeometryCspad2x1V1.h 10053 2015-05-11 22:27:46Z dubrovin@SLAC.STANFORD.EDU $
00118  *
00119  *  @author Mikhail S. Dubrovin
00120  */ 
00121 
00122 class SegGeometryCspad2x1V1 : public PSCalib::SegGeometry {
00123 public:
00124 
00125   /// Number of pixel rows in 2x1 
00126   static const size_t  ROWS     = 185;
00127 
00128   /// Number of pixel columnss in 2x1
00129   static const size_t  COLS     = 388;
00130 
00131   /// Half number of pixel columnss in 2x1
00132   static const size_t  COLSHALF = 194;
00133 
00134   /// Number of pixels in 2x1
00135   static const size_t  SIZE     = COLS*ROWS; 
00136 
00137   /// Number of corners
00138   static const size_t  NCORNERS = 4;
00139 
00140   /// Pixel scale size [um] for indexing  
00141   static const pixel_coord_t PIX_SCALE_SIZE; // = 109.92;
00142 
00143   /// Pixel size [um] in column direction
00144   static const pixel_coord_t PIX_SIZE_COLS; //  = 109.92;
00145 
00146   /// Pixel size [um] in row direction
00147   static const pixel_coord_t PIX_SIZE_ROWS; //  = 109.92;
00148 
00149   /// Wide pixel length [um] 
00150   static const pixel_coord_t PIX_SIZE_WIDE; //  = 274.80;
00151 
00152   /// Pixel size [um] in depth
00153   static const pixel_coord_t PIX_SIZE_DEPTH; // = 400.;
00154 
00155   /// Conversion factor between um and pix 
00156   static const double UM_TO_PIX; //             = 1./109.92;
00157 
00158   //---------------------------
00159   /// Implementation of interface methods
00160 
00161   /// Prints segment info for selected bits
00162   virtual void print_seg_info(const unsigned& pbits=0);
00163 
00164   /// Returns size of the coordinate arrays
00165   virtual const size_t size() { return SIZE; }
00166 
00167   /// Returns number of rows in segment
00168   virtual const size_t rows() { return ROWS; }
00169 
00170   /// Returns number of cols in segment
00171   virtual const size_t cols() { return COLS; }
00172 
00173   /// Returns shape of the segment {rows, cols}
00174   virtual const size_t* shape() { return &ARR_SHAPE[0]; }
00175 
00176   /// Returns pixel size in um for indexing
00177   virtual const pixel_coord_t pixel_scale_size() { return PIX_SCALE_SIZE; }
00178 
00179   /// Returns pointer to the array of pixel areas
00180   virtual const pixel_area_t* pixel_area_array();
00181 
00182   /**  
00183    *  @brief Returns pointer to the array of pixel size in um for AXIS
00184    *  @param[in] axis       Axis from the enumerated list for X, Y, and Z axes
00185    */
00186   virtual const pixel_coord_t* pixel_size_array(AXIS axis);
00187 
00188   /// Returns pointer to the array of segment pixel coordinates in um for AXIS
00189   virtual const pixel_coord_t* pixel_coord_array(AXIS axis);
00190 
00191   /// Returns minimal value in the array of segment pixel coordinates in um for AXIS
00192   virtual const pixel_coord_t pixel_coord_min(AXIS axis);
00193 
00194   /// Returns maximal value in the array of segment pixel coordinates in um for AXIS
00195   virtual const pixel_coord_t pixel_coord_max(AXIS axis);
00196 
00197   /**  
00198    *  @brief Returns pointer to the array of pixel mask: 1/0 = ok/masked
00199    *  @param[in] mbits - mask control bits;
00200    *             + 1 - mask edges,
00201    *             + 2 - mask two central columns, 
00202    *             + 4 - mask non-bounded pixels,
00203    *             + 8 - mask nearest neighbours of nonbonded pixels. 
00204    */  
00205   virtual const pixel_mask_t* pixel_mask_array(const unsigned& mbits = 0377);
00206 
00207 
00208   //---------------------------
00209   // Singleton stuff:
00210 
00211   static PSCalib::SegGeometry* instance(const bool& use_wide_pix_center=false);
00212 
00213 private:
00214 
00215   // Constructor
00216   /**
00217    *  @brief Fills-in the map of perfect 2x1 coordinates, defined through the chip geometry.
00218    *  @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.
00219    */
00220   SegGeometryCspad2x1V1 (const bool& use_wide_pix_center=false);
00221 
00222   /// Destructor
00223   virtual ~SegGeometryCspad2x1V1 ();
00224 
00225   static PSCalib::SegGeometry* m_pInstance;
00226 
00227   //---------------------------
00228 
00229   /// Generator of the pixel coordinate arrays.
00230   void make_pixel_coord_arrs ();
00231 
00232   /// Generator of the pixel size and area arrays.
00233   void make_pixel_size_arrs ();
00234 
00235   /// Prints class member data
00236   void print_member_data ();
00237 
00238   /// Prints 2x1 pixel coordinates
00239   void print_coord_arrs();
00240 
00241   /// Prints minimal and maximal values of the 2x1 coordinates for X, Y, and Z axes
00242   void print_min_max_coords();
00243 
00244 
00245   /// switch between two options of the wide pixel row center
00246   bool m_use_wide_pix_center;
00247 
00248   /// done bits
00249   unsigned m_done_bits;
00250 
00251   /// 1-d pixel coordinates of rows and cols
00252   pixel_coord_t  m_x_rhs_um [COLSHALF];  
00253   pixel_coord_t  m_x_arr_um [COLS];  
00254   pixel_coord_t  m_y_arr_um [ROWS];  
00255 
00256   const static size_t IND_CORNER[NCORNERS];
00257   const static size_t ARR_SHAPE[2];
00258 
00259   /// 2-d pixel coordinate arrays
00260   pixel_coord_t  m_x_pix_coord_um [ROWS][COLS];  
00261   pixel_coord_t  m_y_pix_coord_um [ROWS][COLS];  
00262   pixel_coord_t  m_z_pix_coord_um [ROWS][COLS];
00263 
00264   /// 2-d pixel size arrays
00265   pixel_coord_t  m_x_pix_size_um [ROWS][COLS];  
00266   pixel_coord_t  m_y_pix_size_um [ROWS][COLS];  
00267   pixel_coord_t  m_z_pix_size_um [ROWS][COLS];
00268 
00269   /// 2-d pixel area arrays
00270   pixel_area_t  m_pix_area_arr [ROWS][COLS];  
00271 
00272   /// 2-d pixel mask arrays
00273   pixel_mask_t  m_pix_mask_arr [ROWS][COLS];  
00274 
00275   // Copy constructor and assignment are disabled by default
00276   SegGeometryCspad2x1V1 ( const SegGeometryCspad2x1V1& ) ;
00277   SegGeometryCspad2x1V1& operator = ( const SegGeometryCspad2x1V1& ) ;
00278 };
00279 
00280 } // namespace PSCalib
00281 
00282 #endif // PSCALIB_SEGGEOMETRYCSPAD2X1V1_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7