...
Code Block |
---|
| none |
---|
| none |
---|
title | getCsPadQuads |
---|
|
def event(self,evt,env):
quads = evt.getCsPadQuads(self.img_source, env)
if not quads :
print '*** cspad information is missing ***'
return
# dump information about quadrants
print "Number of quadrants: %d" % len(quads)
for q in quads:
print " Quadrant %d" % q.quad()
print " virtual_channel: %s" % q.virtual_channel()
print " lane: %s" % q.lane()
print " tid: %s" % q.tid()
print " acq_count: %s" % q.acq_count()
print " op_code: %s" % q.op_code()
print " seq_count: %s" % q.seq_count()
print " ticks: %s" % q.ticks()
print " fiducials: %s" % q.fiducials()
print " frame_type: %s" % q.frame_type()
print " sb_temp: %s" % map(q.sb_temp, range(4))
# image data as 3-dimentional array
data = q.data()
|
data2 will give you the third section stored, but be aware that sections sometimes are missing,
and in this case So far so good. 'quads' is a list of CsPad Element objects, and not necessarily ordered in the expected way. So you'll need to check with the configuration information that you can obtain in beginjob:to use q.quad() to obtain the quad number.
q.data() gives you a 3D numpy arrayrowcolsec. Here sections will be ordered as expected, but be aware in case of missing sections, that you may need to check the
configuration object. You can get that from the env object, typically something you do in beginjob:
Code Block |
---|
|
def beginjob(self,evt,env):
config = env.getConfig(xtc.TypeId.Type.Id_CspadConfig, self.img_source)
if not config:
print '*** cspad config object is missing ***'
return
quadsprint = range(4)
"Cspad configuration"
print
" N quadrants print "Cspad configuration"
print " N quadrants : %d" % config.numQuads()
print " Quad mask : %#x" % config.quadMask()
print " payloadSize : %d" % config.payloadSize()
print " badAsicMask0 : %#x" % config.badAsicMask0()
print " badAsicMask1 : %#x" % config.badAsicMask1()
print " asicMask : %#x" % config.asicMask()
print " numAsicsRead : %d" % config.numAsicsRead()
try# get the indices of sections in use:
qn = range(0,config.numQuads) # older versions may not have all methods
self.sections print " roiMask= map(config.sections, qn ) : [%s]" % ', '.join([hex(config.roiMask(q)) for q in quads])
print " numAsicsStored: %s" % str(map(config.numAsicsStored, quads))
except:
pass
print " sections : %s" % str(map(config.sections, quads))
print
|
If you want to draw the whole CsPad image, there's currently no pyana function that does this. Pyana only supplies the pixels in a numpy array, and the
exact location of each pixel depends on the conditions at the time of data collection. A simplified way of making the image can be seen e.g. in the
XtcExplorer/src/cspad.py (I'll upload the example code shortly).