12Example to create lepton particle list and apply LeptonID corrections to a MC sample
13by retrieving lookup tables from the conditions DB.
21 parser = argparse.ArgumentParser(description=__doc__,
22 formatter_class=argparse.RawTextHelpFormatter)
24 parser.add_argument(
"--release",
27 help=
"The major release number associated to the corrections that are being applied.\n"
28 "Default: %(default)s.")
29 parser.add_argument(
"--global_tag_append",
32 default=[
'analysis_tools_light-2302-genetta'],
33 help=
"List of names of conditions DB global tag(s) to append on top of GT replay.\n"
34 "NB: these GTs will have lowest priority over GT replay.\n"
35 "The order of the sequence passed determines the priority of the GTs, w/ the highest coming first.\n"
36 "Pass a space-separated list of names.\n"
37 "Default: %(default)s.")
38 parser.add_argument(
"--lid_weights_gt",
40 default=
"leptonid_Moriond2022_Official_rel5_v1a",
41 help=
"Name of conditions DB global tag with recommended lepton ID correction factors.\n"
42 "Default: %(default)s.")
49 Main entry point allowing external calls.
52 args = argparser().parse_args()
55 import modularAnalysis
as ma
56 from variables
import variables
as vm
59 from stdCharged
import stdE, stdMu
61 b2.set_log_level(b2.LogLevel.INFO)
63 for tag
in args.global_tag_append:
64 b2.conditions.append_globaltag(tag)
65 print(f
"Appending GTs:\n{args.global_tag_append}")
67 path = b2.create_path()
73 ma.inputMdst(environmentType=
"default",
74 filename=b2.find_file(
"mdst16.root",
"validation"),
75 entrySequence=
"6500:16500",
85 ma.fillParticleList(
"e+:uncorrected",
86 cut=
"dr < 2 and abs(dz) < 4",
88 ma.fillParticleList(
"gamma:bremsinput",
91 ma.correctBremsBelle(outputListName=
"e+:corrected",
92 inputListName=
"e+:uncorrected",
93 gammaListName=
"gamma:bremsinput",
96 ma.fillParticleList(
"mu+:presel",
97 cut=
"dr < 2 and abs(dz) < 4",
106 ma.fillParticleList(
"pi+:ref",
"inCDCAcceptance", path=path)
109 vm.addAlias(
"minET2ETIsoScore",
"minET2ETIsoScore(pi+:ref, 1, CDC, TOP, ARICH, ECL, KLM)")
111 _ = ma.calculateTrackIsolation(
"e+:corrected",
113 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
114 reference_list_name=
"pi+:ref")
116 _ = ma.calculateTrackIsolation(
"mu+:presel",
118 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
119 reference_list_name=
"pi+:ref")
125 electrons_fixed09 =
"lh_B_fixed09"
126 electrons_wp =
"FixedThresh09"
127 electron_id_var, electron_id_weights = stdE(electrons_wp,
"likelihood",
"binary", args.lid_weights_gt,
128 release=args.release,
129 inputListName=
"e+:corrected",
130 outputListLabel=electrons_fixed09,
133 muons_uniform90 =
"bdt_G_uniform90"
134 muons_wp =
"UniformEff90"
135 muon_id_var, muon_id_weights = stdMu(muons_wp,
"bdt",
"global", args.lid_weights_gt,
136 release=args.release,
137 inputListName=
"mu+:presel",
138 outputListLabel=muons_uniform90,
145 ma.applyCuts(f
"e-:{electrons_fixed09}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
146 ma.applyCuts(f
"mu-:{muons_uniform90}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
152 jpsiee = f
"J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}"
153 jpsimumu = f
"J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}"
157 "[daughterSumOf(charge) == 0]",
159 jpsi_cut =
" and ".join(jpsi_cuts)
161 ma.reconstructDecay(jpsiee, jpsi_cut, path=path)
162 ma.reconstructDecay(jpsimumu, jpsi_cut, path=path)
173 variables_jpsi += vc.kinematics
174 variables_jpsi += vc.inv_mass
176 variables_e += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
177 variables_mu += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
179 cms_kinematics = vu.create_aliases(vc.kinematics,
"useCMSFrame({variable})",
"CMS")
181 variables_e += cms_kinematics
182 variables_mu += cms_kinematics
184 lid_e = [electron_id_var] + electron_id_weights
187 lid_mu = [muon_id_var] + muon_id_weights
188 variables_mu += lid_mu
190 aliases_jpsiee = vu.create_aliases_for_selected(
192 f
"^J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}",
194 aliases_jpsimumu = vu.create_aliases_for_selected(
196 f
"^J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}",
199 aliases_e = vu.create_aliases_for_selected(
201 f
"J/psi:ee -> ^e+:{electrons_fixed09} ^e-:{electrons_fixed09}",
203 aliases_mu = vu.create_aliases_for_selected(
205 f
"J/psi:mumu -> ^mu+:{muons_uniform90} ^mu-:{muons_uniform90}",
210 output_file =
"jpsill_LID_weights.root"
213 ma.variablesToNtuple(decayString=
"J/psi:ee",
214 variables=aliases_jpsiee+aliases_e,
216 filename=output_file,
218 ma.variablesToNtuple(decayString=
"J/psi:mumu",
219 variables=aliases_jpsimumu+aliases_mu,
221 filename=output_file,
228if __name__ ==
"__main__":