Skip to content
Snippets Groups Projects
Commit 49d3e4dc authored by Tommaso Fulghesu's avatar Tommaso Fulghesu Committed by Eduardo Rodrigues
Browse files

Adding example for track isolation variables

parent 444e3431
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!665Adding example for track isolation variables
###############################################################################
# (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. #
###############################################################################
input_files:
- root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/B2JpsiK_spruce.dst
annsvc_config: root://eoslhcb.cern.ch//eos/lhcb/wg/dpa/wp3/tests/B2JpsiK_spruce.tck.json
input_type: ROOT
evt_max: 100
ntuple_file: davinci_ntuple_ft.root
print_freq: 1
data_type: Upgrade
simulation: true
conddb_tag: sim-20201218-vc-md100
dddb_tag: dddb-20201211
......@@ -12,6 +12,7 @@
Read an HLT2 file and create an ntuple using pre-defined Functor collections.
"""
import Functors as F
from PyConf.components import force_location
from FunTuple import FunctorCollection, functorcollections
from FunTuple import FunTuple_Particles as Funtuple
......@@ -19,6 +20,8 @@ from DaVinci.algorithms import add_filter
from DaVinci import make_config
from DaVinci.truth_matching import configured_MCTruthAndBkgCatAlg
from DaVinci.algorithms import get_odin, get_decreports
from PyConf.Algorithms import WeightedRelTableAlg
from Gaudi.Configuration import INFO
def main(options):
......@@ -29,6 +32,13 @@ def main(options):
mctruth = configured_MCTruthAndBkgCatAlg(
inputs=d02kpi_data, process=options.process)
#configure "WeightedRelTableAlg" algorithm for HLT2 output
iso_rel_table = WeightedRelTableAlg(
ReferenceParticles=d02kpi_data,
InputCandidates=d02kpi_data,
Cut=(F.DR2() < 0.4),
OutputLevel=INFO)
#get location to odin
odin = get_odin(options)
......@@ -40,7 +50,8 @@ def main(options):
functorcollections.Kinematics(),
functorcollections.MCHierarchy(mctruth),
functorcollections.MCKinematics(mctruth),
functorcollections.MCVertexInfo(mctruth)
functorcollections.MCVertexInfo(mctruth),
functorcollections.TrackIsolation(iso_rel_table)
]
evt_collections = [
......
###############################################################################
# (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. #
###############################################################################
"""
Option file for testing the ParticleWeightedAlg algorithm.
The job runs over a spruced sample and retrieves a set of B0 -> J/psi K candidates. For each candidate the algorithm
looks at the TES location which contains the tagged particles and creates a 'one-to-many' relation map
relating all the available tracks to the B candidate of the events.
Important: Setting DVPATH properly.
To run the example: $DVPATH/run lbexec option_davinci_tupling_weightedrelation_trackvariables:main $DVPATH/DaVinciExamples/example_data/spruce_b2jpsik_opt.yaml
"""
import Functors as F
from PyConf.components import force_location
from PyConf.Algorithms import WeightedRelTableAlg
from FunTuple import FunctorCollection, FunTuple_Particles as Funtuple
from FunTuple.functorcollections import TrackIsolation
from DaVinci.reco_objects import make_pvs_v2
from DaVinci.algorithms import add_filter, unpack_locations
from DaVinci import make_config
b2jpsik_data = force_location("/Event/HLT2/Hlt2B2JpsiKLine/Particles")
branches = {
'B': "[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"
}
def main(options):
# Hack used to unpack the tagged data for now
# follows discussion on Mattermost channel DPA WP3 Offline Analysis
# [https://mattermost.web.cern.ch/lhcb/pl/p6tbr8inetf99jgin5ihce63ic]
unpackers = unpack_locations(options, False)
tagged_data = None
for alg in unpackers:
if "OutputName" in alg.outputs.keys():
if (alg.OutputName.location ==
"/Event/HLT2/Hlt2B2JpsiKLine/LongTaggingParticles/Particles"
):
tagged_data = alg.OutputName
pvs = make_pvs_v2(process=options.process)
ftAlg = WeightedRelTableAlg(
ReferenceParticles=b2jpsik_data,
InputCandidates=tagged_data,
Cut=F.SHARE_BPV(pvs))
ftAlg_Rels = ftAlg.OutputRelations
#Set the variables
extra_variables = FunctorCollection({
'THOR_MASS':
F.MASS,
"First_P":
F.MAP_INPUT(Functor=F.P, Relations=ftAlg_Rels),
"First_PT":
F.MAP_INPUT(Functor=F.PT, Relations=ftAlg_Rels),
"Sum_P":
F.SUMCONE(Functor=F.P, Relations=ftAlg_Rels),
"Sum_PT":
F.SUMCONE(Functor=F.PT, Relations=ftAlg_Rels),
"Max_P":
F.MAXCONE(Functor=F.P, Relations=ftAlg_Rels),
"Max_PT":
F.MAXCONE(Functor=F.PT, Relations=ftAlg_Rels),
"Min_P":
F.MINCONE(Functor=F.P, Relations=ftAlg_Rels),
"Min_PT":
F.MINCONE(Functor=F.PT, Relations=ftAlg_Rels),
"Asym_P":
F.ASYM(Functor=F.P, Relations=ftAlg_Rels),
"Asym_PT":
F.ASYM(Functor=F.PT, Relations=ftAlg_Rels),
"Num_tracks":
F.VALUE_OR(0) @ F.NINCONE(Relations=ftAlg_Rels),
})
variables_all = FunctorCollection({'THOR_P': F.P, 'THOR_PT': F.PT})
track_iso_variables = TrackIsolation(ftAlg)
variables_jpsik = {
'B': variables_all + extra_variables,
'Jpsi': variables_all,
'Kp': variables_all + track_iso_variables,
}
my_filter = add_filter(options, "HDRFilter_B2JpsiK",
"HLT_PASS('Hlt2B2JpsiKLineDecision')")
my_tuple = Funtuple(
name="Tuple",
tuple_name="DecayTree",
fields=branches,
variables=variables_jpsik,
inputs=b2jpsik_data)
return make_config(options, [my_filter, my_tuple])
<?xml version="1.0" ?>
<!--
###############################################################################
# (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. #
###############################################################################
-->
<!DOCTYPE extension PUBLIC '-//QM/2.3/Extension//EN' 'http://www.codesourcery.com/qm/dtds/2.3/-//qm/2.3/extension//en.dtd'>
<extension class="GaudiTest.GaudiExeTest" kind="test">
<argument name="program"><text>lbexec</text></argument>
<argument name="args"><set>
<text>DaVinciExamples.tupling.option_davinci_tupling_weightedrelation_trackvariables:main</text>
</set></argument>
<argument name="options_yaml_fn"><text>$DAVINCIEXAMPLESROOT/example_data/spruce_b2jpsik_opt.yaml</text></argument>
<argument name="extra_options_yaml"><text>
input_type: ROOT
evt_max: 100
ntuple_file: davinci_ntuple_ft.root
print_freq: 1
data_type: Upgrade
simulation: true
</text></argument>
<argument name="timeout"><integer>3600</integer></argument>
<argument name="reference"><text>$DAVINCIEXAMPLESROOT/tests/refs/test_davinci_tupling_weightedrelation_trackvariables.ref</text></argument>
<argument name="validator"><text>
findReferenceBlock("""Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=32 {B_THOR_P,B_THOR_PT,B_THOR_MASS,B_First_P,B_First_PT,B_Sum_P,B_Sum_PT,B_Max_P,B_Ma}""")
countErrorLines({"FATAL":0, "ERROR":0})
</text></argument>
</extension>
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