Skip to content
Snippets Groups Projects
Commit d5932306 authored by Patrick Koppenburg's avatar Patrick Koppenburg :leaves:
Browse files

Merge branch 'update_tuple_algo' into 'master'

Update tupling example including LoKi and now ThOr functors

See merge request lhcb/DaVinci!539
parents 4306d9a2 476b242b
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!539Update tupling example including LoKi and now ThOr functors
Pipeline #2632771 passed
......@@ -18,11 +18,13 @@ Example of a typical DaVinci job:
__author__ = "Maurizio Martinelli"
__date__ = "2021-03-16"
from PyConf.Algorithms import PrintDecayTree
from PyConf.Algorithms import FunTuple_Particles as FunTuple
from DaVinci import options, run_davinci, DVNode, DVHelper
from DaVinci.standard_particles import make_detached_mumu
from DaVinci import options, run_davinci, DVNode, DVHelper
from DaVinci.reco_objects import upfront_reconstruction_from_file as upfront_reconstruction
import Functors as F
from FunTuple import ParticleTupleProp, convert_to_parsable_objs
from PyConf.Algorithms import PrintDecayTree
from PyConf.Algorithms import FunTuple_Particles as FunTuple
# print control flow and data flow graphs
options.control_flow_file = 'control_flow.gv'
......@@ -42,29 +44,52 @@ print(options)
# Prepare the node with the selection
dimuons = make_detached_mumu()
# Prepare the node with the user algorithms
pdt = PrintDecayTree(name="PrintDimuons", Input=dimuons)
# Add a FUNTuple
decay_descriptors = [
'[J/psi(1S) -> mu+ mu-]CC', '[J/psi(1S) -> ^mu+ mu-]CC',
'[J/psi(1S) -> mu+ ^mu-]CC'
]
branch_names = ['Jpsi', 'MuPlus', 'MuMinus']
#for Jpsi store p, pt and mu+ store p and mu- store pt
functors = [['P', 'PT'], ['P'], ['PT']]
functor_branch_names = [['P', 'PT'], ['P'], ['PT']]
#FunTuple: define list of preambles for loki
loki_preamble = ['TRACK_MAX_PT = MAXTREE(ISBASIC & HASTRACK, PT, -1)']
#FunTuple: Jpsi info
ParticleJpsi = ParticleTupleProp(
branch_name_prefix="Jpsi",
decay_descriptor="J/psi(1S) -> mu+ mu-",
#Dict -> {name:functor}
particle_code_loki={
'LOKI_P': 'P',
'LOKI_PT': 'PT',
'LOKI_Muonp_PT': 'CHILD(PT, 1)',
'LOKI_Muonm_PT': 'CHILD(PT, 2)',
'LOKI_MAXPT': 'TRACK_MAX_PT',
'LOKI_N_HIHGPT_TRCKS': 'NINTREE(ISBASIC & HASTRACK & (PT > 1500*MeV))'
},
particle_code_thor={
'THOR_P': F.P,
'THOR_PT': F.PT
})
#FunTuple: Mu plus info: Can also muon and make a seperate ParticleTupleProp object
ParticleMuPlus = ParticleTupleProp(
branch_name_prefix="MuPlus",
decay_descriptor="J/psi(1S) -> ^mu+ mu-",
particle_code_loki={'LOKI_P': 'P'},
particle_code_thor={'THOR_P': F.P})
#FunTuple: Do not need to do this if a custom gaudi property for ParticleTupleProp is implemented
parsable_objs = convert_to_parsable_objs([ParticleJpsi, ParticleMuPlus])
#FunTuple: Configure FunTuple algorithm
ftup = FunTuple(
name="DimuonsTuple",
tree_name="DecayTree",
decay_descriptors=decay_descriptors,
branch_names=branch_names,
functors=functors,
functor_branch_names=functor_branch_names,
branch_names_prefix=parsable_objs[0],
decay_descriptors=parsable_objs[1],
loki_functors=parsable_objs[2][0],
loki_functor_branch_names=parsable_objs[2][1],
thor_functors=parsable_objs[3][0],
thor_functor_branch_names=parsable_objs[3][1],
loki_preamble=loki_preamble,
input_location=dimuons)
dvh = DVHelper()
dvh.add_selections_node("Selection1", upfront_reconstruction() + [dimuons])
dvh.add_user_node('User1', [pdt])
dvh.add_tuples_node('Tuple1', [ftup])
dvh.run(options)
......@@ -18,16 +18,53 @@
</set></argument>
<argument name="validator"><text>
findReferenceBlock("""
PrintDimuons.PrintDecayTreeTool INFO Name E M P Pt phi Vz P(C/K) PP(C/K)
PrintDimuons.PrintDecayTreeTool INFO MeV MeV MeV MeV mrad mm
PrintDimuons.PrintDecayTreeTool INFO J/psi(1S) 30155.22 4062.62 29880.30 3993.47 -3007.05 45.68 0/0 N/A
PrintDimuons.PrintDecayTreeTool INFO +-->mu+ 12777.17 105.66 12776.73 3572.06 -2747.17 45.41 1/99 2/99
PrintDimuons.PrintDecayTreeTool INFO +-->mu- 17377.81 105.66 17377.49 1065.10 2238.10 43.82 1/54 2/54
PrintDimuons.PrintDecayTreeTool INFO
PrintDimuons.PrintDecayTreeTool INFO Used TES locations :-
PrintDimuons.PrintDecayTreeTool INFO 0 = '/Event/CombineParticles/Particles'
PrintDimuons.PrintDecayTreeTool INFO 1 = '/Event/FunctionalParticleMaker/Particles'
PrintDimuons.PrintDecayTreeTool INFO 2 = '/Event/Rec/ProtoP/Charged'
RFileCnv INFO dumping contents of /NTUPLES/FILE1
TFile: name=DV-example-tupling-basic-ntp.root, title=Gaudi Trees, option=CREATE
******************************************************************************
*Tree :DecayTree : DecayTree *
*Entries : 3 : Total = 6907 bytes File Size = 2072 *
* : : Tree compression factor = 1.00 *
******************************************************************************
*Br 0 :Jpsi_LOKI_N_HIHGPT_TRCKS : Jpsi_LOKI_N_HIHGPT_TRCKS/D *
*Entries : 3 : Total Size= 697 bytes File Size = 120 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 1 :Jpsi_LOKI_PT : Jpsi_LOKI_PT/D *
*Entries : 3 : Total Size= 637 bytes File Size = 108 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 2 :Jpsi_LOKI_MAXPT : Jpsi_LOKI_MAXPT/D *
*Entries : 3 : Total Size= 652 bytes File Size = 111 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 3 :Jpsi_LOKI_Muonp_PT : Jpsi_LOKI_Muonp_PT/D *
*Entries : 3 : Total Size= 667 bytes File Size = 114 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 4 :Jpsi_LOKI_Muonm_PT : Jpsi_LOKI_Muonm_PT/D *
*Entries : 3 : Total Size= 667 bytes File Size = 114 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 5 :Jpsi_LOKI_P : Jpsi_LOKI_P/D *
*Entries : 3 : Total Size= 632 bytes File Size = 107 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 6 :Jpsi_THOR_P : Jpsi_THOR_P/D *
*Entries : 3 : Total Size= 632 bytes File Size = 107 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 7 :Jpsi_THOR_PT : Jpsi_THOR_PT/D *
*Entries : 3 : Total Size= 637 bytes File Size = 108 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 8 :MuPlus_LOKI_P : MuPlus_LOKI_P/D *
*Entries : 3 : Total Size= 642 bytes File Size = 109 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
*Br 9 :MuPlus_THOR_P : MuPlus_THOR_P/D *
*Entries : 3 : Total Size= 642 bytes File Size = 109 *
*Baskets : 1 : Basket Size= 32000 bytes Compression= 1.00 *
*............................................................................*
""", stdout, result, causes, signature_offset = 0)
countErrorLines({"FATAL":0, "ERROR":0})
......@@ -46,7 +83,7 @@ try:
except IOError as err:
raise IOError('Impossible to open file: ', err)
except:
print('Unexpected error while opening file: ', sys.exc_info()[0])
raise Exception('Unexpected error while opening file: ')
<argument name="exit_code"><integer>1</integer></argument>
</text></argument>
</extension>
</extension>
\ No newline at end of file
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