PSCalib/examples/ex-get-detid.py

Go to the documentation of this file.
00001 # import
00002 import psana
00003 import PSCalib.GlobalUtils as gu
00004 
00005 
00006 def init_psana(tname) :
00007     """initialize psana
00008     """
00009     dsname, src = None, None
00010     
00011     if   tname == '1' :
00012         #dsname = '/reg/g/psdm/detector/data_test/types/0018-MfxEndstation.0-Epix100a.0.xtc' # 'exp=mfxm5116:run=20'
00013         dsname = 'exp=mfxm5116:run=20'
00014         src = psana.Source('MfxEndstation.0:Epix100a.0') # or 'VonHamos'
00015 
00016     elif tname == '2' :
00017         dsname = '/reg/g/psdm/detector/data_test/types/0019-XppGon.0-Epix100a.0.xtc' # 'exp=xppl1316:run=193'
00018         src = psana.Source('XppGon.0:Epix100a.0')
00019 
00020     elif tname == '3' :
00021         dsname = '/reg/g/psdm/detector/data_test/types/0007-NoDetector.0-Epix100a.0.xtc' # 'exp=xppi0614:run=74'
00022         src = psana.Source('NoDetector.0:Epix100a.0')
00023  
00024     ds  = psana.DataSource(dsname)
00025     evt = ds.events().next()
00026     env = ds.env()
00027 
00028     print 'calib_dir: %s' % gu.calib_dir(env)
00029     print 'exp_name : %s' % gu.exp_name(env)
00030     print 'alias_for_src_name : %s' % gu.alias_for_src_name(env)
00031 
00032     #print 'src_name_from_alias:\n'
00033     #gu.src_name_from_alias(env)
00034 
00035     #for i, evt in enumerate(ds.events()) :
00036     #    print 'event %d' % i
00037     #    o = evt.get(psana.CsPad.DataV2, src)
00038     #    if o is not None : 
00039     #        print o.data()
00040     #        break
00041     #runnum = evt.run()
00042 
00043     print 80*'_', '\nenv.configStore().keys():\n'
00044     for k in env.configStore().keys() : print k
00045 
00046     print 80*'_', '\nevt.keys():\n'
00047     for k in evt.keys() : print k
00048 
00049     print 80*'_'
00050 
00051     return ds, src, evt, env
00052 
00053 #------------------------------
00054 
00055 def get_epix_config_object(e, s) :
00056     """get epix config object
00057     """
00058     cs = e.configStore()
00059     o = cs.get(psana.Epix.Config100aV2, s)
00060     if o is not None : return o
00061 
00062     o = cs.get(psana.Epix.Config100aV1, s)
00063     if o is not None : return o
00064 
00065     return None
00066 
00067 #------------------------------
00068 
00069 def print_epix100_id(tname) :
00070 
00071     ds, src, evt, env = init_psana(tname)
00072 
00073     o = get_epix_config_object(env, src)
00074     
00075     if o is None :
00076         print 'get_epix_config_object returns None'
00077         return
00078 
00079     print 'version         :', o.version()   
00080     print 'Version         :', o.Version
00081     print 'numberOfColumns :', o.numberOfColumns()
00082     print 'numberOfRows    :', o.numberOfRows()
00083     print 'TypeId          :', o.TypeId
00084     print 'digitalCardId0/1:', o.digitalCardId0(), '/', o.digitalCardId1()
00085     print 'analogCardId0/1 :', o.analogCardId0(), '/', o.analogCardId1()
00086     print 'carrierId0/1    :', o.carrierId0(), '/', o.carrierId1()
00087 
00088 #------------------------------
00089 
00090 def print_epix100_id_cpo(tname) :
00091     """cpo version of epix100_id
00092     """
00093     ds, src, evt, env = init_psana('2')
00094     o = get_epix_config_object(env, src)
00095 
00096     print 'carrierId0/1     :', str(o.carrierId0())+'/'+str(o.carrierId1())
00097     print 'digitalCardId0/1 :', str(o.digitalCardId0())+'/'+str(o.digitalCardId1())
00098     print 'analogCardId0/1  :', str(o.analogCardId0())+'/'+str(o.analogCardId1())
00099     print 'version          :', o.version()   
00100 
00101 #------------------------------
00102 
00103 if __name__ == "__main__" :
00104     import sys
00105 
00106     tname = '1' if len(sys.argv) < 2 else sys.argv[1]
00107     if tname in ('1', '2', '3') : print_epix100_id(tname)
00108     elif tname == '4' : print_epix100_id_cpo(tname)
00109     else : sys.exit ('Not recognized test name: "%s"' % tname)
00110 
00111     sys.exit ('End of %s' % sys.argv[0])
00112 
00113 #------------------------------

Generated on 19 Dec 2016 for PSANAmodules by  doxygen 1.4.7