PSCalib/include/CSPad2x2CalibPars.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: CSPad2x2CalibPars.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 // Collaborating Class Headers --
00022 //-------------------------------
00023 #include "psddl_psana/cspad.ddl.h"
00024 #include "pdsdata/xtc/Src.hh"
00025 
00026 #include "pdscalibdata/CsPad2x2CenterV1.h"      
00027 #include "pdscalibdata/CsPad2x2TiltV1.h"        
00028 
00029 //-----------------------------
00030 
00031 namespace PSCalib {
00032 
00033 /// @addtogroup PSCalib PSCalib
00034 
00035 /**
00036  *  @ingroup PSCalib
00037  *
00038  *  @brief CSPad2x2CalibPars class loads/holds/provides access to the CSPad2x2
00039  *  geometry calibration parameters.
00040  *
00041  *  This software was developed for the LCLS project. If you use all or 
00042  *  part of it, please give an appropriate acknowledgment.
00043  *
00044  *  @see CalibFileFinder
00045  *
00046  *  @version $Id: CSPad2x2CalibPars.h 8068 2014-04-29 17:23:05Z dubrovin@SLAC.STANFORD.EDU $
00047  *
00048  *  @author Mikhail S. Dubrovin
00049  *
00050  *
00051  *
00052  *
00053  *  @anchor interface
00054  *  @par<interface> Interface Description
00055  * 
00056  *  @li  Include and typedef
00057  *  @code
00058  *  #include "PSCalib/CSPad2x2CalibPars.h"
00059  *  typedef PSCalib::CSPad2x2CalibPars CALIB;
00060  *  @endcode
00061  *
00062  *  @li Instatiation
00063  *  \n
00064  *  For default constructor:
00065  *  @code
00066  *  CALIB *calibpars = new CALIB();  
00067  *  @endcode
00068  *  \n
00069  *  For regular constructor:
00070  *  @code
00071  *  const std::string calibDir   = "/reg/d/psdm/xpp/xpptut13/calib/";
00072  *  const std::string groupName  = "CsPad2x2::CalibV1/";
00073  *  unsigned long     runNumber  = 10;
00074  *  Pds::Src src; env.get(...,&src);
00075  *  CALIB *calibpars = new CALIB(calibDir, groupName, src, runNumber);  
00076  *  @endcode
00077  *  \n
00078  *  For explicit constructor (depricated):
00079  *  @code
00080  *  const std::string calibDir   = "/reg/d/psdm/xpp/xpptut13/calib/";
00081  *  const std::string groupName  = "CsPad2x2::CalibV1/";
00082  *  const std::string source     = "XppGon.0:Cspad2x2.1";
00083  *  unsigned long     runNumber  = 10;
00084  *  CALIB *calibpars = new CALIB(calibDir, groupName, source, runNumber);  
00085  *  @endcode
00086  *
00087  *  @li Printing methods
00088  *  @code
00089  *  calibpars -> printInputPars();
00090  *  calibpars -> printCalibPars();
00091  *  calibpars -> printCalibParsStatus();
00092  *  @endcode
00093  *
00094  *  @li Access methods
00095  *  @code
00096  *  size_t sect=1; // for example...
00097  *  int status  = calibpars -> getCalibTypeStatus("center") // Returns status: 0-default, 1-loaded from file
00098  *  double xc   = calibpars -> getCenterX(sect);
00099  *  double tilt = calibpars -> getTilt(sect);
00100  *  ... etc. for all other access methods
00101  *  @endcode
00102  *
00103  *  @see CalibFileFinder
00104  */
00105 
00106 //----------------
00107 
00108 class CSPad2x2CalibPars  {
00109 public:
00110 
00111   /// Default and test constructor
00112   CSPad2x2CalibPars ( bool isTestMode = false ) ;
00113 
00114 
00115   /**
00116    *  @brief DEPRICATED constructor, which use string& source
00117    *  
00118    *  @param[in] calibDir       Calibration directory for current experiment.
00119    *  @param[in] typeGroupName  Data type and group names.
00120    *  @param[in] source         The name of the data source.
00121    *  @param[in] runNumber      Run number to search the valid file name.
00122    */ 
00123   CSPad2x2CalibPars ( const std::string&   calibDir,           //  /reg/d/psdm/mec/mec73313/calib
00124                       const std::string&   typeGroupName,      //  CsPad2x2::CalibV1
00125                       const std::string&   source,             //  MecTargetChamber.0:Cspad2x2.1
00126                       const unsigned long& runNumber ) ;       //  10
00127 
00128   /**
00129    *  @brief Regular constructor, which use Pds::Src& src
00130    *  
00131    *  @param[in] calibDir       Calibration directory for current experiment.
00132    *  @param[in] typeGroupName  Data type and group names.
00133    *  @param[in] src            The data source object, for example Pds::Src m_src; defined in the env.get(...,&m_src)
00134    *  @param[in] runNumber      Run number to search the valid file name.
00135    */ 
00136   CSPad2x2CalibPars ( const std::string&   calibDir,           //  /reg/d/psdm/mec/mec73313/calib
00137                       const std::string&   typeGroupName,      //  CsPad2x2::CalibV1
00138                       const Pds::Src&      src,                //  Pds::Src m_src; <- is defined in env.get(...,&m_src)
00139                       const unsigned long& runNumber ) ;       //  10
00140 
00141   /// Destructor
00142   virtual ~CSPad2x2CalibPars () ;
00143 
00144   //size_t   getNRows             (){ return m_nrows;   };
00145   //size_t   getNCols             (){ return m_ncols;   };
00146 
00147   /// Makes member data vector with all supported calibration types such as center, tilt, ...
00148   void fillCalibNameVector   ();
00149 
00150   /// Define the path to the calibration file based on input parameters
00151   void getCalibFileName      ();
00152 
00153   /// Load all known calibration parameters
00154   void loadCalibPars         ();
00155 
00156   /// Open calibration file
00157   void openCalibFile         ();
00158 
00159   /// Close calibration file
00160   void closeCalibFile        ();
00161 
00162   /// Read parameters from calibration file to vector
00163   void readCalibPars         ();
00164 
00165   /// Fill calibration parameters from vector
00166   void fillCalibParsV1       ();
00167 
00168   /// Fill default calibration parameters
00169   void fillDefaultCalibParsV1();
00170 
00171   /// Generate error message in the log and abort
00172   void fatalMissingFileName  ();
00173 
00174   /// Generate warning message in the log
00175   void msgUseDefault         ();
00176 
00177   /// Prints calibration parameters
00178   void printCalibPars        ();
00179 
00180   /// Prints input parameters of the object
00181   void printInputPars        ();
00182 
00183   /// Prints calibration parameters status
00184   void printCalibParsStatus  ();
00185 
00186   /// Returns x-coordinate [pix] of the 2x1 section center @param[in] sect - 2x1 section number 0 or 1
00187   double getCenterX(size_t sect){ return m_center -> getCenterX(sect); };
00188 
00189   /// Returns y-coordinate [pix] of the 2x1 section center @param[in] sect - 2x1 section number 0 or 1 
00190   double getCenterY(size_t sect){ return m_center -> getCenterY(sect); };
00191 
00192   /// Returns z-coordinate [pix] of the 2x1 section center @param[in] sect - 2x1 section number 0 or 1 
00193   double getCenterZ(size_t sect){ return m_center -> getCenterZ(sect); };
00194 
00195   /// Returns the tilt angle [degree] of the 2x1 section @param[in] sect - 2x1 section number 0 or 1
00196   double getTilt   (size_t sect){ return m_tilt   -> getTilt   (sect); };
00197 
00198   /// Returns 109.92 um
00199   static double getRowSize_um()   { return 109.92; }  // pixel size of the row in um                                           
00200 
00201   /// Returns 109.92 um
00202   static double getColSize_um()   { return 109.92; }  // pixel size of the column in um                                        
00203 
00204   /// Returns 274.80 um
00205   static double getGapRowSize_um(){ return 274.80; }  // pixel size of the gap column in um
00206 
00207   /// Returns size of the gap
00208   static double getGapSize_um()   { return 2*getGapRowSize_um() - getRowSize_um(); }  // pixel size of the total gap in um 
00209 
00210   /// Returns 500 um
00211   static double getOrtSize_um()   { return 500.00; }  // pixel size of the ortogonal dimension in um  
00212 
00213   /// Returns 1 / 109.92 um
00214   static double getRowUmToPix()   { return 1./getRowSize_um(); } // conversion factor of um to pixels for rows
00215 
00216   /// Returns 1 / 109.92 um
00217   static double getColUmToPix()   { return 1./getColSize_um(); } // conversion factor of um to pixels for columns 
00218 
00219   /// Returns 1
00220   static double getOrtUmToPix()   { return 1.; }                 // conversion factor of um to pixels for ort
00221 
00222   /// Returns status of the calibration constants, 0-default, 1-loaded from file @param[in] type - calibration type string-name, for example "center" or "tilt"
00223   int getCalibTypeStatus(const std::string&  type) { return m_calibtype_status[type]; };
00224 
00225 private:
00226 
00227   /// Copy constructor is disabled by default
00228   CSPad2x2CalibPars ( const CSPad2x2CalibPars& ) ;
00229   /// Assignment is disabled by default
00230   CSPad2x2CalibPars operator = ( const CSPad2x2CalibPars& ) ;
00231 
00232 //------------------
00233 // Static Members --
00234 //------------------
00235 
00236   // Assuming path: /reg/d/psdm/mec/mec73313/calib/CsPad2x2::CalibV1/MecTargetChamber.0:Cspad2x2.1/1-end.data
00237   // Data members for TEST constructor       
00238   std::string m_calibdir;       // /reg/d/psdm/mec/mec73313/calib
00239   std::string m_calibfilename;  // 1-end.data
00240 
00241   // Data members for regular constructor 
00242   std::string   m_calibDir;
00243   std::string   m_typeGroupName;
00244   std::string   m_source;
00245   Pds::Src      m_src;
00246   std::string   m_dataType;
00247   unsigned long m_runNumber;
00248 
00249   std::vector<std::string> v_calibname; // center, tilt, ...
00250   std::vector<double>      v_parameters;
00251 
00252   std::map<std::string, int> m_calibtype_status; // =0-default, =1-from file
00253 
00254   std::string m_cur_calibname;  
00255   std::string m_fname;
00256 
00257   bool m_isTestMode;
00258 
00259   //size_t m_nrows; 
00260   //size_t m_ncols; 
00261 
00262   std::ifstream m_file;
00263 
00264   pdscalibdata::CsPad2x2CenterV1 *m_center;
00265   pdscalibdata::CsPad2x2TiltV1   *m_tilt;   
00266 };
00267 
00268 } // namespace PSCalib
00269 
00270 #endif // PSCALIB_CSPAD2X2CALIBPARS_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7