ImgPixSpectra/include/CSPad2x2PixSpectra.h

Go to the documentation of this file.
00001 #ifndef IMGPIXSPECTRA_CSPAD2X2PIXSPECTRA_H
00002 #define IMGPIXSPECTRA_CSPAD2X2PIXSPECTRA_H
00003 
00004 //--------------------------------------------------------------------------
00005 // File and Version Information:
00006 //      $Id$
00007 //
00008 // Description:
00009 //      Class CSPad2x2PixSpectra.
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 CSPad2x2 detector.
00042  *
00043  *  CSPad2x2PixSpectra class is a psana module which creates and fills 
00044  *  the spectral array for all pixels in the CSPad2x2 array. The spectral
00045  *  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/CXI/cxi49812/xtc/e157-r0203-s00-c00.xtc
00053  *    modules       = ImgPixSpectra.CSPad2x2PixSpectra
00054  *    
00055  *    [ImgPixSpectra.CSPad2x2PixSpectra]
00056  *    source        = CxiSc1.0:Cspad2x2.0
00057  *    amin          =   500.
00058  *    amax          =  1000.
00059  *    nbins         =   100
00060  *    arr_fname     = cspad2x2-pix-spectra.txt
00061  *    #events       =   500                                                  
00062  *    @endcode
00063  *
00064  *  The output file "cspad2x2-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 cspad2x2-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: CSPad2x2PixSpectra.h$
00078  *
00079  *  @author Mikhail S. Dubrovin
00080  */
00081 
00082 class CSPad2x2PixSpectra : public Module {
00083 public:
00084 
00085   // Default constructor
00086   CSPad2x2PixSpectra (const std::string& name) ;
00087 
00088   // Destructor
00089   virtual ~CSPad2x2PixSpectra () ;
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 int16_t* data);
00119   void saveArrayInFile();
00120   void saveShapeInFile();
00121   int  ampToIndex(double amp);
00122   
00123 private:
00124 
00125   // Data members, this is for example purposes only
00126 
00127   enum {m_npix_2x2 = 185 * 388 * 2};
00128   
00129   Source        m_src;         // Data source set from config file
00130   Pds::Src      m_actualSrc;
00131   std::string   m_key;
00132   double        m_amin;
00133   double        m_amax;
00134   int           m_nbins;
00135   std::string   m_arr_fname;
00136   std::string   m_arr_shape_fname;
00137   unsigned      m_maxEvents;
00138   bool          m_filter;
00139   long          m_count;
00140 
00141   int           m_nbins1;
00142   double        m_factor;
00143 
00144   int*          m_arr;
00145 };
00146 
00147 } // namespace ImgPixSpectra
00148 
00149 #endif // IMGPIXSPECTRA_CSPAD2X2PIXSPECTRA_H

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7