00001 #ifndef PSCALIB_CALIBFILEFINDER_H 00002 #define PSCALIB_CALIBFILEFINDER_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: CalibFileFinder.h 9866 2015-04-08 00:44:28Z dubrovin@SLAC.STANFORD.EDU $ 00007 // 00008 // $Revision: 9866 $ 00009 //------------------------------------------------------------------------ 00010 00011 //----------------- 00012 // C/C++ Headers -- 00013 //----------------- 00014 #include <string> 00015 #include <vector> 00016 00017 //------------------------------- 00018 // Collaborating Class Headers -- 00019 //------------------------------- 00020 #include "pdsdata/xtc/Src.hh" 00021 00022 //----------------------------- 00023 00024 namespace PSCalib { 00025 00026 /// @addtogroup PSCalib PSCalib 00027 00028 /** 00029 * @ingroup PSCalib 00030 * 00031 * @brief CalibFileFinder class finds the pass to calibration file. 00032 * 00033 * When all input parameters are provided at class initialization 00034 * the method findCalibFile(...) returns the path/name to the file 00035 * with requested 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 CSPadCalibPars 00041 * 00042 * @version $Id: CalibFileFinder.h 9866 2015-04-08 00:44:28Z dubrovin@SLAC.STANFORD.EDU $ 00043 * 00044 * @author Mikhail S. Dubrovin 00045 */ 00046 00047 class CalibFileFinder { 00048 public: 00049 00050 // Default constructor 00051 CalibFileFinder () {} 00052 00053 // Default constructor 00054 00055 /** 00056 * @brief Creates object with elements of the path to the calibration file. 00057 * 00058 * Calibration directory typically comes from environment for psana jobs. 00059 * 00060 * @param[in] calibDir Calibration directory for current experiment. 00061 * @param[in] className Calibration class name, e.g. CsPad::CalibV1 00062 * @param[in] print_bits =0-print nothing, +1-wrong file extension, +2-skipping file 00063 */ 00064 00065 CalibFileFinder (const std::string& calibDir, 00066 const std::string& className, 00067 const unsigned& print_bits=255); 00068 00069 // Destructor 00070 ~CalibFileFinder () ; 00071 00072 /** 00073 * @brief Returns complete path/name of the calibration file. 00074 * 00075 * @param[in] src The name of the data source, e.g. CxiDs1.0:Cspad.0 00076 * @param[in] datatype Type of the calibration parameters (i.e. "rotation"). 00077 * @param[in] runNumber Run number to search the valid file name. 00078 */ 00079 std::string findCalibFile(const std::string& src, const std::string& datatype, unsigned long runNumber) const; 00080 00081 /** 00082 * @brief Returns complete path/name of the calibration file. 00083 * 00084 * @param[in] src Address of the data source, only DetInfo addresses are accepted. 00085 * @param[in] datatype Type of the calibration parameters (i.e. "rotation"). 00086 * @param[in] runNumber Run number to search the valid file name. 00087 */ 00088 std::string findCalibFile(const Pds::Src& src, const std::string& datatype, unsigned long runNumber) const; 00089 00090 /** 00091 * @brief Selects calibration file from a list of file names. 00092 * 00093 * This method is mostly for testing purposes, it is used in implementation of findCalibFile(). 00094 * It can be used if you have the list of file names instead of scanning pre-defined directory. 00095 * File names that do not match standard naming convention are ignored. Standard convention is 00096 * two run number separated with '-' and extension '.data', second run can be specified as 'end'. 00097 * 00098 * @param[in] files List of file names. 00099 * @param[in] runNumber Run number to search the valid file name. 00100 * @param[in] print_bits print control bit-word. 00101 */ 00102 static std::string selectCalibFile(const std::vector<std::string>& files, unsigned long runNumber, unsigned print_bits=255); 00103 00104 00105 /** 00106 * @brief If source name has DetInfo(...) - remove it 00107 * @param[in] str - input string with source name, ex: "DetInfo(Camp.0:pnCCD.0)" 00108 */ 00109 static std::string trancateSourceName(const std::string& str); 00110 00111 00112 protected: 00113 00114 private: 00115 00116 // Data members 00117 const std::string m_calibDir; 00118 const std::string m_typeGroupName; 00119 unsigned m_print_bits; 00120 }; 00121 00122 } // namespace PSCalib 00123 00124 #endif // PSCALIB_CALIBFILEFINDER_H