Skip to content
Snippets Groups Projects
Commit f8882df5 authored by Ching-Hua Li's avatar Ching-Hua Li
Browse files

update everything

parent 33c51739
No related branches found
No related tags found
1 merge request!1513Bp_Dststp_l Run3 MC sample for extra isolation study
Pipeline #7733518 failed
This diff is collapsed.
###############################################################################
# (c) Copyright 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. #
###############################################################################
from Moore import Options
from Moore.config import run_allen
from RecoConf.hlt1_allen import allen_gaudi_config as allen_sequence
def main(options: Options):
with allen_sequence.bind(sequence="hlt1_pp_matching_no_ut_1000KHz"):
return run_allen(options)
###############################################################################
# (c) Copyright 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. #
###############################################################################
"""
Stolen and adapted from Hlt/Hlt2Conf/options/hlt2_pp_expected_24_without_UT.py from v55r7.
"""
from Moore import Options,options, run_moore, config
from Hlt2Conf.algorithms_thor import ParticleContainersMerger
from Hlt2Conf.lines.semileptonic.builders import sl_line_prefilter
from Hlt2Conf.lines.semileptonic.builders.base_builder import make_candidate
from Hlt2Conf.lines.semileptonic.builders.charm_hadron_builder import make_d0_tokpi
from GaudiKernel.SystemOfUnits import MeV, GeV,mm
from Hlt2Conf.algorithms_thor import ParticleCombiner
from Hlt2Conf.settings.defaults import get_default_hlt1_filter_code_for_hlt2
from Hlt2Conf.lines.semileptonic import all_lines as slb_lines
from Hlt2Conf.lines.topological_b import all_lines as topo_lines
from Moore.config import Hlt2Line,register_line_builder
from Moore.streams import Stream, Streams, DETECTORS
from RecoConf.event_filters import require_gec
from RecoConf.global_tools import stateProvider_with_simplified_geom, trackMasterExtrapolator_with_simplified_geom
from RecoConf.hlt2_global_reco import reconstruction as hlt2_reconstruction, make_light_reco_pr_kf_without_UT
from RecoConf.reconstruction_objects import reconstruction,make_pvs
from RecoConf.decoders import default_ft_decoding_version,default_VeloCluster_source
from RecoConf.hlt2_tracking import (
make_TrackBestTrackCreator_tracks,
make_PrKalmanFilter_noUT_tracks,
make_PrKalmanFilter_Velo_tracks,
make_PrKalmanFilter_Seed_tracks,
)
from Hlt2Conf.standard_particles import (
make_long_electrons_with_brem,
make_has_rich_long_pions,
make_has_rich_up_pions,
make_has_rich_down_pions)
import Functors as F
from Functors.math import in_range
import sys
#things to control
SUFFIX_NAME = '_BToDzl'
HLT2LINE = f'Hlt2SLB_myBuToD0ENu_D0ToKPi'
CHARM_MASS = 1864.84 #D0 mass
CHARM_BUILDER_NAME = 'Dz2KPi_combiner'
B_BUILDER_NAME = 'BToDzl_combiner'
def get_charm_cuts():
#make loose cuts for D0
delta_mass = 80. #80.0
make_d0tokpi_cuts = {}
make_d0tokpi_cuts['comb_m_min'] = (CHARM_MASS - delta_mass) * MeV
make_d0tokpi_cuts['comb_m_max'] = (CHARM_MASS + delta_mass) * MeV
make_d0tokpi_cuts['comb_docachi2_max'] = 5.
make_d0tokpi_cuts['vchi2pdof_max'] = 6 #6 (Now) 6/4 (v55r7 e/taue)
make_d0tokpi_cuts['bpvfdchi2_min'] = 25 #25 (Now)
make_d0tokpi_cuts['bpvdira_min'] = 0.99 #0.99 (Now) 0.99/0.999 (v55r7 e/taue)
make_d0tokpi_cuts['comb_pt_min'] = None #None (Now) None/2000 * MeV (v55r7 e/taue)
make_d0tokpi_cuts['comb_pt_any_min'] = None #None (Now) None/800 * MeV (v55r7 e/taue)
make_d0tokpi_cuts['comb_pt_sum_min'] = None #None (Now) None/2.5 * GeV (v55r7 e/taue)
make_d0tokpi_cuts['comb_doca_max'] = None #None (Now) None/0.1 mm (v55r7 e/taue)
make_d0tokpi_cuts['daughter_pt_min'] = 600 * MeV #600 * MeV (Now) 750 * MeV (v55r7)
make_d0tokpi_cuts['daughter_mipchi2_min'] = 9. #10. (Now) 10./9. (v55r7 e/taue)
make_d0tokpi_cuts['kaon_pid'] = (F.PID_K > 0.) #(F.PID_K > 0.) (Now) (F.PID_K > 4.) (v55r7)
make_d0tokpi_cuts['pion_pid'] = (F.PID_K < 2.)
return make_d0tokpi_cuts
def get_electron_cuts():
#make loose cuts for electron and tauonic muon
make_electron_cuts = {}
make_electron_cuts["p_min"] = 3. * GeV #3. * GeV (Now) 5. *GeV (v55r7)
make_electron_cuts["pt_min"] = 300. * MeV #300. * MeV (Now) 500. * MeV (v55r7)
make_electron_cuts["mipchi2_min"] = 9. #9. (Now) 9./16. (v55r7 e/taue)
make_electron_cuts["mip_min"] = None #0.
make_electron_cuts["pid"] = (F.PID_E > 0.)
make_electron_cuts["make_particles"] = make_long_electrons_with_brem #does not require in calo
return make_electron_cuts
def make_b():
make_d0tokpi_cuts = get_charm_cuts()
make_electron_cuts= get_electron_cuts()
pvs = make_pvs()
with make_candidate.bind(p_min=15. * GeV):
dzs = make_d0_tokpi(**make_d0tokpi_cuts, name = CHARM_BUILDER_NAME)
electrons = make_candidate(**make_electron_cuts, name = "Electron_maker")
cut_vertex = F.require_all(F.CHI2DOF<9,F.BPVDIRA(pvs) >0.999,in_range(0 * MeV, F.MASS, 10000 * MeV))
rs_btodze = ParticleCombiner(
Inputs=[dzs, electrons],
name=f'rs_{B_BUILDER_NAME}_e',
DecayDescriptor='[B- -> D0 e-]cc',
CombinationCut=F.ALL,
CompositeCut=cut_vertex)
ws_btodze = ParticleCombiner(
Inputs=[dzs, electrons],
name=f'ws_{B_BUILDER_NAME}_e',
DecayDescriptor='[B+ -> D0 e+]cc',
CombinationCut=F.ALL,
CompositeCut=cut_vertex)
return ParticleContainersMerger([rs_btodze,ws_btodze])
@register_line_builder(slb_lines)
def hlt2_mybutod0enu_d0tokpi_line(name=HLT2LINE,prescale=1):
Bcands = make_b()
return Hlt2Line(name=name, prescale=prescale,persistreco=True, algs=sl_line_prefilter() + [Bcands])
def pass_through_line(name="Hlt2Passthrough"):
"""Return a HLT2 line that performs no selection but runs and persists the reconstruction
"""
return Hlt2Line(name=name, prescale=1, algs=[], persistreco=True)
from Hlt2Conf.lines.topological_b import *
def _make_lines():
ret = []
for line_dict in [slb_lines]:
for line_name, builder in line_dict.items() :
if "D0ToKPi" in line_name and "TauToPiPiPi" not in line_name and "Bc" not in line_name:
print(line_name)
ret.append(builder())
ret += [twobody_line(),threebody_line(),pass_through_line()]
return ret
def make_streams():
streams = [
Stream(lines=_make_lines(), routing_bit=98, detectors=DETECTORS)
]
return Streams(streams=streams)
public_tools = [
trackMasterExtrapolator_with_simplified_geom(),
stateProvider_with_simplified_geom(),
]
def main(options: Options):
# NOTE: the TBTC does not apply a chi2 cut because it is applied by the PrKF
with reconstruction.bind(from_file=False),\
hlt2_reconstruction.bind(make_reconstruction=make_light_reco_pr_kf_without_UT),\
require_gec.bind(skipUT=True),\
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.),\
get_default_hlt1_filter_code_for_hlt2.bind(code=r"Hlt1(?!PassthroughLargeEvent).*Decision"):
return run_moore(options, make_streams, public_tools=[])
from FunTuple import FunctorCollection
import Functors as F
def trail_seeker(MCTRUTH):
mcMatch = lambda decay_descriptor: (F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor)))
mcMatch_both = lambda decay_descriptor1,decay_descriptor2: (F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor1))+F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor2)))
variables = FunctorCollection({
'IS_Dtaunu':mcMatch_both("[B0 -> D*(2010)- tau+ nu_tau]CC","[B~0 -> D*(2010)- tau+ nu_tau]CC"),
'IS_Denu':mcMatch_both("[B0 -> D*(2010)- e+ nu_e]CC","[B~0 -> D*(2010)- e+ nu_e]CC"),
'IS_Dstar_2460enu':mcMatch_both("[B0 -> D*(2640)- e+ nu_e]CC","[B~0 -> D*(2640)- e+ nu_e]CC"),
'IS_D_2Senu':mcMatch_both("[B0 -> D(2S)- e+ nu_e]CC","[B~0 -> D(2S)- e+ nu_e]CC"),
'IS_Dstar_2460_2enu':mcMatch_both("[B0 -> D*_2(2460)- e+ nu_e]CC","[B~0 -> D*_2(2460)- e+ nu_e]CC"),
'IS_D_2460_1enu':mcMatch_both("[B0 -> D_1(2420)- e+ nu_e]CC","[B~0 -> D_1(2420)- e+ nu_e]CC"),
'IS_Dstar_0taunu':mcMatch_both("[B0 -> D*_0- tau+ nu_tau]CC","[B~0 -> D*_0- tau+ nu_tau]CC"),
'IS_D_H_1taunu':mcMatch_both("[B0 -> D_1(H)- tau+ nu_tau]CC","[B~0 -> D_1(H)- tau+ nu_tau]CC"),
'IS_D_2420_1taunu':mcMatch_both("[B0 -> D_1(2420)- tau+ nu_tau]CC","[B~0 -> D_1(2420)- tau+ nu_tau]CC"),
'IS_Dstar_2460_2taunu':mcMatch_both("[B0 -> D*_2(2460)- tau+ nu_tau]CC","[B~0 -> D*_2(2460)- tau+ nu_tau]CC"),
'IS_Dstar0_2640enu':mcMatch("[B- -> D*(2640)0 e- nu_e~]CC"),
'IS_D0_2Senu':mcMatch("[B- -> D(2S)0 e- nu_e~]CC"),
'IS_Dstar0_2460_2enu':mcMatch("[B- -> D*_2(2460)0 e- nu_e~]CC"),
'IS_D0_2460_1enu':mcMatch("[B- -> D_1(2420)0 e- nu_e~]CC"),
'IS_D0_H_1taunu':mcMatch("[B- -> D_1(H)0 tau- nu_tau~]CC"),
'IS_D0_2420_1taunu':mcMatch("[B- -> D_1(2420)0 tau- nu_tau~]CC"),
'IS_Dstar0_2460_2taunu':mcMatch("[B- -> D*_2(2460)0 tau- nu_tau~]CC"),
})
return(variables)
###############################################################################
# (c) Copyright 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. #
###############################################################################
#Example follows from hlt2_with_hlt1_decision.py
from Moore import Options,options, run_moore, config
from Hlt2Conf.lines.semileptonic.builders import sl_line_prefilter
from Moore.config import SpruceLine,register_line_builder
from .Hlt2 import make_b
from Moore.streams import DETECTORS, Stream, Streams
from PyConf.application import configure_input, configure, default_raw_event
from RecoConf.global_tools import stateProvider_with_simplified_geom
from RecoConf.reconstruction_objects import reconstruction
from PyConf.reading import reconstruction as reco_spruce, upfront_reconstruction as upfront_spruce
from RecoConf.decoders import default_ft_decoding_version
from Hlt2Conf.lines.semileptonic.spruce_semileptonic import spruce_butod0munu_d0tokpi_line,spruce_butod0taunu_d0tokpi_tautomununu_line
from Hlt2Conf.lines.semileptonic.HbToHcTauNu_TauToLNuNu import make_butod0taunu_d0tokpi_tautolnunu
from Hlt2Conf.lines.semileptonic.HbToHcLNu import make_butod0lnu_d0tokpi
from Moore.persistence.hlt2_tistos import list_of_full_stream_lines
from Hlt2Conf.lines.semileptonic import all_lines as slb_lines
from Hlt2Conf.lines.topological_b import all_lines as topo_lines
from Hlt2Conf.lines.semileptonic import sprucing_lines as slb_sprucing_lines
def lines_for_tistos():
"""
Nikole Comment :
This TISTOS part is only needed for exclusive Sprucing
and it saves the candidates of the FULL HLT2 lines that fired for each event.
You need to make sure its only FULL HLT2 lines in the lines_for_tistos
and they are the ones you care about ie. RD inclusive lines
"""
return [linename for line_dict in [slb_lines,topo_lines] for linename in line_dict.keys()]
@register_line_builder(slb_sprucing_lines)
def spruce_mybutod0enu_d0tokpi_line(name='SpruceSLB_myBuToD0ENu_D0ToKPi',prescale=1):
Bcands = make_b()
return SpruceLine(name=name, hlt2_filter_code=[
f"{name.replace('Spruce','Hlt2')}Decision",
"Hlt2Topo2BodyDecision", "Hlt2Topo3BodyDecision"]
,prescale=prescale,persistreco=True, algs=sl_line_prefilter() + [Bcands])
def make_full_streams():
lines = [builder() for builder in slb_sprucing_lines.values()]
streams = [Stream(lines=lines, detectors=[])]
return Streams(streams=streams)
def main(options: Options):
public_tools = [stateProvider_with_simplified_geom()]
with reconstruction.bind(from_file=True, spruce=True),\
reco_spruce.bind(simulation=True),\
upfront_spruce.bind(simulation=True),\
list_of_full_stream_lines.bind(lines=lines_for_tistos()):
return run_moore(options, make_full_streams, public_tools=public_tools)
defaults:
inform:
- ching-hua.li@cern.ch
wg: SL
{%- set evttype_lines_and_leptons = [
('12685400','SLB_BuToDststENu','bp_dstst_e'),
('12883000','SLB_BuToDststTauNu_TauToENuNu','bp_dstst_taue'),
] %}
{%- set polarity_variables = [
('MagDown','sim-20231017-vc-md100'),
('MagUp','sim-20231017-vc-mu100'),
]%}
{%- for polarity, cond_tag in polarity_variables %}
{%- for evttype, line, dk in evttype_lines_and_leptons %}
HLT1_{{dk}}_{{ polarity }}:
application: "Moore/v55r7@x86_64_v3-el9-gcc13+detdesc-opt+g"
#application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
input:
bk_query: "/MC/Dev/Beam6800GeV-expected-2024-{{polarity}}-Nu7.6-25ns-Pythia8/Sim10c/{{evttype}}/DIGI"
dq_flags:
- OK
n_test_lfns: 1
output: hlt1.dst
options:
entrypoint: SL_l_nu_D0toKpi_Run3_MC_data.Hlt1:main
extra_options:
input_raw_format: 0.3
conddb_tag: {{cond_tag}}
dddb_tag: dddb-20231017
input_type: ROOT
output_type: ROOT
simulation: True
data_type: "Upgrade"
scheduler_legacy_mode: False
compression:
algorithm: ZSTD
level: 1
max_buffer_size: 1048576
#evt_max: 1000
HLT2_{{dk}}_{{ polarity }}:
application: "Moore/v55r7p3@x86_64_v3-el9-gcc13+detdesc-opt+g"
#application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
input:
job_name: HLT1_{{dk}}_{{ polarity }}
output: hlt2.dst
options:
entrypoint: SL_l_nu_D0toKpi_Run3_MC_data.Hlt2:main
extra_options:
input_raw_format: 0.5
conddb_tag: {{cond_tag}}
dddb_tag: dddb-20231017
input_type: ROOT
output_type: ROOT
simulation: True
data_type: "Upgrade"
scheduler_legacy_mode: False
output_manifest_file: "HLT2.tck.json"
compression:
algorithm: ZSTD
level: 1
max_buffer_size: 1048576
#evt_max: 1000
SPRUCE_{{dk}}_{{ polarity }}:
application: "Moore/v55r7p3@x86_64_v3-el9-gcc13+detdesc-opt+g"
#application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
input:
job_name: HLT2_{{dk}}_{{ polarity }}
output: spruce.dst
options:
entrypoint: SL_l_nu_D0toKpi_Run3_MC_data.Spruce:main
extra_options:
input_raw_format: 0.5
conddb_tag: {{cond_tag}}
dddb_tag: dddb-20231017
input_type: ROOT
output_type: ROOT
simulation: True
data_type: "Upgrade"
scheduler_legacy_mode: False
input_process: "Hlt2"
input_manifest_file: "HLT2.tck.json"
output_manifest_file: "SPRUCE.tck.json"
compression:
algorithm: ZSTD
level: 1
max_buffer_size: 1048576
#evt_max: 1000
DV_{{dk}}_{{ polarity }}:
application: "DaVinci/v64r5@x86_64_v3-el9-gcc13+detdesc-opt+g"
input:
job_name: SPRUCE_{{dk}}_{{ polarity }}
output: NTuple.root
options:
entrypoint: SL_l_nu_D0toKpi_Run3_MC_data.DV:MC_{{line}}
extra_options:
input_raw_format: 0.5
conddb_tag: {{cond_tag}}
dddb_tag: dddb-20231017
input_type: ROOT
simulation: True
data_type: "Upgrade"
#geometry_version: run3/2024.Q1.2-v00.00
input_process: "Spruce"
input_manifest_file: "SPRUCE.tck.json"
#evt_max: 1000
{%- endfor %}
{%- endfor %}
###############################################################################
# (c) Copyright 2024 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 sys
from DaVinci import Options,make_config
from PyConf.reading import get_pvs, get_rec_summary, get_particles
from PyConf.Algorithms import ThOrParticleSelection
import Functors as F
from FunTuple import FunctorCollection
from FunTuple import FunTuple_Particles as Funtuple
from DaVinci.algorithms import create_lines_filter
import FunTuple.functorcollections as FC
from DaVinciMCTools import MCTruthAndBkgCat
from Hlt2Conf.standard_particles import make_has_rich_long_pions,make_has_rich_up_pions,make_has_rich_down_pions
from Hlt2Conf.algorithms_thor import ParticleCombiner, ParticleFilter
from Hlt2Conf.algorithms_thor import ParticleContainersMerger
from Functors.grammar import Functor
from Hlt2Conf.lines.semileptonic.isolationMVA import mva_functor_e_inclusive,mva_functor_mu_inclusive
_BPVCORRM = Functor('_BPVCORRM', 'Composite::CorrectedMass','Compute the corrected mass')
_allpv_FDVEC = (F.ENDVERTEX_POS @ F.FORWARDARG1 - F.TOLINALG @ F.POSITION @ F.FORWARDARG0)
_allpv_NORMEDDOT = F.NORMEDDOT.bind(F.THREEMOMENTUM @ F.FORWARDARG1, _allpv_FDVEC)
#ALLPV_CHI2 = lambda Vertices: F.MAP(F.CHI2) @ F.TES(Vertices)
#ALLPV_CHI2DOF = lambda Vertices: F.MAP(F.CHI2DOF) @ F.TES(Vertices)
ALLPV_IPCHI2 = lambda Vertices: F.MAP(F.IPCHI2).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_FDCHI2 = lambda Vertices: F.MAP(F.VTX_FDCHI2).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_DIRA = lambda Vertices: F.MAP(_allpv_NORMEDDOT).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_CORRM = lambda Vertices: F.MAP(_BPVCORRM).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_LTIME = lambda Vertices: F.MAP(F.VTX_LTIME).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_DLS = lambda Vertices: F.MAP(F.VTX_DLS).bind(F.TES(Vertices), F.FORWARDARGS)
ALLPV_FD_COORDINATE = lambda coordinate, Vertices: F.MAP(coordinate @ _allpv_FDVEC).bind(F.TES(Vertices), F.FORWARDARGS)
TRUE_ID_IS = lambda id, mctruth: (F.VALUE_OR(0) @ mctruth(F.ABS @ F.PARTICLE_ID) == id)
def make_Bst(B, pions):
hadron_cut = F.IS_ABS_ID('Lambda_c+') # Getting the hadron candidates
code_hadron = F.FILTER(hadron_cut) @ F.GET_CHILDREN()
hadron_TES = ThOrParticleSelection(
name="hadron_iso",
InputParticles=B,
Functor=code_hadron).OutputSelection
lepton_cut = F.IS_ABS_ID('mu-')
code_lepton = F.FILTER(lepton_cut) @ F.GET_CHILDREN()
lepton_TES = ThOrParticleSelection(
name="lepton_iso",
InputParticles=B,
Functor=code_lepton).OutputSelection
#combine to make [B*- -> Lambda_c+ mu-]cc
Bstm = ParticleCombiner(
Inputs=[hadron_TES, lepton_TES],
name=f'Bstm_mu',
DecayDescriptor='[B*- -> Lambda_c+ mu-]cc',
CombinationCut=F.ALL,
CompositeCut=F.ALL,
ParticleCombiner="ParticleVertexFitter",
)
cut_combination = F.require_all(F.MAXDOCA < 8.0, F.MAXDOCACHI2 < 20)
#combine to make [B*0 -> B*- pi+]cc
Bst_1 = ParticleCombiner(
Inputs=[Bstm, pions],
name='Bst_1',
DecayDescriptor='[B*0 -> B*- pi+]cc',
CombinationCut=cut_combination,
CompositeCut=F.ALL,
ParticleCombiner="ParticleVertexFitter", #for neutrals need to use different combiner e.g. ParticleAdder
#OutputLevel=1
)
#combine to make [B*0 -> B*- pi-]cc
Bst_2 = ParticleCombiner(
Inputs=[Bstm, pions],
name='Bst_2',
DecayDescriptor='[B*0 -> B*- pi-]cc',
CombinationCut=cut_combination,
CompositeCut=F.ALL,
ParticleCombiner="ParticleVertexFitter", #for neutrals need to use different combiner e.g. ParticleAdder
#OutputLevel=1
)
#merge the two Bst candidates
Bst = ParticleContainersMerger([Bst_1, Bst_2], name = 'Bst_combiner')
return Bst
def get_functors(v2_pvs, rec_summary):
#define common variables for all fields (composite and basic)
vars_common = FunctorCollection()
#all pvs: ip, ipchi2. The PV positions are stored in event variables
vars_common['ALLPV_IP[pv_indx]'] = F.ALLPV_IP(v2_pvs)
vars_common['ALLPV_IPCHI2[pv_indx]'] = ALLPV_IPCHI2(v2_pvs)
#best pv: x, y, z, ip, ipchi2
vars_common['BPV_X'] = F.BPVX(v2_pvs)
vars_common['BPV_Y'] = F.BPVY(v2_pvs)
vars_common['BPV_Z'] = F.BPVZ(v2_pvs)
vars_common['BPV_IP'] = F.BPVIP(v2_pvs)
vars_common['BPV_IPCHI2'] = F.BPVIPCHI2(v2_pvs)
vars_common['BPV_CHI2'] = F.CHI2 @ F.BPV(v2_pvs)
vars_common['BPV_CHI2DOF'] = F.CHI2DOF @ F.BPV(v2_pvs)
#particle id, key, truekey. The trueid is stored in MCHierarchy
vars_common['ID'] = F.PARTICLE_ID
vars_common['KEY'] = F.OBJECT_KEY
#get charge, min ip and min ipchi2
vars_common['CHARGE'] = F.CHARGE
vars_common['MINIP'] = F.MINIP(v2_pvs)
vars_common['MINIPCHI2'] = F.MINIPCHI2(v2_pvs)
#reco kinematics
vars_common += FC.Kinematics()
vars_common['ETA'] = F.ETA
vars_common['PHI'] = F.PHI
#variables for composite particles
vars_composite = FunctorCollection()
#end vertex position and end vertex chi2
vars_composite['ENDVERTEX_POS_'] = F.ENDVERTEX_POS
vars_composite['ENDVERTEX_CHI2'] = F.CHI2 @ F.ENDVERTEX
vars_composite['ENDVERTEX_CHI2DOF'] = F.CHI2DOF @ F.ENDVERTEX
#all pvs: dira, fd, fdchi2
vars_composite['ALLPV_DIRA[pv_indx]'] = ALLPV_DIRA(v2_pvs)
vars_composite['ALLPV_FD_X[pv_indx]'] = ALLPV_FD_COORDINATE(F.X_COORDINATE, v2_pvs)
vars_composite['ALLPV_FD_Y[pv_indx]'] = ALLPV_FD_COORDINATE(F.Y_COORDINATE, v2_pvs)
vars_composite['ALLPV_FD_Z[pv_indx]'] = ALLPV_FD_COORDINATE(F.Z_COORDINATE, v2_pvs)
vars_composite['ALLPV_FDCHI2[pv_indx]'] = ALLPV_FDCHI2(v2_pvs)
vars_composite['ALLPV_CORRM[pv_indx]'] = ALLPV_CORRM(v2_pvs)
vars_composite['ALLPV_LTIME[pv_indx]'] = ALLPV_LTIME(v2_pvs)
vars_composite['ALLPV_DLS[pv_indx]'] = ALLPV_DLS(v2_pvs)
#best pv: dira, fd, fdchi2, corrm, ltime, dls
vars_composite['BPV_DIRA'] = F.BPVDIRA(v2_pvs)
vars_composite['BPV_FD_'] = F.BPVFDVEC(v2_pvs)
vars_composite['BPV_FDCHI2'] = F.BPVFDCHI2(v2_pvs)
vars_composite['BPV_CORRM'] = F.BPVCORRM(v2_pvs)
vars_composite['BPV_LTIME'] = F.BPVLTIME(v2_pvs)
vars_composite['BPV_DLS'] = F.BPVDLS(v2_pvs)
#Compute maximum DOCA and maximum DOCACHI2. Since there are
# only two daughters of Sb particles, the maximum DOCA/DOCACHI2 is
# the DOCA/DOCACHI2 see below.
vars_composite['MAX_DOCA'] = F.MAXDOCA
vars_composite['MAX_DOCACHI2'] = F.MAXDOCACHI2
vars_composite['MAX_SDOCA'] = F.MAXSDOCA
vars_composite['MAX_SDOCACHI2'] = F.MAXSDOCACHI2
#variables for Lb field
var_B = FunctorCollection()
#variables for basics
vars_basic = FunctorCollection()
vars_basic['TRACKTYPE'] = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKTYPE @ F.TRACK
vars_basic['TRACKHISTORY'] = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKHISTORY @ F.TRACK
vars_basic['TRACKFLAG'] = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKFLAG @ F.TRACK
vars_basic['TRACKNDOF'] = F.VALUE_OR(-1) @ F.NDOF @ F.TRACK
vars_basic['TRACKCHI2'] = F.CHI2 @ F.TRACK
vars_basic['TRACKCHI2DOF'] = F.CHI2DOF @ F.TRACK
vars_basic['GHOSTPROB'] = F.GHOSTPROB
vars_basic['PIDpi'] = F.PID_PI
vars_basic['PIDk'] = F.PID_K
vars_basic['PIDp'] = F.PID_P
vars_basic['PIDe'] = F.PID_E
vars_basic['PIDmu'] = F.PID_MU
#variables for event
evt_vars = FunctorCollection()
#evt_vars['ALLPV_X[pv_indx]'] = F.ALLPVX(v2_pvs)
#evt_vars['ALLPV_Y[pv_indx]'] = F.ALLPVY(v2_pvs)
#evt_vars['ALLPV_Z[pv_indx]'] = F.ALLPVZ(v2_pvs)
#evt_vars['ALLPV_CHI2[pv_indx]'] = ALLPV_CHI2(v2_pvs)
#evt_vars['ALLPV_CHI2DOF[pv_indx]']= ALLPV_CHI2DOF(v2_pvs)
evt_vars['nTracks'] = F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nTracks")
evt_vars['nLongTracks'] = F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nLongTracks")
evt_vars['nPVs'] = F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nPVs")
evt_vars['nFTClusters'] = F.VALUE_OR(-1) @ F.RECSUMMARY_INFO(rec_summary, "nFTClusters")
#return all functors
functors = (vars_common, vars_composite, var_B, vars_basic, evt_vars)
return functors
def tuple_Bst(Bst, v2_pvs, rec_summary):
#get functors
functors = get_functors(v2_pvs, rec_summary)
vars_common = functors[0]
vars_composite = functors[1]
var_B = functors[2]
vars_basic = functors[3]
evt_vars = functors[4]
#variables for Sb field
vars_Bst = FunctorCollection()
B_child = F.CHILD(1, F.FORWARDARG0)
Epi_child = F.CHILD(2, F.FORWARDARG0)
bpv_pi = F.BPV(v2_pvs).bind(Epi_child)
#diff in vtx chi2 with and without extra particle
vars_Bst['DELTA_ENDVERTEX_CHI2'] = (F.CHI2 @ F.ENDVERTEX) - (F.CHI2 @ F.ENDVERTEX.bind(B_child))
#IP and IPChi2 of extra particle wrt to Sb end vertex
vars_Bst['Epi_IP_WRT_SbENDVERTEX'] = F.IP.bind(F.TOLINALG @ F.POSITION @ F.ENDVERTEX @ F.FORWARDARG0 , Epi_child)
vars_Bst['Epi_IPCHI2_WRT_SbENDVERTEX'] = F.IPCHI2.bind(F.ENDVERTEX @ F.FORWARDARG0 , Epi_child)
#IP and IPChi2 of extra particle wrt to Lb end vertex
vars_Bst['Epi_IP_WRT_LbENDVERTEX'] = F.IP.bind(F.TOLINALG @ F.POSITION @ F.ENDVERTEX @ B_child , Epi_child)
vars_Bst['Epi_IPCHI2_WRT_LbENDVERTEX'] = F.IPCHI2.bind(F.ENDVERTEX @ B_child , Epi_child)
#angle between extra particle and Lb
vars_Bst['Epi_COSANGLE_Lb'] = F.COSANGLE.bind(F.THREEMOMENTUM @ B_child, F.THREEMOMENTUM @ Epi_child)
#diff in fd chi2 with and without extra particle
vars_Bst['Delta_BPV_of_Epi_FDCHI2'] = F.VTX_FDCHI2.bind(bpv_pi, F.FORWARDARGS) - F.VTX_FDCHI2.bind(bpv_pi, B_child)
vars_Bst['BPV_of_Epi_FDCHI2'] = F.VTX_FDCHI2.bind(bpv_pi, F.FORWARDARGS)
#IP chi2 of extra particle wrt PV and SV of Sb
vars_Bst['Epi_IP_WRT_SbBPV'] = F.IP.bind(F.TOLINALG @ F.POSITION @ F.BPV(v2_pvs) @ F.FORWARDARG0, Epi_child)
vars_Bst['Epi_IPCHI2_WRT_SbBPV'] = F.IPCHI2.bind(F.BPV(v2_pvs) @ F.FORWARDARG0, Epi_child)
#IP chi2 of extra particle wrt PV and SV of Bb
vars_Bst['Epi_IP_WRT_LbBPV'] = F.IP.bind(F.TOLINALG @ F.POSITION @ F.BPV(v2_pvs) @ B_child, Epi_child)
vars_Bst['Epi_IPCHI2_WRT_LbBPV'] = F.IPCHI2.bind(F.BPV(v2_pvs) @ B_child, Epi_child)
#DOCA and DOCACHI2 b/w Lb and extra particle
vars_Bst['DOCA12'] = F.DOCA(1, 2)
vars_Bst['DOCA12_CHI2_12'] = F.DOCACHI2(1, 2)
#vars_Bst['SDOCA12'] = F.SDOCA(1, 2)
#vars_Bst['SDOCA_CHI2_12'] = F.SDOCACHI2(1, 2)
#DOCACHI2 of extra particle wrt to mother i.e. Sb
vars_Bst['MTDOCACHI2_1'] = F.MTDOCACHI2(1, v2_pvs)
vars_Bst['MTDOCACHI2_2'] = F.MTDOCACHI2(2, v2_pvs)
vars_Bst['iso_mva'] = mva_functor_mu_inclusive(v2_pvs)[0]
#define fields
fields_mu = {}
fields_mu['Sb'] = '[B*0 -> (B*- -> Lambda_c+ mu-) [pi+]CC]CC'
fields_mu['Lb'] = '[B*0 -> ^(B*- -> Lambda_c+ mu-) [pi+]CC]CC'
fields_mu['Lc'] = '[B*0 -> (B*- -> ^Lambda_c+ mu-) [pi+]CC]CC'
fields_mu['Lep'] = '[B*0 -> (B*- -> Lambda_c+ ^mu-) [pi+]CC]CC'
fields_mu['Epi'] = '[B*0 -> (B*- -> Lambda_c+ mu-) ^[pi+]CC]CC'
fields_mu['p'] = '[B*0 -> (B*- -> (Lambda_c+ -> ^p+ K- pi+) mu-) [pi+]CC]CC'
fields_mu['Km'] = '[B*0 -> (B*- -> (Lambda_c+ -> p+ ^K- pi+) mu-) [pi+]CC]CC'
fields_mu['pip'] = '[B*0 -> (B*- -> (Lambda_c+ -> p+ K- ^pi+) mu-) [pi+]CC]CC'
#add variables
variables = {}
variables["ALL"] = vars_common
variables["Sb"] = vars_composite + vars_Bst
variables["Lb"] = vars_composite + var_B
variables["Lc"] = vars_composite
variables["Lep"] = vars_basic
variables["Epi"] = vars_basic
variables["p"] = vars_basic
variables["Km"] = vars_basic
variables["pip"]= vars_basic
#define tuple
my_tuple = Funtuple(
name="Tuple",
tuple_name="DecayTree",
fields=fields_mu,
variables=variables,
event_variables=evt_vars,
inputs=Bst)
return my_tuple
def get_extra_pions():
"""
Note this function in DaVinci requires:
https://gitlab.cern.ch/lhcb/Moore/-/merge_requests/3203
and it's related LHCb, DaVinci and Rec MRs
"""
long_pions = make_has_rich_long_pions()
up_pions = make_has_rich_up_pions()
down_pions = make_has_rich_down_pions()
return ParticleContainersMerger([long_pions, up_pions, down_pions],
name='Pions_combiner')
def main(options: Options):
#define filer
my_filter = create_lines_filter(name="Filter", lines=['SpruceSLB_LbToLcMuNu_LcToPKPi'])
#get data and extra particles
lb = get_particles("/Event/Spruce/SpruceSLB_LbToLcMuNu_LcToPKPi/Particles")
extra_particles = get_extra_pions()
#get v2_pvs and rec_summary
v2_pvs = get_pvs()
rec_summary = get_rec_summary()
#make sb candidate
Bst = make_Bst(lb, extra_particles)
#MCTRUTH_Bst = MCTruthAndBkgCat(Bst, name='MCTRUTH_Bst')
tuple_file = tuple_Bst(Bst, v2_pvs, rec_summary)
#define algorithms
user_algorithms = {}
user_algorithms['Alg'] = [my_filter, tuple_file]
return make_config(options, user_algorithms)
defaults:
inform:
- ching-hua.li@cern.ch
wg: SL
data_lb_lc_mu:
application: "DaVinci/v64r5"
input:
bk_query: "/LHCb/Collision24/Beam6800GeV-VeloClosed-MagDown-Excl-UT/Real Data/Sprucing24c1/90000000/SL.DST"
dq_flags:
- UNCHECKED
- OK
keep_running: true
n_test_lfns: 1
output: DATA.ROOT
options:
entrypoint: lb_lc_mu_2024data.DV:main
extra_options:
input_raw_format: 0.5
input_type: ROOT # ROOT for SprucingPass, RAW for RAW data (Hlt2 output)
simulation: False
#data_type: "Upgrade"
geometry_version: run3/trunk
conditions_version: master
input_process: "Spruce" # Spruce for SprucingPass, "Hlt2" for RAW data (Hlt2 output)
input_stream: "sl" # for streamed data
#evt_max: 1000
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment