psana_examples/src/DumpCsPad.cpp

Go to the documentation of this file.
00001 //--------------------------------------------------------------------------
00002 // File and Version Information:
00003 //      $Id: DumpCsPad.cpp 6173 2013-04-26 17:19:22Z salnikov@SLAC.STANFORD.EDU $
00004 //
00005 // Description:
00006 //      Class DumpCsPad...
00007 //
00008 // Author List:
00009 //      Andrei Salnikov
00010 //
00011 //------------------------------------------------------------------------
00012 
00013 //-----------------------
00014 // This Class's Header --
00015 //-----------------------
00016 #include "psana_examples/DumpCsPad.h"
00017 
00018 //-----------------
00019 // C/C++ Headers --
00020 //-----------------
00021 #include <algorithm>
00022 #include <iomanip>
00023 #include <iterator>
00024 #include <numeric>
00025 #include <functional>
00026 
00027 //-------------------------------
00028 // Collaborating Class Headers --
00029 //-------------------------------
00030 #include "MsgLogger/MsgLogger.h"
00031 #include "psddl_psana/cspad.ddl.h"
00032 
00033 //-----------------------------------------------------------------------
00034 // Local Macros, Typedefs, Structures, Unions and Forward Declarations --
00035 //-----------------------------------------------------------------------
00036 
00037 using namespace psana_examples;
00038 PSANA_MODULE_FACTORY(DumpCsPad)
00039 
00040 namespace {
00041 
00042   void dumpQuadReg(std::ostream& str, const Psana::CsPad::ConfigV1QuadReg& quad)
00043   {
00044     str << "\n    shiftSelect = " << quad.shiftSelect();
00045     str << "\n    edgeSelect = " << quad.edgeSelect();
00046     str << "\n    readClkSet = " << quad.readClkSet();
00047     str << "\n    readClkHold = " << quad.readClkHold();
00048     str << "\n    dataMode = " << quad.dataMode();
00049     str << "\n    prstSel = " << quad.prstSel();
00050     str << "\n    acqDelay = " << quad.acqDelay();
00051     str << "\n    intTime = " << quad.intTime();
00052     str << "\n    digDelay = " << quad.digDelay();
00053     str << "\n    ampIdle = " << quad.ampIdle();
00054     str << "\n    injTotal = " << quad.injTotal();
00055     str << "\n    rowColShiftPer = " << quad.rowColShiftPer();
00056     str << "\n    digitalPots = " << quad.dp().pots();
00057     str << "\n    readOnly = shiftTest: " << quad.ro().shiftTest() << " verstion: " << quad.ro().version();
00058     str << "\n    gainMap = " << quad.gm().gainMap();
00059   }
00060 
00061   void dumpQuadReg(std::ostream& str, const Psana::CsPad::ConfigV2QuadReg& quad)
00062   {
00063     str << "\n    shiftSelect = " << quad.shiftSelect();
00064     str << "\n    edgeSelect = " << quad.edgeSelect();
00065     str << "\n    readClkSet = " << quad.readClkSet();
00066     str << "\n    readClkHold = " << quad.readClkHold();
00067     str << "\n    dataMode = " << quad.dataMode();
00068     str << "\n    prstSel = " << quad.prstSel();
00069     str << "\n    acqDelay = " << quad.acqDelay();
00070     str << "\n    intTime = " << quad.intTime();
00071     str << "\n    digDelay = " << quad.digDelay();
00072     str << "\n    ampIdle = " << quad.ampIdle();
00073     str << "\n    injTotal = " << quad.injTotal();
00074     str << "\n    rowColShiftPer = " << quad.rowColShiftPer();
00075     str << "\n    ampReset = " << quad.ampReset();
00076     str << "\n    digCount = " << quad.digCount();
00077     str << "\n    digPeriod = " << quad.digPeriod();
00078     str << "\n    digitalPots = " << quad.dp().pots();
00079     str << "\n    readOnly = shiftTest: " << quad.ro().shiftTest() << " verstion: " << quad.ro().version();
00080     str << "\n    gainMap = " << quad.gm().gainMap();
00081   }
00082 
00083   void dumpQuadReg(std::ostream& str, const Psana::CsPad::ConfigV3QuadReg& quad)
00084   {
00085     str << "\n    shiftSelect = " << quad.shiftSelect();
00086     str << "\n    edgeSelect = " << quad.edgeSelect();
00087     str << "\n    readClkSet = " << quad.readClkSet();
00088     str << "\n    readClkHold = " << quad.readClkHold();
00089     str << "\n    dataMode = " << quad.dataMode();
00090     str << "\n    prstSel = " << quad.prstSel();
00091     str << "\n    acqDelay = " << quad.acqDelay();
00092     str << "\n    intTime = " << quad.intTime();
00093     str << "\n    digDelay = " << quad.digDelay();
00094     str << "\n    ampIdle = " << quad.ampIdle();
00095     str << "\n    injTotal = " << quad.injTotal();
00096     str << "\n    rowColShiftPer = " << quad.rowColShiftPer();
00097     str << "\n    ampReset = " << quad.ampReset();
00098     str << "\n    digCount = " << quad.digCount();
00099     str << "\n    digPeriod = " << quad.digPeriod();
00100     str << "\n    biasTuning = " << quad.biasTuning();
00101     str << "\n    pdpmndnmBalance = " << quad.pdpmndnmBalance();
00102     str << "\n    digitalPots = " << quad.dp().pots();
00103     str << "\n    readOnly = shiftTest: " << quad.ro().shiftTest() << " verstion: " << quad.ro().version();
00104     str << "\n    gainMap = " << quad.gm().gainMap();
00105   }
00106 
00107 }
00108 
00109 
00110 //              ----------------------------------------
00111 //              -- Public Function Member Definitions --
00112 //              ----------------------------------------
00113 
00114 namespace psana_examples {
00115 
00116 //----------------
00117 // Constructors --
00118 //----------------
00119 DumpCsPad::DumpCsPad (const std::string& name)
00120   : Module(name)
00121 {
00122   m_key = configStr("inputKey", "");
00123   m_src = configSrc("source", "DetInfo(:Cspad)");
00124 }
00125 
00126 //--------------
00127 // Destructor --
00128 //--------------
00129 DumpCsPad::~DumpCsPad ()
00130 {
00131 }
00132 
00133 // Method which is called at the beginning of the calibration cycle
00134 void 
00135 DumpCsPad::beginCalibCycle(Event& evt, Env& env)
00136 {
00137   MsgLog(name(), trace, "in beginCalibCycle()");
00138 
00139   shared_ptr<Psana::CsPad::ConfigV1> config1 = env.configStore().get(m_src);
00140   if (config1) {
00141     
00142     WithMsgLog(name(), info, str) {
00143       str << "CsPad::ConfigV1:";
00144       str << "\n  concentratorVersion = " << config1->concentratorVersion();
00145       str << "\n  runDelay = " << config1->runDelay();
00146       str << "\n  eventCode = " << config1->eventCode();
00147       str << "\n  inactiveRunMode = " << config1->inactiveRunMode();
00148       str << "\n  activeRunMode = " << config1->activeRunMode();
00149       str << "\n  tdi = " << config1->tdi();
00150       str << "\n  payloadSize = " << config1->payloadSize();
00151       str << "\n  badAsicMask0 = " << config1->badAsicMask0();
00152       str << "\n  badAsicMask1 = " << config1->badAsicMask1();
00153       str << "\n  asicMask = " << config1->asicMask();
00154       str << "\n  quadMask = " << config1->quadMask();
00155       str << "\n  numAsicsRead = " << config1->numAsicsRead();
00156       str << "\n  numQuads = " << config1->numQuads();
00157       str << "\n  numSect = " << config1->numSect();
00158       for (unsigned iq = 0; iq != config1->numQuads(); ++ iq) {
00159         str << "\n  quad #" << iq;
00160         dumpQuadReg(str, config1->quads(iq));
00161       }
00162     }
00163     
00164   }
00165 
00166   shared_ptr<Psana::CsPad::ConfigV2> config2 = env.configStore().get(m_src);
00167   if (config2) {
00168     
00169     WithMsgLog(name(), info, str) {
00170       str << "CsPad::ConfigV2:";
00171       str << "\n  concentratorVersion = " << config2->concentratorVersion();
00172       str << "\n  runDelay = " << config2->runDelay();
00173       str << "\n  eventCode = " << config2->eventCode();
00174       str << "\n  inactiveRunMode = " << config2->inactiveRunMode();
00175       str << "\n  activeRunMode = " << config2->activeRunMode();
00176       str << "\n  tdi = " << config2->tdi();
00177       str << "\n  payloadSize = " << config2->payloadSize();
00178       str << "\n  badAsicMask0 = " << config2->badAsicMask0();
00179       str << "\n  badAsicMask1 = " << config2->badAsicMask1();
00180       str << "\n  asicMask = " << config2->asicMask();
00181       str << "\n  quadMask = " << config2->quadMask();
00182       str << "\n  numAsicsRead = " << config2->numAsicsRead();
00183       str << "\n  numQuads = " << config2->numQuads();
00184       str << "\n  numSect = " << config2->numSect();
00185       str << "\n  roiMask =";
00186       for (unsigned i = 0; i < config2->numQuads(); ++ i) {
00187         str.setf(std::ios::showbase);
00188         str << ' ' << std::hex << config2->roiMask(i) << std::dec;
00189       }
00190       str << "\n  numAsicsStored =";
00191       for (unsigned i = 0; i < config2->numQuads(); ++ i) {
00192         str << ' ' << config2->numAsicsStored(i);
00193       }
00194       for (unsigned iq = 0; iq != config2->numQuads(); ++ iq) {
00195         str << "\n  quad #" << iq;
00196         dumpQuadReg(str, config2->quads(iq));
00197       }
00198     }
00199     
00200   }
00201 
00202   shared_ptr<Psana::CsPad::ConfigV3> config3 = env.configStore().get(m_src);
00203   if (config3) {
00204     
00205     WithMsgLog(name(), info, str) {
00206       str << "CsPad::ConfigV3:";
00207       str << "\n  concentratorVersion = " << config3->concentratorVersion();
00208       str << "\n  runDelay = " << config3->runDelay();
00209       str << "\n  eventCode = " << config3->eventCode();
00210       str << "\n  protectionEnable = " << config3->protectionEnable();
00211       str << "\n  protectionThresholds:";
00212       for (unsigned i = 0; i < config3->numQuads(); ++ i) {
00213         const Psana::CsPad::ProtectionSystemThreshold& thr = config3->protectionThresholds()[i];
00214         str << "\n    adcThreshold=" << thr.adcThreshold()
00215             << " pixelCountThreshold=" << thr.pixelCountThreshold();
00216       }
00217       str << "\n  inactiveRunMode = " << config3->inactiveRunMode();
00218       str << "\n  activeRunMode = " << config3->activeRunMode();
00219       str << "\n  tdi = " << config3->tdi();
00220       str << "\n  payloadSize = " << config3->payloadSize();
00221       str << "\n  badAsicMask0 = " << config3->badAsicMask0();
00222       str << "\n  badAsicMask1 = " << config3->badAsicMask1();
00223       str << "\n  asicMask = " << config3->asicMask();
00224       str << "\n  quadMask = " << config3->quadMask();
00225       str << "\n  numAsicsRead = " << config3->numAsicsRead();
00226       str << "\n  numQuads = " << config3->numQuads();
00227       str << "\n  numSect = " << config3->numSect();
00228       str << "\n  roiMask =";
00229       for (unsigned i = 0; i < config3->numQuads(); ++ i) {
00230         str.setf(std::ios::showbase);
00231         str << ' ' << std::hex << config3->roiMask(i) << std::dec;
00232       }
00233       str << "\n  numAsicsStored =";
00234       for (unsigned i = 0; i < config3->numQuads(); ++ i) {
00235         str << ' ' << config3->numAsicsStored(i);
00236       }
00237       for (unsigned iq = 0; iq != config3->numQuads(); ++ iq) {
00238         str << "\n  quad #" << iq;
00239         dumpQuadReg(str, config3->quads(iq));
00240       }
00241     }
00242     
00243   }
00244 
00245   shared_ptr<Psana::CsPad::ConfigV4> config4 = env.configStore().get(m_src);
00246   if (config4) {
00247     
00248     WithMsgLog(name(), info, str) {
00249       str << "CsPad::ConfigV4:";
00250       str << "\n  concentratorVersion = " << config4->concentratorVersion();
00251       str << "\n  runDelay = " << config4->runDelay();
00252       str << "\n  eventCode = " << config4->eventCode();
00253       str << "\n  protectionEnable = " << config4->protectionEnable();
00254       str << "\n  protectionThresholds:";
00255       for (unsigned i = 0; i < config4->numQuads(); ++ i) {
00256         const Psana::CsPad::ProtectionSystemThreshold& thr = config4->protectionThresholds()[i];
00257         str << "\n    adcThreshold=" << thr.adcThreshold()
00258             << " pixelCountThreshold=" << thr.pixelCountThreshold();
00259       }
00260       str << "\n  inactiveRunMode = " << config4->inactiveRunMode();
00261       str << "\n  activeRunMode = " << config4->activeRunMode();
00262       str << "\n  tdi = " << config4->tdi();
00263       str << "\n  payloadSize = " << config4->payloadSize();
00264       str << "\n  badAsicMask0 = " << config4->badAsicMask0();
00265       str << "\n  badAsicMask1 = " << config4->badAsicMask1();
00266       str << "\n  asicMask = " << config4->asicMask();
00267       str << "\n  quadMask = " << config4->quadMask();
00268       str << "\n  numAsicsRead = " << config4->numAsicsRead();
00269       str << "\n  numQuads = " << config4->numQuads();
00270       str << "\n  numSect = " << config4->numSect();
00271       str << "\n  roiMask =";
00272       for (unsigned i = 0; i < config4->numQuads(); ++ i) {
00273         str.setf(std::ios::showbase);
00274         str << ' ' << std::hex << config4->roiMask(i) << std::dec;
00275       }
00276       str << "\n  numAsicsStored =";
00277       for (unsigned i = 0; i < config4->numQuads(); ++ i) {
00278         str << ' ' << config4->numAsicsStored(i);
00279       }
00280       for (unsigned iq = 0; iq != config4->numQuads(); ++ iq) {
00281         str << "\n  quad #" << iq;
00282         dumpQuadReg(str, config4->quads(iq));
00283       }
00284     }
00285     
00286   }
00287 
00288   shared_ptr<Psana::CsPad::ConfigV5> config5 = env.configStore().get(m_src);
00289   if (config5) {
00290 
00291     WithMsgLog(name(), info, str) {
00292       str << "CsPad::ConfigV5:";
00293       str << "\n  concentratorVersion = " << config5->concentratorVersion();
00294       str << "\n  runDelay = " << config5->runDelay();
00295       str << "\n  eventCode = " << config5->eventCode();
00296       str << "\n  protectionEnable = " << config5->protectionEnable();
00297       str << "\n  protectionThresholds:";
00298       for (unsigned i = 0; i < config5->numQuads(); ++ i) {
00299         const Psana::CsPad::ProtectionSystemThreshold& thr = config5->protectionThresholds()[i];
00300         str << "\n    adcThreshold=" << thr.adcThreshold()
00301             << " pixelCountThreshold=" << thr.pixelCountThreshold();
00302       }
00303       str << "\n  inactiveRunMode = " << config5->inactiveRunMode();
00304       str << "\n  activeRunMode = " << config5->activeRunMode();
00305       str << "\n  tdi = " << config5->tdi();
00306       str << "\n  payloadSize = " << config5->payloadSize();
00307       str << "\n  badAsicMask0 = " << config5->badAsicMask0();
00308       str << "\n  badAsicMask1 = " << config5->badAsicMask1();
00309       str << "\n  asicMask = " << config5->asicMask();
00310       str << "\n  quadMask = " << config5->quadMask();
00311       str << "\n  internalTriggerDelay = " << config5->internalTriggerDelay();
00312       str << "\n  numAsicsRead = " << config5->numAsicsRead();
00313       str << "\n  numQuads = " << config5->numQuads();
00314       str << "\n  numSect = " << config5->numSect();
00315       str << "\n  roiMask =";
00316       for (unsigned i = 0; i < config5->numQuads(); ++ i) {
00317         str.setf(std::ios::showbase);
00318         str << ' ' << std::hex << config5->roiMask(i) << std::dec;
00319       }
00320       str << "\n  numAsicsStored =";
00321       for (unsigned i = 0; i < config5->numQuads(); ++ i) {
00322         str << ' ' << config5->numAsicsStored(i);
00323       }
00324       for (unsigned iq = 0; iq != config5->numQuads(); ++ iq) {
00325         str << "\n  quad #" << iq;
00326         dumpQuadReg(str, config5->quads(iq));
00327       }
00328     }
00329 
00330   }
00331 }
00332 
00333 // Method which is called with event data
00334 void 
00335 DumpCsPad::event(Event& evt, Env& env)
00336 {
00337 
00338   shared_ptr<Psana::CsPad::DataV1> data1 = evt.get(m_src, m_key);
00339   if (data1) {
00340     
00341     WithMsgLog(name(), info, str) {
00342       str << "CsPad::DataV1:";
00343       int nQuads = data1->quads_shape()[0];
00344       for (int q = 0; q < nQuads; ++ q) {
00345         const Psana::CsPad::ElementV1& el = data1->quads(q);
00346         str << "\n  Element #" << q ;
00347         str << "\n    virtual_channel = " << el.virtual_channel() ;
00348         str << "\n    lane = " << el.lane() ;
00349         str << "\n    tid = " << el.tid() ;
00350         str << "\n    acq_count = " << el.acq_count() ;
00351         str << "\n    op_code = " << el.op_code() ;
00352         str << "\n    quad = " << el.quad() ;
00353         str << "\n    seq_count = " << el.seq_count() ;
00354         str << "\n    ticks = " << el.ticks() ;
00355         str << "\n    fiducials = " << el.fiducials() ;
00356         str << "\n    frame_type = " << el.frame_type() ;
00357         str << "\n    sb_temp = " << el.sb_temp();
00358 
00359         const ndarray<const int16_t, 3>& data = el.data();
00360         str << "\n    common_mode = [ ";
00361         for (unsigned i = 0; i != data.shape()[0]; ++ i) {
00362             str << el.common_mode(i) << ' ';
00363         }
00364         str << "]";
00365         str << "\n    data = " << data;
00366       }
00367 
00368     }
00369   }
00370 
00371 
00372   shared_ptr<Psana::CsPad::DataV2> data2 = evt.get(m_src, m_key);
00373   if (data2) {
00374     
00375     WithMsgLog(name(), info, str) {
00376       str << "CsPad::DataV2:";
00377       int nQuads = data2->quads_shape()[0];
00378       for (int q = 0; q < nQuads; ++ q) {
00379         const Psana::CsPad::ElementV2& el = data2->quads(q);
00380         str << "\n  Element #" << q ;
00381         str << "\n    virtual_channel = " << el.virtual_channel() ;
00382         str << "\n    lane = " << el.lane() ;
00383         str << "\n    tid = " << el.tid() ;
00384         str << "\n    acq_count = " << el.acq_count() ;
00385         str << "\n    op_code = " << el.op_code() ;
00386         str << "\n    quad = " << el.quad() ;
00387         str << "\n    seq_count = " << el.seq_count() ;
00388         str << "\n    ticks = " << el.ticks() ;
00389         str << "\n    fiducials = " << el.fiducials() ;
00390         str << "\n    frame_type = " << el.frame_type() ;
00391 
00392         str << "\n    sb_temp = " << el.sb_temp();
00393 
00394         const ndarray<const int16_t, 3>& data = el.data();
00395         str << "\n    common_mode = [ ";
00396         for (unsigned i = 0; i != data.shape()[0]; ++ i) {
00397             str << el.common_mode(i) << ' ';
00398         }
00399         str << "]";
00400         str << "\n    data = " << data;
00401       }
00402 
00403     }
00404   }
00405 
00406 }
00407 
00408 } // namespace psana_examples

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7