psana/src/EventKeys.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: EventKeys.cpp 8884 2014-09-11 18:43:40Z dubrovin@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class EventKeys...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana/EventKeys.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <iostream>
00022 
00023 //-------------------------------
00024 // Collaborating Class Headers --
00025 //-------------------------------
00026 #include "MsgLogger/MsgLogger.h"
00027 
00028 //-----------------------------------------------------------------------
00029 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00030 //-----------------------------------------------------------------------
00031 
00032 using namespace psana;
00033 PSANA_MODULE_FACTORY(EventKeys)
00034 
00035 namespace {
00036   
00037   const char* logger = "EventKeys"; 
00038   
00039   void printKeys(std::ostream& out, const std::list<EventKey>& keys)
00040   {
00041     for (std::list<EventKey>::const_iterator it = keys.begin(); it != keys.end(); ++it) {
00042       std::cout << "  " << *it << '\n';
00043     }
00044   }
00045 }
00046 
00047 //              ----------------------------------------
00048 //              -- Public Function Member Definitions --
00049 //              ----------------------------------------
00050 
00051 namespace psana {
00052 
00053 //----------------
00054 // Constructors --
00055 //----------------
00056 EventKeys::EventKeys (const std::string& name)
00057   : Module(name)
00058   , m_print_cfg_in_evt()
00059   , m_print_clb_in_evt()
00060 {
00061   m_print_cfg_in_evt = config("print_cfg_in_evt", false);
00062   m_print_clb_in_evt = config("print_clb_in_evt", false);
00063 }
00064 
00065 //--------------
00066 // Destructor --
00067 //--------------
00068 EventKeys::~EventKeys ()
00069 {
00070 }
00071 
00072 /// Method which is called once at the beginning of the job
00073 void 
00074 EventKeys::beginJob(Event& evt, Env& env)
00075 {
00076   MsgLog(logger, info, name() << ": in beginJob()");
00077   
00078   std::cout << "Config keys:\n";
00079   ::printKeys(std::cout, env.configStore().keys());
00080   std::cout << "Calib keys:\n";
00081   ::printKeys(std::cout, env.calibStore().keys());
00082   std::cout << "Event keys:\n";
00083   ::printKeys(std::cout, evt.keys());
00084 }
00085 
00086 /// Method which is called at the beginning of the run
00087 void 
00088 EventKeys::beginRun(Event& evt, Env& env)
00089 {
00090   MsgLog(logger, info, name() << ": in beginRun()");
00091   
00092   std::cout << "Config keys:\n";
00093   ::printKeys(std::cout, env.configStore().keys());
00094   std::cout << "Calib keys:\n";
00095   ::printKeys(std::cout, env.calibStore().keys());
00096   std::cout << "Event keys:\n";
00097   ::printKeys(std::cout, evt.keys());
00098 }
00099 
00100 /// Method which is called at the beginning of the calibration cycle
00101 void 
00102 EventKeys::beginCalibCycle(Event& evt, Env& env)
00103 {
00104   MsgLog(logger, info, name() << ": in beginCalibCycle()");
00105   
00106   std::cout << "Config keys:\n";
00107   ::printKeys(std::cout, env.configStore().keys());
00108   std::cout << "Calib keys:\n";
00109   ::printKeys(std::cout, env.calibStore().keys());
00110   std::cout << "Event keys:\n";
00111   ::printKeys(std::cout, evt.keys());
00112 }
00113 
00114 /// Method which is called with event data, this is the only required 
00115 /// method, all other methods are optional
00116 void 
00117 EventKeys::event(Event& evt, Env& env)
00118 {
00119   MsgLog(logger, info, name() << ": in event()");
00120   
00121   if(m_print_cfg_in_evt) {
00122     std::cout << "Config keys:\n";
00123     ::printKeys(std::cout, env.configStore().keys());
00124   }
00125 
00126   if(m_print_clb_in_evt) {
00127     std::cout << "Calib keys:\n";
00128     ::printKeys(std::cout, env.calibStore().keys());
00129   }
00130 
00131   std::cout << "Event keys:\n";
00132   ::printKeys(std::cout, evt.keys());
00133 }
00134 
00135 /// Method which is called at the end of the calibration cycle
00136 void
00137 EventKeys::endCalibCycle(Event& evt, Env& env)
00138 {
00139   MsgLog(logger, info, name() << ": in endCalibCycle()");
00140 
00141   std::cout << "Event keys:\n";
00142   ::printKeys(std::cout, evt.keys());
00143 }
00144 
00145 /// Method which is called at the end of the run
00146 void
00147 EventKeys::endRun(Event& evt, Env& env)
00148 {
00149   MsgLog(logger, info, name() << ": in endRun()");
00150 
00151   std::cout << "Event keys:\n";
00152   ::printKeys(std::cout, evt.keys());
00153 }
00154 
00155 /// Method which is called once at the end of the job
00156 void
00157 EventKeys::endJob(Event& evt, Env& env)
00158 {
00159   MsgLog(logger, info, name() << ": in endJob()");
00160 
00161   std::cout << "Event keys:\n";
00162   ::printKeys(std::cout, evt.keys());
00163 }
00164 
00165 
00166 } // namespace psana

Generated on 19 Dec 2016 for PSANAclasses by  doxygen 1.4.7