00001 #ifndef PSANA_EXAMPLES_DUMPDAMAGE_H 00002 #define PSANA_EXAMPLES_DUMPDAMAGE_H 00003 00004 //-------------------------------------------------------------------------- 00005 // File and Version Information: 00006 // $Id: 00007 // 00008 // Description: 00009 // Class DumpDamage 00010 // 00011 //------------------------------------------------------------------------ 00012 00013 //----------------- 00014 // C/C++ Headers -- 00015 //----------------- 00016 #include <map> 00017 00018 //---------------------- 00019 // Base Class Headers -- 00020 //---------------------- 00021 #include "psana/Module.h" 00022 00023 //------------------------------- 00024 // Collaborating Class Headers -- 00025 //------------------------------- 00026 00027 //------------------------------------ 00028 // Collaborating Class Declarations -- 00029 //------------------------------------ 00030 #include "PSEvt/DamageMap.h" 00031 00032 // --------------------- 00033 // -- Class Interface -- 00034 // --------------------- 00035 00036 namespace psana_examples { 00037 00038 /// @addtogroup psana_examples 00039 00040 /** 00041 * @ingroup psana_examples 00042 * 00043 * @brief Module class that dumps damage, event/config/calib keys, and changed config keys 00044 * 00045 * This module is very similar to psana.EventKeys however it also dumps any damage 00046 * information that is available as well as updates to the configStore. It reports 00047 * on any keys that are found in more than one place. 00048 * 00049 * Here is an example of some output: 00050 * 00051 @verbatim 00052 [info:DumpDamage] event() run=0 calib=0 eventNumber=1 totalEvents= 1 00053 cfg --- --- --- EventKey(type=Pds::Camera::FrameFexConfigV1, src=DetInfo(CxiDg4.0:Tm6740.0)) 00054 cfg --- --- dmg 0x00000000 EventKey(type=Psana::Camera::FrameFexConfigV1, src=DetInfo(CxiDg4.0:Tm6740.0)) 00055 --- --- evt --- EventKey(type=PSEvt::EventId) 00056 --- --- evt --- EventKey(type=Pds::Dgram) 00057 --- --- evt dmg 0x00000000 EventKey(type=Psana::Bld::BldDataEBeamV1, src=BldInfo(EBeam)) 00058 --- --- --- dmg 0x00004000 EventKey(type=Psana::Ipimb::ConfigV1, src=BldInfo(NH2-SB1-IPM-01)) 00059 dropped=0 unititialized=0 OutOfOrder=0 OutOfSynch=0 UserDefined=1 IncompleteContribution=0 ContainsIncomplete=0 userBits=0x0 00060 -------- src damage with dropped contribs --------- 00061 0x00000002 ProcInfo(ac.15.15.2b, pid=6ccb) 00062 @endverbatim 00063 * Notice the counter which gives the event number within the calib cycle, as well as the 00064 * total number of events the module has seen. 00065 * 00066 * There are two sections of output, the list of keys and their damage, as well as src damage. 00067 * The first four columns indicate where the EventKey was found: 00068 * 00069 * - cfg: in the ConfigStore 00070 * - clb: in the CalibStore 00071 * - evt: in the Event 00072 * - dmg: in the DamageMap 00073 * 00074 * Keys that are in the damage map will also have their 32 bit damage value printed. 00075 * If this damage value is nonzero, then a second line is printed which indicates which 00076 * damage bits are on, and the value of the user damage bits. 00077 * 00078 * The second section, if present, means that src only damage was found. The damage, and then the 00079 * src are printed. A 00080 * 00081 * @note This software was developed for the LCLS project. If you use all or 00082 * part of it, please give an appropriate acknowledgment. 00083 * 00084 * @see Psana::EventKeys PSEvt::DamageMap PSEvt::HistI 00085 * 00086 * @version \$Id: 00087 * 00088 * @author David Schneider 00089 */ 00090 00091 class DumpDamage : public Module { 00092 public: 00093 00094 // Default constructor 00095 DumpDamage (const std::string& name) ; 00096 00097 // Destructor 00098 virtual ~DumpDamage () ; 00099 00100 /// Method which is called once at the beginning of the job 00101 virtual void beginJob(Event& evt, Env& env); 00102 00103 /// Method which is called at the beginning of the run 00104 virtual void beginRun(Event& evt, Env& env); 00105 00106 /// Method which is called at the beginning of the calibration cycle 00107 virtual void beginCalibCycle(Event& evt, Env& env); 00108 00109 /// Method which is called with event data 00110 virtual void event(Event& evt, Env& env); 00111 00112 /// Method which is called at the end of the calibration cycle 00113 virtual void endCalibCycle(Event& evt, Env& env); 00114 00115 /// Method which is called at the end of the run 00116 virtual void endRun(Event& evt, Env& env); 00117 00118 /// Method which is called once at the end of the job 00119 virtual void endJob(Event& evt, Env& env); 00120 00121 protected: 00122 void printConfigKeyUpdates(Env &env); 00123 void printKeysAndDamage(std::ostream &out, Event &evt, Env &env); 00124 private: 00125 long m_eventNumber, m_runNumber, m_calibCycleNumber; 00126 long m_totalEvents; 00127 std::map<PSEvt::EventKey, unsigned> m_configUpdates; 00128 std::map<PSEvt::EventKey, unsigned> m_calibUpdates; 00129 boost::shared_ptr<PSEvt::DamageMap> m_damageMap; 00130 }; 00131 00132 } // namespace psana_examples 00133 00134 #endif // PSANA_EXAMPLES_DUMPDAMAGE_H