Detector/src/NDArrProducerCamera.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: NDArrProducerCamera.cpp 10649 2015-09-09 15:30:05Z dubrovin@SLAC.STANFORD.EDU $
00004 //
00005 // Author:
00006 //      Mikhail S. Dubrovin
00007 //
00008 //------------------------------------------------------------------------
00009 
00010 //---------------
00011 // -- Headers --
00012 //---------------
00013 
00014 #include "Detector/NDArrProducerCamera.h"
00015 
00016 //-----------------------------
00017 
00018 namespace {  
00019   void printFrameCoord(std::ostream& str, const Psana::Camera::FrameCoord& coord) {
00020     str << "(" << coord.column() << ", " << coord.row() << ")";
00021   }  
00022 }
00023 
00024 //-----------------------------
00025 namespace Detector {
00026 
00027   //typedef NDArrProducerCamera::data_t data_t;
00028 
00029 //-----------------------------
00030 
00031 NDArrProducerCamera::NDArrProducerCamera(const PSEvt::Source& source, const unsigned& mode, const unsigned& pbits, const float& vdef)
00032   : NDArrProducerBase(source, mode, pbits, vdef)
00033   , m_count_evt(0)
00034   , m_count_msg(0)
00035 {
00036   set_mode(mode);
00037 }
00038 
00039 //-----------------------------
00040 
00041 NDArrProducerCamera::~NDArrProducerCamera ()
00042 {
00043 }
00044 
00045 //-----------------------------
00046 
00047 void NDArrProducerCamera::set_mode(const unsigned& mode)
00048 {
00049   m_as_data         = (mode&1) ? true  : false;
00050   m_subtract_offset = (mode)   ? false : true; 
00051 }
00052 
00053 //-----------------------------
00054 
00055 void
00056 NDArrProducerCamera::print_warning(const char* msg)
00057 {
00058   m_count_msg++;
00059   if (m_count_msg < 11 && m_pbits) {
00060     MsgLog(name(), warning, "Psana::Camera::FrameV1 for data type" << msg 
00061            << " is not available in this run/event for source:" << m_source);
00062     if (m_count_msg == 10) MsgLog(name(), warning, "STOP PRINT WARNINGS for source:" << m_source);
00063   }
00064 }
00065 
00066 //-----------------------------
00067 
00068 ndarray<const uint16_t, 2> 
00069 NDArrProducerCamera::data_nda_uint16_2(PSEvt::Event& evt, PSEnv::Env& env)
00070 {
00071   ndarray<const uint16_t, 2> nda = getNDArrForType16<Psana::Camera::FrameV1, uint16_t>(evt, env);
00072   if ( ! nda.empty()) return nda; 
00073 
00074   print_warning("uint16_t");
00075   return nda;
00076 }
00077 
00078 //-----------------------------
00079 
00080 ndarray<const uint8_t, 2> 
00081 NDArrProducerCamera::data_nda_uint8_2(PSEvt::Event& evt, PSEnv::Env& env)
00082 {
00083   ndarray<const uint8_t, 2> nda = getNDArrForType8<Psana::Camera::FrameV1, uint8_t>(evt, env);
00084   if ( ! nda.empty()) return nda; 
00085 
00086   print_warning("uint8_t");
00087   return nda;
00088 }
00089 //-----------------------------
00090 
00091 void
00092 NDArrProducerCamera::print_config(PSEvt::Event& evt, PSEnv::Env& env)
00093 {
00094   boost::shared_ptr<Psana::Camera::FrameFexConfigV1> frmConfig = env.configStore().get(m_source);
00095   if (frmConfig) {
00096     WithMsgLog(name(), info, str) {
00097       str << "Camera::FrameFexConfigV1:";
00098       str << "\n  forwarding = " << frmConfig->forwarding();
00099       str << "\n  forward_prescale = " << frmConfig->forward_prescale();
00100       str << "\n  processing = " << frmConfig->processing();
00101       str << "\n  roiBegin = ";
00102       ::printFrameCoord(str, frmConfig->roiBegin());
00103       str << "\n  roiEnd = ";
00104       ::printFrameCoord(str, frmConfig->roiEnd());
00105       str << "\n  threshold = " << frmConfig->threshold();
00106       str << "\n  number_of_masked_pixels = " << frmConfig->number_of_masked_pixels();
00107       const ndarray<const Psana::Camera::FrameCoord, 1>& masked_pixels = frmConfig->masked_pixel_coordinates();
00108       for (unsigned i = 0; i < masked_pixels.shape()[0]; ++ i) {
00109         str << "\n    ";
00110         ::printFrameCoord(str, masked_pixels[i]);
00111       }
00112     }
00113   }
00114   else MsgLog(name(), info, "Camera::FrameFexConfigV1 object is not found for source " << m_source);  
00115 
00116   //------------
00117 
00118   boost::shared_ptr<Psana::Camera::FrameV1> frmData = evt.get(m_source);
00119   if (frmData) {
00120     WithMsgLog(name(), info, str) {
00121       str << "Camera::FrameV1:"
00122           << "\n  width =" << frmData->width()
00123           << "\n  height=" << frmData->height()
00124           << "\n  depth =" << frmData->depth()
00125           << "\n  offset=" << frmData->offset() ;
00126     }
00127   }
00128   else MsgLog(name(), info, "Camera::FrameV1 object is not found for source " << m_source);  
00129 }
00130 
00131 //-----------------------------
00132 } // namespace Detector
00133 //-----------------------------

Generated on 19 Dec 2016 for PSDMSoftware by  doxygen 1.4.7