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

Remove DecayTreeTuple

parent c16c7c4f
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!554Remove DecayTreeTuple
#!/usr/bin/env python
###############################################################################
# (c) Copyright 2000-2021 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. #
###############################################################################
"""
Test of the DFTDict module
"""
from __future__ import print_function
__author__ = "Davide Fazzini davide.fazzini@cern.ch"
from Configurables import GaudiSequencer
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
from Configurables import LoKi__Hybrid__DictOfFunctors, LoKi__Hybrid__Dict2Tuple
from Configurables import LoKi__Hybrid__DTFDict as DTFDict
from Configurables import CondDB
def get_selection_sequence(name):
"""Get the selection from stripping stream"""
alg = FilterDesktop('SelFilterFor{}B2D'.format(name))
alg.Code = 'ALL'
reqSels = [
DataOnDemand(Location='/Phys/BetaSBd2JpsiKstarDetachedLine/Particles')
]
sel = Selection('Sel' + name, Algorithm=alg, RequiredSelections=reqSels)
return SelectionSequence('SelSeq' + name, TopSelection=sel)
####################
# some options
DaVinci().EvtMax = -1 # Number of events
DaVinci().PrintFreq = 10 # Events to skip
DaVinci().DataType = "Upgrade" # Must be given
DaVinci().Simulation = True
DaVinci().InputType = 'LDST'
DaVinci().Lumi = False
CondDB().Upgrade = True
DaVinci().CondDBtag = "sim-20171127-vc-md100"
DaVinci().DDDBtag = "dddb-20171126"
#for MDST
DaVinci(StrippingStream='AllStreams', InputType='LDST')
DaVinci().EvtMax = 1000
DaVinci().TupleFile = 'test_DFTDict.root'
# define the sequence
seq = GaudiSequencer('MyBd2KstMuMuDTTupleSeq')
sel = get_selection_sequence('Bd2JpsiKstarSel')
seq.Members += [sel.sequence()]
tuple_input = sel.outputLocation()
print("sequence test: passed")
# make a tuple
tpl = DecayTreeTuple("Bd2JpsiKstar")
tpl.Inputs = [tuple_input]
tpl.ToolList = ['TupleToolKinematic']
tpl.Decay = "[B0 -> ^(J/psi(1S) -> ^mu+ ^mu-) ^(K*(892)0 -> ^K+ ^pi-)]CC"
# add a branch
tpl.addBranches({"B0": "[B0 -> J/psi(1S) K*(892)0]CC"})
tpl.B0.ToolList = ["TupleToolDecayTreeFitter/Cons"] # fit with mass constraint
tpl.B0.addTool(TupleToolDecayTreeFitter("Cons"))
DictTuple = tpl.B0.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 = ["J/psi(1S)", "K*(892)0"]
DictTuple.Cons.Substitutions = {
'J/psi(1S) -> ^mu+ mu-': 'e+',
'J/psi(1S) -> mu+ ^mu-': 'e-',
}
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])
<?xml version="1.0" ?>
<!--
(c) Copyright 2000-2021 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>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['Upgrade_Bd2KstarMuMu'].run(configurable=DaVinci())</text>
</set></argument>
<argument name="validator"><text>
countErrorLines({"FATAL":0, "ERROR":0})
</text></argument>
</extension>
###############################################################################
# (c) Copyright 2000-2020 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. #
# #
###############################################################################
#
# Simple DaVinci example job running on K*mumu data and filling an nTuple
#
# syntax
# ./run gaudirun.py DaVinci-Example.py options/DaVinciTestData.py
#
# @author P. Koppenburg based on previous versions
#
##
from Gaudi.Configuration import MessageSvc
from Gaudi.Configuration import INFO
from Configurables import DaVinci, CombineParticles
from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence
# from StandardParticles import StdLooseMuons
from Configurables import DecayTreeTuple, TupleToolMCTruth, TupleToolEventInfo, MCTupleToolHierarchy
from Configurables import TimingAuditor, SequencerTimerTool
TimingAuditor().addTool(SequencerTimerTool, name="TIMER")
TimingAuditor().TIMER.NameSize = 60
MessageSvc().Format = "% F%80W%S%7W%R%T %0W%M"
DaVinci().EvtMax = -1
DaVinci().TupleFile = 'DVNtuple.root'
#DaVinci().HistogramFile = 'DVHistos.root'
#from PhysConf.Selections import AutomaticData
StdLooseMuons = AutomaticData('Phys/StdLooseMuons/Particles')
name = "TwoBody"
TwoBodyComb = CombineParticles(
"TwoBodyComb",
#Preambulo=["from LoKiPhysMC.decorators import *","from LoKiPhysMC.functions import mcMatch"],
DecayDescriptors=['J/psi(1S) -> mu+ mu-', '[J/psi(1S) -> mu+ mu+]cc'],
CombinationCut="(ADOCACHI2CUT(30, ''))",
MotherCut="(BPVVDCHI2() > 30) & (VFASPF(VCHI2/VDOF) < 10)",
DaughtersCuts={
#'mu+': '(MIPCHI2DV(PRIMARY)>9) & (PROBNNmu>0.2) & (PT > 0*GeV) & (TRGHOSTPROB<0.25)',
#'mu-': '(MIPCHI2DV(PRIMARY)>9) & (PROBNNmu>0.2) & (PT > 0*GeV) & (TRGHOSTPROB<0.25)'}
'mu+': '(MIPCHI2DV(PRIMARY)>9) & (PT > 0*GeV) & (TRGHOSTPROB<0.25)',
'mu-': '(MIPCHI2DV(PRIMARY)>9) & (PT > 0*GeV) & (TRGHOSTPROB<0.25)'
})
TwoBodySel = Selection(
"TwoBodySel", Algorithm=TwoBodyComb, RequiredSelections=[StdLooseMuons])
TwoBodySeq = SelectionSequence("Seq" + name, TopSelection=TwoBodySel)
tuple1 = DecayTreeTuple("TwoBody")
tuple1.TupleName = "TwoBody"
tuple1.NTupleDir = ""
ToolList = ['TupleToolMCTruth', 'TupleToolEventInfo']
tuple1.ToolList = ToolList
tuple1.addBranches({
"TwoBody": "J/psi(1S)",
"Track1": "J/psi(1S) -> ^[mu+]CC [mu-]CC",
"Track2": "J/psi(1S) -> [mu+]CC ^[mu-]CC",
})
tuple1.TwoBody.addTool(TupleToolEventInfo)
tuple1.addTool(TupleToolMCTruth)
tuple1.TupleToolMCTruth.OutputLevel = INFO
tuple1.TupleToolMCTruth.ToolList = ["MCTupleToolHierarchy"]
tuple1.TupleToolMCTruth.addTool(MCTupleToolHierarchy)
tuple1.TupleToolMCTruth.MCTupleToolHierarchy.OutputLevel = INFO
tuple1.addTool(TupleToolMCTruth)
LoKi_TwoBody = tuple1.TwoBody.addTupleTool(
"LoKi::Hybrid::TupleTool/LoKi_TwoBody")
LoKi_TwoBody.Preambulo.append("from LoKiPhysMC.decorators import *")
LoKi_TwoBody.Preambulo.append("from LoKiPhysMC.functions import mcMatch")
LoKi_TwoBody.Variables = {
'Mcorr':
"BPVCORRM()",
'M':
"M",
'P':
"P",
'PT':
"PT",
'ETA':
"ETA",
'MINIPCHI2':
"MIPCHI2DV(PRIMARY)",
'DIRA_OWNPV':
"BPVDIRA()",
'FDCHI2_OWNPV':
"BPVVDCHI2()",
'ENDVERTEX_CHI2':
"VFASPF(VCHI2/VDOF)",
'DOCAMAX':
"PFUNA(ADOCAMAX(''))",
'FromSameB':
"switch( mcMatch('([ (Beauty) --> [X+]CC [X-]CC ... ]CC) ') , 1 , 0)",
}
LoKi_one = tuple1.Track1.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_one")
LoKi_one.Preambulo.append("from LoKiPhysMC.decorators import *")
LoKi_one.Preambulo.append("from LoKiPhysMC.functions import mcMatch")
LoKi_one.Variables = {
'ID': "ID",
'P': "P",
'PT': "PT",
'ETA': "ETA",
'MINIPCHI2': "MIPCHI2DV(PRIMARY)",
'TRCHI2DOF': "TRCHI2DOF",
'TRGHOSTPROB': "TRGHOSTPROB",
'FromB': "switch( mcMatch('([ (Beauty) --> X+ ... ]CC) ') , 1 , 0)",
}
LoKi_two = tuple1.Track2.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_two")
LoKi_two.Preambulo = LoKi_one.Preambulo
LoKi_two.Variables = LoKi_one.Variables
tuple1.Decay = "J/psi(1S) -> ^[mu+]CC ^[mu-]CC"
tuple1.Inputs = [TwoBodySeq.outputLocation()]
DaVinci().appendToMainSequence([TwoBodySeq, tuple1])
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