00001 #ifndef IMGPIXSPECTRA_CAMERAPIXSPECTRA_H 00002 #define IMGPIXSPECTRA_CAMERAPIXSPECTRA_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id$ 00007 // 00008 // Description: 00009 // Class CameraPixSpectra. 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 00017 //---------------------- 00018 // Base Class Headers -- 00019 //---------------------- 00020 #include "psana/Module.h" 00021 00022 //------------------------------- 00023 // Collaborating Class Headers -- 00024 //------------------------------- 00025 00026 //------------------------------------ 00027 // Collaborating Class Declarations -- 00028 //------------------------------------ 00029 00030 // --------------------- 00031 // -- Class Interface -- 00032 // --------------------- 00033 00034 namespace ImgPixSpectra { 00035 00036 /// @addtogroup ImgPixSpectra 00037 00038 /** 00039 * @ingroup ImgPixSpectra 00040 * 00041 * @brief Creates the spectal array for all pixels in the Opal-1k, Princeton, etc camera-detectors. 00042 * 00043 * CameraPixSpectra class is a psana module which creates and fills 00044 * the spectral array for all pixels in the Opal-1k, Princeton, etc array. 00045 * The spectral array has two dimensions, the total number of pixels and 00046 * the number of amplitude bins requested in the list of configuration parameters. 00047 * 00048 * An example of the configuration file (psana.cfg) for this module: 00049 * 00050 * @code 00051 * [psana] 00052 * files = /reg/d/psdm/sxr/sxr16410/xtc/e75-r0081-s01-c00.xtc 00053 * modules = ImgPixSpectra.CameraPixSpectra 00054 * 00055 * [ImgPixSpectra.CameraPixSpectra] 00056 * source = SxrBeamline.0:Opal1000.1 00057 * amin = 0. 00058 * amax = 1000. 00059 * nbins = 100 00060 * arr_fname = camera-pix-spectra.txt 00061 * #events = 500 00062 * @endcode 00063 * 00064 * The output file "camera-pix-spectra.txt" contains the spectral array 00065 * for CSPad pixels accumulated in job. 00066 * Axillary file with additional name extension ".sha" contains the shape parameters 00067 * of the spectral array. The file(s) can be used for further analysis 00068 * or presentation, for example, using the python script: 00069 * 00070 * @code 00071 * ImgPixSpectra/data/PlotSpectralArrayFromFile.py camera-pix-spectra.txt 00072 * @endcode 00073 * 00074 * This software was developed for the LCLS project. If you use all or 00075 * part of it, please give an appropriate acknowledgment. 00076 * 00077 * @version \$Id: CameraPixSpectra.h$ 00078 * 00079 * @author Mikhail S. Dubrovin 00080 */ 00081 00082 class CameraPixSpectra : public Module { 00083 public: 00084 00085 // Default constructor 00086 CameraPixSpectra (const std::string& name) ; 00087 00088 // Destructor 00089 virtual ~CameraPixSpectra () ; 00090 00091 /// Method which is called once at the beginning of the job 00092 virtual void beginJob(Event& evt, Env& env); 00093 00094 /// Method which is called at the beginning of the run 00095 virtual void beginRun(Event& evt, Env& env); 00096 00097 /// Method which is called at the beginning of the calibration cycle 00098 virtual void beginCalibCycle(Event& evt, Env& env); 00099 00100 /// Method which is called with event data, this is the only required 00101 /// method, all other methods are optional 00102 virtual void event(Event& evt, Env& env); 00103 00104 /// Method which is called at the end of the calibration cycle 00105 virtual void endCalibCycle(Event& evt, Env& env); 00106 00107 /// Method which is called at the end of the run 00108 virtual void endRun(Event& evt, Env& env); 00109 00110 /// Method which is called once at the end of the job 00111 virtual void endJob(Event& evt, Env& env); 00112 00113 protected: 00114 00115 void printInputPars(); 00116 void arrayInit(); 00117 void arrayDelete(); 00118 void arrayFill (const uint16_t* data); 00119 void arrayFill8(const uint8_t* data); 00120 void saveArrayInFile(); 00121 void saveShapeInFile(); 00122 int ampToIndex(double amp); 00123 00124 private: 00125 00126 // Data members, this is for example purposes only 00127 00128 //enum {m_npix_mini1 = 185 * 388 * 2}; 00129 00130 //enum {m_npix_mini1 = 1024}; // *1024}; 00131 00132 Source m_src; // Data source set from config file 00133 Pds::Src m_actualSrc; 00134 std::string m_key; 00135 double m_amin; 00136 double m_amax; 00137 int m_nbins; 00138 std::string m_arr_fname; 00139 std::string m_arr_shape_fname; 00140 unsigned m_maxEvents; 00141 bool m_filter; 00142 long m_count; 00143 00144 int m_offset; 00145 int m_width; 00146 int m_height; 00147 int m_numPixels; 00148 int m_nbins1; 00149 double m_factor; 00150 00151 int* m_arr; 00152 }; 00153 00154 } // namespace ImgPixSpectra 00155 00156 #endif // IMGPIXSPECTRA_CAMERAPIXSPECTRA_H