Functions | Variables
PandAna.reco_validation.plot_pid_data_mc 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 kCVNCut (tables)
 
def main (horn_current)
 

Variables

 cvn_cut = pa.Cut(kCVNCut)
 
 parser
 
 help
 
 type
 
 str
 
 default
 
 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.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 62 of file plot_pid_data_mc.py.

References PandAna.reco_validation.plot_pid_data_mc.get_sam_definition().

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

62  period='full', version='v1', suffix=''):
63  """Get a list of miniprod5 definitions for a given horn current.
64 
65  Parameters
66  ----------
67  horn_current : string
68  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
69  prod_str : string
70  Describes the production file-type (default is `prod_h5`).
71  tag : string
72  Release for this production tag (default is
73  `R19-02-23-miniprod5.n`)
74  det : string
75  Which detector: far (`fd`, default) or near (`nd`)?
76  data_mc_str : string
77  Describes whether this is data or MC and which generator
78  (default is `genie_default`).
79  period : string
80  Specify a specific data-taking period or `full` (default) for
81  all periods.
82  version : string
83  Definition version (default is `v1`).
84  suffix : string
85  Provides extra information on networks and training.
86 
87  Returns
88  -------
89  string
90  Contains samweb definition for all permutations of swap string.
91 
92  """
93  swap_str = 'allswap'
94  return get_sam_definition(prod_str, tag, det, data_mc_str, swap_str,
95  horn_current, period, version, suffix)
96 
97 
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.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 21 of file plot_pid_data_mc.py.

References PandAna.reco_validation.plot_pid_data_mc.get_fd_miniprod_defs().

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

21  swap_str, horn_current, period, version, suffix):
22  """Get a single samweb definition.
23 
24  Parameters
25  ----------
26  prod_str : string
27  Describes the production file-type e.g. `prod_h5`.
28  tag : string
29  Release for this production tag.
30  det : string
31  Which detector: far (`fd`) or near (`nd`)?
32  data_mc_str : string
33  Describes whether this is data or MC and which generator e.g
34  `genie_default`.
35  swap_str : string
36  Either `nonswap`, `fluxswap` or `tauswap`.
37  horn_current : string
38  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
39  period : string
40  Specify a specific data-taking period or `full` for all periods.
41  version : string
42  Definition version e.g. `v1`.
43  suffix : string
44  Provides extra information on networks and training.
45 
46  Returns
47  -------
48  string
49  Correctly formatted, full definition name.
50 
51  """
52  definition_string = 'Defname: '
53  definition_string += (prod_str + '_' + tag + '_' + det + '_' +
54  data_mc_str + '_' + swap_str + '_' + horn_current +
55  '_nova_v08_' + period + '_' + version + '_' + suffix)
56  return definition_string
57 
58 
def PandAna.reco_validation.plot_pid_data_mc.kCVNCut (   tables)

Definition at line 98 of file plot_pid_data_mc.py.

References ana.kCVNe.

98 def kCVNCut(tables):
99  cvn_min = 0.
100  df = kCVNe(tables)
101  dfRHC = df[kRHC(tables)==1] >= cvn_min
102  dfFHC = df[kRHC(tables)!=1] >= cvn_min
103 
104  return pd.concat([dfRHC, dfFHC])
const Var kCVNe
PID
Definition: Vars.cxx:35
def PandAna.reco_validation.plot_pid_data_mc.main (   horn_current)
Plot PID distributions using miniprod5 Monte-Carlo.

Parameters
----------
horn_current : string
    Beam focusing current: either forward (`fhc`) or reverse (`rhc`).

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

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

Definition at line 108 of file plot_pid_data_mc.py.

References PandAna.reco_validation.plot_pid_data_mc.get_fd_miniprod_defs(), RunSnowGlobes.histogram, and print.

108 def main(horn_current):
109  """Plot PID distributions using miniprod5 Monte-Carlo.
110 
111  Parameters
112  ----------
113  horn_current : string
114  Beam focusing current: either forward (`fhc`) or reverse (`rhc`).
115 
116  Returns
117  -------
118  type
119  Description of returned object.
120 
121  Raises
122  -------
123  ExceptionName
124  Why the exception is raised.
125 
126  """
127  # Set up loaders
128  # Samweb definitions
129  suffix = 'eval'
130  definition = get_fd_miniprod_defs(horn_current, suffix=suffix)
131  #definition = 'Defname: prod_h5_R19-02-23-miniprod5.n_fd_genie_default_allswap_fhc_nova_v08_full_v1_eval'
132  print(definition)
133 
134  # Get tables
135  limit = 30
136  stride = 30
137  tables = pa.loader(definition, stride=stride, limit=limit)
138 
139  # What permutations do we want
140  cuts = {'no_cut': cvn_cut, 'nue_core_presel': kNueCorePresel}
141  vars = {'cvn_e': kCVNe,
142  'cvn_mu': kCVNm,
143  'cvn_nc': kCVNnc}
144 
145  # Create a spectrum
146  spectra = {}
147  for cut_name, cut in cuts.iteritems():
148  spectra[cut_name] = {}
149  for var_name, var in vars.iteritems():
150  spectra[cut_name][var_name] = pa.spectrum(tables, cut, var)
151 
152  # Let's do it!
153  tables.Go()
154 
155  # Make a histogram
156  for cut_name, cut in cuts.iteritems():
157  fig, ax = plt.subplots()
158  for var_name, var in vars.iteritems():
159  n, bins = spectra[cut_name][var_name].histogram(
160  bins=20, range=(0, 1))
161 
162  ax.hist(bins[:-1], bins, weights=n, histtype='step', label=var_name)
163  ax.set_xlabel('CVN 2017 score')
164  ax.set_ylabel('Events')
165 
166  plt.legend(loc='upper right')
167 
168  title = 'cvn2017_' + horn_current + '_' + cut_name
169  #plt.show()
170 
171  fig.savefig(title + '.png')
172 
173 
bool print
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.args = parser.parse_args()

Definition at line 183 of file plot_pid_data_mc.py.

PandAna.reco_validation.plot_pid_data_mc.cvn_cut = pa.Cut(kCVNCut)

Definition at line 105 of file plot_pid_data_mc.py.

PandAna.reco_validation.plot_pid_data_mc.default

Definition at line 182 of file plot_pid_data_mc.py.

PandAna.reco_validation.plot_pid_data_mc.help

Definition at line 180 of file plot_pid_data_mc.py.

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

Definition at line 177 of file plot_pid_data_mc.py.

PandAna.reco_validation.plot_pid_data_mc.str

Definition at line 182 of file plot_pid_data_mc.py.

PandAna.reco_validation.plot_pid_data_mc.type

Definition at line 182 of file plot_pid_data_mc.py.