-
Notifications
You must be signed in to change notification settings - Fork 0
/
client.py
50 lines (38 loc) · 1.45 KB
/
client.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#run this with: mpirun -n 2 python mpiGather.py
from psana import *
import numpy as np
from hitdata import hitdata
from fitDroplet import dofitting
from tofHitFind import tofhitfind
from mpi4py import MPI
comm = MPI.COMM_WORLD
rank = comm.Get_rank()
size = comm.Get_size()
def runclient(args):
hd=hitdata()
hf=tofhitfind()
ds = DataSource(args.exprun+':smd')
det1 = Detector('pnccdFront',ds.env())
det2 = Detector('ACQ4',ds.env())
epics = ds.env().epicsStore()
thresh = 0.40
# print "rank, size = ", rank, size
for nevent,evt in enumerate(ds.events()):
if nevent%(size-1)==rank-1: # different ranks look at different events
# print rank," processing event", nevent
eid = evt.get(EventId)
sec = eid.time()[0]
nsec = eid.time()[1]
fid = eid.fiducials()
et = EventTime(int((sec<<32)|nsec),fid)
tof, tofAxis = det2.raw(evt)
if (hf.hitfind(tof[0],tofAxis[0],thresh)):
epdict=dict()
for name in epics.names():
epdict[name]=epics.value(name)
img = det1.image(evt)
obj = dofitting(img) #call fitting routine
comp = {'et':et , 'tof':tof[0], 'tofAxis':tofAxis[0], 'epics':epdict, 'drop':obj['drop'],'tofsum':hf.sum}
hd.send(comp, obj['orig'], obj['fit'])
if nevent == args.noe : break
hd.endrun()