CSPadPixCoords/include/PixCoordsCSPad2x2V2.h

Go to the documentation of this file.
00001 #ifndef CSPADPIXCOORDS_PIXCOORDSCSPAD2X2V2_H
00002 #define CSPADPIXCOORDS_PIXCOORDSCSPAD2X2V2_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: PixCoordsCSPad2x2V2.h 8040 2014-04-19 01:00:36Z dubrovin@SLAC.STANFORD.EDU $
00007 //
00008 // Description:
00009 //      Class PixCoordsCSPad2x2V2.
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 "PSCalib/CSPad2x2CalibPars.h"
00026 
00027 //------------------------------------
00028 // Collaborating Class Declarations --
00029 //------------------------------------
00030 
00031 //              ---------------------
00032 //              -- Class Interface --
00033 //              ---------------------
00034 
00035 namespace CSPadPixCoords {
00036 
00037 /// @addtogroup CSPadPixCoords
00038 
00039 /**
00040  *  @ingroup CSPadPixCoords
00041  *
00042  *  @brief PixCoordsCSPad2x2V2 class defines the CSPAD2x2 pixel coordinates.
00043  *
00044  *  Use the same frame like in optical measurement, but in "matrix style" geometry:
00045  *  X axis goes along rows (from top to bottom)
00046  *  Y axis goes along columns (from left to right)
00047  *
00048  *  This software was developed for the LCLS project.  If you use all or 
00049  *  part of it, please give an appropriate acknowledgment.
00050  *
00051  *  @see PixCoords2x1V2, PSCalib::CSPad2x2CalibPars
00052  *
00053  *  @version $Id: PixCoordsCSPad2x2V2.h 8040 2014-04-19 01:00:36Z dubrovin@SLAC.STANFORD.EDU $
00054  *
00055  *  @author Mikhail S. Dubrovin
00056  */
00057 
00058 
00059 /**   
00060  *  <h1>Interface Description</h1>
00061  *   
00062  *  @li  Include and typedef
00063  *  @code
00064  *  #include "CSPadPixCoords/PixCoordsCSPad2x2V2.h"
00065  *  #include "PSCalib/CSPad2x2CalibPars.h"
00066  *  //#include "CSPadPixCoords/Image2D.h"
00067  *
00068  *  typedef CSPadPixCoords::PixCoordsCSPad2x2V2 PC2X2;
00069  *  typedef PSCalib::CSPad2x2CalibPars CALIB2X2;
00070  *  @endcode
00071  *
00072  *  @li  Instatiation \n
00073  *  Default constructor without any parameters makes an object
00074  *  with default geometry which does not account for real detector geometry. 
00075  *  This constructor can be used for test purpose or if relative position of two 2x1s is not important. 
00076  *  @code
00077  *         PC2X2 *pix_coords_2x2 = new PC2X2();  
00078  *  @endcode
00079  *  \n 
00080  *  Precise detector geometry can be accounted using pointer to the store of calibration parameters:
00081  *  @code
00082  *         PC2X2 *pix_coords_2x2 = new PC2X2(calibpars2x2);
00083  *  @endcode
00084  *  or with additional parameters:
00085  *  @code
00086  *         bool tiltIsApplied = true, 
00087  *         bool use_wide_pix_center=false;
00088  *         PC2X2 *pix_coords_2x2 = new PC2X2(calibpars2x2, tiltIsApplied, use_wide_pix_center);  
00089  *  @endcode
00090  *  where calibpars2x2 is a properly prio-initialized object of the class PSCalib/CSPad2x2CalibPars.
00091  *  For example, for explisit list of parameters,
00092  *  @code
00093  *         const std::string calibDir  = "/reg/d/psdm/xpp/xpptut13/calib";
00094  *         const std::string groupName = "CsPad2x2::CalibV1";
00095  *         const std::string source    = "XppGon.0:Cspad2x2.1";
00096  *         unsigned          runNumber = 10;
00097  *         CALIB2X2 *calibpars2x2 = new CALIB2X2(calibDir, groupName, source, runNumber);  
00098  *  @endcode
00099  *       
00100  *       
00101  *  @li  Printing methods
00102  *  @code
00103  *         pix_coords_2x2 -> printXYLimits();
00104  *         pix_coords_2x2 -> printConstants();
00105  *  
00106  *         unsigned row_begin=15, row_end=20, col_begin=40, col_end=50;
00107  *         pix_coords_2x2 -> printCoordArray(row_begin, row_end, col_begin, col_end);
00108  *  @endcode
00109  *
00110  *
00111  *  @li  Access methods
00112  *  Get pixel coordinate for specified axia, section, row, and column numbers
00113  *  @code
00114  *         unsigned s=1, r=123, c=235;
00115  *         double ix = pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_X, s, r, c);
00116  *         double iy = pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_Y, s, r, c);
00117  *  @endcode
00118  *
00119  *
00120  *  @li Example of how to compose image of pixel coordinates:
00121  *  @code
00122  *         const unsigned NX=400, NY=400;
00123  *         double img_arr[NY][NX];
00124  *         std::fill_n(&img_arr[0][0], int(NX*NY), double(0));
00125  *        
00126  *         for (unsigned r=0; r<PC2X2::ROWS2X1; r++){
00127  *         for (unsigned c=0; c<PC2X2::COLS2X1; c++){
00128  *         for (unsigned s=0; s<PC2X2::N2X1_IN_DET; s++){
00129  *        
00130  *         int ix = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_X, s, r, c) + 0.1);
00131  *         int iy = int (pix_coords_2x2 -> getPixCoor_pix(PC2X2::AXIS_Y, s, r, c) + 0.1);
00132  *       
00133  *           img_arr[ix][iy] = ix+iy; // <--- This should be an intensity in this pixel.
00134  *         }
00135  *         }
00136  *         }
00137  *  @endcode
00138  *       
00139  */
00140  
00141 class PixCoordsCSPad2x2V2 : public PixCoords2x1V2 {
00142 public:
00143   /// Number of 2x1s in the CSPAD2x2
00144   const static unsigned N2X1_IN_DET = 2;
00145  
00146   // Default constructor
00147   //PixCoordsCSPad2x2V2 ();
00148 
00149   /**
00150    *  @brief PixCoordsCSPad2x2V2 class fills and provides access to the CSPAD2x2 pixel coordinates.
00151    *  
00152    *  @param[in] cspad_calibpars - pointer to the store of CSPAD2x2 calibration parameters
00153    *  @param[in] tiltIsApplied - boolean key indicating if the tilt angle correction for 2x1 in the detector is applied.
00154    *  @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.
00155    */
00156   PixCoordsCSPad2x2V2 (PSCalib::CSPad2x2CalibPars *cspad_calibpars = new PSCalib::CSPad2x2CalibPars(), 
00157                        bool tiltIsApplied = true, 
00158                        bool use_wide_pix_center=false);
00159 
00160   /// Destructor
00161   virtual ~PixCoordsCSPad2x2V2 () ;
00162 
00163   /// Prints X and Y limits of the pixel coordinate map
00164   void printXYLimits();
00165 
00166   /// Prints member data and partial coordinate map
00167   void printConstants();
00168 
00169   /// Prints the part of the 2-D coordinate array in the specified ranges of rows and columns  
00170   void printCoordArray(unsigned r1=10, unsigned r2=21, unsigned c1=15, unsigned c2=18);
00171 
00172   /**
00173    *  @brief Returns coordimate of the pixel in [um](micrometers) for specified axis, section, row, and column
00174    *  @param[in] axis - enomerated axes, can be PC2X2::AXIS_X or PC2X2::AXIS_Y
00175    *  @param[in] sect - section index [0,1]
00176    *  @param[in] row - row index [0,184]
00177    *  @param[in] col - column index [0,387]
00178    */
00179   double getPixCoor_um (AXIS axis, unsigned sect, unsigned row, unsigned col) ;
00180 
00181   /**
00182    *  @brief Returns coordimate of the pixel in [pix](pixel size) for specified axis, section, row, and column
00183    *  @param[in] axis - enumerated axes, can be set to PC2X2::AXIS_X or PC2X2::AXIS_Y
00184    *  @param[in] sect - section index [0,1] (two 2x1 sensors in CSPAD2x2)
00185    *  @param[in] row - row index [0,184]
00186    *  @param[in] col - column index [0,387]
00187    */
00188   double getPixCoor_pix(AXIS axis, unsigned sect, unsigned row, unsigned col) ;
00189 
00190 
00191   /// Returns minimal x coordinate of the pixel in [um]
00192   double get_x_min() { return m_coor_x_min; };
00193 
00194   /// Returns maximal x coordinate of the pixel in [um]
00195   double get_x_max() { return m_coor_x_max; };
00196 
00197   /// Returns minimal y coordinate of the pixel in [um]
00198   double get_y_min() { return m_coor_y_min; };
00199 
00200   /// Returns maximal y coordinate of the pixel in [um]
00201   double get_y_max() { return m_coor_y_max; };
00202 
00203 protected:
00204   /// Protected method for filling pixel coordinate array in constructor
00205   void fillPixelCoordinateArrays();
00206 
00207   /// Protected method for filling pixel coordinate array for specified sensor
00208   void fillOneSectionInDet(uint32_t sect, double xcenter, double ycenter, double zcenter, double rotation);
00209 
00210   /// Protected method which resets the origin of the pixel coordinate map to (0,0)
00211   void resetXYOriginAndMinMax();
00212 
00213 private:
00214 
00215   /// Pointer to the store of calibration parameters
00216   PSCalib::CSPad2x2CalibPars *m_cspad2x2_calibpars;  
00217 
00218   /// Flag showing whether tilt angle needs to be applied.
00219   bool                        m_tiltIsApplied;
00220 
00221   /// Array of x pixel coordinates in [um]
00222   double m_coor_x[ROWS2X1][COLS2X1][N2X1_IN_DET];
00223 
00224   /// Array of y pixel coordinates in [um]
00225   double m_coor_y[ROWS2X1][COLS2X1][N2X1_IN_DET];
00226 
00227   /// Minimal x coordinate of the pixel in [um]
00228   double m_coor_x_min;
00229 
00230   /// Maximal x coordinate of the pixel in [um]
00231   double m_coor_x_max;
00232 
00233   /// Minimal y coordinate of the pixel in [um]
00234   double m_coor_y_min;
00235 
00236   /// Maximal y coordinate of the pixel in [um]
00237   double m_coor_y_max;
00238 
00239   /// Copy constructor
00240   PixCoordsCSPad2x2V2 ( const PixCoordsCSPad2x2V2& ) ;
00241 
00242   /// Assignment constructor
00243   PixCoordsCSPad2x2V2& operator = ( const PixCoordsCSPad2x2V2& ) ;
00244 };
00245 
00246 } // namespace CSPadPixCoords
00247 
00248 #endif // CSPADPIXCOORDS_PIXCOORDSCSPAD2X2V2_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7