psana_examples/src/DumpDgram.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id$
00004 //
00005 // Description:
00006 //      Class DumpDgram
00007 //
00008 // Author List:
00009 //
00010 //------------------------------------------------------------------------
00011 
00012 //-----------------------
00013 // This Class's Header --
00014 //-----------------------
00015 #include "psana_examples/DumpDgram.h"
00016 
00017 //-----------------
00018 // C/C++ Headers --
00019 //-----------------
00020 
00021 //-------------------------------
00022 // Collaborating Class Headers --
00023 //-------------------------------
00024 #include "MsgLogger/MsgLogger.h"
00025 
00026 //-----------------------------------------------------------------------
00027 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00028 //-----------------------------------------------------------------------
00029 
00030 using namespace psana_examples;
00031 PSANA_MODULE_FACTORY(DumpDgram)
00032 
00033 namespace {
00034     
00035 
00036 } // local namespace
00037 
00038 //              ----------------------------------------
00039 //              -- Public Function Member Definitions --
00040 //              ----------------------------------------
00041 
00042 namespace psana_examples {
00043 
00044 //----------------
00045 // Constructors --
00046 //----------------
00047 DumpDgram::DumpDgram (const std::string& name)
00048   : Module(name)
00049 {
00050 }
00051 
00052 //--------------
00053 // Destructor --
00054 //--------------
00055 DumpDgram::~DumpDgram ()
00056 {
00057 }
00058 
00059 void 
00060 DumpDgram::beginJob(Event& evt, Env& env)
00061 {
00062   dgramDump(evt,"beginJob()");
00063 }
00064 
00065 void 
00066 DumpDgram::beginRun(Event& evt, Env& env)
00067 {
00068   dgramDump(evt, "beginRun()");
00069 }
00070 
00071 void 
00072 DumpDgram::beginCalibCycle(Event& evt, Env& env)
00073 {
00074   dgramDump(evt, "beginCalibCycle()");
00075 }
00076 
00077 void 
00078 DumpDgram::event(Event& evt, Env& env)
00079 {
00080   dgramDump(evt, "event()");
00081 }
00082 
00083 /// Method which is called at the end of the calibration cycle
00084 void
00085 DumpDgram::endCalibCycle(Event& evt, Env& env)
00086 {
00087   dgramDump(evt, "endCalibCycle()");
00088 }
00089 
00090 /// Method which is called at the end of the run
00091 void
00092 DumpDgram::endRun(Event& evt, Env& env)
00093 {
00094   dgramDump(evt, "endRun()");
00095 }
00096 
00097 /// Method which is called once at the end of the job
00098 void
00099 DumpDgram::endJob(Event& evt, Env& env)
00100 {
00101   dgramDump(evt, "endJob()");
00102 }
00103 
00104 void
00105 DumpDgram::dgramDump(Event &evt, const std::string & hdr) 
00106 {
00107   XtcInput::Dgram::ptr dgptr = evt.get();
00108   boost::shared_ptr<XtcInput::DgramList> dgListptr = evt.get();
00109   if ((not dgptr) and (not dgListptr)) {
00110     MsgLog( name(), info, " " << hdr << ": no XtcInput::DgramList or Pds::Dgram found in Event.");
00111   }
00112   if (dgptr) {
00113     const Pds::ClockTime &clock = dgptr->seq.clock();
00114     const Pds::TimeStamp & stamp = dgptr->seq.stamp();
00115     MsgLog(name(), info, " " << hdr << ": Pds::Dgram found: "
00116            << " sec=" << clock.seconds()
00117            << " nsec=" << clock.nanoseconds()
00118            << " fid=" << stamp.fiducials());
00119   }
00120   if (dgListptr) {
00121     std::vector<XtcInput::Dgram::ptr> dgrams=  dgListptr->getDgrams();
00122     if (dgrams.size()==0) {
00123       MsgLog( name(), info, " " << hdr << ": XtcInput::DgramList found with no dgrams.");
00124       return;
00125     }
00126     MsgLog( name(), info, " " << hdr << ": XtcInput::DgramList found with " << dgrams.size() << " dgrams.");
00127     std::vector<XtcInput::XtcFileName> files =  dgListptr->getFileNames();
00128     std::vector<off64_t> offsets =  dgListptr->getOffsets();
00129     for (unsigned idx = 0; idx < files.size(); ++idx) {
00130       XtcInput::XtcFileName &file = files.at(idx);
00131       off64_t offset = offsets.at(idx);
00132       XtcInput::Dgram::ptr &dgptr = dgrams.at(idx);
00133       const Pds::ClockTime &clock = dgptr->seq.clock();
00134       const Pds::TimeStamp & stamp = dgptr->seq.stamp();
00135       std::cout << " dg " << idx << ": " 
00136                 << " sec=" << clock.seconds()
00137                 << " nsec=" << clock.nanoseconds()
00138                 << " fid=" << stamp.fiducials()
00139                 << " basename=" << file.basename()
00140                 << " run=" << file.run()
00141                 << " stream=" << file.stream()
00142                 << " chunk=" << file.chunk()
00143                 << " offset=" << offset
00144                 << std::endl;
00145     }
00146   }
00147 }
00148 
00149 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7