psana_examples/src/dump_acqiris.py

Go to the documentation of this file.
00001 #--------------------------------------------------------------------------
00002 # File and Version Information:
00003 #  $Id: dump_acqiris.py 2622 2011-11-11 14:35:00Z salnikov@SLAC.STANFORD.EDU $
00004 #
00005 # Description:
00006 #  Pyana user analysis module dump_princeton...
00007 #
00008 #------------------------------------------------------------------------
00009 
00010 """Example module for accessing SharedIpimb data.
00011 
00012 This software was developed for the LCLS project.  If you use all or 
00013 part of it, please give an appropriate acknowledgment.
00014 
00015 @version $Id: dump_acqiris.py 2622 2011-11-11 14:35:00Z salnikov@SLAC.STANFORD.EDU $
00016 
00017 @author Andy Salnikov
00018 """
00019 
00020 #------------------------------
00021 #  Module's version from SVN --
00022 #------------------------------
00023 __version__ = "$Revision: 2622 $"
00024 # $Source$
00025 
00026 #--------------------------------
00027 #  Imports of standard modules --
00028 #--------------------------------
00029 import sys
00030 import logging
00031 
00032 #-----------------------------
00033 # Imports for other modules --
00034 #-----------------------------
00035 from psana import *
00036 
00037 #----------------------------------
00038 # Local non-exported definitions --
00039 #----------------------------------
00040 
00041 # local definitions usually start with _
00042 
00043 #---------------------
00044 #  Class definition --
00045 #---------------------
00046 class dump_acqiris (object) :
00047     """Class whose instance will be used as a user analysis module. """
00048 
00049     #----------------
00050     #  Constructor --
00051     #----------------
00052     def __init__ ( self ) :
00053         
00054         self.m_src = self.configSrc('source', "")
00055 
00056     #-------------------
00057     #  Public methods --
00058     #-------------------
00059     def beginjob( self, evt, env ) :
00060         
00061         config = env.configStore().get(Acqiris.Config, self.m_src)
00062         if config:
00063         
00064             print "%s: %s" % (config.__class__.__name__, self.m_src)
00065             
00066             print "  nbrBanks =", config.nbrBanks(),
00067             print "channelMask =", config.channelMask(),
00068             print "nbrChannels =", config.nbrChannels(),
00069             print "nbrConvertersPerChannel =", config.nbrConvertersPerChannel()
00070      
00071             h = config.horiz()
00072             print "  horiz: sampInterval =", h.sampInterval(),
00073             print "delayTime =", h.delayTime(),
00074             print "nbrSegments =", h.nbrSegments(),
00075             print "nbrSamples =", h.nbrSamples()
00076 
00077             nch = config.nbrChannels()
00078             vert = config.vert()
00079             for ch in range(nch):
00080                 v = vert[ch]
00081                 print "  vert(%d):" % ch,
00082                 print "fullScale =", v.fullScale(),
00083                 print "slope =", v.slope(),
00084                 print "offset =", v.offset(),
00085                 print "coupling =", v.coupling(),
00086                 print "bandwidth=", v.bandwidth()
00087 
00088     def event( self, evt, env ) :
00089         """This method is called for every L1Accept transition.
00090 
00091         @param evt    event data object
00092         @param env    environment object
00093         """
00094 
00095         acqData = evt.get(Acqiris.DataDesc, self.m_src)
00096         if not acqData:
00097             return
00098 
00099         # find matching config object
00100         config = env.configStore().get(Acqiris.Config, self.m_src)
00101 
00102         # loop over channels
00103         nchan = acqData.data_shape()[0];
00104         for chan in range(nchan):
00105             
00106             elem = acqData.data(chan);
00107             v = config.vert()[chan]
00108             slope = v.slope()
00109             offset = v.offset()
00110 
00111             print "Acqiris::DataDescV1: channel=%d" % chan ### XXX should print real class name instead
00112             print "  nbrSegments=%d" % elem.nbrSegments()
00113             print "  nbrSamplesInSeg=%d" % elem.nbrSamplesInSeg()
00114             print "  indexFirstPoint=%d" % elem.indexFirstPoint()
00115 
00116             timestamps = elem.timestamp()
00117             raw = elem.waveforms()
00118             wf = raw*slope + offset
00119 
00120             # loop over segments
00121             for seg in range(elem.nbrSegments()):
00122                 print "  Segment #%d" % seg
00123                 print "    timestamp =", timestamps[seg].pos()
00124                 print "    raw =", raw[seg]
00125                 print "    wf =", wf[seg]

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7