Skip to content
Snippets Groups Projects
Commit 438cfcf7 authored by Abhijit Mathad's avatar Abhijit Mathad Committed by Sebastien Ponce
Browse files

Test usage of F.CHILD with F.MAP_INPUT with DTF

parent a6db4baf
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!713Test usage of F.CHILD with F.MAP_INPUT with DTF
......@@ -24,7 +24,7 @@ from Gaudi.Configuration import INFO
from DaVinci import options
from DaVinci.algorithms import filter_on, add_filter
from DecayTreeFitter import DTFAlg
from FunTuple import FunctorCollection
from FunTuple import FunctorCollection as FC
from FunTuple import FunTuple_Particles as Funtuple
#fields for FunTuple
......@@ -42,19 +42,22 @@ data_filtered = filter_on(
DTF = DTFAlg(Input=data_filtered, MassConstraints=["D_s-"], OutputLevel=INFO)
DTFRelations = DTF.OutputRelations # Relations
#make a helper lambda function
DTF_func = lambda func: F.MAP_INPUT(Functor=func, Relations=DTFRelations)
#make collection of functors for all particles
variables_all = FunctorCollection({
variables_all = FC({
'THOR_P': F.P,
'THOR_PT': F.PT,
'THOR_MASS': F.MASS,
})
#make collection of functors for Ds meson
variables_ds = FunctorCollection({
'DTF_PT':
F.MAP_INPUT(Functor=F.PT, Relations=DTFRelations),
'DTF_MASS':
F.MAP_INPUT(Functor=F.MASS, Relations=DTFRelations),
variables_ds = FC({
'DTF_PT': DTF_func(F.PT),
'DTF_MASS': DTF_func(F.MASS),
'DTF_CHILD1_ID': DTF_func(F.CHILD(1, F.PARTICLE_ID)),
'DTF_CHILD1_MASS': DTF_func(F.CHILD(1, F.MASS)),
})
#associate FunctorCollection to field (branch) name
......
......@@ -12,7 +12,7 @@
Read an HLT2 file and create an ntuple with the new DaVinci configuration.
"""
import Functors as F
from FunTuple import FunctorCollection
from FunTuple import FunctorCollection as FC
from FunTuple import FunTuple_Particles as Funtuple
from PyConf.components import force_location
from DaVinci.reco_objects import make_pvs_v2
......@@ -33,7 +33,7 @@ fields = {
# Creating v2 reconstructed vertices to be used in the following functor
v2_pvs = make_pvs_v2(process=options.process)
d0_variables = FunctorCollection({
d0_variables = FC({
"ID": F.PARTICLE_ID,
"KEY": F.OBJECT_KEY,
"PT": F.PT,
......@@ -48,7 +48,7 @@ d0_variables = FunctorCollection({
"BPVIPCHI2": F.BPVIPCHI2(v2_pvs)
})
daughter_variables = FunctorCollection({
daughter_variables = FC({
"ID": F.PARTICLE_ID,
"PT": F.PT,
"PX": F.PX,
......@@ -76,38 +76,34 @@ def main():
#get configured "MCTruthAndBkgCatAlg" algorithm for HLT2 output
mctruth = configured_MCTruthAndBkgCatAlg(
inputs=d02kpi_data, process=options.process)
#add helper lambda that configures a functor to get truth information
MC_TRUTH = lambda func: F.MAP_INPUT(Functor=func, Relations=mctruth.MCAssocTable)
#Add true ID info to each of the fields (branches)
trueid_bkgcat_info = {
"TRUEID":
F.MAP_INPUT(Functor=F.PARTICLE_ID, Relations=mctruth.MCAssocTable),
"TRUEKEY":
F.MAP_INPUT(Functor=F.OBJECT_KEY, Relations=mctruth.MCAssocTable),
"TRUEPT":
F.MAP_INPUT(Functor=F.PT, Relations=mctruth.MCAssocTable),
"TRUEPX":
F.MAP_INPUT(Functor=F.PX, Relations=mctruth.MCAssocTable),
"TRUEPY":
F.MAP_INPUT(Functor=F.PY, Relations=mctruth.MCAssocTable),
"TRUEPZ":
F.MAP_INPUT(Functor=F.PZ, Relations=mctruth.MCAssocTable),
"TRUEENERGY":
F.MAP_INPUT(Functor=F.ENERGY, Relations=mctruth.MCAssocTable),
"TRUEP":
F.MAP_INPUT(Functor=F.P, Relations=mctruth.MCAssocTable),
"TRUEFOURMOMENTUM":
F.MAP_INPUT(Functor=F.FOURMOMENTUM, Relations=mctruth.MCAssocTable),
"BKGCAT":
F.BKGCAT(Relations=mctruth.BkgCatTable)
"TRUEID": MC_TRUTH(F.PARTICLE_ID),
"TRUEKEY": MC_TRUTH(F.OBJECT_KEY),
"TRUEPT": MC_TRUTH(F.PT),
"TRUEPX": MC_TRUTH(F.PX),
"TRUEPY": MC_TRUTH(F.PY),
"TRUEPZ": MC_TRUTH(F.PZ),
"TRUEENERGY": MC_TRUTH(F.ENERGY),
"TRUEP": MC_TRUTH(F.P),
"TRUEFOURMOMENTUM": MC_TRUTH(F.FOURMOMENTUM),
"BKGCAT": F.BKGCAT(Relations=mctruth.BkgCatTable)
}
for field in variables.keys():
variables[field] += FunctorCollection(trueid_bkgcat_info)
variables[field] += FC(trueid_bkgcat_info)
##doesn't work since no "decayProducts" method in MCParticle
#sort of related issue (https://gitlab.cern.ch/lhcb/Rec/-/issues/356)
#variables['D0'] += FC({'TRUEPT_Kaon': MC_TRUTH(F.CHILD(1, F.PT))})
#get ODIN and DecReports location
odin = get_odin(options)
hlt2_dec = get_decreports("Hlt2", options)
#define event level variables
evt_variables = FunctorCollection({
evt_variables = FC({
"RUNNUMBER": F.RUNNUMBER(odin),
"EVENTNUMBER": F.EVENTNUMBER(odin)
})
......
......@@ -9,7 +9,6 @@ NTupleSvc INFO Added stream file:DV-example-tupling
RootHistSvc INFO Writing ROOT histograms to: DV-example-tupling-DTF-his-filtered.root
HistogramPersistencySvc INFO Added successfully Conversion service:RootHistSvc
FSROutputStreamDstWriter INFO Data source: EventDataSvc output: SVC='Gaudi::RootCnvSvc'
EventClockSvc.FakeEventTime INFO Event times generated from 0 with steps of 0
ApplicationMgr INFO Application Manager Initialized successfully
DeFTDetector INFO Current FT geometry version = 63
ApplicationMgr INFO Application Manager Started successfully
......@@ -22,7 +21,7 @@ FSROutputStreamDstWriter INFO Set up File Summary Record
FSROutputStreamDstWriter INFO Events output: 1
B0DsK_Tuple SUCCESS Booked 1 N-Tuples and 0 Event Tag Collections
B0DsK_Tuple SUCCESS List of booked N-Tuples in directory "FILE1/B0DsK_Tuple"
B0DsK_Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=11 {B0_THOR_P,B0_THOR_PT,B0_THOR_MASS,Ds_DTF_PT,Ds_DTF_MASS,Ds_THOR_P,Ds_THOR_PT,Ds_T}
B0DsK_Tuple SUCCESS ID=DecayTree Title="DecayTree" #items=13 {B0_THOR_P,B0_THOR_PT,B0_THOR_MASS,Ds_DTF_PT,Ds_DTF_MASS,Ds_DTF_CHILD1_ID,Ds_DTF_C}
LAZY_AND: DaVinci #=10 Sum=8 Eff=|( 80.00000 +- 12.6491 )%|
NONLAZY_OR: FileSummaryRecords #=10 Sum=10 Eff=|( 100.0000 +- 0.00000 )%|
LAZY_AND: GenFSR #=10 Sum=10 Eff=|( 100.0000 +- 0.00000 )%|
......
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