15 Example to create lepton particle list and apply LeptonID corrections to a MC sample
16 by retrieving lookup tables from the conditions DB.
25 parser = argparse.ArgumentParser(description=__doc__,
26 formatter_class=argparse.RawTextHelpFormatter)
28 parser.add_argument(
"--release",
31 help=
"The major release number associated to the corrections that are being applied.\n"
32 "Default: %(default)s.")
33 parser.add_argument(
"--global_tag_append",
36 default=[
'analysis_tools_light-2302-genetta'],
37 help=
"List of names of conditions DB global tag(s) to append on top of GT replay.\n"
38 "NB: these GTs will have lowest priority over GT replay.\n"
39 "The order of the sequence passed determines the priority of the GTs, w/ the highest coming first.\n"
40 "Pass a space-separated list of names.\n"
41 "Default: %(default)s.")
42 parser.add_argument(
"--lid_weights_gt",
44 default=
"leptonid_Moriond2022_Official_rel5_v1a",
45 help=
"Name of conditions DB global tag with recommended lepton ID correction factors.\n"
46 "Default: %(default)s.")
53 Main entry point allowing external calls.
56 args = argparser().parse_args()
59 import modularAnalysis
as ma
60 from variables
import variables
as vm
63 from stdCharged
import stdE, stdMu
65 b2.set_log_level(b2.LogLevel.INFO)
67 for tag
in args.global_tag_append:
68 b2.conditions.append_globaltag(tag)
69 print(f
"Appending GTs:\n{args.global_tag_append}")
71 path = b2.create_path()
77 ma.inputMdst(environmentType=
"default",
78 filename=b2.find_file(
"mdst14.root",
"validation"),
79 entrySequence=
"0:10000",
89 ma.fillParticleList(
"e+:uncorrected",
90 cut=
"dr < 2 and abs(dz) < 4",
92 ma.fillParticleList(
"gamma:bremsinput",
95 ma.correctBremsBelle(outputListName=
"e+:corrected",
96 inputListName=
"e+:uncorrected",
97 gammaListName=
"gamma:bremsinput",
100 ma.fillParticleList(
"mu+:presel",
101 cut=
"dr < 2 and abs(dz) < 4",
110 ma.fillParticleList(
"pi+:ref",
"inCDCAcceptance", path=path)
113 vm.addAlias(
"minET2ETIsoScore",
"minET2ETIsoScore(pi+:ref, 1, CDC, TOP, ARICH, ECL, KLM)")
115 _ = ma.calculateTrackIsolation(
"e+:corrected",
117 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
118 reference_list_name=
"pi+:ref")
120 _ = ma.calculateTrackIsolation(
"mu+:presel",
122 *[
"CDC",
"TOP",
"ARICH",
"ECL",
"KLM"],
123 reference_list_name=
"pi+:ref")
129 electrons_fixed09 =
"lh_B_fixed09"
130 electrons_wp =
"FixedThresh09"
131 electron_id_var, electron_id_weights = stdE(electrons_wp,
"likelihood",
"binary", args.lid_weights_gt,
132 release=args.release,
133 inputListName=
"e+:corrected",
134 outputListLabel=electrons_fixed09,
137 muons_uniform90 =
"bdt_G_uniform90"
138 muons_wp =
"UniformEff90"
139 muon_id_var, muon_id_weights = stdMu(muons_wp,
"bdt",
"global", args.lid_weights_gt,
140 release=args.release,
141 inputListName=
"mu+:presel",
142 outputListLabel=muons_uniform90,
149 ma.applyCuts(f
"e-:{electrons_fixed09}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
150 ma.applyCuts(f
"mu-:{muons_uniform90}",
"[pt > 0.1] and thetaInCDCAcceptance", path=path)
156 jpsiee = f
"J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}"
157 jpsimumu = f
"J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}"
161 "[daughterSumOf(charge) == 0]",
163 jpsi_cut =
" and ".join(jpsi_cuts)
165 ma.reconstructDecay(jpsiee, jpsi_cut, path=path)
166 ma.reconstructDecay(jpsimumu, jpsi_cut, path=path)
177 variables_jpsi += vc.kinematics
178 variables_jpsi += vc.inv_mass
180 variables_e += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
181 variables_mu += (vc.kinematics + [
"theta",
"charge",
"minET2ETIsoScore"])
183 cms_kinematics = vu.create_aliases(vc.kinematics,
"useCMSFrame({variable})",
"CMS")
185 variables_e += cms_kinematics
186 variables_mu += cms_kinematics
188 lid_e = [electron_id_var] + electron_id_weights
191 lid_mu = [muon_id_var] + muon_id_weights
192 variables_mu += lid_mu
194 aliases_jpsiee = vu.create_aliases_for_selected(
196 f
"^J/psi:ee -> e+:{electrons_fixed09} e-:{electrons_fixed09}",
198 aliases_jpsimumu = vu.create_aliases_for_selected(
200 f
"^J/psi:mumu -> mu+:{muons_uniform90} mu-:{muons_uniform90}",
203 aliases_e = vu.create_aliases_for_selected(
205 f
"J/psi:ee -> ^e+:{electrons_fixed09} ^e-:{electrons_fixed09}",
207 aliases_mu = vu.create_aliases_for_selected(
209 f
"J/psi:mumu -> ^mu+:{muons_uniform90} ^mu-:{muons_uniform90}",
214 output_file =
"jpsill_LID_weights.root"
217 ma.variablesToNtuple(decayString=
"J/psi:ee",
218 variables=aliases_jpsiee+aliases_e,
220 filename=output_file,
222 ma.variablesToNtuple(decayString=
"J/psi:mumu",
223 variables=aliases_jpsimumu+aliases_mu,
225 filename=output_file,
235 if __name__ ==
"__main__":
int main(int argc, char **argv)
Run all tests.