Skip to content
Snippets Groups Projects
Commit cac027f6 authored by Dong Ao's avatar Dong Ao
Browse files

Merge branch 'jiangyi/Lb2LcDKS_Run12' into 'master'

add Lb -> Lc+ D- KS data of Run1/2

See merge request !2344
parents adb472eb c596718f
No related branches found
No related tags found
2 merge requests!2344add Lb -> Lc+ D- KS data of Run1/2,!2313Draft: Rquaglia rd ap 2024 for b->v ee very low q2 fixes on DTF and vertex errors
###
from Gaudi.Configuration import *
from Configurables import GaudiSequencer
from Configurables import DaVinci
from Configurables import DecayTreeTuple, CheckPV, SubstitutePID, SubPIDMMFilter, FilterInTrees
from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence, DataOnDemand, MergedSelection
from Configurables import CombineParticles, FilterDesktop, OfflineVertexFitter
from Configurables import FitDecayTrees, TupleToolGeometry
from Configurables import DecayTreeTuple, LoKi__Hybrid__TupleTool, TupleToolDecay, TupleToolTrigger, TupleToolTISTOS, TupleToolTagging, TupleToolRecoStats, TupleToolPi0Info, TupleToolPhotonInfo
from Configurables import LoKi__Hybrid__TupleTool as LoKiTupleTool
from Configurables import TupleToolDecayTreeFitter
from Configurables import LoKi__Hybrid__EvtTupleTool as LoKiTool
from Configurables import CondDB
from Configurables import TupleToolMCTruth, TupleToolMCBackgroundInfo
from Configurables import LoKi__Hybrid__DictOfFunctors
from Configurables import LoKi__Hybrid__Dict2Tuple
from Configurables import LoKi__Hybrid__DTFDict
from StandardParticles import StdLooseResolvedPi0 as pi0, StdAllNoPIDsPions as pip, StdAllNoPIDsKaons as Km, StdLoosePhotons as gamma
from StandardParticles import StdLooseKsDD as KSDD, StdLooseKsLL as KSLL, StdLooseLambdaDD as LDD, StdLooseLambdaLL as LLL
# lines = [ 'B02DstD0KBeauty2CharmLine',
# 'B02DstD0KD02K3PiBeauty2CharmLine',
# 'B02DstD0KDstarD02K3PiBeauty2CharmLine',
# 'B02DstD0KDstarD02K3PiD02K3PiBeauty2CharmLine']
lines = ['Lb2LcDD2HHHPIDBeauty2CharmLine',
'X2LcD0D02KPiBeauty2CharmLine'
]
#hlt filters
from PhysConf.Filters import LoKi_Filters
fltrs = LoKi_Filters(STRIP_Code = "("+"|".join(["HLT_PASS_RE('Stripping{}Decision')".format(line) for line in lines]) + ")")
# _Dst = FilterInTrees('dst_in_line', Code="('D*(2010)+' == ABSID)")
_D0 = FilterInTrees('d0_in_line', Code="('Lambda_c+' == ABSID)|('D0' == ABSID)")
_Dp = FilterInTrees('dp_in_line', Code="('Lambda_c+' == ABSID)|('D-' == ABSID)")
_Lc = FilterInTrees('lc_in_line', Code="('Lambda_c+' == ABSID)")
_Lb = CombineParticles('comb_lb1',
DecayDescriptors=["[Lambda_b0 -> Lambda_c+ D- KS0]cc"],
CombinationCut="(AM<6000*MeV)",
MotherCut="(ALL)", # VFASPF(VCHI2/VDOF) < 15) & (BPVDIRA > 0.999) & (BPVLTIME() > 0.2*ps) & (BPVIPCHI2()<25)",
DaughtersCuts = {
"Lambda_c+": "ALL",
"D-": "ALL",
"KS0": "ALL"},
ReFitPVs = True)
_B0 = CombineParticles('comb_b1',
DecayDescriptors=["[B0 -> Lambda_c+ D- Lambda~0]cc"],
CombinationCut="(AM<6000*MeV)",
MotherCut="(ALL)", # (VFASPF(VCHI2/VDOF) < 15) & (BPVDIRA > 0.999) & (BPVLTIME() > 0.2*ps) & (BPVIPCHI2()<25)",
DaughtersCuts = {
"Lambda_c+": "ALL",
"D-": "ALL",
"Lambda0": "ALL"},
ReFitPVs = True)
_Bp = CombineParticles('comb_b1',
DecayDescriptors=["B- -> Lambda_c~- D0 Lambda0", "B+ -> Lambda_c+ D0 Lambda~0"],
CombinationCut="(AM<6000*MeV)",
MotherCut="(ALL)", # (VFASPF(VCHI2/VDOF) < 15) & (BPVDIRA > 0.999) & (BPVLTIME() > 0.2*ps) & (BPVIPCHI2()<25)",
DaughtersCuts = {
"Lambda_c+": "ALL",
"D0": "ALL",
"Lambda0": "ALL"},
ReFitPVs = True)
line_loc_lcd = "/Phys/{}/Particles".format(lines[0])
line_data_lcd = DataOnDemand(line_loc_lcd)
line_loc_lcd0 = "/Phys/{}/Particles".format(lines[1])
line_data_lcd0 = DataOnDemand(line_loc_lcd0)
cache_sel = {}
def simple_sel(name, sel, data):
key= (sel, data)
if key in cache_sel:
return cache_sel[key]
ret= Selection(name,
Algorithm=sel,
RequiredSelections=[data])
cache_sel[key] = ret
return ret
name = "Lb2LcDKS"
#
seqs = []
##DecayTree
from DecayTreeTuple.Configuration import *
#Dm Dsp pi pi
def make_dtf(dtt, name, mass_constains, pv):
tup1 = dtt.B.addTupleTool(LoKi__Hybrid__Dict2Tuple, name + "FitTupTuple")
tup1.NumVar = 300
tup2 = tup1.addTool(LoKi__Hybrid__DTFDict, name + "FitTup")
tup1.Source = "LoKi::Hybrid::DTFDict/"+name+"FitTup"
tup2.constrainToOriginVertex = pv
tup2.daughtersToConstrain = mass_constains # [ "D-", "D_s+", "B0", "phi(1020)"]
tup3 = tup2.addTool(LoKi__Hybrid__DictOfFunctors, name+"FitTupdict")
tup2.Source = "LoKi::Hybrid::DictOfFunctors/"+name+"FitTupdict"
tup3.Variables = {}
for branch, decaychain in dtt.Branches.items():
for var in ['E','PX','PY','PZ','PT','ETA','M','ID']:
if branch == 'B':
tup3.Variables.update( {"{}_{}".format(branch, var): var})
else:
tup3.Variables.update( {"{}_{}".format(branch, var): "CHILD({},'{}')".format(var, decaychain)})
# tuple.setDescriptorTemplate("${B}[B0 -> ${D1}(D- -> ${D1_K}K+ ${D1_pi1}pi- ${D1_pi2}pi-) ${D2}(D_s+ -> ${D2_K1}K- ${D2_K2}K+ ${D2_pi}pi+) ${phi}(phi(1020) -> ${K1}K+ ${K2}K-)]CC")
#add tools
triglist = [
"L0DiMuonDecision","L0ElectronDecision","L0ElectronHiDecision",
"L0HadronDecision","L0MuonDecision",
"L0PhotonDecision","L0HadronDecision",
"Hlt1TrackAllL0Decision","Hlt1TrackMVADecision","Hlt1TwoTrackMVADecision",
"Hlt2Topo2BodyBBDTDecision","Hlt2Topo3BodyBBDTDecision","Hlt2Topo4BodyBBDTDecision","Hlt2IncPhiDecision","Hlt2PhiIncPhiDecision",
"Hlt2Topo2BodyDecision","Hlt2Topo3BodyDecision","Hlt2Topo4BodyDecision"
]
tistos = TupleToolTISTOS('tistos')
tistos.VerboseL0 = True
tistos.VerboseHlt1 = True
tistos.VerboseHlt2 = True
tistos.TriggerList = triglist[:]
tupletools = ["TupleToolGeometry",
"TupleToolKinematic",
"TupleToolEventInfo",
"TupleToolPid",
"TupleToolTrackInfo",
"TupleToolRecoStats",
# "TupleToolMCTruth",
# "TupleToolMCBackgroundInfo"
]
Bach_sel_map = {
"KSDD": KSDD,
"KSLL": KSLL,
"LLL": LLL,
"LDD": LDD,
}
global_sel_B = None
def make_tuple(name, d, Bach):
global global_sel_B
if d == "D0":
line_data = line_data_lcd0
d_d = "^([D0]CC -> ^K+ ^pi-)"
d_n = ["D2_K", "D2_pi"]
d_m = "D0"
d_sel = _D0
else:
line_data = line_data_lcd
d_d = "^(D- -> ^K+ ^pi- ^pi-)"
d_n = ["D2_K", "D2_pi1", "D2_pi2"]
d_m = "D-"
d_sel = _Dp
# sel_Lc = simple_sel(name+"_Lc",_Lc,line_data)
sel_D = simple_sel(name+"_D",d_sel,line_data)
sel_Bach = Bach_sel_map[Bach]
if d == "D0":
b_m = "B+"
_B = _Bp
else:
if "KS" in Bach:
b_m = "Lambda_b0"
_B = _Lb
else:
b_m = "[B0]CC"
_B = _B0
sel_B = Selection(name + "_B", Algorithm=_B,
RequiredSelections=[sel_D, sel_Bach])
global_sel_B = sel_B
seq = SelectionSequence(name+'_seq', TopSelection=sel_B)
ret = DecayTreeTuple( name )
ret.Inputs = [ seq.outputLocation() ]
ret.TupleName = "DecayTree"
if "KS" in Bach:
k_d = "^(KS0 -> ^pi+ ^pi-)"
k_n = ["K", "K_pip", "K_pim"]
k_m = "KS0"
else:
k_d = "^(Lambda~0 -> ^p~- ^pi+)"
k_n = ["L" , "L_p", "L_pi"]
k_m = "Lambda_b0"
decay_temp = "^[{} -> ^(Lambda_c+ -> ^p+ ^K- ^pi+) {} {}]CC".format(b_m, d_d, k_d)
names = ['B','D1', "D1_p", "D1_K", "D1_pi", 'D2'] + d_n + k_n
decay_temp = decay_temp.replace("^", "{{{}}}").format(*names)
# print(name, decay_temp)
ret.Decay = decay_temp.format(**{k: "^" for k in names})
decay_node_map = {k1: decay_temp.format(**{k2: "^" if k2 == k1 else "" for k2 in names}) for k1 in names}
# print(decay_node_map)
ret.addBranches(decay_node_map)
for part in names:
tool = ret.addTupleTool(TupleToolDecay, name = part)
ret.ToolList+=tupletools
ret.B.ToolList = [ "TupleToolPropertime" ]
#TISTOS
ret.B.addTool(tistos)
ret.B.ToolList+=["TupleToolTISTOS/tistos"]
#loki
ret.ReFitPVs = True
LoKi_Lb=LoKi__Hybrid__TupleTool("LoKi_Lb")
LoKi_Lb.Variables = {
"ETA" : "ETA",
"Y" : "Y",
"LOKI_DTF_CTAU" : "DTF_CTAU( 0, True )",
"LOKI_DTF_CHI2NDOF" : "DTF_CHI2NDOF( True )",
"LOKI_DTF_CTAUERR" : "DTF_CTAUERR( 0, True )",
"FDCHI2_BPV" : "BPVVDCHI2",
"FD_BPV" : "BPVVD",
"IPCHI2_BPV" : "BPVIPCHI2()",
"VFSPF_VCHI2_VDOF": "VFASPF(VCHI2/VDOF)",
"BPVLTIME": "BPVLTIME()",
"BPVLTFITCHI2": "BPVLTFITCHI2()",
"BPVLTCHI2": "BPVLTCHI2()",
"BPVDIRA": "BPVDIRA",
}
ret.B.addTool(LoKi_Lb)
ret.B.ToolList+=["LoKi::Hybrid::TupleTool/LoKi_Lb"]
extra_mass = []
#Btag
if False:
tagtuple = ret.B.addTool(TupleToolTagging, name="BTag")
ret.B.ToolList+=["TupleToolTagging/BTag"]
from FlavourTagging.Tunings import applyTuning, BTaggingTool
btagtool = tagtuple.addTool(BTaggingTool, name = "MyBTaggingTool2")
applyTuning(btagtool, tuning_version="Summer2017Optimisation_v4_Run2")
tagtuple.TaggingToolName = btagtool.getFullName()
# inclusive B tag
tagtuple_ift = ret.B.addTool(TupleToolTagging, name="BTag_ift")
ret.B.ToolList+=["TupleToolTagging/BTag_ift"]
tagtuple_ift.Verbose = True
tagtuple_ift.AddMVAFeatureInfo = False
tagtuple_ift.AddTagPartsInfo = False
tagtuple_ift.OutputLevel = INFO
tagtuple_ift.ActiveTaggerTypes = ["InclusiveTagger"]
btagtool_ift = tagtuple_ift.addTool(BTaggingTool, name = "IftBTaggingTool")
btagtool_ift.TaggingParticleLocation = "Phys/TaggingIFTTracks"
bsbd = "Bs" if b_m == "B_s0" else "Bd"
tagtuple_ift.allConfigurables["ToolSvc.InclusiveTagger"].setProp("ClassifierVersion", "IFT_{}_v111120".format(bsbd))
tagtuple_ift.ExtraName = "IFT"
applyTuning(btagtool_ift, tuning_version="Summer2019Optimisation_v1_Run2")
tagtuple_ift.TaggingToolName = btagtool_ift.getFullName()
#DTF
make_dtf(ret, "PV", [], True)
make_dtf(ret, "PVALL", [d_m, k_m, b_m], True)
make_dtf(ret, "PVDau", [d_m, k_m], True)
make_dtf(ret, "PVDauD", [d_m], True)
make_dtf(ret, "NOPV", [], False)
return seq, ret
dtts = []
for d in ["D0", "Dm"]:
for k1 in ["KS", "L"]:
for k2 in ["DD" , "LL"]:
if k1 == "KS":
name = "Lb2Lc{0}{1}".format(d, k1+k2)
else:
name = "B2Lc{0}{1}".format(d, k1+k2)
if k1 == "KS" and d == "D0":
continue
seq, dtt = make_tuple(name, d, k1+k2)
seqs.append(seq)
dtts.append(dtt)
if True:
from Configurables import PrintDecayTree, PrintDecayTreeTool
tree = PrintDecayTree("PrintFoundBs")
tree.Inputs = [ global_sel_B.outputLocation()] # seqs[2].outputLocations() #[ "/Event/CharmCompleteEvent/Phys/{}/Particles".format(lines[0]) ]
tree.addTool( PrintDecayTreeTool, name = "PrintDecay" )
tree.PrintDecay.Information = "Name M P Px Py Pz Pt chi2"
DaVinci().MoniSequence += [ tree ]
tuples = dtts
from Configurables import CheckPV
checkpv = CheckPV()
from Configurables import TrackScaleState as SCALER
scaler = SCALER('Scaler')
from Configurables import TrackSmearState as SMEAR
smear = SMEAR('Smear')
###davinci
DaVinci().EvtMax = -1 # Number of events
DaVinci().Simulation = False
DaVinci().Lumi = not DaVinci().Simulation
DaVinci().EventPreFilters = fltrs.filters('Filter')
DaVinci().UserAlgorithms = [ checkpv]
if(DaVinci().Simulation == False):
DaVinci().UserAlgorithms += [scaler];
else:
DaVinci().UserAlgorithms += [smear]
DaVinci().UserAlgorithms += seqs + tuples
#DaVinci().TupleFile = "B02DmDspipi.root"
DaVinci().PrintFreq = 1000
#locationRoot = "/Event/CharmCompleteEvent"
#DaVinci().RootInTES = locationRoot
# DaVinci().InputType = 'DST'
########################################################################
MessageSvc().Format = "% F%60W%S%7W%R%T %0W%M"
from Configurables import DaVinciInit, GetIntegratedLuminosity
# DaVinciInit().OutputLevel = 6
# MessageSvc().OutputLevel = 6
GetIntegratedLuminosity().OutputLevel = INFO
ToolSvc().OutputLevel = 6
NTupleSvc().OutputLevel = 6
defaults:
application: DaVinci/v46r11
wg: B2OC
automatically_configure: yes
turbo: no
inform:
- y.jiang@cern.ch
root_in_tes: /Event/Bhadron
# Real data (collision)
{%- set collision_datasets2 = [
('11', '3500', '14', '21r1'),
('12', '4000', '14', '21'),
('15', '6500', '15a', '24r2'),
('16', '6500', '16', '28r2'),
('17', '6500', '17', '29r2'),
('18', '6500', '18', '34'),
]%}
{%- for year, beam, reco, strip in collision_datasets2 %}
{%- for polarity in ['MagDown','MagUp'] %}
20{{year}}_{{polarity}}_collision_Lb2LcDKS:
input:
bk_query: /LHCb/Collision{{year}}/Beam{{beam}}GeV-VeloClosed-{{polarity}}/Real Data/Reco{{reco}}/Stripping{{strip}}/90000000/BHADRON.MDST
n_test_lfns: 3
options:
- dv_tupling.py
output: Lb2LcDKS.ROOT
{%- endfor %}
{%- endfor %}
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