psana_examples/src/EBeamHist.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: EBeamHist.cpp 9881 2015-04-08 21:20:56Z davidsch@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class EBeamHist...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/EBeamHist.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 
00022 //-------------------------------
00023 // Collaborating Class Headers --
00024 //-------------------------------
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "psddl_psana/bld.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(EBeamHist)
00035 
00036 //              ----------------------------------------
00037 //              -- Public Function Member Definitions --
00038 //              ----------------------------------------
00039 
00040 namespace psana_examples {
00041 
00042 //----------------
00043 // Constructors --
00044 //----------------
00045 EBeamHist::EBeamHist (const std::string& name)
00046   : Module(name)
00047   , m_ebeamHisto(0)
00048   , m_chargeHisto(0)
00049 {
00050   m_ebeamSrc = configSrc("eBeamSource", "BldInfo(EBeam)");
00051 }
00052 
00053 //--------------
00054 // Destructor --
00055 //--------------
00056 EBeamHist::~EBeamHist ()
00057 {
00058 }
00059 
00060 // Method which is called once at the beginning of the job
00061 void 
00062 EBeamHist::beginJob(Event& evt, Env& env)
00063 {
00064   if (not env.hmgr()) {
00065     MsgLog(name(), fatal, "psana env is not providing a hisogram manager. "
00066            "This example is for histogramming.");
00067   }
00068   m_ebeamHisto = env.hmgr()->hist1i("ebeamHisto", "ebeamL3Energy value", Axis(1000, 13000, 16000));
00069   m_chargeHisto = env.hmgr()->hist1i("echargeHisto", "ebeamCharge value", Axis(250, 0, 0.25));
00070 }
00071 
00072 // Method which is called with event data
00073 void 
00074 EBeamHist::event(Event& evt, Env& env)
00075 {
00076   shared_ptr<Psana::Bld::BldDataEBeamV1> ebeam = evt.get(m_ebeamSrc);
00077   if (ebeam) {
00078     m_ebeamHisto->fill(ebeam->ebeamL3Energy());
00079     m_chargeHisto->fill(ebeam->ebeamCharge());
00080   }
00081 }
00082 
00083 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7