Functions | Variables
PandAna.reco_validation.plot_pid_data_mc_cvn2020 Namespace Reference

Functions

def get_sam_definition (prod_str, tag, det, data_mc_str, swap_str, horn_current, period, version, suffix)
 
def get_fd_miniprod_defs (horn_current, prod_str='prod_h5', tag='R19-02-23-miniprod5.n', det='fd', data_mc_str='genie_default', period='full', version='v1', suffix='')
 
def get_files (swap_str, horn_current)
 
def get_all_files (horn_current)
 
def main (horn_current, on_wc, stride=None, limit=None)
 

Variables

 cvn2020veto_nueid
 
 cvn2020veto_numuid
 
 cvn2020veto_ncid = pa.Var(lambda tables: tables['rec.sel.cvn2020veto']['ncid'])
 
 cvn2020veto_nutauid
 
 cvn2020veto_cosmicid
 
 cvn2020taucut_nueid
 
 cvn2020taucut_numuid
 
 cvn2020taucut_ncid
 
 cvn2020taucut_nutauid
 
 cvn2020taucut_cosmicid
 
 cvn2020ptpcut_nueid
 
 cvn2020ptpcut_numuid
 
 cvn2020ptpcut_ncid
 
 cvn2020ptpcut_nutauid
 
 cvn2020ptpcut_cosmicid
 
 cvn2020allcut_nueid
 
 cvn2020allcut_numuid
 
 cvn2020allcut_ncid
 
 cvn2020allcut_nutauid
 
 cvn2020allcut_cosmicid
 
 parser
 
 help
 
 type
 
 str
 
 default
 
 action
 
 int
 
 args = parser.parse_args()
 

Detailed Description

Plotting data/mc distributions of different PID variable.

For reco validation with PandAna.

Function Documentation

def PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_all_files (   horn_current)

Definition at line 160 of file plot_pid_data_mc_cvn2020.py.

References novadaq::HexUtils.format(), PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_files(), and print.

Referenced by PandAna.reco_validation.plot_pid_data_mc_cvn2020.main().

160 def get_all_files(horn_current):
161  swap_strs = ['Nonswap', 'Fluxswap', 'Tau']
162  all_files = []
163  for swap_str in swap_strs:
164  all_files = all_files + get_files(swap_str, horn_current)
165  print('Generated a list of {} files'.format(len(all_files)))
166  return all_files
167 
168 
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_fd_miniprod_defs (   horn_current,
  prod_str = 'prod_h5',
  tag = 'R19-02-23-miniprod5.n',
  det = 'fd',
  data_mc_str = 'genie_default',
  period = 'full',
  version = 'v1',
  suffix = '' 
)
Get a list of miniprod5 definitions for a given horn current.

Parameters
----------
horn_current : string
    Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
prod_str : string
    Describes the production file-type (default is `prod_h5`).
tag : string
    Release for this production tag (default is
    `R19-02-23-miniprod5.n`)
det : string
    Which detector: far (`fd`, default) or near (`nd`)?
data_mc_str : string
    Describes whether this is data or MC and which generator
    (default is `genie_default`).
period : string
    Specify a specific data-taking period or `full` (default) for
    all periods.
version : string
    Definition version (default is `v1`).
suffix : string
    Provides extra information on networks and training.

Returns
-------
string
    Contains samweb definition for all permutations of swap string.

Definition at line 116 of file plot_pid_data_mc_cvn2020.py.

References PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_sam_definition().

Referenced by PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_sam_definition(), and PandAna.reco_validation.plot_pid_data_mc_cvn2020.main().

116  period='full', version='v1', suffix=''):
117  """Get a list of miniprod5 definitions for a given horn current.
118 
119  Parameters
120  ----------
121  horn_current : string
122  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
123  prod_str : string
124  Describes the production file-type (default is `prod_h5`).
125  tag : string
126  Release for this production tag (default is
127  `R19-02-23-miniprod5.n`)
128  det : string
129  Which detector: far (`fd`, default) or near (`nd`)?
130  data_mc_str : string
131  Describes whether this is data or MC and which generator
132  (default is `genie_default`).
133  period : string
134  Specify a specific data-taking period or `full` (default) for
135  all periods.
136  version : string
137  Definition version (default is `v1`).
138  suffix : string
139  Provides extra information on networks and training.
140 
141  Returns
142  -------
143  string
144  Contains samweb definition for all permutations of swap string.
145 
146  """
147  swap_str = 'allswap'
148  return get_sam_definition(prod_str, tag, det, data_mc_str, swap_str,
149  horn_current, period, version, suffix)
150 
151 
def get_sam_definition(prod_str, tag, det, data_mc_str, swap_str, horn_current, period, version, suffix)
def PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_files (   swap_str,
  horn_current 
)

Definition at line 152 of file plot_pid_data_mc_cvn2020.py.

Referenced by PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_all_files().

152 def get_files(swap_str, horn_current):
153  d = ('/lfstev/nnet/R19-02-23-miniprod5/FD-' +
154  swap_str + '-' + horn_current + '-Eval/')
155  var = ['rec.sel.cvn2020veto', 'rec.sel.cvn2020ptpcut',
156  'rec.sel.cvn2020taucut', 'rec.sel.cvn2020allcut']
157  return [os.path.join(d, f) for f in os.listdir(d) if 'h5caf.h5' in f]
158 
159 
def PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_sam_definition (   prod_str,
  tag,
  det,
  data_mc_str,
  swap_str,
  horn_current,
  period,
  version,
  suffix 
)
Get a single samweb definition.

Parameters
----------
prod_str : string
    Describes the production file-type e.g. `prod_h5`.
tag : string
    Release for this production tag.
det : string
    Which detector: far (`fd`) or near (`nd`)?
data_mc_str : string
    Describes whether this is data or MC and which generator e.g
    `genie_default`.
swap_str : string
    Either `nonswap`, `fluxswap` or `tauswap`.
horn_current : string
    Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
period : string
    Specify a specific data-taking period or `full` for all periods.
version : string
    Definition version e.g. `v1`.
suffix : string
    Provides extra information on networks and training.

Returns
-------
string
    Correctly formatted, full definition name.

Definition at line 75 of file plot_pid_data_mc_cvn2020.py.

References PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_fd_miniprod_defs().

Referenced by PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_fd_miniprod_defs().

75  swap_str, horn_current, period, version, suffix):
76  """Get a single samweb definition.
77 
78  Parameters
79  ----------
80  prod_str : string
81  Describes the production file-type e.g. `prod_h5`.
82  tag : string
83  Release for this production tag.
84  det : string
85  Which detector: far (`fd`) or near (`nd`)?
86  data_mc_str : string
87  Describes whether this is data or MC and which generator e.g
88  `genie_default`.
89  swap_str : string
90  Either `nonswap`, `fluxswap` or `tauswap`.
91  horn_current : string
92  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
93  period : string
94  Specify a specific data-taking period or `full` for all periods.
95  version : string
96  Definition version e.g. `v1`.
97  suffix : string
98  Provides extra information on networks and training.
99 
100  Returns
101  -------
102  string
103  Correctly formatted, full definition name.
104 
105  """
106  definition_string = 'Defname: '
107  definition_string += (prod_str + '_' + tag + '_' + det + '_' +
108  data_mc_str + '_' + swap_str + '_' + horn_current +
109  '_nova_v08_' + period + '_' + version + '_' + suffix)
110  return definition_string
111 
112 
def PandAna.reco_validation.plot_pid_data_mc_cvn2020.main (   horn_current,
  on_wc,
  stride = None,
  limit = None 
)
Plot PID distributions using miniprod5 Monte-Carlo.

Parameters
----------
horn_current : string
    Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
on_wc: bool
    Flag if running on Wilson Cluster.

Returns
-------
type
    Description of returned object.

Raises
-------
ExceptionName
    Why the exception is raised.

Definition at line 169 of file plot_pid_data_mc_cvn2020.py.

References novadaq::HexUtils.format(), PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_all_files(), PandAna.reco_validation.plot_pid_data_mc_cvn2020.get_fd_miniprod_defs(), RunSnowGlobes.histogram, and print.

169 def main(horn_current, on_wc, stride=None, limit=None):
170  """Plot PID distributions using miniprod5 Monte-Carlo.
171 
172  Parameters
173  ----------
174  horn_current : string
175  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
176  on_wc: bool
177  Flag if running on Wilson Cluster.
178 
179  Returns
180  -------
181  type
182  Description of returned object.
183 
184  Raises
185  -------
186  ExceptionName
187  Why the exception is raised.
188 
189  """
190  # Set up loaders
191  files = []
192  if on_wc:
193  if horn_current == 'fhc':
194  files = get_all_files('FHC')
195  else:
196  files = get_all_files('RHC')
197  else:
198  # Samweb definitions
199  suffix = 'eval'
200  files = get_fd_miniprod_defs(horn_current, suffix=suffix)
201  print(files)
202 
203  # Get tables
204  tables = pa.loader(files, stride=stride, limit=limit)
205 
206  # What permutations do we want
207  # Cuts
208  # No Numu containment
209  # Warning! No data read for rec.trk.kalman.tracks
210  any_fd_containment = kNueProngContainment | kNusFDContain
211  any_fd_presel = kNueCorePresel | kNusFDPresel
212  cuts = {
213  'no_cut': kVeto,
214  'any_fd_containment': any_fd_containment,
215  'any_fd_presel': any_fd_presel,
216  }
217 
218  # Vars
219  vars = {
220  'nueid': {
221  'cvn2020veto': cvn2020veto_nueid,
222  'cvn2020taucut': cvn2020taucut_nueid,
223  'cvn2020ptpcut': cvn2020ptpcut_nueid,
224  'cvn2020allcut': cvn2020allcut_nueid,
225  'cvnProd3Train': cvnProd3Train_nueid,
226  },
227  'numuid': {
228  'cvn2020veto': cvn2020veto_numuid,
229  'cvn2020taucut': cvn2020taucut_numuid,
230  'cvn2020ptpcut': cvn2020ptpcut_numuid,
231  'cvn2020allcut': cvn2020allcut_numuid,
232  'cvnProd3Train': cvnProd3Train_numuid,
233  },
234  'ncid': {
235  'cvn2020veto': cvn2020veto_ncid,
236  'cvn2020taucut': cvn2020taucut_ncid,
237  'cvn2020ptpcut': cvn2020ptpcut_ncid,
238  'cvn2020allcut': cvn2020allcut_ncid,
239  'cvnProd3Train': cvnProd3Train_ncid,
240  },
241  # 'nutauid': {
242  # 'cvn2020veto': cvn2020veto_nutauid,
243  # 'cvn2020taucut': cvn2020taucut_nutauid,
244  # 'cvn2020ptpcut': cvn2020ptpcut_nutauid,
245  # 'cvn2020allcut': cvn2020allcut_nutauid,
246  # 'cvnProd3Train': cvnProd3Train_nutauid,
247  # },
248  'cosmicid': {
249  'cvn2020veto': cvn2020veto_cosmicid,
250  'cvn2020taucut': cvn2020taucut_cosmicid,
251  'cvn2020ptpcut': cvn2020ptpcut_cosmicid,
252  'cvn2020allcut': cvn2020allcut_cosmicid,
253  },
254  }
255 
256  # Create a spectrum
257  print('Creating spectra')
258  spectra = {}
259  spectra_list = []
260  spectra_names = []
261  for cut_name, cut in cuts.items():
262  spectra[cut_name] = {}
263  for pid_name, networks in vars.items():
264  spectra[cut_name][pid_name] = {}
265  for network_name, var in networks.items():
266  spectrum = pa.spectrum(tables, cut, var)
267  spectrum_name = cut_name + '_' + pid_name + '_' + network_name
268  spectra[cut_name][pid_name][network_name] = spectrum
269  spectra_list.append(spectrum)
270  spectra_names.append(spectrum_name)
271 
272  # Let's do it!
273  print('Loaders Go!')
274  tables.Go()
275 
276  # Save them
277  print('Saving spectra')
278  filename = 'saved_spectra'
279  if stride:
280  filename += '_s{}'.format(stride)
281  if limit:
282  filename += '_l{}'.format(limit)
283  filename += '.hdf5'
284  pa.save_spectra(filename, spectra_list, spectra_names)
285 
286  # Make a histogram
287  print('Making histograms')
288  for cut_name, cut in cuts.items():
289  for pid_name, networks in vars.items():
290  fig, ax = plt.subplots()
291  for network_name, var in networks.items():
292  n, bins = spectra[cut_name][pid_name][network_name].histogram(
293  bins=20, range=(0, 1))
294 
295  ax.hist(bins[:-1], bins, weights=n,
296  histtype='step', label=network_name)
297  ax.set_xlabel('PID score')
298  ax.set_ylabel('Events')
299 
300  plt.legend(loc='upper center')
301 
302  # Save it
303  title = horn_current + '_' + cut_name + '_' + pid_name
304  # fig.savefig(title + '.png')
305  fig.suptitle(title)
306 
307  # Logscale y
308  ax.set_yscale('log')
309  title += '_log'
310 
311  if stride:
312  title += '_s{}'.format(stride)
313  if limit:
314  title += '_l{}'.format(limit)
315  fig.savefig(title + '.png')
316 
317 
def main(horn_current, on_wc, stride=None, limit=None)
bool print
std::string format(const int32_t &value, const int &ndigits=8)
Definition: HexUtils.cpp:14
def get_fd_miniprod_defs(horn_current, prod_str='prod_h5', tag='R19-02-23-miniprod5.n', det='fd', data_mc_str='genie_default', period='full', version='v1', suffix='')

Variable Documentation

PandAna.reco_validation.plot_pid_data_mc_cvn2020.action

Definition at line 328 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.args = parser.parse_args()

Definition at line 333 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020allcut_cosmicid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020allcut']['cosmicid'])

Definition at line 70 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020allcut_ncid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020allcut']['ncid'])

Definition at line 66 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020allcut_nueid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020allcut']['nueid'])

Definition at line 62 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020allcut_numuid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020allcut']['numuid'])

Definition at line 64 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020allcut_nutauid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020allcut']['nutauid'])

Definition at line 68 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020ptpcut_cosmicid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020ptpcut']['cosmicid'])

Definition at line 58 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020ptpcut_ncid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020ptpcut']['ncid'])

Definition at line 54 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020ptpcut_nueid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020ptpcut']['nueid'])

Definition at line 50 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020ptpcut_numuid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020ptpcut']['numuid'])

Definition at line 52 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020ptpcut_nutauid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020ptpcut']['nutauid'])

Definition at line 56 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020taucut_cosmicid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020taucut']['cosmicid'])

Definition at line 46 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020taucut_ncid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020taucut']['ncid'])

Definition at line 42 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020taucut_nueid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020taucut']['nueid'])

Definition at line 38 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020taucut_numuid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020taucut']['numuid'])

Definition at line 40 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020taucut_nutauid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020taucut']['nutauid'])

Definition at line 44 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020veto_cosmicid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020veto']['cosmicid'])

Definition at line 34 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020veto_ncid = pa.Var(lambda tables: tables['rec.sel.cvn2020veto']['ncid'])

Definition at line 31 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020veto_nueid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020veto']['nueid'])

Definition at line 27 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020veto_numuid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020veto']['numuid'])

Definition at line 29 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.cvn2020veto_nutauid
Initial value:
1 = pa.Var(
2  lambda tables: tables['rec.sel.cvn2020veto']['nutauid'])

Definition at line 32 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.default

Definition at line 326 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.help

Definition at line 324 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.int

Definition at line 329 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.parser
Initial value:
1 = argparse.ArgumentParser(
2  description='Plot PID distributions using miniprod5 Monte-Carlo.')

Definition at line 321 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.str

Definition at line 326 of file plot_pid_data_mc_cvn2020.py.

PandAna.reco_validation.plot_pid_data_mc_cvn2020.type

Definition at line 326 of file plot_pid_data_mc_cvn2020.py.