psana_examples/src/DumpImp.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpImp.cpp 6345 2013-05-22 15:42:35Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpImp...
00007 //
00008 // Author List:
00009 //      Andy Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpImp.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "psddl_psana/imp.ddl.h"
00027 
00028 //-----------------------------------------------------------------------
00029 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00030 //-----------------------------------------------------------------------
00031 
00032 // This declares this class as psana module
00033 using namespace psana_examples;
00034 PSANA_MODULE_FACTORY(DumpImp)
00035 
00036 //              ----------------------------------------
00037 //              -- Public Function Member Definitions --
00038 //              ----------------------------------------
00039 
00040 namespace psana_examples {
00041 
00042 //----------------
00043 // Constructors --
00044 //----------------
00045 DumpImp::DumpImp (const std::string& name)
00046   : Module(name)
00047   , m_src()
00048 {
00049   m_src = configSrc("source", "DetInfo(:Imp)");
00050 }
00051 
00052 //--------------
00053 // Destructor --
00054 //--------------
00055 DumpImp::~DumpImp ()
00056 {
00057 }
00058 
00059 /// Method which is called at the beginning of the run
00060 void 
00061 DumpImp::beginRun(Event& evt, Env& env)
00062 {
00063   MsgLog(name(), info, "in beginRun()");
00064 
00065   Pds::Src actualSrc;
00066   shared_ptr<Psana::Imp::ConfigV1> config1 = env.configStore().get(m_src, &actualSrc);
00067   if (config1) {
00068     WithMsgLog(name(), info, str) {
00069       str << "Imp::ConfigV1 at " << actualSrc;
00070       str << "\n  range = " << config1->range();
00071       str << "\n  calRange = " << config1->calRange();
00072       str << "\n  reset = " << config1->reset();
00073       str << "\n  biasData = " << config1->biasData();
00074       str << "\n  calData = " << config1->calData();
00075       str << "\n  biasDacData = " << config1->biasDacData();
00076       str << "\n  calStrobe = " << config1->calStrobe();
00077       str << "\n  numberOfSamples = " << config1->numberOfSamples();
00078       str << "\n  trigDelay = " << config1->trigDelay();
00079       str << "\n  adcDelay = " << config1->adcDelay();
00080     }
00081   }
00082 }
00083 
00084 /// Method which is called with event data, this is the only required 
00085 /// method, all other methods are optional
00086 void 
00087 DumpImp::event(Event& evt, Env& env)
00088 {
00089   Pds::Src actualSrc;
00090   shared_ptr<Psana::Imp::ElementV1> data1 = evt.get(m_src, "", &actualSrc);
00091   if (data1) {
00092 
00093     WithMsgLog(name(), info, str) {
00094       str << "Imp::ElementV1 at " << actualSrc
00095           << "\n  vc = " << int(data1->vc())
00096           << "\n  lane = " << int(data1->lane())
00097           << "\n  frameNumber = " << data1->frameNumber()
00098           << "\n  range = " << data1->range();
00099 
00100       Psana::Imp::LaneStatus laneStatus = data1->laneStatus();
00101       str << "\n  laneStatus.linkErrCount = " << int(laneStatus.linkErrCount())
00102           << "\n  laneStatus.linkDownCount = " << int(laneStatus.linkDownCount())
00103           << "\n  laneStatus.cellErrCount = " << int(laneStatus.cellErrCount())
00104           << "\n  laneStatus.rxCount = " << int(laneStatus.rxCount())
00105           << "\n  laneStatus.locLinked = " << int(laneStatus.locLinked())
00106           << "\n  laneStatus.remLinked = " << int(laneStatus.remLinked())
00107           << "\n  laneStatus.zeros = " << int(laneStatus.zeros())
00108           << "\n  laneStatus.powersOkay = " << int(laneStatus.powersOkay());
00109 
00110       // get samples 1-d array
00111       const ndarray<const Psana::Imp::Sample, 1>& samples = data1->samples();
00112       for (unsigned i = 0; i != samples.size(); ++ i) {
00113         str << "\n  sample[" << i << "]: channels = " << samples[i].channels();
00114       }
00115 
00116     }
00117   }
00118 }
00119   
00120 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7