00001 #ifndef PSCALIB_SEGGEOMETRYSTORE_H 00002 #define PSCALIB_SEGGEOMETRYSTORE_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: SegGeometryStore.h 12308 2016-07-20 20:52:38Z dubrovin@SLAC.STANFORD.EDU $ 00007 // 00008 // $Revision: 12308 $ 00009 //------------------------------------------------------------------------ 00010 00011 //----------------- 00012 // C/C++ Headers -- 00013 //----------------- 00014 //#include <iostream> 00015 #include <string> 00016 00017 //#include "PSCalib/SegGeometry.h" 00018 #include "PSCalib/SegGeometryCspad2x1V1.h" 00019 //#include "PSCalib/SegGeometryCspad2x1V2.h" 00020 //#include "PSCalib/SegGeometryCspad2x1V3.h" 00021 #include "PSCalib/SegGeometryEpix100V1.h" 00022 #include "PSCalib/SegGeometryMatrixV1.h" 00023 00024 //------------------------------- 00025 // Collaborating Class Headers -- 00026 //------------------------------- 00027 //#include "ImgAlgos/GlobalMethods.h" // ::toString( const Pds::Src& src ) 00028 //#include "ndarray/ndarray.h" 00029 //#include "pdsdata/xtc/Src.hh" 00030 #include "MsgLogger/MsgLogger.h" 00031 00032 //----------------------------- 00033 00034 namespace PSCalib { 00035 00036 /// @addtogroup PSCalib PSCalib 00037 00038 /** 00039 * @ingroup PSCalib 00040 * 00041 * @brief class SegGeometryStore has a static factory method Create for SegGeometry object 00042 * 00043 * This software was developed for the LCLS project. If you use all or 00044 * part of it, please give an appropriate acknowledgment. 00045 * 00046 * @version $Id: SegGeometryStore.h 12308 2016-07-20 20:52:38Z dubrovin@SLAC.STANFORD.EDU $ 00047 * 00048 * @author Mikhail S. Dubrovin 00049 * 00050 * @see SegGeometry, SegGeometryCspad2x1V1 00051 * 00052 * @anchor interface 00053 * @par<interface> Interface Description 00054 * 00055 * @li Includes 00056 * @code 00057 * // #include "PSCalib/SegGeometry.h" // already included under SegGeometryStore.h 00058 * #include "PSCalib/SegGeometryStore.h" 00059 * typedef PSCalib::SegGeometry SG; 00060 * @endcode 00061 * 00062 * @li Instatiation 00063 * \n 00064 * Classes like SegGeometryCspad2x1V1 containing implementation of the SegGeometry interface methods are self-sufficient. 00065 * Factory method Create should returns the pointer to the SegGeometry object by specified segname parameter or returns 0-pointer if segname is not recognized (and not implemented). 00066 * Code below instateates SegGeometry object using factory static method PSCalib::SegGeometryStore::Create() 00067 * @code 00068 * std::string source = "SENS2X1:V1"; 00069 * or 00070 * std::string source = "EPIX100:V1"; 00071 * or 00072 * std::string source = "PNCCD:V1"; 00073 * unsigned print_bits=0377; // does not print by default if parameter omited 00074 * PSCalib::SegGeometry* segeo = PSCalib::SegGeometryStore::Create(segname, print_bits); 00075 * @endcode 00076 * 00077 * @li Print info 00078 * @code 00079 * segeo -> print_seg_info(0377); 00080 * @endcode 00081 * 00082 * @li Access methods 00083 * \n are defined in the interface SegGeometry and implemented in SegGeometryCspad2x1V1 00084 * @code 00085 * // scalar values 00086 * const SG::size_t array_size = segeo -> size(); 00087 * const SG::size_t number_of_rows = segeo -> rows(); 00088 * const SG::size_t number_of_cols = segeo -> cols(); 00089 * const SG::pixel_coord_t pixel_scale_size = segeo -> pixel_scale_size(); 00090 * const SG::pixel_coord_t pixel_coord_min = segeo -> pixel_coord_min(SG::AXIS_Z); 00091 * const SG::pixel_coord_t pixel_coord_max = segeo -> pixel_coord_max(SG::AXIS_X); 00092 * 00093 * // pointer to arrays with size equal to array_size 00094 * const SG::size_t* p_array_shape = segeo -> shape(); 00095 * const SG::pixel_area_t* p_pixel_area = segeo -> pixel_area_array(); 00096 * const SG::pixel_coord_t* p_pixel_size_arr = segeo -> pixel_size_array(SG::AXIS_X); 00097 * const SG::pixel_coord_t* p_pixel_coord_arr = segeo -> pixel_coord_array(SG::AXIS_Y); 00098 * @endcode 00099 * 00100 * @li How to add new segment to the factory 00101 * \n 1. implement SegGeometry interface methods in class like SegGeometryCspad2x1V1 00102 * \n 2. add it to SegGeometryStore with unique segname 00103 */ 00104 00105 //---------------- 00106 00107 class SegGeometryStore { 00108 public: 00109 00110 //SegGeometryStore () {} 00111 //virtual ~SegGeometryStore () {} 00112 00113 /** 00114 * @brief Static factory method for SegGeometry of the segments defined by the name 00115 * 00116 * @param[in] segname segment name 00117 * @param[in] print_bits print control bit-word. 00118 */ 00119 00120 static PSCalib::SegGeometry* 00121 Create (const std::string& segname="SENS2X1:V1", const unsigned print_bits=0) 00122 { 00123 if (print_bits & 1) MsgLog("SegGeometryStore", info, "Segment geometry factory for " << segname); 00124 00125 //if (segname=="SENS2X1:V1") { return new PSCalib::SegGeometryCspad2x1V1(); } 00126 if (segname=="SENS2X1:V1") { return PSCalib::SegGeometryCspad2x1V1::instance(); } // use singleton 00127 00128 //if (segname=="EPIX100:V1") { return new PSCalib::SegGeometryEpix100V1(); } 00129 if (segname=="EPIX100:V1") { return PSCalib::SegGeometryEpix100V1::instance(); } // use singleton 00130 00131 if (segname=="PNCCD:V1") { return new PSCalib::SegGeometryMatrixV1(512,512,75.,75.,400.,75.); } 00132 00133 if (segname.find("MTRX") != std::string::npos) { 00134 00135 MsgLog("SegGeometryStore", info, "Segment geometry factory for " << segname); 00136 std::size_t rows; 00137 std::size_t cols; 00138 float rpixsize; 00139 float cpixsize; 00140 00141 if(! PSCalib::matrix_pars(segname, rows, cols, rpixsize, cpixsize)) { 00142 if (print_bits) MsgLog("SegGeometryStore", error, "Can't demangle geometry segment name: " << segname); 00143 return 0; // NULL; 00144 } 00145 00146 if (print_bits & 1) MsgLog("SegGeometryStore", info, "segname: " << segname 00147 << " rows: " << rows << " cols:" << cols 00148 << " rpixsize: " << rpixsize << " cpixsize: " << cpixsize); 00149 00150 return new PSCalib::SegGeometryMatrixV1(rows, cols, rpixsize, cpixsize); 00151 // pix_size_depth, pix_scale_size); 00152 } 00153 00154 if (print_bits & 2) MsgLog("SegGeometryStore", info, "Segment geometry is undefined for segment name " << segname << " - return 0-pointer..."); 00155 //abort(); 00156 return 0; // NULL; 00157 } 00158 }; 00159 00160 } // namespace PSCalib 00161 00162 #endif // PSCALIB_SEGGEOMETRYSTORE_H