00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "psana_examples/DumpEvr.h"
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include "MsgLogger/MsgLogger.h"
00026 #include "psddl_psana/evr.ddl.h"
00027
00028
00029
00030
00031
00032 using namespace psana_examples;
00033 PSANA_MODULE_FACTORY(DumpEvr)
00034
00035 namespace {
00036
00037
00038
00039 void print(std::ostream& str, unsigned i, const Psana::EvrData::PulseConfig& pcfg)
00040 {
00041 str << "\n pulse config #" << i
00042 << ": pulse=" << pcfg.pulse()
00043 << " polarity=" << int(pcfg.polarity())
00044 << " prescale=" << pcfg.prescale()
00045 << " delay=" << pcfg.delay()
00046 << " width=" << pcfg.width();
00047 }
00048
00049 void print(std::ostream& str, unsigned i, const Psana::EvrData::OutputMap& ocfg)
00050 {
00051 str << "\n output config #" << i
00052 << ": source=" << ocfg.source()
00053 << " source_id=" << int(ocfg.source_id())
00054 << " conn=" << ocfg.conn()
00055 << " conn_id=" << int(ocfg.conn_id())
00056 << " map=" << ocfg.map();
00057 }
00058
00059 void print(std::ostream& str, unsigned i, const Psana::EvrData::OutputMapV2& ocfg)
00060 {
00061 str << "\n output config #" << i
00062 << ": source=" << ocfg.source()
00063 << " source_id=" << int(ocfg.source_id())
00064 << " conn=" << ocfg.conn()
00065 << " conn_id=" << int(ocfg.conn_id())
00066 << " module=" << int(ocfg.module())
00067 << " map=" << ocfg.map();
00068 }
00069
00070 void print(std::ostream& str, unsigned i, const Psana::EvrData::PulseConfigV3& pcfg)
00071 {
00072 str << "\n pulse config #" << i
00073 << ": pulseId=" << pcfg.pulseId()
00074 << " polarity=" << int(pcfg.polarity())
00075 << " prescale=" << pcfg.prescale()
00076 << " delay=" << pcfg.delay()
00077 << " width=" << pcfg.width();
00078 }
00079
00080 void print(std::ostream& str, unsigned i, const Psana::EvrData::EventCodeV3& ecfg)
00081 {
00082 str << "\n event code #" << i
00083 << ": code=" << ecfg.code()
00084 << " isReadout=" << int(ecfg.isReadout())
00085 << " isTerminator=" << int(ecfg.isTerminator())
00086 << " maskTrigger=" << ecfg.maskTrigger()
00087 << " maskSet=" << ecfg.maskSet()
00088 << " maskClear=" << ecfg.maskClear();
00089
00090 }
00091
00092 void print(std::ostream& str, unsigned i, const Psana::EvrData::EventCodeV4& ecfg)
00093 {
00094 str << "\n event code #" << i
00095 << ": code=" << ecfg.code()
00096 << " isReadout=" << int(ecfg.isReadout())
00097 << " isTerminator=" << int(ecfg.isTerminator())
00098 << " reportDelay=" << ecfg.reportDelay()
00099 << " reportWidth=" << ecfg.reportWidth()
00100 << " maskTrigger=" << ecfg.maskTrigger()
00101 << " maskSet=" << ecfg.maskSet()
00102 << " maskClear=" << ecfg.maskClear();
00103 }
00104
00105 void print(std::ostream& str, unsigned i, const Psana::EvrData::EventCodeV5& ecfg)
00106 {
00107 str << "\n event code #" << i
00108 << ": code=" << ecfg.code()
00109 << " isReadout=" << int(ecfg.isReadout())
00110 << " isCommand=" << int(ecfg.isCommand())
00111 << " isLatch=" << int(ecfg.isLatch())
00112 << " reportDelay=" << ecfg.reportDelay()
00113 << " reportWidth=" << ecfg.reportWidth()
00114 << " maskTrigger=" << ecfg.maskTrigger()
00115 << " maskSet=" << ecfg.maskSet()
00116 << " maskClear=" << ecfg.maskClear()
00117 << " description=" << ecfg.desc();
00118 }
00119
00120 void print(std::ostream& str, unsigned i, const Psana::EvrData::EventCodeV6& ecfg)
00121 {
00122 str << "\n event code #" << i
00123 << ": code=" << ecfg.code()
00124 << " isReadout=" << int(ecfg.isReadout())
00125 << " isCommand=" << int(ecfg.isCommand())
00126 << " isLatch=" << int(ecfg.isLatch())
00127 << " reportDelay=" << ecfg.reportDelay()
00128 << " reportWidth=" << ecfg.reportWidth()
00129 << " maskTrigger=" << ecfg.maskTrigger()
00130 << " maskSet=" << ecfg.maskSet()
00131 << " maskClear=" << ecfg.maskClear()
00132 << " readoutGroup=" << ecfg.readoutGroup()
00133 << " description=" << ecfg.desc();
00134 }
00135
00136 void print(std::ostream& str, unsigned i, const Psana::EvrData::SequencerEntry& e)
00137 {
00138 str << "\n entry #" << i << " delay=" << e.delay() << " eventcode=" << e.eventcode();
00139 }
00140
00141 void print(std::ostream& str, unsigned i, const Psana::EvrData::IOChannel& ioch)
00142 {
00143 str << "\n io channel #" << i
00144 << ": name=" << ioch.name()
00145 << " infos=[";
00146 for (unsigned d = 0; d != ioch.ninfo(); ++ d) {
00147 str << " " << Pds::DetInfo::name(ioch.infos()[d]);
00148 }
00149 str << " ]";
00150 }
00151
00152 void print(std::ostream& str, unsigned i, const Psana::EvrData::FIFOEvent& f)
00153 {
00154 str << "\n fifo event #" << i
00155 << " timestampHigh=" << f.timestampHigh()
00156 << " timestampLow=" << f.timestampLow()
00157 << " eventCode=" << f.eventCode();
00158 }
00159
00160 template <typename T>
00161 void print_array(std::ostream& str, const ndarray<T, 1>& array) {
00162 for (unsigned i = 0; i < array.size(); ++ i) {
00163 ::print(str, i, array[i]);
00164 }
00165 }
00166
00167 }
00168
00169
00170
00171
00172
00173 namespace psana_examples {
00174
00175
00176
00177
00178 DumpEvr::DumpEvr (const std::string& name)
00179 : Module(name)
00180 {
00181 m_src = configSrc("source", "DetInfo(:Evr)");
00182 }
00183
00184
00185
00186
00187 DumpEvr::~DumpEvr ()
00188 {
00189 }
00190
00191
00192 void
00193 DumpEvr::beginCalibCycle(Event& evt, Env& env)
00194 {
00195 MsgLog(name(), trace, "in beginCalibCycle()");
00196
00197
00198 shared_ptr<Psana::EvrData::ConfigV1> config1 = env.configStore().get(m_src);
00199 if (config1) {
00200
00201 WithMsgLog(name(), info, str) {
00202 str << "EvrData::ConfigV1: npulses = " << config1->npulses()
00203 << " noutputs = " << config1->noutputs();
00204
00205 ::print_array(str, config1->pulses());
00206 ::print_array(str, config1->output_maps());
00207
00208 }
00209
00210 }
00211
00212
00213 shared_ptr<Psana::EvrData::ConfigV2> config2 = env.configStore().get(m_src);
00214 if (config2) {
00215
00216 WithMsgLog(name(), info, str) {
00217 str << "EvrData::ConfigV2: npulses = " << config2->npulses()
00218 << " noutputs = " << config2->noutputs()
00219 << " beam = " << config2->beam()
00220 << " rate = " << config2->rate() ;
00221
00222 ::print_array(str, config2->pulses());
00223 ::print_array(str, config2->output_maps());
00224
00225 }
00226
00227 }
00228
00229
00230 shared_ptr<Psana::EvrData::ConfigV3> config3 = env.configStore().get(m_src);
00231 if (config3) {
00232
00233 WithMsgLog(name(), info, str) {
00234 str << "EvrData::ConfigV3: npulses = " << config3->npulses()
00235 << " noutputs = " << config3->noutputs()
00236 << " neventcodes = " << config3->neventcodes();
00237
00238 ::print_array(str, config3->pulses());
00239 ::print_array(str, config3->output_maps());
00240 ::print_array(str, config3->eventcodes());
00241
00242 }
00243
00244 }
00245
00246
00247 shared_ptr<Psana::EvrData::ConfigV4> config4 = env.configStore().get(m_src);
00248 if (config4) {
00249
00250 WithMsgLog(name(), info, str) {
00251 str << "EvrData::ConfigV4: npulses = " << config4->npulses()
00252 << " noutputs = " << config4->noutputs()
00253 << " neventcodes = " << config4->neventcodes();
00254
00255 ::print_array(str, config4->pulses());
00256 ::print_array(str, config4->output_maps());
00257 ::print_array(str, config4->eventcodes());
00258
00259 }
00260
00261 }
00262
00263
00264 shared_ptr<Psana::EvrData::ConfigV5> config5 = env.configStore().get(m_src);
00265 if (config5) {
00266
00267 WithMsgLog(name(), info, str) {
00268 str << "EvrData::ConfigV5: npulses = " << config5->npulses()
00269 << " noutputs = " << config5->noutputs()
00270 << " neventcodes = " << config5->neventcodes();
00271
00272 ::print_array(str, config5->pulses());
00273 ::print_array(str, config5->output_maps());
00274 ::print_array(str, config5->eventcodes());
00275
00276 const Psana::EvrData::SequencerConfigV1& scfg = config5->seq_config();
00277 str << "\n seq_config: sync_source=" << scfg.sync_source()
00278 << " beam_source=" << scfg.beam_source()
00279 << " length=" << scfg.length()
00280 << " cycles=" << scfg.cycles();
00281
00282 ::print_array(str, scfg.entries());
00283
00284 }
00285
00286 }
00287
00288
00289 shared_ptr<Psana::EvrData::ConfigV6> config6 = env.configStore().get(m_src);
00290 if (config6) {
00291
00292 WithMsgLog(name(), info, str) {
00293 str << "EvrData::ConfigV6: npulses = " << config6->npulses()
00294 << " noutputs = " << config6->noutputs()
00295 << " neventcodes = " << config6->neventcodes();
00296
00297 ::print_array(str, config6->pulses());
00298 ::print_array(str, config6->output_maps());
00299 ::print_array(str, config6->eventcodes());
00300
00301 const Psana::EvrData::SequencerConfigV1& scfg = config6->seq_config();
00302 str << "\n seq_config: sync_source=" << scfg.sync_source()
00303 << " beam_source=" << scfg.beam_source()
00304 << " length=" << scfg.length()
00305 << " cycles=" << scfg.cycles();
00306
00307 ::print_array(str, scfg.entries());
00308
00309 }
00310
00311 }
00312
00313
00314 shared_ptr<Psana::EvrData::ConfigV7> config7 = env.configStore().get(m_src);
00315 if (config7) {
00316
00317 WithMsgLog(name(), info, str) {
00318 str << "EvrData::ConfigV7: npulses = " << config7->npulses()
00319 << " noutputs = " << config7->noutputs()
00320 << " neventcodes = " << config7->neventcodes();
00321
00322 ::print_array(str, config7->pulses());
00323 ::print_array(str, config7->output_maps());
00324 ::print_array(str, config7->eventcodes());
00325
00326 const Psana::EvrData::SequencerConfigV1& scfg = config7->seq_config();
00327 str << "\n seq_config: sync_source=" << scfg.sync_source()
00328 << " beam_source=" << scfg.beam_source()
00329 << " length=" << scfg.length()
00330 << " cycles=" << scfg.cycles();
00331
00332 ::print_array(str, scfg.entries());
00333
00334 }
00335
00336 }
00337
00338 shared_ptr<Psana::EvrData::IOConfigV1> iocfg1 = env.configStore().get(m_src);
00339 if (iocfg1) {
00340
00341 WithMsgLog(name(), info, str) {
00342 str << "EvrData::IOConfigV1: nchannels = " << iocfg1->nchannels()
00343 << " conn = " << iocfg1->conn();
00344
00345 ::print_array(str, iocfg1->channels());
00346
00347 }
00348 }
00349
00350 }
00351
00352
00353 void
00354 DumpEvr::event(Event& evt, Env& env)
00355 {
00356 shared_ptr<Psana::EvrData::DataV3> data3 = evt.get(m_src);
00357 if (data3) {
00358
00359 WithMsgLog(name(), info, str) {
00360 str << "EvrData::DataV3: numFifoEvents=" << data3->numFifoEvents();
00361 ::print_array(str, data3->fifoEvents());
00362 }
00363 }
00364
00365 }
00366
00367 }