psana_examples/src/DumpCamera.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpCamera.cpp 5355 2013-02-05 22:07:12Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpCamera...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpCamera.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "psddl_psana/camera.ddl.h"
00027 
00028 //-----------------------------------------------------------------------
00029 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00030 //-----------------------------------------------------------------------
00031 
00032 using namespace psana_examples;
00033 PSANA_MODULE_FACTORY(DumpCamera)
00034 
00035 namespace {
00036   
00037   void
00038   printFrameCoord(std::ostream& str, const Psana::Camera::FrameCoord& coord) 
00039   {
00040     str << "(" << coord.column() << ", " << coord.row() << ")";
00041   }
00042   
00043 }
00044 
00045 //              ----------------------------------------
00046 //              -- Public Function Member Definitions --
00047 //              ----------------------------------------
00048 
00049 namespace psana_examples {
00050 
00051 //----------------
00052 // Constructors --
00053 //----------------
00054 DumpCamera::DumpCamera (const std::string& name)
00055   : Module(name)
00056 {
00057   m_src = configSrc("source", "DetInfo()");
00058 }
00059 
00060 //--------------
00061 // Destructor --
00062 //--------------
00063 DumpCamera::~DumpCamera ()
00064 {
00065 }
00066 
00067 // Method which is called at the beginning of the calibration cycle
00068 void 
00069 DumpCamera::beginCalibCycle(Event& evt, Env& env)
00070 {
00071   MsgLog(name(), trace, ": in beginCalibCycle()");
00072 
00073   shared_ptr<Psana::Camera::FrameFexConfigV1> frmConfig = env.configStore().get(m_src);
00074   if (not frmConfig) {
00075     MsgLog(name(), info, "Camera::FrameFexConfigV1 not found");    
00076   } else {
00077     
00078     WithMsgLog(name(), info, str) {
00079       str << "Camera::FrameFexConfigV1:";
00080       str << "\n  forwarding = " << frmConfig->forwarding();
00081       str << "\n  forward_prescale = " << frmConfig->forward_prescale();
00082       str << "\n  processing = " << frmConfig->processing();
00083       str << "\n  roiBegin = ";
00084       ::printFrameCoord(str, frmConfig->roiBegin());
00085       str << "\n  roiEnd = ";
00086       ::printFrameCoord(str, frmConfig->roiEnd());
00087       str << "\n  threshold = " << frmConfig->threshold();
00088       str << "\n  number_of_masked_pixels = " << frmConfig->number_of_masked_pixels();
00089       const ndarray<const Psana::Camera::FrameCoord, 1>& masked_pixels = frmConfig->masked_pixel_coordinates();
00090       for (unsigned i = 0; i < masked_pixels.shape()[0]; ++ i) {
00091         str << "\n    ";
00092         ::printFrameCoord(str, masked_pixels[i]);
00093       }
00094     }
00095     
00096   }
00097 }
00098 
00099 // Method which is called with event data
00100 void 
00101 DumpCamera::event(Event& evt, Env& env)
00102 {
00103 
00104   shared_ptr<Psana::Camera::FrameV1> frmData = evt.get(m_src);
00105   if (frmData) {
00106     WithMsgLog(name(), info, str) {
00107       str << "Camera::FrameV1: width=" << frmData->width()
00108           << "\n  height=" << frmData->height()
00109           << "\n  depth=" << frmData->depth()
00110           << "\n  offset=" << frmData->offset() ;
00111 
00112       const ndarray<const uint8_t, 2>& data8 = frmData->data8();
00113       if (not data8.empty()) {
00114         str << "\n  data8=" << data8;
00115       }
00116 
00117       const ndarray<const uint16_t, 2>& data16 = frmData->data16();
00118       if (not data16.empty()) {
00119         str << "\n  data16=" << data16;
00120       }
00121     }
00122   }
00123 
00124   shared_ptr<Psana::Camera::TwoDGaussianV1> gaussData = evt.get(m_src);
00125   if (gaussData) {
00126     WithMsgLog(name(), info, str) {
00127       str << "Camera::TwoDGaussianV1: integral=" << gaussData->integral()
00128           << "\n  xmean=" << gaussData->xmean()
00129           << "\n  ymean=" << gaussData->ymean()
00130           << "\n  major_axis_width=" << gaussData->major_axis_width()
00131           << "\n  minor_axis_width=" << gaussData->minor_axis_width()
00132           << "\n  major_axis_tilt=" << gaussData->major_axis_tilt();
00133     }
00134   }
00135 
00136 }
00137   
00138 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7