diff --git a/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/dv_data.py b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/dv_data.py new file mode 100644 index 0000000000000000000000000000000000000000..b1080e22caf83e97c0c87e69355b6bf1c13898f2 --- /dev/null +++ b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/dv_data.py @@ -0,0 +1,120 @@ +from .tupling_maker import template, line_prefilter +from DaVinci import Options, make_config +import Functors as F +from Functors.math import in_range +from GaudiKernel.SystemOfUnits import MeV +# import yaml + +def Bz2JpsiKst_mTag_NoMuonID( ): + decay_descriptor = { + "Bz": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + "Jpsi": '[B0 -> ^(J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + "Kstar": '[B0 -> (J/psi(1S) -> mu+ mu-) ^(K*(892)0 -> K+ pi-)]CC', + "Kp": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> ^K+ pi-)]CC', + "pim": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ ^pi-)]CC', + "mum": '[B0 -> (J/psi(1S) -> mu+ ^mu-) (K*(892)0 -> K+ pi-)]CC', + "mup": '[B0 -> (J/psi(1S) -> ^mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + } + line_name = "Hlt2BandQ_Bz2JpsiKst_mTag_NoMuonID" + decay_name = "Bs2JpsiKst_mTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bz", "Jpsi", "Kstar"], ["Kp", "pim", "mup", "mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Bz2JpsiKst_pTag_NoMuonID( ): + decay_descriptor = { + "Bz": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + "Jpsi": '[B0 -> ^(J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + "Kstar": '[B0 -> (J/psi(1S) -> mu+ mu-) ^(K*(892)0 -> K+ pi-)]CC', + "Kp": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> ^K+ pi-)]CC', + "pim": '[B0 -> (J/psi(1S) -> mu+ mu-) (K*(892)0 -> K+ ^pi-)]CC', + "mum": '[B0 -> (J/psi(1S) -> mu+ ^mu-) (K*(892)0 -> K+ pi-)]CC', + "mup": '[B0 -> (J/psi(1S) -> ^mu+ mu-) (K*(892)0 -> K+ pi-)]CC', + } + line_name = "Hlt2BandQ_Bz2JpsiKst_pTag_NoMuonID" + decay_name = "Bz2JpsiKst_pTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bz", "Jpsi", "Kstar"], ["Kp", "pim", "mup", "mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Bs2JpsiPhi_mTag_NoMuonID( ): + decay_descriptor = { + "Bs": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-)]CC', + "Jpsi": '[B_s0 -> ^(J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-)]CC', + "phi": '[B_s0 -> (J/psi(1S) -> mu+ mu-) ^(phi(1020) -> K+ K-)]CC', + "Kp": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> ^K+ K-)]CC', + "Km": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ ^K-)]CC', + "mum": '[B_s0 -> (J/psi(1S) -> mu+ ^mu-) (phi(1020) -> K+ K-)]CC', + "mup": '[B_s0 -> (J/psi(1S) -> ^mu+ mu-) (phi(1020) -> K+ K-)]CC', + } + line_name = "Hlt2BandQ_Bs2JpsiPhi_mTag_NoMuonID" + decay_name = "Bs2JpsiPhi_mTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bs", "Jpsi", "phi"], ["Kp", "Km", "mup","mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Bs2JpsiPhi_pTag_NoMuonID( ): + decay_descriptor = { + "Bs": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-)]CC', + "Jpsi": '[B_s0 -> ^(J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ K-)]CC', + "phi": '[B_s0 -> (J/psi(1S) -> mu+ mu-) ^(phi(1020) -> K+ K-)]CC', + "Kp": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> ^K+ K-)]CC', + "Km": '[B_s0 -> (J/psi(1S) -> mu+ mu-) (phi(1020) -> K+ ^K-)]CC', + "mum": '[B_s0 -> (J/psi(1S) -> mu+ ^mu-) (phi(1020) -> K+ K-)]CC', + "mup": '[B_s0 -> (J/psi(1S) -> ^mu+ mu-) (phi(1020) -> K+ K-)]CC', + } + line_name = "Hlt2BandQ_Bs2JpsiPhi_pTag_NoMuonID" + decay_name = "Bs2JpsiPhi_pTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bs", "Jpsi", "phi"], ["Kp", "Km", "mup","mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Bp2JpsiKp_mTag_NoMuonID( ): + decay_descriptor = { + "Bp": '[B+ -> (J/psi(1S) -> mu+ mu-) K+]CC', + "Jpsi": '[B+ -> ^(J/psi(1S) -> mu+ mu-) K+]CC', + "Kp": '[B+ -> (J/psi(1S) -> mu+ mu-) ^K+]CC', + "mum": '[B+ -> (J/psi(1S) -> mu+ ^mu-) K+]CC', + "mup": '[B+ -> (J/psi(1S) -> ^mu+ mu-) K+]CC', + } + line_name = "Hlt2BandQ_Bp2JpsiKp_mTag_NoMuonID" + decay_name = "Bp2JpsiKp_mTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bp", "Jpsi"], ["Kp", "mup","mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Bp2JpsiKp_pTag_NoMuonID( ): + decay_descriptor = { + "Bp": '[B+ -> (J/psi(1S) -> mu+ mu-) K+]CC', + "Jpsi": '[B+ -> ^(J/psi(1S) -> mu+ mu-) K+]CC', + "Kp": '[B+ -> (J/psi(1S) -> mu+ mu-) ^K+]CC', + "mum": '[B+ -> (J/psi(1S) -> mu+ ^mu-) K+]CC', + "mup": '[B+ -> (J/psi(1S) -> ^mu+ mu-) K+]CC', + } + line_name = "Hlt2BandQ_Bp2JpsiKp_pTag_NoMuonID" + decay_name = "Bp2JpsiKp_pTag" + dict = {} + my_tuple = template(decay_descriptor, line_name, True, [], ["Bp", "Jpsi"], ["Kp", "mup","mum"]) + my_filter = line_prefilter(line_name) + dict[decay_name] = [my_filter, my_tuple] + return dict + +def Entry_Point(options: Options): + algs_dict = Bp2JpsiKp_pTag_NoMuonID() + algs_dict.update(Bp2JpsiKp_mTag_NoMuonID()) + algs_dict.update(Bz2JpsiKst_pTag_NoMuonID()) + algs_dict.update(Bz2JpsiKst_mTag_NoMuonID()) + algs_dict.update(Bs2JpsiPhi_pTag_NoMuonID()) + algs_dict.update(Bs2JpsiPhi_mTag_NoMuonID()) + return make_config(options, algs_dict) + \ No newline at end of file diff --git a/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/info.yaml b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/info.yaml new file mode 100644 index 0000000000000000000000000000000000000000..8900ecf298a22bb156a5a0e79fc27028bf4c4d26 --- /dev/null +++ b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/info.yaml @@ -0,0 +1,43 @@ +{%- set dv_platform_detdesc = "x86_64_v2-el9-clang16-opt" %} +defaults: + application: "DaVinci/v64r10" + wg: BandQ + inform: + - yuc@cern.ch + +# data configuration +{%- set datasets = [ + ('Collision24', 'Sprucing24c4/94000000', 'BANDQ', 'B2JpsiX_pmTag_NoMuonID', 'MagDown', 'VeloClosed', 'TurboPass', 'bandq'), + ('Collision24', 'Sprucing24c3/94000000', 'BANDQ', 'B2JpsiX_pmTag_NoMuonID', 'MagDown', 'VeloClosed', 'TurboPass', 'bandq'), + ('Collision24', 'Sprucing24c4/94000000', 'BANDQ', 'B2JpsiX_pmTag_NoMuonID', 'MagUp', 'VeloClosed', 'TurboPass', 'bandq'), + ('Collision24', 'Sprucing24c3/94000000', 'BANDQ', 'B2JpsiX_pmTag_NoMuonID', 'MagUp', 'VeloClosed', 'TurboPass', 'bandq'), +]%} + + + +{%- for data, Type, wg, decay, polarity, Velo, process, stream in datasets %} + +data_{{decay}}_{{wg}}_c{{Type[11]}}_v2_{{Velo}}_WithUT_{{polarity}}: + application: "DaVinci/v64r10@{{dv_platform_detdesc}}" + input: + bk_query: "/LHCb/{{data}}/Beam6800GeV-{{Velo}}-{{polarity}}/Real Data/{{Type}}/{{wg}}.DST" + dq_flags: + - OK + - UNCHECKED + keep_running: True + n_test_lfns: 1 + options: + entrypoint: BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines.dv_data:Entry_Point + extra_options: + input_type: ROOT + input_process: "{{process}}" + input_stream: "{{stream}}" + input_raw_format: 0.5 + simulation: False + data_type: "Upgrade" + geometry_version: run3/2024.Q1.2-v00.00 + conditions_version: master + output: Data_v2_{{stream}}_{{decay}}.ROOT +{%- endfor %} + + diff --git a/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/make_dtf.py b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/make_dtf.py new file mode 100644 index 0000000000000000000000000000000000000000..b179e05028c29f8f029161aef2a98942b0e3655c --- /dev/null +++ b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/make_dtf.py @@ -0,0 +1,268 @@ +import Functors as F +from Functors.math import log + +from FunTuple import FunctorCollection +from FunTuple.functorcollections import ( + MCHierarchy, + MCPromptDecay, + Kinematics, + SelectionInfo, + HltTisTos, + MCVertexInfo, + MCKinematics, + ParticleID, #wrong variables PID_PI = 0, PROBNN_D = nan + EventInfo, + LHCInfo, + ParticleIsolation, + MCPrimaries, + MCReconstructed, + MCReconstructible, +) + +from DaVinciMCTools import MCTruthAndBkgCat, MCReconstructed, MCReconstructible +from PyConf.Algorithms import ParticleToSubcombinationsAlg +from DecayTreeFitter import DecayTreeFitter + +from DaVinci.algorithms import create_lines_filter +from PyConf.reading import get_particles +from FunTuple import FunTuple_Particles as Funtuple + + + +def make_basic_dtf_variables(pvs, data, DTF=None, pv_constraint=False, mass_constraint=False, particle_name=""): + variables = ( + FunctorCollection( + { + "TRCHI2DOF": F.CHI2DOF @ F.TRACK, + "ETA": F.ETA, + "PHI": F.PHI, + "TRGHOSTPROB": F.GHOSTPROB, + "BPVIPCHI2": F.BPVIPCHI2(pvs), + "BPVIP": F.BPVIP(pvs), + "BPVX": F.BPVX(pvs), + "BPVY": F.BPVY(pvs), + "BPVZ": F.BPVZ(pvs), + "TX" : F.TX, + "TY" : F.TY, + # "MINIPCHI2" : F.MINIPCHI2(pvs), + # "MINIP" : F.MINIP(pvs), + "KEY" : F.VALUE_OR(-1) @ F.OBJECT_KEY @ F.TRACK, + "CTB" : F.POSITION @ F.CLOSESTTOBEAM @ F.TRACK, + "TRACKPT": F.TRACK_PT, + "TRACKHISTORY": F.VALUE_OR(-1) @ F.TRACKHISTORY @ F.TRACK, + "QOVERP": F.QOVERP @ F.TRACK, + "NDOF": F.VALUE_OR(-1) @ F.NDOF @ F.TRACK, + } + ) + + Kinematics() + ) + + if(mass_constraint): + if(pv_constraint): # MASS + PV + dtf_variables_mass_pv = FunctorCollection({ + 'DTF_PV_M'+ particle_name + '_' + k: DTF(v) + for k, v in variables.get_thor_functors().items() + }) + return dtf_variables_mass_pv + else: # MASS + dtf_variables_mass = FunctorCollection( + {'DTF_M'+ particle_name + '_' + k: DTF(v) + for k, v in variables.get_thor_functors().items()}) + return dtf_variables_mass + + elif(pv_constraint): # PV + dtf_variables_pv = FunctorCollection({ + 'DTF_PV_' + k: DTF(v) + for k, v in variables.get_thor_functors().items() + }) + return dtf_variables_pv + + else: # NO MASS/PV + dtf_variables = FunctorCollection( + {'DTF_' + k: DTF(v) + for k, v in variables.get_thor_functors().items()}) + return dtf_variables + + +def make_composite_dtf_variables(pvs, data, DTF=None, pv_constraint=False, mass_constraint=False, particle_name=""): + variables = ( + FunctorCollection( + { + # "MAXPT": F.MAX(F.PT), + # "MINPT": F.MIN(F.PT), + # "SUMPT": F.SUM(F.PT), + # "MAXP": F.MAX(F.P), + # "MINP": F.MIN(F.P), + "BPVDIRA": F.BPVDIRA(pvs), + "VCHI2DOF": F.CHI2DOF, #CHI2VXNDOF + "BPVFDCHI2": F.BPVFDCHI2(pvs), + "BPVFD": F.BPVFD(pvs), + "BPVVDRHO": F.BPVVDRHO(pvs), + "BPVVDZ": F.BPVVDZ(pvs), + "BPVIPCHI2": F.BPVIPCHI2(pvs), + "BPVIP": F.BPVIP(pvs), + # "LOGBPVIPCHI2": log(F.BPVIPCHI2(pvs)), + "BPVLTIME": F.BPVLTIME(pvs), + # "MAXBPVIPCHI2": F.MAX(F.BPVIPCHI2(pvs)), #MAX_ + # "MINBPVIPCHI2": F.MIN(F.BPVIPCHI2(pvs)), + # "MAXBPVIP": F.MAX(F.BPVIP(pvs)), + # "MINBPVIP": F.MIN(F.BPVIP(pvs)), + "ETA": F.ETA, + "PHI": F.PHI, + "END_VX": F.END_VX, #END_ + "END_VY": F.END_VY, + "END_VZ": F.END_VZ, + "BPVX": F.BPVX(pvs), + "BPVY": F.BPVY(pvs), + "BPVZ": F.BPVZ(pvs), + "ALLPVFD" : F.ALLPV_FD(pvs), + "ALLPVIP" : F.ALLPV_IP(pvs), + + } + ) + + Kinematics() + ) + + addstring = "DTF" + if(pv_constraint): + addstring += '_PV' + if(mass_constraint): + addstring += '_M' + addstring += particle_name + + DTF_chi2ndof = FunctorCollection( + { + addstring+"_DTFCHI2": DTF.CHI2, + addstring+"_DTFNDOF": DTF.NDOF, + addstring+"_CTAU": DTF.CTAU, + addstring+"_CTAUERR": DTF.CTAUERR, + addstring+"_MERR": DTF.MASSERR, + } + ) + + if(mass_constraint): + if(pv_constraint): # MASS + PV + dtf_variables_mass_pv = FunctorCollection({ + 'DTF_PV_M'+ particle_name + '_' + k: DTF(v) + for k, v in variables.get_thor_functors().items() + }) + return dtf_variables_mass_pv+DTF_chi2ndof + else: # MASS + dtf_variables_mass = FunctorCollection( + {'DTF_M'+ particle_name + '_' + k: DTF(v) + for k, v in variables.get_thor_functors().items()}) + return dtf_variables_mass+DTF_chi2ndof + + elif(pv_constraint): # PV + dtf_variables_pv = FunctorCollection({ + 'DTF_PV_' + k: DTF(v) + for k, v in variables.get_thor_functors().items() + }) + return dtf_variables_pv+DTF_chi2ndof + + else: # NO MASS/PV + dtf_variables = FunctorCollection( + {'DTF_' + k: DTF(v) + for k, v in variables.get_thor_functors().items()}) + return dtf_variables+DTF_chi2ndof + + + +def make_dtf_variables(pvs, input_data, ptype): + + if ptype not in ["basic", "composite"]: + Exception(f"Need \'basic\' or \'composite\'. Got {ptype}") + + from DecayTreeFitter import DecayTreeFitter + + DTF = DecayTreeFitter( + name=f'DTF_{{hash}}', + input_particles=input_data) + + DTFvtx = DecayTreeFitter( + name=f'DTFvtx_{{hash}}', + input_particles=input_data, + input_pvs=pvs) + + DTFmassJpsi = DecayTreeFitter( + name=f'DTFmassJpsi_{{hash}}', + input_particles=input_data, + mass_constraints=["J/psi(1S)"]) + + DTFvtxmassJpsi = DecayTreeFitter( + name=f'DTFvtxmassJpsi_{{hash}}', + input_particles=input_data, + input_pvs=pvs, + mass_constraints=["J/psi(1S)"]) + + # DTFmassBcJpsi = DecayTreeFitter( + # name=f'DTFmassBcJpsi_{{hash}}', + # input_particles=input_data, + # mass_constraints=["B_c+","J/psi(1S)"]) + + # DTFvtxmassBcJpsi = DecayTreeFitter( + # name=f'DTFvtxmassBcJpsi_{{hash}}', + # input_particles=input_data, + # input_pvs=pvs, + # mass_constraints=["B_c+","J/psi(1S)"]) + + + if ptype == "basic": + dtf_vars = make_basic_dtf_variables(pvs, input_data, + DTF=DTFvtx, + pv_constraint=True, + mass_constraint=False) + # dtf_vars += make_basic_dtf_variables(pvs, input_data, + # DTF=DTF, + # pv_constraint=False, + # mass_constraint=False) + + # dtf_vars += make_basic_dtf_variables(pvs, input_data, + # DTF=DTFmassJpsi, + # pv_constraint=False, + # mass_constraint=True, particle_name="Jpsi") + dtf_vars += make_basic_dtf_variables(pvs, input_data, + DTF=DTFvtxmassJpsi, + pv_constraint=True, + mass_constraint=True, particle_name="Jpsi") + # dtf_vars += make_basic_dtf_variables(pvs, input_data, + # DTF=DTFmassBcJpsi, + # pv_constraint=False, + # mass_constraint=True, particle_name="BcJpsi") + # dtf_vars += make_basic_dtf_variables(pvs, input_data, + # DTF=DTFvtxmassBcJpsi, + # pv_constraint=True, + # mass_constraint=True, particle_name="BcJpsi") + + return dtf_vars + + if ptype == "composite": + dtf_vars = make_composite_dtf_variables(pvs, input_data, + DTF=DTFvtx, + pv_constraint=True, + mass_constraint=False) + + # dtf_vars += make_composite_dtf_variables(pvs, input_data, + # DTF=DTF, + # pv_constraint=False, + # mass_constraint=False) + + # dtf_vars += make_composite_dtf_variables(pvs, input_data, + # DTF=DTFmassJpsi, + # pv_constraint=False, + # mass_constraint=True, particle_name="Jpsi") + dtf_vars += make_composite_dtf_variables(pvs, input_data, + DTF=DTFvtxmassJpsi, + pv_constraint=True, + mass_constraint=True, particle_name="Jpsi") + # dtf_vars += make_composite_dtf_variables(pvs, input_data, + # DTF=DTFmassBcJpsi, + # pv_constraint=False, + # mass_constraint=True, particle_name="BcJpsi") + # dtf_vars += make_composite_dtf_variables(pvs, input_data, + # DTF=DTFvtxmassBcJpsi, + # pv_constraint=True, + # mass_constraint=True, particle_name="BcJpsi") + + return dtf_vars + diff --git a/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/tupling_maker.py b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/tupling_maker.py new file mode 100644 index 0000000000000000000000000000000000000000..9f516921b47a31aff16e70cc6f6405570fd61b96 --- /dev/null +++ b/BandQ_Bp2JpsiKp_MuonID_NoMuonID_Lines/tupling_maker.py @@ -0,0 +1,367 @@ +############################################################################### +# (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. # +############################################################################### +""" +Read an HLT2 file and create an ntuple with the new DaVinci configuration. +""" +import Functors as F +import FunTuple.functorcollections as FC +from FunTuple import FunctorCollection +from FunTuple import FunTuple_Particles as Funtuple +from PyConf.reading import get_particles, get_pvs, get_rec_summary +from DaVinci.algorithms import create_lines_filter +from DaVinciMCTools import MCTruthAndBkgCat +from FunTuple.functorcollections import MCHierarchy, MCPrimaries, MCPromptDecay, Kinematics, SelectionInfo, HltTisTos, MCVertexInfo, MCKinematics, ParticleID, EventInfo +from PyConf.reading import get_odin # get_decreports, +from DecayTreeFitter import DecayTreeFitter +from Hlt2Conf.algorithms_thor import ParticleFilter +from GaudiKernel.SystemOfUnits import MeV +from .make_dtf import * + +_basic = "basic" +_composite = "composite" +_toplevel = "toplevel" + +def all_variables(pvs, mctruth, ptype, candidates=None, ftAlg=None): + """ + function that returns dictionary of functors that work. + + functors are listed in order of https://lhcbdoc.web.cern.ch/lhcbdoc/moore/master/selection/thor_functors_reference.html#module-Functo + """ + if ptype not in [_basic, _composite]: + Exception(f"I want {_basic} or {_composite}. Got {ptype}") + all_vars = FunctorCollection({}) + + comp = _composite == ptype or _toplevel == ptype # is composite + basic = _basic == ptype # is not composite + top = _toplevel == ptype # the B + + # First import everything that comes in functorcollections + all_vars += FC.Kinematics() + if basic: + all_vars += FC.ParticleID(extra_info=True) + + if comp: + all_vars.update({"ALV": F.ALV(Child1=1, Child2=2)}) + + if comp: # all these require a vertex + all_vars.update({"BPVCORRM": F.BPVCORRM(pvs)}) + all_vars.update({"BPVCORRMERR": F.BPVCORRMERR(pvs)}) + all_vars.update({"BPVDIRA": F.BPVDIRA(pvs)}) + all_vars.update({"BPVDLS": F.BPVDLS(pvs)}) + all_vars.update({"BPVETA": F.BPVETA(pvs)}) + all_vars.update({"BPVFD": F.BPVFD(pvs)}) + all_vars.update({"BPVFDCHI2": F.BPVFDCHI2(pvs)}) + all_vars.update({"BPVFDIR": F.BPVFDIR(pvs)}) + all_vars.update({"BPVFDVEC": F.BPVFDVEC(pvs)}) + + all_vars.update({"BPVIP": F.BPVIP(pvs)}) + all_vars.update({"BPVIPCHI2": F.BPVIPCHI2(pvs)}) + all_vars.update({"BPVX": F.BPVX(pvs)}) + all_vars.update({"BPVY": F.BPVY(pvs)}) + all_vars.update({"BPVZ": F.BPVZ(pvs)}) + + if comp: # all these require a vertex + all_vars.update({"ALLPV_FD": F.ALLPV_FD(pvs)}) + all_vars.update({"ALLPV_IP": F.ALLPV_IP(pvs)}) + all_vars.update({"BPVLTIME": F.BPVLTIME(pvs)}) + all_vars.update({"BPVVDRHO": F.BPVVDRHO(pvs)}) + all_vars.update({"BPVVDX": F.BPVVDX(pvs)}) + all_vars.update({"BPVVDY": F.BPVVDY(pvs)}) + all_vars.update({"BPVVDZ": F.BPVVDZ(pvs)}) + + all_vars.update({"CHARGE": F.CHARGE}) + all_vars.update({"CHI2": F.CHI2}) + all_vars.update({"CHI2DOF": F.CHI2DOF}) + + if top: # apply this only to B + all_vars.update({"CHILD1_PT": F.CHILD(1, F.PT)}) # example of CHILD + all_vars.update({"Ds_END_VZ": F.CHILD(1, F.END_VZ)}) + all_vars.update({"Delta_END_VZ_DsB0": F.CHILD(1, F.END_VZ) - F.END_VZ}) + + if comp: + all_vars.update({"DOCA": F.SDOCA(Child1=1, Child2=2)}) + all_vars.update({"DOCACHI2": F.SDOCACHI2(Child1=1, Child2=2)}) + all_vars.update({"END_VRHO": F.END_VRHO}) + all_vars.update({"END_VX": F.END_VX}) + all_vars.update({"END_VY": F.END_VY}) + all_vars.update({"END_VZ": F.END_VZ}) + all_vars.update({"NEWW_DIFF_MASS":F.MASS-F.CHILD(1,F.MASS)}) + + all_vars.update({"ETA": F.ETA}) + all_vars.update({"FOURMOMENTUM": F.FOURMOMENTUM}) + all_vars.update({"ISBASIC": F.ISBASICPARTICLE}) + + if basic: + all_vars.update({"GHOSTPROB": F.GHOSTPROB}) + all_vars.update({"ISMUON": F.ISMUON}) + all_vars.update({"INMUON": F.INMUON}) + all_vars.update({"INECAL": F.INECAL}) + all_vars.update({"INHCAL": F.INHCAL}) + all_vars.update({"HASBREM": F.HASBREM}) + all_vars.update({"BREMENERGY": F.BREMENERGY}) + all_vars.update({"BREMBENDCORR": F.BREMBENDCORR}) + all_vars.update({"BREMPIDE": F.BREMPIDE}) + all_vars.update({"ECALPIDE": F.ECALPIDE}) + all_vars.update({"ECALPIDMU": F.ECALPIDMU}) + all_vars.update({"HCALPIDE": F.HCALPIDE}) + all_vars.update({"HCALPIDMU": F.HCALPIDMU}) + all_vars.update({"ELECTRONSHOWEREOP": F.ELECTRONSHOWEREOP}) + all_vars.update({"CLUSTERMATCH": F.CLUSTERMATCH_CHI2}) + all_vars.update({"ELECTRONMATCH": F.ELECTRONMATCH_CHI2}) + all_vars.update({"BREMHYPOMATCH": F.BREMHYPOMATCH_CHI2}) + all_vars.update({"ELECTRONENERGY": F.ELECTRONENERGY}) + all_vars.update({"BREMHYPOENERGY": F.BREMHYPOENERGY}) + all_vars.update({"BREMHYPODELTAX": F.BREMHYPODELTAX}) + all_vars.update({"ELECTRONID": F.ELECTRONID}) + all_vars.update({"HCALEOP": F.HCALEOP}) + # Note: the observables for the two functors below are (TRACK_MOM_X, TRACK_MOM_Y, TRACK_MOM_Z}) + # and (TRACK_POS_CLOSEST_TO_BEAM_X, TRACK_POS_CLOSEST_TO_BEAM_Y, TRACK_POS_CLOSEST_TO_BEAM_Z), + # which is why the trailing underscore in the name is added i.e. "TRACK_MOM_" and "TRACK_POS_CLOSEST_TO_BEAM_" + all_vars.update({"TRACK_MOM_": F.TRACK_MOMVEC}) + all_vars.update({"TRACK_POS_CLOSESTTOBEAM_": F.TRACK_POSVEC_CLOSESTTOBEAM}) + + all_vars.update({"IS_ABS_ID_pi": F.IS_ABS_ID("pi+")}) + all_vars.update({"IS_ID_pi": F.IS_ID("pi-")}) + all_vars.update({"PDG_MASS_pi": F.PDG_MASS("pi+")}) + all_vars.update({"SIGNED_DELTA_MASS_pi": F.SIGNED_DELTA_MASS("pi+")}) + all_vars.update({"ABS_DELTA_MASS_pi": F.ABS_DELTA_MASS("pi+")}) + all_vars.update({"IS_NOT_H": F.IS_NOT_H}) + all_vars.update({"IS_PHOTON": F.IS_PHOTON}) + + # update ?OK + all_vars.update({"RICH_DLL_MU": F.RICH_DLL_MU}) + all_vars.update({"RICH_DLL_E": F.RICH_DLL_E}) + all_vars.update({"RICH_DLL_P": F.RICH_DLL_P}) + all_vars.update({"RICH_DLL_K": F.RICH_DLL_K}) + all_vars.update({"RICH_DLL_Pi": F.RICH_DLL_PI}) + + all_vars.update({"MASS": F.MASS}) + + if comp: + all_vars.update({"MAXPT": F.MAX(F.PT)}) + all_vars.update({"MAXDOCA": F.MAXSDOCA}) + all_vars.update({"MAXDOCACHI2": F.MAXSDOCACHI2}) + # the above in cut versions. + + if comp: + all_vars.update({"MINPT": F.MIN(F.PT)}) + all_vars.update({"MINIP": F.MINIP(pvs)}) + all_vars.update({"MINIPCHI2": F.MINIPCHI2(pvs)}) + + if basic: + all_vars.update({"TRACKPT": F.TRACK_PT}) + all_vars.update({"TRACKHISTORY": F.VALUE_OR(-1) @ F.TRACKHISTORY @ F.TRACK}) + all_vars.update({"QOVERP": F.QOVERP @ F.TRACK}) + all_vars.update({"NDOF": F.VALUE_OR(-1) @ F.NDOF @ F.TRACK}) + all_vars.update({"NFTHITS": F.VALUE_OR(-1) @ F.NFTHITS @ F.TRACK}) + all_vars.update({"NHITS": F.VALUE_OR(-1) @ F.NHITS @ F.TRACK}) + all_vars.update({"NUTHITS": F.VALUE_OR(-1) @ F.NUTHITS @ F.TRACK}) + all_vars.update({"NVPHITS": F.VALUE_OR(-1) @ F.NVPHITS @ F.TRACK}) + all_vars.update({"TRACKHASVELO": F.VALUE_OR(-1) @ F.TRACKHASVELO @ F.TRACK}) + all_vars.update({"TRACKHASUT": F.VALUE_OR(-1) @ F.TRACKHASUT @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M1_position_X": F.POSITION_X @ F.EXTRAPOLATE_TRACK( 12100.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M1_position_Y": F.POSITION_Y @ F.EXTRAPOLATE_TRACK( 12100.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M2_position_X": F.POSITION_X @ F.EXTRAPOLATE_TRACK( 15100.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M2_position_Y": F.POSITION_Y @ F.EXTRAPOLATE_TRACK( 15100.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M3_position_X": F.POSITION_X @ F.EXTRAPOLATE_TRACK( 16300.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M3_position_Y": F.POSITION_Y @ F.EXTRAPOLATE_TRACK( 16300.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M4_position_X": F.POSITION_X @ F.EXTRAPOLATE_TRACK( 17500.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M4_position_Y": F.POSITION_Y @ F.EXTRAPOLATE_TRACK( 17500.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M5_position_X": F.POSITION_X @ F.EXTRAPOLATE_TRACK( 18700.) @ F.TRACK}) + all_vars.update({"STATEAT_MUON_M5_position_Y": F.POSITION_Y @ F.EXTRAPOLATE_TRACK( 18700.) @ F.TRACK}) + + all_vars.update({"OBJECT_KEY": F.OBJECT_KEY}) + + all_vars.update({"PHI": F.PHI}) + + all_vars.update({"ABS_PX": F.ABS @ F.PX}) + + all_vars.update({"REFERENCEPOINT_X": F.REFERENCEPOINT_X}) + all_vars.update({"REFERENCEPOINT_Y": F.REFERENCEPOINT_Y}) + all_vars.update({"REFERENCEPOINT_Z": F.REFERENCEPOINT_Z}) + + if comp: + all_vars.update({"SDOCA": F.SDOCA(1, 2)}) + all_vars.update({"SDOCACHI2": F.SDOCACHI2(1, 2)}) + if basic: + all_vars.update({"SHOWER_SHAPE": F.CALO_NEUTRAL_SHOWER_SHAPE}) + + if comp: + all_vars.update({"SUBCOMB12_MM": F.SUBCOMB(Functor=F.MASS, Indices=(1, 2))}) + all_vars.update({"SUMPT": F.SUM(F.PT)}) + + if basic: + all_vars.update({"TX": F.TX}) + all_vars.update({"TY": F.TY}) + + print(f"### For {ptype} returning variables {all_vars.functor_dict.keys()}") + return all_vars + + +def event_variables(PVs, ODIN, decreports, lines): + """ + event variables + """ + + evt_vars = FunctorCollection({}) + evt_vars += FC.EventInfo() + + evt_vars += FC.SelectionInfo(selection_type="Hlt2", trigger_lines=lines) + + if decreports: + evt_vars.update( + { + "DECISIONS": F.DECISIONS( + Lines=[bd2dsk_line + "Decision"], DecReports=decreports + ) + } + ) + evt_vars.update( + { + "DECREPORTS_FILTER": F.DECREPORTS_FILTER( + Lines=[bd2dsk_line + "Decision"], DecReports=decreports + ) + } + ) + + if ODIN: + evt_vars.update({"EVENTTYPE": F.EVENTTYPE(ODIN)}) + + evt_vars.update({"PV_SIZE": F.SIZE(PVs)}) + + if decreports: + evt_vars.update({"TCK": F.TCK(decreports)}) + + print(f"### For event returning variables {evt_vars.functor_dict.keys()}") + return evt_vars + + +def template(decay_descriptor, line_name, isturbo, Hlt2_decisions, composite_particles, daughter_particles, cutAdd=(F.MASS>1.*MeV)): + + evtpath_prefix = "/Event/Spruce/" + if isturbo: + evtpath_prefix = "/Event/HLT2/" + + PsiXXX_data_raw = get_particles(evtpath_prefix + f"{line_name}/Particles") + PsiXXX_data = ParticleFilter(PsiXXX_data_raw, Cut=F.FILTER(cutAdd) ) + + + + + + + + + pvs = get_pvs() + + Hlt1_decisions = [ # already contain Hlt1TrackMVADecision ?OK + 'Hlt1TrackMVADecision', 'Hlt1TwoTrackMVADecision', #'Hlt1D2KKDecision', + #'Hlt1D2KPiDecision', 'Hlt1D2PiPiDecision', + 'Hlt1DiMuonHighMassDecision', #'Hlt1DiMuonLowMassDecision', + #'Hlt1DiMuonSoftDecision', + #'Hlt1KsToPiPiDecision', 'Hlt1LowPtMuonDecision', + 'Hlt1LowPtDiMuonDecision', 'Hlt1SingleHighPtMuonDecision', + 'Hlt1TrackMuonMVADecision', "Hlt1DiMuonNoIP_SSDecision", + #"Hlt1DiMuonDrellYan_VLowMassDecision", + #"Hlt1DiMuonDrellYan_VLowMass_SSDecision", + #"Hlt1DiMuonDrellYanDecision", + #"Hlt1DiMuonDrellYan_SSDecision", + #"Hlt1DetJpsiToMuMuPosTagLineDecision", + #"Hlt1DetJpsiToMuMuNegTagLineDecision", + #"Hlt1TrackElectronMVADecision", + #"Hlt1SingleHighPtElectronDecision", + #"Hlt1DiElectronDisplacedDecision", + #"Hlt1SingleHighEtDecision", + #"Hlt1DiPhotonHighMassDecision", + #"Hlt1Pi02GammaGammaDecision", + #"Hlt1DiElectronHighMass_SSDecision", + #"Hlt1DiElectronHighMassDecision", + "Hlt1DiMuonNoIPDecision", + ] + + composite_variables = FunctorCollection({ + "END_VX_ERR":F.SQRT @ F.CALL(0,0) @ F.POS_COV_MATRIX @ F.ENDVERTEX, + "END_VY_ERR":F.SQRT @ F.CALL(1,1) @ F.POS_COV_MATRIX @ F.ENDVERTEX, + "END_VZ_ERR":F.SQRT @ F.CALL(2,2) @ F.POS_COV_MATRIX @ F.ENDVERTEX, + "BPVX_ERR": F.SQRT @ F.CALL(0,0) @ F.POS_COV_MATRIX @ F.BPV(pvs), + "BPVY_ERR": F.SQRT @ F.CALL(1,1) @ F.POS_COV_MATRIX @ F.BPV(pvs), + "BPVZ_ERR": F.SQRT @ F.CALL(2,2) @ F.POS_COV_MATRIX @ F.BPV(pvs), + "PERR": F.SQRT @ F.PERR2, + "PXERR": F.SQRT @ F.CALL(0,0) @ F.THREE_MOM_COV_MATRIX, + "PYERR": F.SQRT @ F.CALL(1,1) @ F.THREE_MOM_COV_MATRIX, + "PZERR": F.SQRT @ F.CALL(2,2) @ F.THREE_MOM_COV_MATRIX, + }) + + composite_variables += HltTisTos( selection_type="Hlt1", trigger_lines=Hlt1_decisions, data=PsiXXX_data) + if not isturbo: + composite_variables += HltTisTos( selection_type="Hlt2", trigger_lines=Hlt2_decisions, data=PsiXXX_data) + + daughter_variables = FunctorCollection({ + "PERR": F.SQRT @ F.PERR2, + "PZERR": F.SQRT @ F.CALL(2,2) @ F.THREE_MOM_COV_MATRIX, + }) + + #define event level variables + odin = get_odin() + decreports = None + rec_sum=get_rec_summary() + event_info = event_variables(pvs, odin, decreports, [line_name]) + FunctorCollection({ + "nPVs": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nPVs"), + "nTTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nTTracks"), + "nLongTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nLongTracks"), + "nDownstreamTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nDownstreamTracks"), + "nUpstreamTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nUpstreamTracks"), + "nVeloTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nVeloTracks"), + "nBackTracks": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nBackTracks"), + "nRich1Hits": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nRich1Hits"), + "nRich2Hits": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nRich2Hits"), + "nVPClusters": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nVPClusters"), + "nFTClusters": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nFTClusters"), + "eCalTot": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"eCalTot"), + "hCalTot": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"hCalTot"), + "nEcalClusters": F.VALUE_OR(-1) @F.RECSUMMARY_INFO(rec_sum,"nEcalClusters"), + "ALLPVX": F.ALLPVX(pvs), + "ALLPVY": F.ALLPVY(pvs), + "ALLPVZ": F.ALLPVZ(pvs), + + }) + + event_info += FC.SelectionInfo( + selection_type="Hlt1", trigger_lines=Hlt1_decisions + ) + + variables = {} + + for composite_particle in composite_particles: + variables[composite_particle] = composite_variables + all_variables(pvs, None, _composite) + make_dtf_variables(pvs, PsiXXX_data, _composite) + for daughter_particle in daughter_particles: + variables[daughter_particle] = daughter_variables + all_variables(pvs, None, _basic) + make_dtf_variables(pvs, PsiXXX_data, _basic) +# variables = { +# "QQbar": composite_variables + all_variables(pvs, None, _composite), +# "mup": daughter_variables + all_variables(pvs, None, _basic), +# "mum": daughter_variables + all_variables(pvs, None, _basic), +# } + + #define FunTuple instance + my_tuple = Funtuple( + name=line_name, + tuple_name="DecayTree", + fields=decay_descriptor, + variables=variables, + event_variables=event_info, + store_multiple_cand_info = True, + inputs=PsiXXX_data) + + return my_tuple + + +def line_prefilter(line_name): + return create_lines_filter(name=f"PreFilter_{line_name}", lines=[line_name]) diff --git a/Beauty_XS_Bs2DsPi/README.md b/Beauty_XS_Bs2DsPi/README.md deleted file mode 100644 index 769ed08b696e40389437865e22cb34a3bab2cfa9..0000000000000000000000000000000000000000 --- a/Beauty_XS_Bs2DsPi/README.md +++ /dev/null @@ -1,3 +0,0 @@ -Production of Bs -> Ds pi to run on 2024 collision data to include both up and down polarities - -This is for use in early measurements of Beauty XS diff --git a/Beauty_XS_Bs2DsPi/dv_simple.py b/Beauty_XS_Bs2DsPi/dv_simple.py deleted file mode 100644 index b4254db88035c1df0041355ffc4ef5974a6b8c2f..0000000000000000000000000000000000000000 --- a/Beauty_XS_Bs2DsPi/dv_simple.py +++ /dev/null @@ -1,252 +0,0 @@ -# Based on: -# https://gitlab.cern.ch/lhcb/DaVinci/-/blob/v63r2/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2.py - -import Functors as F -import FunTuple.functorcollections as FC -from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple -from PyConf.reading import get_particles, get_pvs, get_rec_summary, get_odin -#from PyConf.Algorithms import AdvancedCloneKiller, Run2SSPionTagger -from GaudiKernel.SystemOfUnits import GeV -from Hlt2Conf.algorithms_thor import ParticleFilter -#from DaVinci.common_particles import make_long_pions -from DaVinci.algorithms import create_lines_filter -from DaVinci import Options, make_config -from DaVinciMCTools import MCTruthAndBkgCat -from DecayTreeFitter import DecayTreeFitter -from Hlt2Conf.flavourTagging import run2_all_taggers -# specific for the B2OC SigmaNet -import Functors.math as fmath -import os - - -def alg_config(options: Options): - - line = "Hlt2B2OC_BdToDsmPi_DsmToKpKmPim" - line_data = get_particles(f"/Event/HLT2/{line}/Particles") - my_filter = create_lines_filter("Hlt2Line_Filter", - lines=[f"{line}"]) - Hlt1_decisions = [ - "Hlt1TrackMVADecision", - "Hlt1TwoTrackMVADecision", - ] - Hlt2_decisions = ['Hlt2B2OC_BdToDsmPi_DsmToKpKmPimDecision', - 'Hlt2Topo2BodyDecision', - 'Hlt2Topo3BodyDecision'] - - fields = { - "lab0": "[[B0]CC -> (D_s- -> K+ K- pi-) pi+]CC", - "lab1": "[[B0]CC -> (D_s- -> K+ K- pi-) ^pi+]CC", - "lab2": "[[B0]CC -> ^(D_s- -> K+ K- pi-) pi+]CC", - "lab3": "[[B0]CC -> (D_s- -> ^K+ K- pi-) pi+]CC", - "lab4": "[[B0]CC -> (D_s- -> K+ ^K- pi-) pi+]CC", - "lab5": "[[B0]CC -> (D_s- -> K+ K- ^pi-) pi+]CC", - } - - pvs = get_pvs() - - DTF_MassFitConsD = DecayTreeFitter(name="DTF_MassFitConsD", - input_particles=line_data, - mass_constraints=["D_s-"]) - DTF_LifetimeFit = DecayTreeFitter(name="DTF_LifetimeFit", - input_particles=line_data, - input_pvs=pvs) - - all_tagging = run2_all_taggers(line_data) - - # define helper functors - get_child = F.CHILD(1, F.FORWARDARG0) # change here the index of the child - get_SV = F.ENDVERTEX @ F.FORWARDARG0 - get_SV_pos = F.TOLINALG @ F.POSITION @ get_SV # only if composite (i.e. has vertex) - get_child_endvtx_pos = F.ENDVERTEX_POS @ get_child - get_fdvec_child = get_child_endvtx_pos - get_SV_pos - - # define observables - IP_wrt_SV = F.IP.bind(get_SV_pos , get_child) - IPCHI2_wrt_SV = F.IPCHI2.bind(get_SV , get_child) # only if child is composite (i.e. has vertex) - FD_wrt_SV = F.MAGNITUDE @ get_fdvec_child - FDCHI2_wrt_SV = F.VTX_FDCHI2.bind(get_SV, get_child) - - B_variables = FunctorCollection( - { - "ID": F.PARTICLE_ID, - "PT": F.PT, - "ETA": F.ETA, - "P": F.P, - "SUMPT": F.SUM(F.PT), - "MASS": F.MASS, - "BPVDIRA": F.BPVDIRA(pvs), - "CHI2DOF": F.CHI2DOF, - "BPVIPCHI2": F.BPVIPCHI2(pvs), - "BPVIP": F.BPVIP(pvs), - "BPVFDCHI2": F.BPVFDCHI2(pvs), - "BPVLTIME": F.BPVLTIME(pvs), - "BPVFD": F.BPVFD(pvs), - "CHILD1_IPwrtSV": IP_wrt_SV, - "CHILD1_IPCHI2wrtSV": IPCHI2_wrt_SV, - "CHILD1_FDwrtSV": FD_wrt_SV, - "CHILD1_FDCHI2wrtSV": FDCHI2_wrt_SV, - "DTF_MassFitConsD_MASS": DTF_MassFitConsD(F.MASS), - "DTF_MassFitConsD_CHI2DOF": DTF_MassFitConsD(F.CHI2DOF), # track or vertex chi2/ndf - "DTF_MassFitConsD_P": DTF_MassFitConsD(F.P), - "DTF_LifetimeFit_MASS": DTF_LifetimeFit(F.MASS), - "DTF_LifetimeFit_CHI2DOF": DTF_LifetimeFit(F.CHI2DOF), # track or vertex chi2/ndf - "DTF_LifetimeFit_CTAU": DTF_LifetimeFit.CTAU, - "DTF_LifetimeFit_CTAUERR": DTF_LifetimeFit.CTAUERR, - "PX": F.PX, - "PY": F.PY, - "PZ": F.PZ, - "BPVX": F.BPVX(pvs), - "BPVY": F.BPVY(pvs), - "BPVZ": F.BPVZ(pvs), - "END_VX": F.END_VX, - "END_VY": F.END_VY, - "END_VZ": F.END_VZ, - "END_VCHI2DOF": F.CHI2DOF @ F.ENDVERTEX, - "BPVCHI2DOF": F.CHI2DOF @ F.BPV(pvs), - # B2OC generic B hadron NN Hlt2 algorithm, - # not planning to use it directly for B2OC EM - "MVA": F.MVA( - MVAType="SigmaNet", - Config={ - "File": - "paramfile://data/Hlt2B2OC_B_SigmaNet_Run3-v2.json", - "Name": - "B2OC_SigmaNet_Generic", - "Lambda": - "2.0", - "NLayers": - "3", - "InputSize": - "6", - "Monotone_Constraints": - "[1,-1,-1,-1,-1,-1]", - "Variables": - "log_B_PT,B_ETA,log_B_DIRA,log_B_ENDVERTEX_CHI2,log_B_IPCHI2_OWNPV,log_B_IP_OWNPV", - }, - Inputs={ - "log_B_PT": fmath.log(F.PT), - "B_ETA": F.ETA, - "log_B_DIRA": fmath.log(1. +1.e-6 - F.BPVDIRA(pvs)), - "log_B_ENDVERTEX_CHI2": fmath.log(F.CHI2DOF), - "log_B_IPCHI2_OWNPV": fmath.log(F.BPVIPCHI2(pvs)), - "log_B_IP_OWNPV": fmath.log(F.BPVIP(pvs)), - }), - } - ) - B_variables+=FC.HltTisTos(selection_type="Hlt1", trigger_lines=Hlt1_decisions, data=line_data) - B_variables+=FC.FlavourTaggingResults(all_tagging) - - C_variables = FunctorCollection( - { - "ID": F.PARTICLE_ID, - "PT": F.PT, - "ETA": F.ETA, - "P": F.P, - "SUMPT": F.SUM(F.PT), - "MASS": F.MASS, - "DOCA12": F.DOCA(1, 2), - "DOCA13": F.DOCA(1, 3), - "DOCA23": F.DOCA(2, 3), - "BPVDIRA": F.BPVDIRA(pvs), - "CHI2DOF": F.CHI2DOF, - "BPVIP": F.BPVIP(pvs), - "BPVIPCHI2": F.BPVIPCHI2(pvs), - "BPVFD": F.BPVFD(pvs), - "BPVFDCHI2": F.BPVFDCHI2(pvs), - "MINIPCHI2": F.MINIPCHI2(pvs), - "PX": F.PX, - "PY": F.PY, - "PZ": F.PZ, - "BPVX": F.BPVX(pvs), - "BPVY": F.BPVY(pvs), - "BPVZ": F.BPVZ(pvs), - "END_VX": F.END_VX, - "END_VY": F.END_VY, - "END_VZ": F.END_VZ, - "END_VCHI2DOF": F.CHI2DOF @ F.ENDVERTEX, - } - ) - - fs_variables = FunctorCollection( - { - "ID": F.PARTICLE_ID, - "PT": F.PT, - "ETA": F.ETA, - "PHI": F.PHI, - "P": F.P, - "MASS": F.MASS, - "CHI2DOF": F.CHI2DOF, - "MINIPCHI2": F.MINIPCHI2(pvs), - "BPVIPCHI2": F.BPVIPCHI2(pvs), - "PX": F.PX, - "PY": F.PY, - "PZ": F.PZ, - "hasRICH": F.PPHASRICH() @ F.PROTOPARTICLE(), - "PIDK": F.PID_K, - "PIDp": F.PID_P, - "PIDe": F.PID_E, - "PIDmu": F.PID_MU, - "isMuon": F.ISMUON, - "TRACK_GhostProb": F.GHOSTPROB, - "ProbNNp": F.PROBNN_P, - "NHITS": F.VALUE_OR(-1) @ F.NHITS @ F.TRACK, - "NVPHITS": F.VALUE_OR(-1) @ F.NVPHITS @ F.TRACK, # VeloPixel hits - "NUTHITS": F.VALUE_OR(-1) @ F.NUTHITS @ F.TRACK, # UpstreamTracker hits - "NFTHITS": F.VALUE_OR(-1) @ F.NFTHITS @ F.TRACK, # ForwardTracker hits - "TRACKHASVELO": F.VALUE_OR(-1) @ F.TRACKHASVELO @ F.TRACK, - } - ) - - variables = { - "lab0": B_variables, - "lab1": fs_variables, - "lab2": C_variables, - "lab3": fs_variables, - "lab4": fs_variables, - "lab5": fs_variables, - } - - if options.simulation: - mctruth = MCTruthAndBkgCat(line_data, name="MCTruthAndBkgCat") - trueid_bkgcat_info = { - "TRUEID": F.VALUE_OR(0) @ mctruth(F.PARTICLE_ID), - "TRUEKEY": F.VALUE_OR(-1) @ mctruth(F.OBJECT_KEY), - "TRUEPT": mctruth(F.PT), - "TRUEPX": mctruth(F.PX), - "TRUEPY": mctruth(F.PY), - "TRUEPZ": mctruth(F.PZ), - "TRUEENERGY": mctruth(F.ENERGY), - "TRUEP": mctruth(F.P), - "TRUEFOURMOMENTUM": mctruth(F.FOURMOMENTUM), - "TRUETAU": mctruth(F.MC_LIFETIME), - "BKGCAT": mctruth.BkgCat, - } - for field in variables.keys(): - variables[field] += FunctorCollection(trueid_bkgcat_info) - - - odin = get_odin() - rec_summary = get_rec_summary() - # define event level variables - evt_variables = FunctorCollection({ - "RUNNUMBER": F.RUNNUMBER(odin), - "EVENTNUMBER": F.EVENTNUMBER(odin), - "nPVs": F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nPVs"), - "nLongTracks": F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nLongTracks"), - }) - evt_variables+=FC.SelectionInfo(selection_type="Hlt1", trigger_lines=Hlt1_decisions) - evt_variables+=FC.SelectionInfo(selection_type="Hlt2", trigger_lines=Hlt2_decisions) - - # define FunTuple instance - my_tuple = Funtuple( - name="Tuple", - tuple_name="DecayTree", - fields=fields, - variables=variables, - event_variables=evt_variables, - inputs=line_data, - store_multiple_cand_info=True, - ) - - return make_config(options, [my_filter, my_tuple]) - diff --git a/Beauty_XS_Bs2DsPi/hlt1.py b/Beauty_XS_Bs2DsPi/hlt1.py deleted file mode 100644 index d40c23bc29209d15b3ced30b1959c81368527495..0000000000000000000000000000000000000000 --- a/Beauty_XS_Bs2DsPi/hlt1.py +++ /dev/null @@ -1,31 +0,0 @@ -############################################################################### -# (c) Copyright 2023 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. # -############################################################################### -""" -Configures running HLT1 via Moore. -""" - -from Moore import Options -from Moore.config import allen_control_flow -from RecoConf.hlt1_allen import allen_gaudi_config, get_allen_line_names -from PyConf.application import configure_input, configure - -def alg_config(options: Options): - """ - Configures algorithm running of HLT1 via Moore to be passed to Analysis Productions. - """ - - config = configure_input(options) - with allen_gaudi_config.bind(sequence="hlt1_pp_matching_no_ut_1000KHz"): - line_names = get_allen_line_names() - allen_node = allen_control_flow(options) - config.update(configure(options, allen_node)) - - return config diff --git a/Beauty_XS_Bs2DsPi/hlt2.py b/Beauty_XS_Bs2DsPi/hlt2.py deleted file mode 100644 index 86070c155cc3219e654c040a0f7dd22cda4b9dd7..0000000000000000000000000000000000000000 --- a/Beauty_XS_Bs2DsPi/hlt2.py +++ /dev/null @@ -1,68 +0,0 @@ -############################################################################### -# (c) Copyright 2023 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. # -############################################################################### -""" -Configures running HLT2 via Moore. -""" - -from Moore import options, Options, run_moore -from Hlt2Conf.lines.b_to_open_charm import all_lines -# -from RecoConf.global_tools import stateProvider_with_simplified_geom, trackMasterExtrapolator_with_simplified_geom -from RecoConf.reconstruction_objects import reconstruction -from RecoConf.hlt2_global_reco import reconstruction as hlt2_reconstruction, make_light_reco_pr_kf_without_UT -from RecoConf.hlt2_tracking import ( - make_TrackBestTrackCreator_tracks, - make_PrKalmanFilter_noUT_tracks, - make_PrKalmanFilter_Velo_tracks, - make_PrKalmanFilter_Seed_tracks, -) -from RecoConf.decoders import default_VeloCluster_source -from RecoConf.event_filters import require_gec -from Hlt2Conf.settings.defaults import get_default_hlt1_filter_code_for_hlt2 -import sys - -all_lines = {} -from Hlt2Conf.lines.b_to_open_charm.hlt2_b2oc import make_hlt2_lines -default_lines = [ - 'BdToDsmPi_DsmToKpKmPim', -] -extra_config = { - 'flavour_tagging': [ - 'BdToDsmPi_DsmToKpKmPim', - ] -} -make_hlt2_lines( - line_dict=all_lines, - all_lines=default_lines, - extra_config=extra_config) - -def make_lines(): - lines = [builder() for builder in all_lines.values()] - return lines - -def alg_config(options: Options): - - public_tools = [ - trackMasterExtrapolator_with_simplified_geom(), - stateProvider_with_simplified_geom() - ] - - # require_gec.bind(skipUT=True),\ # B2OC lines do not have require_gec() - with reconstruction.bind(from_file=False),\ - hlt2_reconstruction.bind(make_reconstruction=make_light_reco_pr_kf_without_UT),\ - default_VeloCluster_source.bind(bank_type="VPRetinaCluster"),\ - make_TrackBestTrackCreator_tracks.bind(max_ghost_prob=0.7, max_chi2ndof=sys.float_info.max),\ - make_PrKalmanFilter_Velo_tracks.bind(max_chi2ndof=5.),\ - make_PrKalmanFilter_noUT_tracks.bind(max_chi2ndof=4.),\ - make_PrKalmanFilter_Seed_tracks.bind(max_chi2ndof=6.): - config = run_moore(options, make_lines, public_tools) - - return config diff --git a/Beauty_XS_Bs2DsPi/info.yaml b/Beauty_XS_Bs2DsPi/info.yaml deleted file mode 100644 index b903958273f8fca7b499470ad64cf523c5cc60e2..0000000000000000000000000000000000000000 --- a/Beauty_XS_Bs2DsPi/info.yaml +++ /dev/null @@ -1,79 +0,0 @@ - -defaults: - wg: B2OC - automatically_configure: no - inform: - - alessandro.bertolin@pd.infn.it - -{%- set mc_datasets = [ -('13264021', 'Down', 'sim10-2024.Q1.2-v1.0-md100', 'dddb-20240427'), -('13264021', 'Up', 'sim10-2024.Q1.2-v1.0-mu100', 'dddb-20240427'), -]%} - -{%- for evttype, polarity, conddb, dddb in mc_datasets %} - -MC_Bs2DsPi_{{ polarity }}_Nu4d3_hlt1: - application: Moore/v55r9@x86_64_v2-el9-gcc13+detdesc-opt - input: - bk_query: "/MC/Dev/Beam6800GeV-2024.Q1.2-Mag{{ polarity }}-VeloDrift-Nu4.3-25ns-Pythia8/Sim10d/{{ evttype }}/DIGI" - dq_flags: - - OK - n_test_lfns: 1 - options: - entrypoint: Beauty_XS_Bs2DsPi.hlt1:alg_config - extra_options: - input_raw_format: 0.5 - conddb_tag: {{ conddb }} - dddb_tag: {{ dddb }} - input_type: "ROOT" - output_type: "ROOT" - simulation: True - data_type: "Upgrade" - scheduler_legacy_mode: False - compression: - algorithm: ZSTD - level: 1 - max_buffer_size: 1048576 - output: hlt1.dst - -MC_Bs2DsPi_{{ polarity }}_Nu4d3_hlt2: - application: Moore/v55r9@x86_64_v2-el9-gcc13+detdesc-opt - input: - job_name: MC_Bs2DsPi_{{ polarity }}_Nu4d3_hlt1 - options: - entrypoint: Beauty_XS_Bs2DsPi.hlt2:alg_config - extra_options: - input_raw_format: 0.5 - persistreco_version: 0.0 - conddb_tag: {{ conddb }} - dddb_tag: {{ dddb }} - input_type: "ROOT" - output_type: "ROOT" - simulation: True - data_type: "Upgrade" - output_manifest_file: hlt2_{{ evttype }}_{{ polarity }}.tck.json - scheduler_legacy_mode: False - compression: - algorithm: ZSTD - level: 1 - max_buffer_size: 1048576 - output: hlt2.dst - -MC_Bs2DsPi_{{ polarity }}_Nu4d3_DV: - application: DaVinci/v64r6@x86_64_v2-el9-gcc13+detdesc-opt - input: - job_name: MC_Bs2DsPi_{{ polarity }}_Nu4d3_hlt2 - output: dv_{{ polarity }}.root - options: - entrypoint: Beauty_XS_Bs2DsPi.dv_simple:alg_config - extra_options: - input_raw_format: 0.5 - input_type: "ROOT" - simulation: True - data_type: "Upgrade" - conddb_tag: {{ conddb }} - dddb_tag: {{ dddb }} - input_process: "Hlt2" - -{%- endfor %} -