00001 #ifndef PSCALIB_CALIBPARS_H 00002 #define PSCALIB_CALIBPARS_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: CalibPars.h 10156 2015-05-23 00:00:36Z dubrovin@SLAC.STANFORD.EDU $ 00007 // 00008 // $Revision: 10156 $ 00009 //------------------------------------------------------------------------ 00010 00011 //----------------- 00012 // C/C++ Headers -- 00013 //----------------- 00014 #include <iostream> 00015 #include <string> 00016 #include <map> 00017 #include <stdint.h> // for uint8_t, uint16_t etc. 00018 00019 //------------------------------- 00020 // Collaborating Class Headers -- 00021 //------------------------------- 00022 00023 #include "ndarray/ndarray.h" 00024 00025 //----------------------------- 00026 00027 namespace PSCalib { 00028 00029 00030 /// @addtogroup PSCalib PSCalib 00031 00032 /** 00033 * @ingroup PSCalib 00034 * 00035 * @brief Abstract base class CalibPars defining interface to access calibration parameters. 00036 * 00037 * This software was developed for the LCLS project. If you use all or 00038 * part of it, please give an appropriate acknowledgment. 00039 * 00040 * @see CalibFileFinder 00041 * 00042 * @version $Id: CalibPars.h 10156 2015-05-23 00:00:36Z dubrovin@SLAC.STANFORD.EDU $ 00043 * 00044 * @author Mikhail S. Dubrovin 00045 * 00046 * @see CalibFileFinder 00047 * 00048 * Calibration parameters are stored in ndarray<TYPE, NDIM>, where TYPE and NDIM are defined idividually for each type of calibration parameters. 00049 */ 00050 00051 //---------------- 00052 00053 enum CALIB_TYPE { PEDESTALS=0, PIXEL_STATUS, PIXEL_RMS, PIXEL_GAIN, PIXEL_MASK, PIXEL_BKGD, COMMON_MODE }; 00054 00055 class CalibPars { 00056 public: 00057 00058 typedef unsigned shape_t; 00059 typedef float pixel_nrms_t; 00060 typedef float pixel_bkgd_t; 00061 typedef uint16_t pixel_mask_t; 00062 typedef uint16_t pixel_status_t; 00063 typedef double common_mode_t; 00064 typedef float pedestals_t; 00065 typedef float pixel_gain_t; 00066 typedef float pixel_rms_t; 00067 00068 std::map<CALIB_TYPE, std::string> map_type2str; 00069 00070 // Destructor 00071 virtual ~CalibPars () {} 00072 00073 // NOTE1: THE METHOD DECLARED AS 00074 // virtual ndarray<pedestals_t, 1> pedestals() = 0; IS PURE VIRTUAL, 00075 // THIS IS NOT OVERLOADABLE BECAUSE THE METHOD SIGNATURE IS DEFINED BY INPUT PARS IN RHS 00076 00077 // NOTE2: PURE VIRTUAL METHOD NEEDS TO BE IMPLEMENTED IN DERIVED CLASS 00078 // OR IT SHOULD NOT BE "PURE" VIRTUAL, BUT JUST A VIRUAL 00079 00080 /// Returns number of dimensions in ndarray 00081 virtual const size_t ndim(const CALIB_TYPE& calibtype=PEDESTALS); 00082 00083 /// Returns size (number of elements) in calibration type 00084 virtual const size_t size(const CALIB_TYPE& calibtype=PEDESTALS); 00085 00086 /// Returns shape of the ndarray with calibration parameters 00087 virtual const shape_t* shape(const CALIB_TYPE& calibtype=PEDESTALS); 00088 00089 /// Returns status of the ndarray with calibration parameters 00090 virtual const int status(const CALIB_TYPE& calibtype); // =PEDESTALS); 00091 00092 /// Returns the pointer to array with pedestals 00093 virtual const pedestals_t* pedestals(); 00094 00095 /// Returns the pointer to array with pixel_status 00096 virtual const pixel_status_t* pixel_status(); 00097 00098 /// Returns the pointer to array with pixel_gain 00099 virtual const pixel_gain_t* pixel_gain(); 00100 00101 /// Returns the pointer to array with pixel_gain 00102 virtual const pixel_rms_t* pixel_rms(); 00103 00104 /// Returns the pointer to array with pixel_mask 00105 virtual const pixel_mask_t* pixel_mask(); 00106 00107 /// Returns the pointer to array with pixel_mask 00108 virtual const pixel_bkgd_t* pixel_bkgd(); 00109 00110 /// Returns the pointer to array with common_mode 00111 virtual const common_mode_t* common_mode(); 00112 00113 /// Partial print of all types of calibration parameters 00114 virtual void printCalibPars (); 00115 00116 /// Print map for known calibration types 00117 void printCalibTypes(); 00118 00119 /* 00120 virtual ndarray<pedestals_t, 3> pedestals() = 0; 00121 virtual void pedestals( ndarray<pedestals_t, 1>& nda ) { nda = make_ndarray<pedestals_t>(2); }; 00122 virtual void pedestals( ndarray<pedestals_t, 2>& nda ) { nda = make_ndarray<pedestals_t>(2, 2); }; 00123 virtual void pedestals( ndarray<pedestals_t, 3>& nda ) { nda = make_ndarray<pedestals_t>(2, 2, 2); }; 00124 virtual void pedestals( ndarray<pedestals_t, 4>& nda ) { nda = make_ndarray<pedestals_t>(2, 2, 2, 2); }; 00125 00126 virtual ndarray<pixel_status_t, 3> pixel_status() = 0; 00127 virtual void pixel_status( ndarray<pixel_status_t, 1>& nda ) { nda = make_ndarray<pixel_status_t>(2); }; 00128 virtual void pixel_status( ndarray<pixel_status_t, 2>& nda ) { nda = make_ndarray<pixel_status_t>(2, 2); }; 00129 virtual void pixel_status( ndarray<pixel_status_t, 3>& nda ) { nda = make_ndarray<pixel_status_t>(2, 2, 2); }; 00130 virtual void pixel_status( ndarray<pixel_status_t, 4>& nda ) { nda = make_ndarray<pixel_status_t>(2, 2, 2, 2); }; 00131 00132 virtual ndarray<common_mode_t, 1> common_mode() = 0; 00133 00134 virtual ndarray<pixel_gain_t, 3> pixel_gain() = 0; 00135 virtual void pixel_gain( ndarray<pixel_gain_t, 1>& nda ) { nda = make_ndarray<pixel_gain_t>(2); }; 00136 virtual void pixel_gain( ndarray<pixel_gain_t, 2>& nda ) { nda = make_ndarray<pixel_gain_t>(2, 2); }; 00137 virtual void pixel_gain( ndarray<pixel_gain_t, 3>& nda ) { nda = make_ndarray<pixel_gain_t>(2, 2, 2); }; 00138 virtual void pixel_gain( ndarray<pixel_gain_t, 4>& nda ) { nda = make_ndarray<pixel_gain_t>(2, 2, 2, 2); }; 00139 */ 00140 00141 protected: 00142 00143 // Default constructor 00144 CalibPars () { fill_map_type2str(); } 00145 00146 private: 00147 00148 void default_msg(const std::string& msg=std::string()); 00149 00150 void fill_map_type2str(); 00151 00152 }; 00153 00154 } // namespace PSCalib 00155 00156 #endif // PSCALIB_CALIBPARS_H