diff --git a/DaVinciTests/tests/options/dtfdict.py b/DaVinciTests/tests/options/dtfdict.py new file mode 100644 index 0000000000000000000000000000000000000000..30c14a49dfb18b7908a09a20340be9bc19c66851 --- /dev/null +++ b/DaVinciTests/tests/options/dtfdict.py @@ -0,0 +1,103 @@ +#!/usr/bin/env python + +""" +Test of the DFTDict module +""" + +__author__ = "Alessio PIUCCI alessio.piucci@cern.ch" + +from Configurables import DaVinci + +from DecayTreeTuple.Configuration import * + +from Configurables import FilterDesktop + +from PhysSelPython.Wrappers import Selection +from PhysSelPython.Wrappers import SelectionSequence +from PhysSelPython.Wrappers import DataOnDemand + +from Configurables import TupleToolDecayTreeFitter, TupleToolDecay, TupleToolKinematic +from Configurables import LoKi__Hybrid__DictOfFunctors, LoKi__Hybrid__Dict2Tuple +from Configurables import LoKi__Hybrid__DTFDict as DTFDict + +def get_selection_sequence(name): + """Get the selection from stripping stream""" + + alg = FilterDesktop('SelFilterFor{}B2D'.format(name)) + alg.Code = 'ALL' + reqSels = [DataOnDemand(Location = 'Phys/Lb2LcDD2HHHPIDBeauty2CharmLine/Particles')] + sel = Selection('Sel' + name, Algorithm=alg, RequiredSelections=reqSels) + + return SelectionSequence('SelSeq' + name, TopSelection=sel) + +#################### + +# some options +DaVinci().Simulation = False +DaVinci().Lumi = True +DaVinci().DataType = '2012' + +#for MDST +DaVinci(RootInTES = '/Event/Bhadron', InputType = 'MDST') + +DaVinci().EvtMax = 1000 +DaVinci().TupleFile = 'test_DFTDict.root' + +# define the sequence +seq = GaudiSequencer('MyLb2LcDsDTTupleSeq') + +sel = get_selection_sequence('Lb2LcDs') +seq.Members += [sel.sequence()] +tuple_input = sel.outputLocation() + +print "sequence test: passed" + +# make a tuple +tpl = DecayTreeTuple('Lb2LcDsDTTuple') +tpl.Inputs = [tuple_input] + +tpl.ToolList = ['TupleToolKinematic'] +tpl.Decay = '[Lambda_b0 -> ^(Lambda_c+ -> ^p+ ^K- ^pi+) ^(D- -> ^K+ ^K- ^pi-)]CC' + +# add a branch +tpl.addBranches({"Lb" : "[Lambda_b0 -> Lambda_c+ D-]CC"}) + +tpl.Lb.ToolList = ["TupleToolDecayTreeFitter/Cons"] # fit with mass constraint +tpl.Lb.addTool(TupleToolDecayTreeFitter("Cons")) + +DictTuple = tpl.Lb.addTupleTool(LoKi__Hybrid__Dict2Tuple, "DTFTuple") + +DictTuple.addTool(DTFDict, "Cons") +DictTuple.Source = "LoKi::Hybrid::DTFDict/Cons" +DictTuple.NumVar = 100 + +DictTuple.Cons.constrainToOriginVertex = True +DictTuple.Cons.daughtersToConstrain = ["Lambda_c+","D_s-"] + +DictTuple.Cons.Substitutions = { + 'Lambda_b0 -> Lambda_c+ ^D-' : 'D_s-', + 'Lambda_b~0 -> Lambda_c~- ^D+' : 'D_s+', + } + +print "LoKi__Hybrid__Dict2Tuple test: passed" + +# Add LoKiFunctors to the tool chain, +# these functors will be applied to the refitted decay tree +# they act as a source to the DTFDict +DictTuple.Cons.addTool(LoKi__Hybrid__DictOfFunctors,"dict") +DictTuple.Cons.Source = "LoKi::Hybrid::DictOfFunctors/dict" + +DictTuple.Cons.dict.Variables = { + "Cons_PE" : "E", + "Cons_PX" : "PX", + "Cons_PY" : "PY", + "Cons_PZ" : "PZ", + } + +print "LoKi__Hybrid__DictOfFunctors test: passed" + +# add the tuple to the main sequence +seq.Members += [tpl] + +DaVinci().appendToMainSequence([seq]) + diff --git a/DaVinciTests/tests/qmtest/davincitests.qms b/DaVinciTests/tests/qmtest/davincitests.qms index 71d4970f19eb348843d93f14faac1d295f0b3337..731c2120e3dd8c5b5c88a9002f06e9d1be5499a9 100644 --- a/DaVinciTests/tests/qmtest/davincitests.qms +++ b/DaVinciTests/tests/qmtest/davincitests.qms @@ -11,5 +11,6 @@ <text>fsrs</text> <text>io</text> <text>kali</text> + <text>dtfdict</text> </set></argument> </extension> diff --git a/DaVinciTests/tests/qmtest/dtfdict.qms/test_dtfdict.qmt b/DaVinciTests/tests/qmtest/dtfdict.qms/test_dtfdict.qmt new file mode 100644 index 0000000000000000000000000000000000000000..479b533617a6da4521711da56dbed49c16f75b68 --- /dev/null +++ b/DaVinciTests/tests/qmtest/dtfdict.qms/test_dtfdict.qmt @@ -0,0 +1,10 @@ +<?xml version="1.0" ?> +<!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>gaudirun.py</text></argument> + <argument name="args"><set> + <text>../options/dtfdict.py</text> + <text>--option</text> + <text>from PRConfig import TestFileDB; from Configurables import DaVinci; TestFileDB.test_file_db['R14S20-bhadron.mdst'].run(configurable=DaVinci())</text> + </set></argument> +</extension>