12Example to create lepton particle list and apply LeptonID corrections to a MC sample
13by retrieving lookup tables from the conditions DB.
24 parser = argparse.ArgumentParser(description=__doc__,
25 formatter_class=argparse.RawTextHelpFormatter)
27 parser.add_argument(
"--release",
30 help=
"The major release number associated to the corrections that are being applied.\n"
31 "Default: %(default)s.")
32 parser.add_argument(
"--global_tag_append",
35 default=[
'analysis_tools_light-2302-genetta'],
36 help=
"List of names of conditions DB global tag(s) to append on top of GT replay.\n"
37 "NB: these GTs will have lowest priority over GT replay.\n"
38 "The order of the sequence passed determines the priority of the GTs, w/ the highest coming first.\n"
39 "Pass a space-separated list of names.\n"
40 "Default: %(default)s.")
41 parser.add_argument(
"--lid_weights_gt",
43 default=
"leptonid_Moriond2022_Official_rel5_v1a",
44 help=
"Name of conditions DB global tag with recommended lepton ID correction factors.\n"
45 "Default: %(default)s.")
52 Main entry point allowing external calls.
55 args = argparser().parse_args()
58 import modularAnalysis
as ma
59 from variables
import variables
as vm
62 from stdCharged
import stdE, stdMu
64 b2.set_log_level(b2.LogLevel.INFO)
66 for tag
in args.global_tag_append:
67 b2.conditions.append_globaltag(tag)
68 print(f
"Appending GTs:\n{args.global_tag_append}")
70 path = b2.create_path()
76 ma.inputMdst(environmentType=
"default",
77 filename=b2.find_file(
"mdst14.root",
"validation"),
78 entrySequence=
"0:10000",
88 ma.fillParticleList(
"e+:uncorrected",
89 cut=
"dr < 2 and abs(dz) < 4",
91 ma.fillParticleList(
"gamma:bremsinput",
94 ma.correctBremsBelle(outputListName=
"e+:corrected",
95 inputListName=
"e+:uncorrected",
96 gammaListName=
"gamma:bremsinput",
99 ma.fillParticleList(
"mu+:presel",
100 cut=
"dr < 2 and abs(dz) < 4",
109 ma.fillParticleList(
"pi+:ref",
"inCDCAcceptance", path=path)
112 vm.addAlias(
"minET2ETIsoScore",
"minET2ETIsoScore(pi+:ref, 1, CDC, TOP, ARICH, ECL, KLM)")
114 _ = ma.calculateTrackIsolation(
"e+:corrected",
116 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
117 reference_list_name=
"pi+:ref")
119 _ = ma.calculateTrackIsolation(
"mu+:presel",
121 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
122 reference_list_name=
"pi+:ref")
128 electrons_fixed09 =
"lh_B_fixed09"
129 electrons_wp =
"FixedThresh09"
130 electron_id_var, electron_id_weights = stdE(electrons_wp,
"likelihood",
"binary", args.lid_weights_gt,
131 release=args.release,
132 inputListName=
"e+:corrected",
133 outputListLabel=electrons_fixed09,
136 muons_uniform90 =
"bdt_G_uniform90"
137 muons_wp =
"UniformEff90"
138 muon_id_var, muon_id_weights = stdMu(muons_wp,
"bdt",
"global", args.lid_weights_gt,
139 release=args.release,
140 inputListName=
"mu+:presel",
141 outputListLabel=muons_uniform90,
148 ma.applyCuts(f
"e-:{electrons_fixed09}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
149 ma.applyCuts(f
"mu-:{muons_uniform90}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
155 jpsiee = f
"J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}"
156 jpsimumu = f
"J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}"
160 "[daughterSumOf(charge) == 0]",
162 jpsi_cut =
" and ".join(jpsi_cuts)
164 ma.reconstructDecay(jpsiee, jpsi_cut, path=path)
165 ma.reconstructDecay(jpsimumu, jpsi_cut, path=path)
176 variables_jpsi += vc.kinematics
177 variables_jpsi += vc.inv_mass
179 variables_e += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
180 variables_mu += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
182 cms_kinematics = vu.create_aliases(vc.kinematics,
"useCMSFrame({variable})",
"CMS")
184 variables_e += cms_kinematics
185 variables_mu += cms_kinematics
187 lid_e = [electron_id_var] + electron_id_weights
190 lid_mu = [muon_id_var] + muon_id_weights
191 variables_mu += lid_mu
193 aliases_jpsiee = vu.create_aliases_for_selected(
195 f
"^J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}",
197 aliases_jpsimumu = vu.create_aliases_for_selected(
199 f
"^J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}",
202 aliases_e = vu.create_aliases_for_selected(
204 f
"J/psi:ee -> ^e+:{electrons_fixed09} ^e-:{electrons_fixed09}",
206 aliases_mu = vu.create_aliases_for_selected(
208 f
"J/psi:mumu -> ^mu+:{muons_uniform90} ^mu-:{muons_uniform90}",
213 output_file =
"jpsill_LID_weights.root"
216 ma.variablesToNtuple(decayString=
"J/psi:ee",
217 variables=aliases_jpsiee+aliases_e,
219 filename=output_file,
221 ma.variablesToNtuple(decayString=
"J/psi:mumu",
222 variables=aliases_jpsimumu+aliases_mu,
224 filename=output_file,
234if __name__ ==
"__main__":