Skip to content
Snippets Groups Projects

Draft: Sprucing and Tupling of reprocessed 2022 data for cut-based dilepton trigger studies

Closed Jamie Gooding requested to merge jagoodin/cutbased-dilepton-trigger into master
1 unresolved thread
Files
4
###############################################################################
# (c) Copyright 2021-2022 CERN for the benefit of the LHCb Collaboration #
# #
# This software is distributed under the terms of the GNU General Public #
# Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# #
# In applying this licence, CERN does not waive the privileges and immunities #
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
import Functors as F
from FunTuple import FunctorCollection as FC
from FunTuple import FunTuple_Particles as Funtuple
from PyConf.reading import get_particles, get_pvs, get_odin, get_decreports
from DaVinci import Options, make_config
from DaVinci.algorithms import create_lines_filter
from DaVinciMCTools import MCTruthAndBkgCat
from itertools import product
from .spruced_tuples import dielectron, dimuon
def construct_tuple(line, fields, label, options: Options, sprucing=False):
pvs = get_pvs()
composite_functors = {
"ID": F.PARTICLE_ID,
"KEY": F.OBJECT_KEY,
'M': F.MASS,
"PT": F.PT,
"PX": F.PX,
"PY": F.PY,
"PZ": F.PZ,
"PE": F.ENERGY,
"P": F.P,
"ETA": F.ETA,
"TAU": F.BPVLTIME(pvs),
"BPVDIRA": F.BPVDIRA(pvs),
"BPVFD": F.BPVFD(pvs),
"BPVFDCHI2": F.BPVFDCHI2(pvs),
"BPVIP": F.BPVIP(pvs),
"BPVIPCHI2": F.BPVIPCHI2(pvs),
"CHI2": F.CHI2,
"CHI2DOF": F.CHI2DOF,
"MAXDOCA": F.MAXDOCA,
"MAXDOCACHI2": F.MAXDOCACHI2
}
daughter_functors = {
"ID": F.PARTICLE_ID,
"PT": F.PT,
"PX": F.PX,
"PY": F.PY,
"PZ": F.PZ,
"PE": F.ENERGY,
"P": F.P,
"ETA": F.ETA,
"BPVIPCHI2": F.BPVIPCHI2(pvs),
"PIDe": F.PID_E,
"PIDmu": F.PID_MU,
"PIDpi": F.PID_PI,
"PIDk": F.PID_K,
"PIDk": F.PID_P,
}
if sprucing:
data = get_particles(f"/Event/Spruce/{line}/Particles")
print(data)
else:
data = get_particles(f"/Event/HLT2/{line}/Particles")
hdr_filter = create_lines_filter(f"HDRFilter_{label}", [line])
odin = get_odin()
DecReports = [get_decreports("Hlt1"), get_decreports("Hlt2")]
linesets = [['Hlt1TrackMuonMVADecision','Hlt1DiMuonLowMassDecision','Hlt1DiMuonHighMassDecision', 'Hlt1LowPtDiMuonDecision','Hlt1TwoTrackMVADecision'],
['Hlt2CutBasedInclDielectronDecision','Hlt2CutBasedInclDielectronPlusTrackDecision','Hlt2CutBasedInclDielectronPlusTwoTrackDecision',
'Hlt2CutBasedInclDimuonDecision','Hlt2CutBasedInclDimuonPlusTrackDecision','Hlt2CutBasedInclDimuonPlusTwoTrackDecision']]
if sprucing:
DecReports += [get_decreports("Spruce")]
linesets += [['SpruceRD_BToEEDecision', 'SpruceRD_BToMuMuDecision','SpruceRD_BuToKpEEDecision', 'SpruceRD_BuToKpMuMuDecision','SpruceRD_B0ToKpPimEEDecision', 'SpruceRD_B0ToKpPimMuMuDecision']]
evt_var_dict = {}
for DecReport, lineset in zip(DecReports, linesets):
for line in lineset:
evt_var_dict.update({f"{line}_DEC" : F.DECISION(DecReports=DecReport, trigger_line_name=line)})
evt_variables = FC(evt_var_dict)
variables = {
"B" : FC(composite_functors)
}
if 'Jpsi' in fields:
variables.update({"Jpsi": FC(composite_functors)})
for particle, charge in product(('e','mu','pi', 'K'), ('P', 'M')):
if particle+charge in fields:
variables.update({particle+charge: FC(daughter_functors)})
funtuple = Funtuple(name=label,
tuple_name="DecayTree",
fields=fields,
variables=variables,
event_variables=evt_variables,
inputs=data)
return {f"{line}_Algs": [hdr_filter, funtuple]}
def tuple_hlt2(options: Options):
tuples = {}
for lepton_label, lepton in zip(("Dielectron", "Dimuon"), ("e", "mu")):
two_body_fields = {
"B" : f"[B_s0 -> {lepton}+ {lepton}-]CC",
f"{lepton}P" : f"[B_s0 -> ^{lepton}+ {lepton}-]CC",
f"{lepton}M" : f"[B_s0 -> {lepton}+ ^{lepton}-]CC",
}
three_body_fields = {
"B" : f"[B+ -> (J/psi(1S) -> {lepton}+ {lepton}-) pi+]CC",
"Jpsi": f"[B+ -> (^J/psi(1S) -> {lepton}+ {lepton}-) pi+]CC",
"piP" : f"[B+ -> (J/psi(1S) -> {lepton}+ {lepton}-) ^pi+]CC",
f"{lepton}P" : f"[B+ -> (J/psi(1S) -> ^{lepton}+ {lepton}-) pi+]CC",
f"{lepton}M" : f"[B+ -> (J/psi(1S) -> {lepton}+ ^{lepton}-) pi+]CC",
}
four_body_fields = {
"B" : f"[B_s0 -> (J/psi(1S) -> {lepton}+ {lepton}-) pi+ pi-]CC",
"Jpsi": f"[B_s0 -> (^J/psi(1S) -> {lepton}+ {lepton}-) pi+ pi-]CC",
"piP" : f"[B_s0 -> (J/psi(1S) -> {lepton}+ {lepton}-) ^pi+ pi-]CC",
"piM" : f"[B_s0 -> (J/psi(1S) -> {lepton}+ {lepton}-) pi+ ^pi-]CC",
f"{lepton}P" : f"[B_s0 -> (J/psi(1S) -> ^{lepton}+ {lepton}-) pi+ pi-]CC",
f"{lepton}M" : f"[B_s0 -> (J/psi(1S) -> {lepton}+ ^{lepton}-) pi+ pi-]CC",
}
for line, fields, tuple_label in zip ((f"Hlt2CutBasedIncl{lepton_label}", f"Hlt2CutBasedIncl{lepton_label}PlusTrack", f"Hlt2CutBasedIncl{lepton_label}PlusTwoTrack"),\
(two_body_fields, three_body_fields, four_body_fields),\
(f"twoBody{lepton_label}Tuple", f"threeBody{lepton_label}Tuple", f"fourBody{lepton_label}Tuple")):
tuples.update(construct_tuple(line, fields, tuple_label, options, False))
config = make_config(options, tuples)
return config
def tuple_spruce(options: Options):
tuples = {}
for dileptons in (dielectron, dimuon):
for tuple_setup in dileptons.values():
tuples.update(construct_tuple(tuple_setup["line"], tuple_setup["fields"], tuple_setup["tuple_label"], options, True))
config = make_config(options, tuples)
return config
\ No newline at end of file
Loading