psana_examples/src/DumpOceanOptics.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpOceanOptics.cpp 7879 2014-03-17 16:59:52Z dubrovin@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpOceanOptics...
00007 //
00008 // Author List:
00009 //      Andy Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpOceanOptics.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "PSTime/Time.h"
00027 #include "psddl_psana/oceanoptics.ddl.h"
00028 
00029 //-----------------------------------------------------------------------
00030 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00031 //-----------------------------------------------------------------------
00032 
00033 // This declares this class as psana module
00034 using namespace psana_examples;
00035 PSANA_MODULE_FACTORY(DumpOceanOptics)
00036 
00037 //              ----------------------------------------
00038 //              -- Public Function Member Definitions --
00039 //              ----------------------------------------
00040 
00041 namespace psana_examples {
00042 
00043 //----------------
00044 // Constructors --
00045 //----------------
00046 DumpOceanOptics::DumpOceanOptics (const std::string& name)
00047   : Module(name)
00048   , m_src()
00049 {
00050   // get the values from configuration or use defaults
00051   m_src = configSrc("source", "DetInfo(:OceanOptics)");
00052 }
00053 
00054 //--------------
00055 // Destructor --
00056 //--------------
00057 DumpOceanOptics::~DumpOceanOptics ()
00058 {
00059 }
00060 
00061 /// Method which is called at the beginning of the calibration cycle
00062 void 
00063 DumpOceanOptics::beginCalibCycle(Event& evt, Env& env)
00064 {
00065   shared_ptr<Psana::OceanOptics::ConfigV1> config1 = env.configStore().get(m_src);
00066   if (config1) {
00067 
00068     WithMsgLog(name(), info, str) {
00069       str << "Psana::OceanOptics::ConfigV1:";
00070       str << "\n  exposureTime = " << config1->exposureTime();
00071       str << "\n  waveLenCalib = " << config1->waveLenCalib();
00072       str << "\n  nonlinCorrect = " << config1->nonlinCorrect();
00073       str << "\n  strayLightConstant = " << config1->strayLightConstant();
00074     }
00075   }
00076 
00077   shared_ptr<Psana::OceanOptics::ConfigV2> config2 = env.configStore().get(m_src);
00078   if (config2) {
00079 
00080     WithMsgLog(name(), info, str) {
00081       str << "Psana::OceanOptics::ConfigV1:";
00082       str << "\n  exposureTime = " << config2->exposureTime();
00083       str << "\n  deviceType = " << config2->deviceType();
00084       str << "\n  waveLenCalib = " << config2->waveLenCalib();
00085       str << "\n  nonlinCorrect = " << config2->nonlinCorrect();
00086       str << "\n  strayLightConstant = " << config2->strayLightConstant();
00087     }
00088   }
00089 
00090 }
00091 
00092 /// Method which is called with event data, this is the only required 
00093 /// method, all other methods are optional
00094 void 
00095 DumpOceanOptics::event(Event& evt, Env& env)
00096 {
00097   shared_ptr<Psana::OceanOptics::DataV1> data1 = evt.get(m_src);
00098   if (data1) {
00099 
00100     WithMsgLog(name(), info, str) {
00101       str << "Psana::OceanOptics::DataV1:";
00102       str << "\n  data = " << data1->data();
00103       str << "\n  frameCounter = " << data1->frameCounter();
00104       str << "\n  numDelayedFrames = " << data1->numDelayedFrames();
00105       str << "\n  numDiscardFrames = " << data1->numDiscardFrames();
00106       str << "\n  timeFrameStart =     " << PSTime::Time(data1->timeFrameStart().tv_sec(), data1->timeFrameStart().tv_nsec());
00107       str << "\n  timeFrameFirstData = " << PSTime::Time(data1->timeFrameFirstData().tv_sec(), data1->timeFrameFirstData().tv_nsec());
00108       str << "\n  timeFrameEnd =       " << PSTime::Time(data1->timeFrameEnd().tv_sec(), data1->timeFrameEnd().tv_nsec());
00109       str << "\n  numSpectraInData = " << int(data1->numSpectraInData());
00110       str << "\n  numSpectraInQueue = " << int(data1->numSpectraInQueue());
00111       str << "\n  numSpectraUnused = " << int(data1->numSpectraUnused());
00112       str << "\n  durationOfFrame = " << data1->durationOfFrame();
00113     }
00114   }
00115 
00116   shared_ptr<Psana::OceanOptics::DataV2> data2 = evt.get(m_src);
00117   if (data2) {
00118 
00119     WithMsgLog(name(), info, str) {
00120       str << "Psana::OceanOptics::DataV1:";
00121       str << "\n  data = " << data2->data();
00122       str << "\n  frameCounter = " << data2->frameCounter();
00123       str << "\n  numDelayedFrames = " << data2->numDelayedFrames();
00124       str << "\n  numDiscardFrames = " << data2->numDiscardFrames();
00125       str << "\n  timeFrameStart =     " << PSTime::Time(data2->timeFrameStart().tv_sec(), data2->timeFrameStart().tv_nsec());
00126       str << "\n  timeFrameFirstData = " << PSTime::Time(data2->timeFrameFirstData().tv_sec(), data2->timeFrameFirstData().tv_nsec());
00127       str << "\n  timeFrameEnd =       " << PSTime::Time(data2->timeFrameEnd().tv_sec(), data2->timeFrameEnd().tv_nsec());
00128       str << "\n  numSpectraInData = " << int(data2->numSpectraInData());
00129       str << "\n  numSpectraInQueue = " << int(data2->numSpectraInQueue());
00130       str << "\n  numSpectraUnused = " << int(data2->numSpectraUnused());
00131       str << "\n  durationOfFrame = " << data2->durationOfFrame();
00132       str << "\n  nonlinerCorrected(0) = " << data2->nonlinerCorrected(0);
00133     }
00134   }
00135 
00136 }
00137 
00138 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7