PSCalib/include/CSPad2x2CalibIntensity.h

Go to the documentation of this file.
00001 #ifndef PSCALIB_CSPAD2X2CALIBPARS_H
00002 #define PSCALIB_CSPAD2X2CALIBPARS_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id: CSPad2x2CalibIntensity.h 8068 2014-04-29 17:23:05Z dubrovin@SLAC.STANFORD.EDU $
00007 //
00008 // $Revision: 8068 $
00009 //------------------------------------------------------------------------
00010 
00011 //-----------------
00012 // C/C++ Headers --
00013 //-----------------
00014 #include <iostream>
00015 #include <string>
00016 #include <vector>
00017 #include <map>
00018 #include <fstream>  // open, close etc.
00019 
00020 //----------------------
00021 // Base Class Headers --
00022 //----------------------
00023 #include "ndarray/ndarray.h"
00024 #include "PSCalib/CalibPars.h"
00025 
00026 //-------------------------------
00027 // Collaborating Class Headers --
00028 //-------------------------------
00029 #include "psddl_psana/cspad2x2.ddl.h"
00030 #include "pdsdata/xtc/Src.hh"
00031 
00032 #include "pdscalibdata/CsPad2x2BaseV2.h"      
00033 #include "pdscalibdata/CsPad2x2PedestalsV2.h"      
00034 #include "pdscalibdata/CsPad2x2CommonModeV2.h"        
00035 #include "pdscalibdata/CsPad2x2PixelStatusV2.h"        
00036 #include "pdscalibdata/CsPad2x2PixelGainV2.h"        
00037 #include "pdscalibdata/CsPad2x2PixelRmsV2.h"        
00038 
00039 //----------------------------
00040 
00041 namespace PSCalib {
00042 
00043 /// @addtogroup PSCalib PSCalib
00044 
00045 /**
00046  *  @ingroup PSCalib
00047  *
00048  *  @brief CSPad2x2CalibIntensity class loads/holds/provides access to the CSPAD2x2
00049  *  geometry calibration parameters.
00050  *
00051  *  This software was developed for the LCLS project. If you use all or 
00052  *  part of it, please give an appropriate acknowledgment.
00053  *
00054  *  @see CalibPars, CalibParsStore
00055  *
00056  *  @version $Id: CSPad2x2CalibIntensity.h 8068 2014-04-29 17:23:05Z dubrovin@SLAC.STANFORD.EDU $
00057  *
00058  *  @author Mikhail S. Dubrovin
00059  *
00060  *
00061  *
00062  *
00063  *  @anchor interface
00064  *  @par<interface> Interface Description
00065  * 
00066  *  @li  Include and typedef
00067  *  @code
00068  *  #include "PSCalib/CSPad2x2CalibIntensity.h"
00069  *  typedef PSCalib::CSPad2x2CalibIntensity CALIB;
00070  *  @endcode
00071  *
00072  *  @li Instatiation
00073  *  \n
00074  *  For default constructor:
00075  *  @code
00076  *  CALIB *calibpars = new CALIB();  
00077  *  @endcode
00078  *  \n
00079  *  For regular constructor:
00080  *  @code
00081  *  const std::string calibDir   = "/reg/d/psdm/AMO/amoa1214/calib";
00082  *  const std::string groupName  = "Cspad2x2::CalibV1";
00083  *  const std::string source     = "Camp.0:Cspad2x2.1";
00084  *  unsigned long     runNumber  = 10;
00085  *  Pds::Src src; env.get(source, key, &src);
00086  *  CALIB *calibpars = new CALIB(calibDir, groupName, src, runNumber);  
00087  *  @endcode
00088  *  \n
00089  *  For explicit constructor (depricated):
00090  *  @code
00091  *  const std::string calibDir   = "/reg/d/psdm/AMO/amoa1214/calib";
00092  *  const std::string groupName  = "Cspad2x2::CalibV1";
00093  *  const std::string source     = "Camp.0:Cspad2x2.1";
00094  *  unsigned long     runNumber  = 10;
00095  *  CALIB *calibpars = new CALIB(calibDir, groupName, source, runNumber);  
00096  *  @endcode
00097  *  \n
00098  *  or for the same list of parameters using polymorphism:
00099  *  @code
00100  *  PSCalib::CalibPars *calibpars = new CALIB(calibDir, groupName, source, runNumber);  
00101  *  @endcode
00102  *  In this case all virtual methods defined in the base class PSCalib::CalibPars will be accessible through the calibpars pointer.
00103  *  
00104  *
00105  *  @li Printing methods
00106  *  @code
00107  *  calibpars -> printInputPars();
00108  *  calibpars -> printCalibPars();
00109  *  calibpars -> printCalibParsStatus();
00110  *  @endcode
00111  *
00112  *  @li Access methods
00113  *  @code
00114  *  const size_t    ndim = calibpars -> ndim();
00115  *  const size_t    size = calibpars -> size();
00116  *  const unsigned* p_shape = calibpars -> shape();
00117  *  const CalibPars::pedestals_t*    p_pedestals   = calibpars -> pedestals()
00118  *  const CalibPars::pixel_status_t* p_pixel_stat  = calibpars -> pixel_status()
00119  *  const CalibPars::common_mode_t*  p_common_mode = calibpars -> common_mode()
00120  *  const CalibPars::pixel_gain_t*   p_pixel_gain  = calibpars -> pixel_gain()
00121  *  const CalibPars::pixel_rms_t*    p_pixel_rms   = calibpars -> pixel_rms()
00122  *  ... etc. for all other access methods
00123  *  @endcode
00124  *
00125  *  @see CalibFileFinder
00126  */
00127 
00128 //----------------
00129 
00130   class CSPad2x2CalibIntensity: public PSCalib::CalibPars  {
00131 public:
00132 
00133   /// Default and test constructor
00134   CSPad2x2CalibIntensity ( bool isTestMode = false ) ;
00135 
00136 
00137   /**
00138    *  @brief DEPRICATED constructor, which use string& source
00139    *  
00140    *  @param[in] calibDir       Calibration directory for current experiment.
00141    *  @param[in] typeGroupName  Data type and group names.
00142    *  @param[in] source         The name of the data source.
00143    *  @param[in] runNumber      Run number to search the valid file name.
00144    *  @param[in] print_bits     =0-print no messages; +1-input parameters, +2-print msges from  PSCalib::CalibFileFinder, +4-use default, +8-missing type
00145    */ 
00146   CSPad2x2CalibIntensity ( const std::string&   calibDir,           //  /reg/d/psdm/AMO/amoa1214/calib
00147                            const std::string&   typeGroupName,      //  Cspad2x2::CalibV1
00148                            const std::string&   source,             //  Camp.0:Cspad2x2.0
00149                            const unsigned long& runNumber,          //  7
00150                            unsigned             print_bits=255 );
00151 
00152   /**
00153    *  @brief Regular constructor, which use Pds::Src& src
00154    *  
00155    *  @param[in] calibDir       Calibration directory for current experiment.
00156    *  @param[in] typeGroupName  Data type and group names.
00157    *  @param[in] src            The data source object, for example Pds::Src m_src; defined in the env.get(...,&m_src)
00158    *  @param[in] runNumber      Run number to search the valid file name.
00159    *  @param[in] print_bits     =0-print no messages; +1-input parameters, +2-print msges from  PSCalib::CalibFileFinder, +4-use default, +8-missing type
00160    */ 
00161   CSPad2x2CalibIntensity ( const std::string&   calibDir,           //  /reg/d/psdm/AMO/amoa1214/calib
00162                            const std::string&   typeGroupName,      //  Cspad2x2::CalibV1
00163                            const Pds::Src&      src,                //  Pds::Src m_src; <- is defined in env.get(...,&m_src)
00164                            const unsigned long& runNumber,          //  7
00165                            unsigned             print_bits=255 ) ;  
00166 
00167   /// Destructor
00168   virtual ~CSPad2x2CalibIntensity () ;
00169 
00170   //size_t   getNRows             (){ return m_nrows;   };
00171   //size_t   getNCols             (){ return m_ncols;   };
00172 
00173   /// Makes member data vector with all supported calibration types such as center, tilt, ...
00174   void fillCalibNameVector   ();
00175 
00176   /// Define the path to the calibration file based on input parameters
00177   void getCalibFileName      ();
00178 
00179   /// Load all known calibration parameters
00180   void loadCalibPars         ();
00181 
00182   /// Fill calibration parameters from vector
00183   void fillCalibParsV1       ();
00184 
00185   /// Fill default calibration parameters
00186   void fillDefaultCalibParsV1();
00187 
00188   /// Generate error message in the log and abort
00189   void fatalMissingFileName  ();
00190 
00191   /// Generate warning message in the log
00192   void msgUseDefault         ();
00193 
00194   /// Prints calibration parameters
00195   void printCalibPars        (); // declared as pure virtual in superclass
00196 
00197   /// Prints input parameters of the object
00198   void printInputPars        ();
00199 
00200   /// Returns status of the calibration constants, 0-default, 1-loaded from file @param[in] type - calibration type string-name, for example "center" or "tilt"
00201   int getCalibTypeStatus(const std::string&  type) { return m_calibtype_status[type]; };
00202 
00203 
00204 
00205   /// INTERFACE METHODS
00206 
00207   /// Prints calibration parameters status
00208   virtual void printCalibParsStatus  ();
00209 
00210   virtual const size_t    ndim() { return pdscalibdata::CsPad2x2BaseV2::Ndim; };
00211   virtual const size_t    size() { return pdscalibdata::CsPad2x2BaseV2::Size; };
00212   virtual const unsigned* shape(){ return m_pedestals -> pedestals().shape(); };
00213 
00214   /// Returns ndarray of CSPAD2x2 pedestals
00215   //pdscalibdata::CsPad2x2PedestalsV2::pars_t
00216   ndarray<CalibPars::pedestals_t, 3> pedestals_ndarr(){ return m_pedestals -> pedestals(); };
00217   virtual const CalibPars::pedestals_t* pedestals(){ return m_pedestals -> pedestals().data(); };
00218 
00219   /// Returns ndarray of CSPAD2x2 pixel status
00220   //pdscalibdata::CsPad2x2PixelStatusV2::pars_t
00221   ndarray<CalibPars::pixel_status_t, 3> pixel_status_ndarr(){ return m_pixel_status -> pixel_status(); };
00222   virtual const CalibPars::pixel_status_t* pixel_status(){ return m_pixel_status -> pixel_status().data(); };
00223 
00224   /// Returns ndarray of CSPAD2x2 common mode
00225   ndarray<CalibPars::common_mode_t, 1> common_mode_ndarr(){ return m_common_mode -> common_mode(); };
00226   virtual const CalibPars::common_mode_t* common_mode(){ return m_common_mode -> common_mode().data(); };
00227 
00228   /// Returns ndarray of CSPAD2x2 pixel gain
00229   ndarray<CalibPars::pixel_gain_t, 3> pixel_gain_ndarr(){ return m_pixel_gain -> pixel_gain(); };
00230   virtual const CalibPars::pixel_gain_t* pixel_gain(){ return m_pixel_gain -> pixel_gain().data(); };
00231 
00232   /// Returns ndarray of CSPAD2x2 pixel rms
00233   ndarray<CalibPars::pixel_rms_t, 3> pixel_rms_ndarr(){ return m_pixel_rms -> pixel_rms(); };
00234   virtual const CalibPars::pixel_rms_t* pixel_rms(){ return m_pixel_rms -> pixel_rms().data(); };
00235 
00236 
00237 private:
00238 
00239   /// Copy constructor is disabled by default
00240   CSPad2x2CalibIntensity ( const CSPad2x2CalibIntensity& ) ;
00241   /// Assignment is disabled by default
00242   //CSPad2x2CalibIntensity operator = ( const CSPad2x2CalibIntensity& ) ;
00243 
00244 //------------------
00245 // Static Members --
00246 //------------------
00247 
00248   // Assuming path: /reg/d/psdm/AMO/amoa1214/calib/Cspad2x2::CalibV1/Camp.0:Cspad2x2.1/pedestals/1-end.data
00249 
00250   std::string   m_calibdir;       // /reg/d/psdm/AMO/amoa1214/calib
00251   std::string   m_calibfilename;  // 1-end.data
00252 
00253   // Data members for regular constructor 
00254   std::string   m_calibDir;
00255   std::string   m_typeGroupName;
00256   std::string   m_source;
00257   Pds::Src      m_src;
00258   std::string   m_dataType;
00259   unsigned long m_runNumber;
00260   unsigned      m_print_bits;
00261 
00262   std::vector<std::string> v_calibname; // center, tilt, ...
00263 
00264   std::map<std::string, int> m_calibtype_status; // =0-default, =1-from file
00265 
00266   std::string m_cur_calibname;  
00267   std::string m_fname;
00268 
00269   bool m_isTestMode;
00270 
00271   //size_t m_nrows; 
00272   //size_t m_ncols; 
00273 
00274   std::ifstream m_file;
00275 
00276   pdscalibdata::CsPad2x2PedestalsV2   *m_pedestals;
00277   pdscalibdata::CsPad2x2PixelGainV2   *m_pixel_gain;
00278   pdscalibdata::CsPad2x2PixelRmsV2    *m_pixel_rms;
00279   pdscalibdata::CsPad2x2CommonModeV2  *m_common_mode;
00280   pdscalibdata::CsPad2x2PixelStatusV2 *m_pixel_status; 
00281 };
00282 
00283 } // namespace PSCalib
00284 
00285 #endif // PSCALIB_CSPAD2X2CALIBPARS_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7