00001 #ifndef CSPAD_MOD_CSPAD2X2PEDESTALS_H 00002 #define CSPAD_MOD_CSPAD2X2PEDESTALS_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: CsPad2x2Pedestals.h 2995 2012-02-28 20:11:09Z salnikov@SLAC.STANFORD.EDU $ 00007 // 00008 // Description: 00009 // Class CsPad2x2Pedestals. 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 #include "psddl_psana/cspad2x2.ddl.h" 00026 00027 //------------------------------------ 00028 // Collaborating Class Declarations -- 00029 //------------------------------------ 00030 00031 // --------------------- 00032 // -- Class Interface -- 00033 // --------------------- 00034 00035 namespace cspad_mod { 00036 00037 /** 00038 * @brief Psana module which calculates 2x2 pedestals from dark CsPad2x2 run. 00039 * 00040 * This software was developed for the LCLS project. If you use all or 00041 * part of it, please give an appropriate acknowledgment. 00042 * 00043 * @version \$Id: CsPad2x2Pedestals.h 2995 2012-02-28 20:11:09Z salnikov@SLAC.STANFORD.EDU $ 00044 * 00045 * @author Andy Salnikov 00046 */ 00047 00048 class CsPad2x2Pedestals : public Module { 00049 public: 00050 00051 enum { MaxSectors = Psana::CsPad2x2::SectorsPerQuad }; 00052 enum { NumColumns = Psana::CsPad2x2::ColumnsPerASIC }; 00053 enum { NumRows = Psana::CsPad2x2::MaxRowsPerASIC*2 }; 00054 00055 // Default constructor 00056 CsPad2x2Pedestals (const std::string& name) ; 00057 00058 // Destructor 00059 virtual ~CsPad2x2Pedestals () ; 00060 00061 /// Method which is called at the beginning of the run 00062 virtual void beginRun(Event& evt, Env& env); 00063 00064 /// Method which is called with event data, this is the only required 00065 /// method, all other methods are optional 00066 virtual void event(Event& evt, Env& env); 00067 00068 /// Method which is called once at the end of the job 00069 virtual void endJob(Event& evt, Env& env); 00070 00071 protected: 00072 00073 /// collect statistics 00074 void collectStat(const int16_t* data); 00075 00076 private: 00077 00078 std::string m_pedFile; 00079 std::string m_noiseFile; 00080 00081 Pds::Src m_src; // source address of the data object 00082 00083 unsigned long m_count; // number of events seen 00084 double m_sum[NumColumns][NumRows][MaxSectors]; // sum per pixel 00085 double m_sum2[NumColumns][NumRows][MaxSectors]; // sum of squares per pixel 00086 00087 }; 00088 00089 } // namespace cspad_mod 00090 00091 #endif // CSPAD_MOD_CSPAD2X2PEDESTALS_H