diff --git a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2_with_matching.py b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2_with_matching.py index 9426dd9d28f853c3740ee1f8910682bc6571b873..2bd875549f6bf04b85db0c4b9f0ad5c8c75bbdec 100644 --- a/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2_with_matching.py +++ b/DaVinciExamples/python/DaVinciExamples/tupling/option_davinci_tupling_from_hlt2_with_matching.py @@ -9,12 +9,12 @@ # or submit itself to any jurisdiction. # ############################################################################### """ -Read an HLT2 file and create an ntuple, containing a matching between +Read an HLT2 file and create an ntuple, containing a matching between particles in the line and persistreco particles based on the VELO IDs. rst_title: Matching example on data -rst_description: This example shows how to read an HLT2 file and create an ntuple, -containing a matching between particles in the line and persistreco +rst_description: This example shows how to read an HLT2 file and create an ntuple, +containing a matching between particles in the line and persistreco particles based on the VELO IDs. rst_running: lb-run DaVinci/vXXrY lbexec DaVinciExamples.tupling.option_davinci_tupling_from_hlt2_with_matching:main $DAVINCIEXAMPLESROOT/example_data/Run255620.yaml @@ -32,7 +32,8 @@ from DaVinci import Options, make_config from PyConf.Algorithms import FlattenDecayTree, VeloIDOverlapRelationTable from Hlt2Conf.algorithms_thor import ParticleFilter -from Hlt2Conf.standard_particles import (make_long_electrons_with_brem) +from Hlt2Conf.standard_particles import make_long_electrons_with_brem +from GaudiKernel.SystemOfUnits import MeV from RecoConf.reconstruction_objects import reconstruction @@ -93,7 +94,18 @@ def main(options: Options): long_electrons = make_long_electrons_with_brem() relation_table_match_by_veloid = VeloIDOverlapRelationTable( - MatchFrom=basic_particles_dz_to_kpi, MatchTo=long_electrons) + MatchFrom=basic_particles_dz_to_kpi, + MatchTo=long_electrons).OutputRelations + + # make electrons with some cuts + with reconstruction.bind(from_file=True, spruce=True): + long_electrons_tight_cuts = ParticleFilter( + Input=make_long_electrons_with_brem(), + Cut=F.FILTER(F.require_all(F.PT > 500. * MeV, F.PID_E > 1.))) + # make a test relation table + relation_table_match_by_veloid_tight_cuts = VeloIDOverlapRelationTable( + MatchFrom=basic_particles_dz_to_kpi, + MatchTo=long_electrons_tight_cuts).OutputRelations my_filter = create_lines_filter( name="HDRFilter_D0Kpi", lines=[f"{line_name}"]) @@ -101,10 +113,16 @@ def main(options: Options): variables["piplus"] += FunctorCollection({ 'Matched_to_Electron_P[nMatchTracks]': F.MAP_INPUT_ARRAY( - Functor=F.P, - Relations=relation_table_match_by_veloid.OutputRelations), + Functor=F.P, Relations=relation_table_match_by_veloid), "Matched_to_Electron_Weight[nMatchTracks]": - F.MAP_WEIGHT(Relations=relation_table_match_by_veloid.OutputRelations) + F.MAP_WEIGHT(Relations=relation_table_match_by_veloid), + 'Matched_to_Electron_P_tight_cuts[nMatchTracks_tight_cuts]': + F.MAP_INPUT_ARRAY( + Functor=F.P, Relations=relation_table_match_by_veloid_tight_cuts), + 'Matched_to_Electron_ID_tight_cuts[nMatchTracks_tight_cuts]': + F.MAP_INPUT_ARRAY( + Functor=F.PARTICLE_ID, + Relations=relation_table_match_by_veloid_tight_cuts), }) evt_variables = FC.SelectionInfo( diff --git a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_hlt2_with_matching.qmt b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_hlt2_with_matching.qmt index 7d5c59bcc4bc4be2ddc1f5d072db3d0dd3f78d11..fc62fca25b571dc9c603ae82eb0b530ee67ca663 100644 --- a/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_hlt2_with_matching.qmt +++ b/DaVinciExamples/tests/qmtest/tupling.qms/test_davinci_tupling_from_hlt2_with_matching.qmt @@ -47,9 +47,12 @@ for branch_to_look_for in expected_branches_matching: raise Exception(f'Match branch {branch_to_look_for} not found in produced nTuple file.') input_tree.GetEntry(1) -if not (input_tree.piplus_Matched_to_Electron_P[0] > 0) or (input_tree.piplus_Matched_to_Electron_P[0] > 500000): +if not (input_tree.piplus_Matched_to_Electron_P[0] > 0) or (input_tree.piplus_Matched_to_Electron_P[0] > 500000): causes.append('Matched momentum value does not make sense.') +if not (input_tree.nMatchTracks_tight_cuts == 0): + causes.append('The nMatchTracks_tight_cuts is not zero. Please check!') + input_file.Close() </text></argument>