13import modularAnalysis
as ma
14from variables
import variables
as vm
15from stdCharged
import stdK, stdPi
18from ROOT
import PyConfig
19PyConfig.IgnoreCommandLineOptions =
True
24from grafei
import graFEI
32 parser = argparse.ArgumentParser()
34 "-c",
"--config", type=str, default=
None, help=
"graFEI config file"
37 "-w",
"--weight", type=str, default=
None, help=
"graFEI weight file"
43 default=
"analysis_tools_light-2403-persian",
44 help=
"Globaltag containing graFEI model",
46 return parser.parse_args()
49if __name__ ==
"__main__":
54 path = b2.create_path()
55 ma.inputMdst(filename=b2.find_file(
'mdst14.root',
'validation',
False), path=path)
57 b2.conditions.prepend_globaltag(ma.getAnalysisGlobaltag())
59 b2.conditions.prepend_globaltag(args.globaltag)
63 priors = [0.068, 0.050, 0.7326, 0.1315, 0.0183, 0.00006]
65 cut_charged_graFEI = [
66 f
"pidIsMostLikely({','.join(str(p) for p in priors)})>0",
68 "thetaInCDCAcceptance",
74 cut_photons_graFEI = [
75 "beamBackgroundSuppression>0.4",
76 "fakePhotonSuppression>0.3",
77 "abs(clusterTiming)<100",
78 "abs(formula(clusterTiming/clusterErrorTiming))<2.0",
79 "[[clusterReg==1 and E>0.09] or [clusterReg==2 and E>0.09] or [clusterReg==3 and E>0.14]]",
81 cut_KL0_graFEI =
"PDG==0"
84 cut_photons_graFEI += [
86 "[clusterErrorTiming < 1e6 and [clusterE1E9 > 0.4 or E > 0.075]]",
90 ranking_variable =
"abs(cosThetaBetweenParticleAndNominalB)"
93 cut_charged_graFEI =
" and ".join(cut_charged_graFEI)
94 cut_photons_graFEI =
" and ".join(cut_photons_graFEI)
102 ma.getBeamBackgroundProbability(
"gamma:all",
"MC15ri", path=path)
103 ma.getFakePhotonProbability(
"gamma:all",
"MC15ri", path=path)
107 stdK(
"loose", path=path)
108 stdPi(
"loose", path=path)
111 "D-:Kpipi -> K+:loose pi-:loose pi-:loose",
"1.85 < M < 1.88", path=path
115 "abs(dz)<2 and dr<0.5 and nCDCHits>20 and thetaInCDCAcceptance and pt>0.6 and E<5.5 and muonID_noSVD>0.9",
119 "B0:sig -> D-:Kpipi mu+:tight",
120 "abs(cosThetaBetweenParticleAndNominalB)<2",
125 ma.buildRestOfEvent(
"B0:sig", path=path)
130 f
"pidIsMostLikely({','.join(str(p) for p in priors)})>0 and nCDCHits>0 and thetaInCDCAcceptance and abs(dz)<4 and dr<2",
131 "inCDCAcceptance and clusterErrorTiming<1e6 and [clusterE1E9>0.4 or E>0.075] and [[clusterReg == 1 and E > 0.05]"
132 " or [clusterReg == 2 and E > 0.05] or [clusterReg == 3 and E > 0.075]]",
138 "nCDCHits > 0 and useCMSFrame(p)<=3.2",
139 "p >= 0.05 and useCMSFrame(p)<=3.2",
142 ma.appendROEMasks(list_name=
"B0:sig", mask_tuples=[csMask, basicMask], path=path)
144 ma.buildContinuumSuppression(list_name=
"B0:sig", roe_mask=
"csMask", path=path)
146 ma.applyCuts(
"B0:sig",
"cosTBz<0.9", path=path)
149 skimfilter = b2.register_module(
"SkimFilter")
150 skimfilter.param(
"particleLists", [
"B0:sig"])
151 empty_path = b2.create_path()
152 skimfilter.if_value(
"=0", empty_path, b2.AfterConditionPath.END)
153 path.add_module(skimfilter)
156 ma.matchMCTruth(
"B0:sig", path=path)
161 variable=ranking_variable,
162 outputVariable=
"Rank",
169 ma.fillParticleListFromROE(
172 maskName=
"basicMask",
173 sourceParticleListName=
"B0:sig",
177 ma.matchMCTruth(
"B0:forTM", path=path)
179 ma.variablesToEventExtraInfo(
"B0:forTM", {
"mcPDG":
"Bsig_ROE_mcPDG"}, path=path)
190 ma.appendROEMasks(
"B0:sig", [graFEI_roe_mask], path=path)
193 ma.fillParticleListFromROE(
196 maskName=
"graFEIROE",
197 sourceParticleListName=
"B0:sig",
202 graFEI_vars = graFEI(
204 store_mc_truth=store_mc_truth,
205 cfg_path=args.config,
206 param_file=args.weight,
207 payload_config_name=
"graFEIConfigFile_Breco_example",
208 payload_model_name=
"graFEIModelFile_Breco_example",
213 ma.reconstructDecay(
"Upsilon(4S):graFEI -> B0:tag B0:sig",
"", path=path)
231 "cosThetaBetweenParticleAndNominalB",
237 "isSignalAcceptMissingNeutrino",
245 vm.addAlias(
"Bsig_Rank",
"daughter(1, extraInfo(Rank))")
247 for var
in default_vars:
248 vm.addAlias(f
"Btag_{var}", f
"daughter(0, {var})")
249 vm.addAlias(f
"Bsig_{var}", f
"daughter(1, {var})")
250 for var
in graFEI_vars:
251 vm.addAlias(f
"Btag_{var}", f
"eventExtraInfo({var})")
253 graFEI_vars = [f
"Btag_{var}" for var
in graFEI_vars + default_vars] + \
254 [
"Btag_Mbc",
"Bsig_Rank"] + [f
"Bsig_{var}" for var
in default_vars]
256 vm.addAlias(
"Bsig_D_M",
"daughter(1, daughter(0, M))")
257 vm.addAlias(
"Bsig_D_E",
"daughter(1, daughter(0, E))")
258 vm.addAlias(
"Bsig_D_pt",
"daughter(1, daughter(0, pt))")
259 vm.addAlias(
"Bsig_D_p",
"daughter(1, daughter(0, p))")
261 graFEI_vars.extend([
"Bsig_D_M",
"Bsig_D_E",
"Bsig_D_pt",
"Bsig_D_p"])
263 ma.variablesToNtuple(
264 "Upsilon(4S):graFEI",
266 filename=
"graFEI_BReco_example.root",