Functions
plot_data_dump Namespace Reference

Functions

def main (argv)
 

Function Documentation

def plot_data_dump.main (   argv)

Definition at line 13 of file plot_data_dump.py.

13 def main(argv):
14 
15  parser = argparse.ArgumentParser(description='Plot data dumped to ROOT file.')
16  parser.add_argument('-i', '--input', help="Input file", default='datadump_hist.root')
17  parser.add_argument('-e', '--event', help="Event index", default='0')
18  parser.add_argument('-v', '--view', help="view index", default='')
19  parser.add_argument('-m', '--module', help="LArSoft module name", default='datadump')
20  args = parser.parse_args()
21 
22  if args.view != '': view_base = 'view_' + args.view
23  else: view_base = ''
24 
25  file0 = TFile(args.input)
26  raw_keys = [k.GetName() for k in file0.Get(args.module).GetListOfKeys() if view_base + '_raw' in k.GetName()]
27  pdg_keys = [k.GetName() for k in file0.Get(args.module).GetListOfKeys() if view_base + '_pdg' in k.GetName()]
28  dep_keys = [k.GetName() for k in file0.Get(args.module).GetListOfKeys() if view_base + '_deposit' in k.GetName()]
29 
30  ev_idx = int(args.event)
31  if ev_idx >= len(raw_keys):
32  print 'event index out of range'
33  return
34  print len(raw_keys), 'keys in the file, reading event key:', raw_keys[ev_idx]
35 
36  dep = hist2array(file0.Get(args.module + '/' + dep_keys[ev_idx]))
37  raw = hist2array(file0.Get(args.module + '/' + raw_keys[ev_idx]))
38  mc = hist2array(file0.Get(args.module + '/' + pdg_keys[ev_idx]))
39  pdg = mc & 0xFF
40 
41  vtx_list = get_vertices(mc)
42 
43  vtx_hadr = vtx_list[:,2] & 1
44  vtx_pi0 = (vtx_list[:,2] >> 1) & 1
45  vtx_decay = (vtx_list[:,2] >> 2) & 1
46  vtx_conv = (vtx_list[:,2] >> 3) & 1
47  vtx_eend = (vtx_list[:,2] >> 4) & 1
48  vtx_list[:,2] = vtx_hadr + 2*vtx_pi0 + 3*vtx_decay + 4*vtx_conv + 5*vtx_eend
49  print 'all vtx:', np.count_nonzero(vtx_list[:,2]), \
50  'hadr:', np.count_nonzero(vtx_hadr), \
51  'pi0:', np.count_nonzero(vtx_pi0), \
52  'decay:', np.count_nonzero(vtx_decay), \
53  'conv:', np.count_nonzero(vtx_conv), \
54  'eend:', np.count_nonzero(vtx_eend)
55 
56  fig, ax = plt.subplots(1, 3, figsize=(36, 10))
57 
58  cs = ax[0].pcolor(np.transpose(pdg), cmap='gist_ncar')
59  ax[0].scatter(vtx_list[:,0]+0.5, vtx_list[:,1]+0.5, s=50, c=vtx_list[:,2], cmap='rainbow', alpha=0.75)
60  ax[0].set_title('PDG')
61  fig.colorbar(cs, ax=ax[0])
62 
63  cs = ax[1].pcolor(np.transpose(dep), cmap='jet')
64  ax[1].set_title('MC truth deposit')
65  fig.colorbar(cs, ax=ax[1])
66 
67  cs = ax[2].pcolor(np.transpose(raw), cmap='jet')
68  ax[2].scatter(vtx_list[:,0]+0.5, vtx_list[:,1]+0.5, s=50, c=vtx_list[:,2], cmap='rainbow', alpha=0.75)
69  ax[2].set_title('ADC')
70  fig.colorbar(cs, ax=ax[2])
71 
72  plt.tight_layout()
73  plt.show()
74 
def get_vertices(A)
Definition: utils.py:151
def main(argv)