hpstr
The Heavy Photon Search Toolkit for Reconstruction (hpstr) provides an interface to physics data from the HPS experiment saved in the LCIO format and converts it into an ROOT based format.
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
bhToys_cfg.py
Go to the documentation of this file.
1import HpstrConf
2import sys
3import baseConfig as base
4
5parser = base.parser
6
7parser.add_argument("-m", "--mass", type=int, dest="mass_hypo",
8 help="Mass hypothesis in MeV.", metavar="mass_hypo", default=145)
9parser.add_argument("-p", "--poly", type=int, dest="poly_order",
10 help="Polynomial order of background model.", metavar="poly_order", default=3)
11parser.add_argument("-P", "--toy_poly", type=int, dest="toy_poly_order",
12 help="Polynomial order of toy generator fit.", metavar="toy_poly_order", default=-1)
13parser.add_argument("-w", "--win", type=int, dest="win_factor",
14 help="Window factor for determining fit window size.", metavar="win_factor", default=11)
15parser.add_argument("-N", "--toys", type=int, dest="nToys",
16 help="Number of toy spectra to throw.", metavar="nToys", default=100)
17parser.add_argument("-s", "--spec", type=str, dest="mass_spec",
18 help="Name of mass spectrum histogram.", metavar="mass_spec",
19 default="mass_tweak__p_tot_min_cut")
20parser.add_argument("-a", "--sig", type=int, dest="toy_sig_samples",
21 help="Number of signal events to add to toy models.", metavar="toy_sig_samples",
22 default=0)
23parser.add_argument("-f", "--sig_file", type=str, dest="signal_shape_h_file",
24 help="Name of the file containing the signal shape injection histogram.", metavar="signal_shape_h_file", default="")
25parser.add_argument("-g", "--sig_hist", type=str, dest="signal_shape_h_name",
26 help="Name of the signal shape injection histogram.", metavar="signal_shape_h_name", default="")
27parser.add_argument("-b", "--bkg", type=int, dest="toy_bkg_mult",
28 help="Number of toy background events in units of the integral of the input distribution.",
29 metavar="toy_bkg_mult", default=1)
30parser.add_argument("-r", "--res_scale", type=float, dest="res_scale",
31 help="Factor by which to scale the mass resolution.", metavar="res_scale", default=1.56)
32parser.add_argument("-M", "--bkg_model", type=int, dest="bkg_model", default="1",
33 help="The type of background fit model. 0 = Chebyshev; 1 = Exponential Chebyshev; 2 = Legendre; 3 = Exponential Legendre.", metavar="bkg_model")
34options = parser.parse_args()
35
36# Use the input file to set the output file name
37histo_file = options.inFilename[0]
38mass_hypo = options.mass_hypo/1000.0
39poly_order = options.poly_order
40win_factor = options.win_factor
41toy_file = '%s/bhToys_m%iw%ip%ir%is%i.root' % (options.outDir, options.mass_hypo, win_factor, poly_order, int(options.res_scale * 100), options.toy_sig_samples)
42
43print('Histo file: %s' % histo_file)
44print('Toy file: %s' % toy_file)
45
47
48p.run_mode = 2
49p.skip_events = options.skip_events
50p.max_events = options.nevents
51#p.max_events = 1000
52
53# Library containing processors
54p.add_library("libprocessors")
55
56
59
60bhtoys = HpstrConf.Processor('bhtoys', 'BhToysHistoProcessor')
61
62
66bhtoys.parameters["debug"] = 1
67bhtoys.parameters["massSpectrum"] = options.mass_spec
68bhtoys.parameters["mass_hypo"] = mass_hypo
69bhtoys.parameters["poly_order"] = poly_order
70bhtoys.parameters["toy_poly_order"] = options.toy_poly_order
71bhtoys.parameters["win_factor"] = win_factor
72bhtoys.parameters["seed"] = 0
73bhtoys.parameters["nToys"] = options.nToys
74bhtoys.parameters["toy_sig_samples"] = options.toy_sig_samples
75bhtoys.parameters["toy_bkg_mult"] = options.toy_bkg_mult
76bhtoys.parameters["res_scale"] = options.res_scale
77bhtoys.parameters["signal_shape_h_name"] = options.signal_shape_h_name
78bhtoys.parameters["signal_shape_h_file"] = options.signal_shape_h_file
79bhtoys.parameters["bkg_model"] = options.bkg_model
80
81# Sequence which the processors will run.
82p.sequence = [bhtoys]
83
84p.input_files = [histo_file]
85p.output_files = [toy_file]
86
87p.printProcess()
Process python class.
Definition HpstrConf.py:20
Processor python class.
Definition HpstrConf.py:4