13import modularAnalysis
as ma
14from variables
import variables
as vm
18from ROOT
import PyConfig
19PyConfig.IgnoreCommandLineOptions =
True
24from grafei
import graFEI
33 parser = argparse.ArgumentParser()
35 "-c",
"--config", type=str, default=
None, help=
"graFEI config file"
38 "-w",
"--weight", type=str, default=
None, help=
"graFEI weight file"
44 default=
"analysis_tools_light-2403-persian",
45 help=
"Globaltag containing graFEI model",
52 help=
"Choose LCAS matrix of signal side",
59 help=
"Choose mass hypotheses of signal side",
65 help=
"Choose not to store MC-truth information",
67 return parser.parse_args()
70if __name__ ==
"__main__":
73 store_mc_truth =
not args.no_mc_truth
75 path = b2.create_path()
76 ma.inputMdst(filename=b2.find_file(
'mdst14.root',
'validation',
False), path=path)
78 b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
80 b2.conditions.prepend_globaltag(args.globaltag)
91 priors = [0.068, 0.050, 0.7326, 0.1315, 0.0183, 0.00006]
94 f
"pidIsMostLikely({','.join(str(p) for p in priors)})>0",
96 "thetaInCDCAcceptance",
104 "beamBackgroundSuppression>0.4",
105 "fakePhotonSuppression>0.3",
106 "abs(clusterTiming)<100",
107 "abs(formula(clusterTiming/clusterErrorTiming))<2.0",
108 "[[clusterReg==1 and E>0.09] or [clusterReg==2 and E>0.09] or [clusterReg==3 and E>0.14]]",
111 evt_cut =
"n_gamma_in_evt<20 and n_charged_in_evt<20"
114 charged_lists = [f
"{c}:final" for c
in [
"p+",
"e+",
"pi+",
"mu+",
"K+"]]
116 ma.fillParticleLists(
117 [(c,
" and ".join(charged_cuts))
for c
in charged_lists],
124 beamBackgroundMVAWeight=
"MC15ri",
125 fakePhotonMVAWeight=
"MC15ri",
132 " and ".join(photon_cuts),
138 vm.addAlias(
"n_gamma_in_evt",
"nParticlesInList(gamma:final)")
139 vm.addAlias(
"n_p_in_evt",
"nParticlesInList(p+:final)")
140 vm.addAlias(
"n_e_in_evt",
"nParticlesInList(e+:final)")
141 vm.addAlias(
"n_mu_in_evt",
"nParticlesInList(mu+:final)")
142 vm.addAlias(
"n_pi_in_evt",
"nParticlesInList(pi+:final)")
143 vm.addAlias(
"n_K_in_evt",
"nParticlesInList(K+:final)")
146 "formula(n_p_in_evt+n_e_in_evt+n_mu_in_evt+n_pi_in_evt+n_K_in_evt)",
149 ma.applyEventCuts(evt_cut, path=path)
151 particle_lists = charged_lists + [
"gamma:final"]
152 particle_types = [x.split(
":")[0]
for x
in particle_lists]
153 charged_types = [x.split(
":")[0]
for x
in charged_lists]
155 graFEI_vars = graFEI(
157 particle_lists=particle_lists,
158 store_mc_truth=store_mc_truth,
159 cfg_path=args.config,
160 param_file=args.weight,
161 sig_side_lcas=args.lcas,
162 sig_side_masses=args.masses,
163 payload_config_name=
"graFEIConfigFile_Upsreco_example",
164 payload_model_name=
"graFEIModelFile_Upsreco_example",
170 "B+:Bsgn -> K+:graFEI",
171 "daughter(0, extraInfo(graFEI_sigSide)) == 1",
176 for part
in particle_types:
180 cut=
"extraInfo(graFEI_sigSide) == 0",
184 ma.combineAllParticles([f
"{part}:Btag" for part
in particle_types],
"B+:Btag", path=path)
188 "Upsilon(4S):neutral -> B+:Bsgn B-:Btag",
"", path=path
191 "Upsilon(4S):charged -> B+:Bsgn B+:Btag",
"", allowChargeViolation=
True, path=path
195 "Upsilon(4S):graFEI",
197 "Upsilon(4S):neutral",
198 "Upsilon(4S):charged",
204 skimfilter = b2.register_module(
"SkimFilter")
205 skimfilter.param(
"particleLists", [
"Upsilon(4S):graFEI"])
206 empty_path = b2.create_path()
207 skimfilter.if_value(
"=0", empty_path, b2.AfterConditionPath.END)
208 path.add_module(skimfilter)
211 ma.matchMCTruth(
"B+:Bsgn", path=path)
212 ma.matchMCTruth(
"B-:Btag", path=path)
213 ma.matchMCTruth(
"Upsilon(4S):graFEI", path=path)
234 default_vars += momentum_vars
240 ]
if store_mc_truth
else []
242 default_vars += tm_vars
245 for var
in default_vars:
246 vm.addAlias(f
"Bsgn_{var}", f
"daughter(0, {var})")
247 vm.addAlias(f
"Bsgn_d0_{var}", f
"daughter(0, daughter(0, {var}))")
248 vm.addAlias(f
"Btag_{var}", f
"daughter(1, {var})")
249 vm.addAlias(f
"Ups_{var}", var)
250 for var
in momentum_vars:
252 f
"Bsgn_d0_CMS_{var}", f
"useCMSFrame(daughter(0, daughter(0, {var})))"
254 vm.addAlias(f
"Btag_CMS_{var}", f
"useCMSFrame(daughter(1, {var}))")
255 for var
in graFEI_vars:
256 vm.addAlias(var, f
"eventExtraInfo({var})")
260 + [f
"Bsgn_{var}" for var
in tm_vars]
261 + [f
"Bsgn_d0_{var}" for var
in default_vars]
262 + [f
"Bsgn_d0_CMS_{var}" for var
in momentum_vars]
263 + [f
"Btag_{var}" for var
in default_vars]
264 + [f
"Btag_CMS_{var}" for var
in momentum_vars]
265 + [f
"Ups_{var}" for var
in default_vars]
268 ma.variablesToNtuple(
269 "Upsilon(4S):graFEI",
271 filename=
"graFEI_UpsReco_example.root",
def stdPhotons(listtype='loose', path=None, beamBackgroundMVAWeight="", fakePhotonMVAWeight="", biasCorrectionTable="")