From 334f0698413158d97fdd21b7805f721b7e72ee7e Mon Sep 17 00:00:00 2001
From: Chencheng Feng <fengc@lxplus9103.cern.ch>
Date: Thu, 17 Oct 2024 11:33:16 +0200
Subject: [PATCH 01/11] Lb2LcD0pi

---
 Lb2LcD0pi/Lb2LcD0pi.py | 487 +++++++++++++++++++++++++++++++++++++++++
 Lb2LcD0pi/info.yaml    |  50 +++++
 2 files changed, 537 insertions(+)
 create mode 100644 Lb2LcD0pi/Lb2LcD0pi.py
 create mode 100644 Lb2LcD0pi/info.yaml

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
new file mode 100644
index 0000000000..a4006363af
--- /dev/null
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -0,0 +1,487 @@
+year = "2016"
+# backend = "local"
+backend = "forAP" 
+
+if backend=="local":
+   nMax = 20000
+elif backend=="forAP":
+   nMax = -1
+
+
+###############################################################
+######################## dv_opts.py ########################
+###############################################################
+from Configurables import DaVinci
+from Configurables import CondDB
+
+########## DaVinci configuration ############
+# DaVinci().InputType = 'DST'
+DaVinci().TupleFile = "Lb2LcD0pi.root"             # Ntuple
+DaVinci().PrintFreq = 10000
+DaVinci().EvtMax = nMax        #Number of events
+DaVinci().Simulation   = False 
+# DaVinci().SkipEvents = 0                       # Events to skip
+
+# if backend != 'forAP':
+# 	DaVinci().DataType = year
+# 	CondDB(LatestGlobalTagByDataType = year )
+# 	DaVinci().Lumi = not DaVinci().Simulation
+
+
+
+###############################################################
+######################## generation.py ########################
+###############################################################
+
+
+
+from os import environ
+from GaudiKernel.SystemOfUnits import *
+from Gaudi.Configuration import *
+from Configurables import GaudiSequencer, CombineParticles
+from Configurables import DecayTreeTuple, EventTuple, TupleToolTrigger, TupleToolTISTOS,FilterDesktop, MCDecayTreeTuple, TupleToolPrimaries, TupleToolPi0Info, TupleToolTrackPosition, TupleToolGeometry, TupleToolTrackInfo
+from Configurables import TupleToolKinematic, TupleToolStripping, FilterInTrees
+from Configurables import BackgroundCategory, TupleToolDecay, TupleToolVtxIsoln,TupleToolPid,EventCountHisto,TupleToolRecoStats, TupleToolPhotonInfo, TupleToolCaloHypo
+from Configurables import TupleToolProtoPData
+from Configurables import TupleToolMCTruth, TupleToolMCBackgroundInfo
+from Configurables import LoKi__Hybrid__TupleTool, TupleToolVeto
+from Configurables import LoKi__Hybrid__EvtTupleTool,LoKi__Hybrid__DictOfFunctors, LoKi__Hybrid__Dict2Tuple, LoKi__Hybrid__DTFDict
+from Configurables import TupleToolDecayTreeFitter
+#from Configurables import LoKi__Hybrid__DictofFunctors,LoKi__Hybrid__DTFDict,LoKi__Hybrid__DictValue, LoKi__Hybrid__Dict2Tuple
+
+from DecayTreeTuple.Configuration import *
+from Configurables import SubstitutePID
+from LoKiPhys.decorators import *
+
+# Load Selection objects
+from PhysConf.Selections import CombineSelection, FilterSelection, MomentumScaling
+from PhysConf.Selections import SelectionSequence
+
+from PhysConf.Selections import Combine3BodySelection
+
+from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence, DataOnDemand, SimpleSelection, MergedSelection
+from PhysConf.Selections import Selection
+from PhysConf.Filters import LoKi_Filters
+
+from Configurables import DaVinci
+
+
+# Load input particles
+from StandardParticles import StdVeryLooseAllPhotons as photons
+from StandardParticles import StdAllLooseGammaLL
+from StandardParticles import StdAllLooseGammaDD
+from StandardParticles import StdLooseResolvedPi0 as pi0resolved
+
+
+from collections import OrderedDict
+from MVADictHelpers import *
+import sys
+sys.path.append('.')
+#from dfrombtools import getMVAVars
+
+
+
+################## functions ####################
+def TISTOSToolConfig(branch):
+   trigger_tool = branch.addTupleTool('TupleToolTISTOS')
+   trigger_tool.VerboseL0 = True
+   trigger_tool.VerboseHlt1 = True
+   trigger_tool.VerboseHlt2 = True
+   trigger_tool.Verbose = True
+   trigger_tool.TriggerList = mtl
+
+def TrackConfig(branch):
+   loki = branch.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_Track')
+   loki.Variables = {
+	   "ETA": "ETA",
+	   "Y_rapidity"  : "Y",
+	   "PHI"  : "PHI",
+	   "KL" : "CLONEDIST",
+	   }
+
+def ResConfig(branch):
+   loki = branch.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_Res')
+   loki.Variables = {
+	   "ETA": "ETA",
+	   "Y_rapidity"  : "Y",
+	   "PHI"  : "PHI",
+	   "LOKI_FDCHI2" : "BPVVDCHI2",
+	   "LOKI_FDS"    : "BPVDLS",
+	   "LOKI_DIRA"   : "BPVDIRA",
+	   "LOKI_TAU"    : "BPVLTIME()",
+	   "LOKI_MAXDOCA": "LoKi.Particles.PFunA(AMAXDOCA('LoKi::DistanceCalculator'))",
+	   "LOKI_LV01" : "LV01",
+	   "LOKI_LV02" : "LV02"
+	   }
+
+
+def PVDTFConfig(branch):
+   loki = branch.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_PVDTF')
+   loki.Variables = {
+	   "PVDTF_CHI2NDOF": "DTF_CHI2NDOF(True)",
+
+	   "PVDTF_M": "DTF_FUN(M, True)", 
+	   "PVDTF_PX": "DTF_FUN(PX, True)", 
+	   "PVDTF_PY": "DTF_FUN(PY, True)", 
+	   "PVDTF_PZ": "DTF_FUN(PZ, True)", 
+	   "PVDTF_P": "DTF_FUN(P, True)", 
+	   "PVDTF_PT": "DTF_FUN(PT, True)", 
+	   "PVDTF_E": "DTF_FUN(E, True)", 
+	   "PVDTF_DIRA": "DTF_FUN(BPVDIRA, True)", 
+	   "PVDTF_IP": "DTF_FUN(BPVIP(), True)", 
+	   "PVDTF_IPCHI2": "DTF_FUN(BPVIPCHI2(), True)", 
+	   "PVDTF_FDCHI2": "DTF_FUN(BPVVDCHI2, True)", 
+	   "PVDTF_FDS": "DTF_FUN(BPVDLS, True)", 
+	   "PVDTF_TAU": "DTF_FUN(BPVLTIME(), True)", 
+
+	   "PVDTF_C1_M": "DTF_FUN(CHILD(M,1), True)", 
+	   "PVDTF_C1_PX": "DTF_FUN(CHILD(PX,1), True)", 
+	   "PVDTF_C1_PY": "DTF_FUN(CHILD(PY,1), True)", 
+	   "PVDTF_C1_PZ": "DTF_FUN(CHILD(PZ,1), True)", 
+	   "PVDTF_C1_P": "DTF_FUN(CHILD(P,1), True)", 
+	   "PVDTF_C1_PT": "DTF_FUN(CHILD(PT,1), True)", 
+	   "PVDTF_C1_E": "DTF_FUN(CHILD(E,1), True)", 
+	   "PVDTF_C1_DIRA": "DTF_FUN(CHILD(BPVDIRA,1), True)", 
+	   "PVDTF_C1_IP": "DTF_FUN(CHILD(BPVIP(),1), True)", 
+	   "PVDTF_C1_IPCHI2": "DTF_FUN(CHILD(BPVIPCHI2(),1), True)", 
+	   "PVDTF_C1_FDCHI2": "DTF_FUN(CHILD(BPVVDCHI2,1), True)", 
+	   "PVDTF_C1_FDS": "DTF_FUN(CHILD(BPVDLS,1), True)", 
+	   "PVDTF_C1_TAU": "DTF_FUN(CHILD(BPVLTIME(),1), True)", 
+
+	   "PVDTF_CTAU": "DTF_CTAU(0, True)",
+	   "PVDTF_CTAUS": "DTF_CTAUSIGNIFICANCE(0, True)",
+	   }
+
+
+def dau_vars():
+  return {"MIPCHI2"                : "MIPCHI2DV(PRIMARY)",
+          "MIP"                    : "MIPDV(PRIMARY)",
+          "KEY"                    : "KEY",
+          "log_TRACK_VeloCHI2NDOF" : "log10(switch(TINFO(LHCb.Track.FitVeloNDoF,-1)>0,TINFO(LHCb.Track.FitVeloChi2,-1)/TINFO(LHCb.Track.FitVeloNDoF,-1),-1))",
+          "log_TRACK_TCHI2NDOF"    : "log10(switch(TINFO(LHCb.Track.FitTNDoF,-1)>0,TINFO(LHCb.Track.FitTChi2,-1)/TINFO(LHCb.Track.FitTNDoF,-1),-1))",
+          "log_TRACK_MatchCHI2"    : "log10(TINFO(LHCb.Track.FitMatchChi2,-1.))",
+          "log_TRACK_GhostProb"    : "log10(TRGHOSTPROB)",
+          "atan_RichDLLe"          : "atan(PPINFO(LHCb.ProtoParticle.RichDLLe,-1000))",
+          "atan_RichDLLmu"         : "atan(PPINFO(LHCb.ProtoParticle.RichDLLmu,-1000))",
+          "atan_RichDLLk"          : "atan(PPINFO(LHCb.ProtoParticle.RichDLLk,-1000))",
+          "atan_RichDLLp"          : "atan(PPINFO(LHCb.ProtoParticle.RichDLLp,-1000))",
+          "atan_RichDLLbt"         : "atan(PPINFO(LHCb.ProtoParticle.RichDLLbt,-1000))",
+          "atan_MuonLLbg"          : "atan(switch(PPINFO(LHCb.ProtoParticle.InAccMuon,0)==1,PPINFO(LHCb.ProtoParticle.MuonBkgLL,-10000),-1000))",
+          "atan_MuonLLmu"          : "atan(switch(PPINFO(LHCb.ProtoParticle.InAccMuon,0)==1,PPINFO(LHCb.ProtoParticle.MuonMuLL,-10000),-1000))",
+          "MuonNShared"            : "switch(PPINFO(LHCb.ProtoParticle.InAccMuon,0)==1,PPINFO(LHCb.ProtoParticle.MuonNShared,0),-1)",
+          "VeloCharge"             : "PPINFO(LHCb.ProtoParticle.VeloCharge,-1000)"}
+
+#tracks and hits
+def event_vars():
+  return {"nPV"     : "RECSUMMARY(LHCb.RecSummary.nPVs,-9999)",
+          "nLong"   : "RECSUMMARY(LHCb.RecSummary.nLongTracks,-9999)",
+          "nDown"   : "RECSUMMARY(LHCb.RecSummary.nDownstreamTracks,-9999)",
+          "nUp"     : "RECSUMMARY(LHCb.RecSummary.nUpstreamTracks,-9999)",
+          "nVelo"   : "RECSUMMARY(LHCb.RecSummary.nVeloTracks,-9999)",
+          "nTT"     : "RECSUMMARY(LHCb.RecSummary.nTTracks,-9999)",
+          "nBack"   : "RECSUMMARY(LHCb.RecSummary.nBackTracks,-9999)",
+          "nMuon"   : "RECSUMMARY(LHCb.RecSummary.nMuonTracks,-9999)",
+          "nTracks" : "RECSUMMARY(LHCb.RecSummary.nTracks,-9999)",
+          "hRich1"  : "RECSUMMARY(LHCb.RecSummary.nRich1Hits,-9999)",
+          "hRich2"  : "RECSUMMARY(LHCb.RecSummary.nRich2Hits,-9999)",
+          "hVelo"   : "RECSUMMARY(LHCb.RecSummary.nVeloClusters,-9999)",
+          "hIT"     : "RECSUMMARY(LHCb.RecSummary.nITClusters,-9999)",
+          "hTT"     : "RECSUMMARY(LHCb.RecSummary.nTTClusters,-9999)",
+          "hOT"     : "RECSUMMARY(LHCb.RecSummary.nOTClusters,-9999)",
+          "hSPD"    : "RECSUMMARY(LHCb.RecSummary.nSPDhits,-9999)"}
+
+
+
+def lorentz_vars(descriptor_template, ptetaphi = False):
+  vars = {"E":"E", "PT":"PT", "ETA":"ETA", "PHI":"PHI"} if ptetaphi else {"PE":"E", "PX":"PX", "PY":"PY", "PZ":"PZ"}
+  def add_variables(branches):
+    for k, v in branches.items() :
+      if ptetaphi :
+        vars[k+"_E"]   = "CHILD(E,'{}')".format(str(v))
+        vars[k+"_PT"]  = "CHILD(PT,'{}')".format(str(v))
+        vars[k+"_ETA"] = "CHILD(ETA,'{}')".format(str(v))
+        vars[k+"_PHI"] = "CHILD(PHI,'{}')".format(str(v))
+      else :
+        vars[k+"_PE"]  = "CHILD(E,'{}')".format(str(v))
+        vars[k+"_PX"]  = "CHILD(PX,'{}')".format(str(v))
+        vars[k+"_PY"]  = "CHILD(PY,'{}')".format(str(v))
+        vars[k+"_PZ"]  = "CHILD(PZ,'{}')".format(str(v))
+    return
+  if(isinstance(descriptor_template, str)):
+    add_variables(parse_descriptor_template(descriptor_template))
+  elif(isinstance(descriptor_template, dict)):
+    add_variables(descriptor_template)
+  else : print("ERROR in std_lorentz_vars: that shouldn't happen")
+  return vars
+
+
+
+
+
+################## END functions #################
+
+
+
+
+# Unit
+
+l0_lines   = [ 'L0GlobalDecision'
+               ,'L0HadronDecision']
+
+hlt1_lines = [ 'Hlt1TrackMVADecision'
+               , 'Hlt1TwoTrackMVADecision'
+               , 'Hlt1TrackMVALooseDecision'
+               , 'Hlt1TwoTrackMVALooseDecision'
+               , 'Hlt1L0AnyDecision'
+               , 'Hlt1GlobalDecision' ]
+
+hlt2_lines = [ 'Hlt2Topo2BodyDecision'
+               , 'Hlt2Topo3BodyDecision'
+               , 'Hlt2Topo4BodyDecision'
+               , 'Hlt2TopoE2BodyDecision'
+               , 'Hlt2TopoE3BodyDecision'
+               , 'Hlt2TopoE4BodyDecision'
+               , 'Hlt2TopoEE2BodyDecision'
+               , 'Hlt2TopoEE3BodyDecision'
+               , 'Hlt2TopoEE4BodyDecision'
+               , 'Hlt2TopoMu2BodyDecision'
+               , 'Hlt2TopoMu3BodyDecision'
+               , 'Hlt2TopoMu4BodyDecision'
+               , 'Hlt2TopoMuE2BodyDecision'
+               , 'Hlt2TopoMuE3BodyDecision'
+               , 'Hlt2TopoMuE4BodyDecision'
+               , 'Hlt2TopoMuMu2BodyDecision'
+               , 'Hlt2TopoMuMu3BodyDecision'
+               , 'Hlt2TopoMuMu4BodyDecision'
+               , 'Hlt2TopoMuMuDDDecision'
+               , 'Hlt2PhiIncPhiDecision']
+
+mtl = l0_lines + hlt1_lines + hlt2_lines
+
+tl = ['TupleToolKinematic', 'TupleToolPid', 'TupleToolEventInfo']
+
+
+LcD0pi_line = '/Event/Bhadron/Phys/X2LcD0PiD02KPiBeauty2CharmLine/Particles'
+
+
+#################################################################
+#################################################################
+############################ Lb2LcD0pi ############################
+#################################################################
+#################################################################
+
+
+FilterLcD0pi = FilterDesktop("FilterLcD0pi")
+DLcdaughter = { "D0" : OrderedDict({'K':1, 'pi':2}), "Lc" : OrderedDict({'p':1, 'K':2, 'pi':3}) }
+FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6.0*GeV ))"  #"((in_range(5.1*GeV,M,6.0*GeV)))" &\
+                       # (P>32*GeV) & (4*GeV<PT) & (PT<80*GeV) & (2<ETA) & (ETA<5) &\
+                       # (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
+                       # (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
+                       # (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
+                       # (CHILD(CHILD(PT,1),1)>300*MeV) & (CHILD(CHILD(PT,2),1)>150*MeV) & (CHILD(CHILD(PT,1),2)>150*MeV) &\
+                       # (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
+                       # (CHILD(DOCA(1,2),1)<0.3*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
+                       # (CHILD(PROBNNk,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) &\
+                       # (CHILD(BPVVD,1)>1.8*mm) & (CHILD(BPVVD,2)>2.0*mm) & ((CHILD(VFASPF(VZ),1) - VFASPF(VZ))>-3*mm) & ((CHILD(VFASPF(VZ),2) - VFASPF(VZ))>-2*mm))"
+
+
+
+LcD0pi_sel = Selection("Sel_LcD0pi",
+                   Algorithm = FilterLcD0pi,
+                   RequiredSelections = [AutomaticData(Location=LcD0pi_line)]
+                   )
+
+LcD0pi_sel = MomentumScaling (LcD0pi_sel )
+
+
+
+############################ Bc2KKpi #############################
+tuple_LcD0pi_Tree = DecayTreeTuple("tuple_LcD0pi_Tree",
+                        Decay = "((B0 -> ^(Lambda_c+ -> ^p+ ^K- ^pi+) ^(D0 -> ^K+ ^pi-) ^pi-) || (B0 -> ^(Lambda_c~- -> ^p~- ^K+ ^pi-) ^(D0 -> ^K- ^pi+) ^pi+))",
+                        Branches = {
+                           "B0"      : "((B0 -> (Lambda_c+ -> p+ K- pi+) (D0 -> K+ pi-) pi-) || (B0 -> (Lambda_c~- -> p~- K+ pi-) (D0 -> K- pi+) pi+))",
+                           "Lc"      : "((B0 -> ^(Lambda_c+ -> p+ K- pi+) (D0 -> K+ pi-) pi-) || (B0 -> ^(Lambda_c~- -> p~- K+ pi-) (D0 -> K- pi+) pi+))",
+                           "D0"      : "((B0 -> (Lambda_c+ -> p+ K- pi+) ^(D0 -> K+ pi-) pi-) || (B0 -> (Lambda_c~- -> p~- K+ pi-) ^(D0 -> K- pi+) pi+))",
+                           "pi"      : "((B0 -> (Lambda_c+ -> p+ K- pi+) (D0 -> K+ pi-) ^pi-) || (B0 -> (Lambda_c~- -> p~- K+ pi-) (D0 -> K- pi+) ^pi+))",
+                           "Lc_p"      : "((B0 -> (Lambda_c+ -> ^p+ K- pi+) (D0 -> K+ pi-) pi-) || (B0 -> (Lambda_c~- -> ^p~- K+ pi-) (D0 -> K- pi+) pi+))",
+                           "Lc_K"      : "((B0 -> (Lambda_c+ -> p+ ^K- pi+) (D0 -> K+ pi-) pi-) || (B0 -> (Lambda_c~- -> p~- ^K+ pi-) (D0 -> K- pi+) pi+))",
+                           "Lc_pi"      : "((B0 -> (Lambda_c+ -> p+ K- ^pi+) (D0 -> K+ pi-) pi-) || (B0 -> (Lambda_c~- -> p~- K+ ^pi-) (D0 -> K- pi+) pi+))",
+                           "D0_K"      : "((B0 -> (Lambda_c+ -> p+ K- pi+) (D0 -> ^K+ pi-) pi-) || (B0 -> (Lambda_c~- -> p~- K+ pi-) (D0 -> ^K- pi+) pi+))",
+                           "D0_pi"      : "((B0 -> (Lambda_c+ -> p+ K- pi+) (D0 -> K+ ^pi-) pi-) || (B0 -> (Lambda_c~- -> p~- K+ pi-) (D0 -> K- ^pi+) pi+))",
+                                    }
+                        )
+
+
+
+tuple_LcD0pi_sel = Selection("tuple_LcD0pi",
+                             Algorithm = tuple_LcD0pi_Tree,
+                             RequiredSelections = [ LcD0pi_sel])
+tuple_LcD0pi = tuple_LcD0pi_sel.algorithm()
+
+
+tuple_LcD0pi.ReFitPVs = True
+tuple_LcD0pi.ToolList += tl
+
+
+
+for particle in ["B0","Lc", "D0", "pi", "Lc_p", "Lc_K", "Lc_pi", "D0_K", "D0_pi"]:
+    tuple_LcD0pi.addTool(TupleToolDecay, name = particle)
+###Track
+TupleToolTrackPosition       = TupleToolTrackPosition('TupleToolTrackPosition')
+#TupleToolTrackPosition.Z     = 7500.#PositionZ?
+
+###reconstruction
+TupleToolRecoStats           = TupleToolRecoStats('TupleToolRecoStats')
+TupleToolRecoStats.Verbose   = True
+###Geometry
+TupleToolGeometry            = TupleToolGeometry('TupleToolGeometry')
+TupleToolGeometry.RefitPVs   = True
+TupleToolGeometry.Verbose    = True
+###TrackInfo
+TupleToolTrackInfo           = TupleToolTrackInfo('TupleToolTrackInfo')
+TupleToolTrackInfo.Verbose   = True
+###Trigger
+TupleToolTrigger             = TupleToolTrigger('TupleToolTrigger')
+TupleToolTrigger.Verbose     = True
+TupleToolTrigger.VerboseL0   = True
+TupleToolTrigger.VerboseHlt1 = True
+TupleToolTrigger.VerboseHlt2 = False
+TupleToolTrigger.FillHlt2    = False
+TupleToolTrigger.TriggerList = tl
+TupleToolTrigger.OutputLevel = 6
+
+tuple_LcD0pi.addTool(TupleToolTrackPosition)
+tuple_LcD0pi.addTool(TupleToolRecoStats)
+tuple_LcD0pi.addTool(TupleToolGeometry)
+tuple_LcD0pi.addTool(TupleToolTrackInfo)
+tuple_LcD0pi.addTool(TupleToolTrigger)
+
+
+# Event
+Event_Tuple = LoKi__Hybrid__EvtTupleTool("EventInfo")
+Event_Tuple.VOID_Variables = event_vars()
+
+tuple_LcD0pi.addTupleTool(Event_Tuple)
+
+################Fit###############
+
+#LCFIT
+#Lc_vars = {"M":"M", "PT":"PT", "Y":"Y", "ETA":"ETA", "PHI":"PHI", "PVDTF_CHI2NDOF": "DTF_CHI2NDOF(True)"}
+#Lc_fun = LoKi__Hybrid__DictOfFunctors("Lc_functors",Variables=Lc_vars)
+#Lc_DTF = LoKi__Hybrid__DTFDict("DTF", constrainToOriginVertex=True, daughtersToConstrain=["Lambda_c+","Lambda_c~-","D0"], Source=Lc_fun.getFullName())
+#Lc_DTF.addTool(Lc_fun)
+#LcTuple = LoKi__Hybrid__Dict2Tuple("Lc_tuple", Source=Lc_DTF.getFullName(), NumVar=len(Lc_vars))
+#LcTuple.addTool(Lc_DTF)
+#tuple_LcD0pi.B0.addTupleTool(LcTuple)
+
+#LBFIT
+#Lb_vars = lorentz_vars(tuple_LcD0pi_Tree.Branches)
+#Lb_fun = LoKi__Hybrid__DictOfFunctors("Lb_functors",Variables=Lb_vars)
+#Lb_DFT = LoKi__Hybrid__DTFDict("Lb_DTF", constrainToOriginVertex=True, daughtersToConstrain=["Lambda_b0","Lambda_b~0","Lambda_c~-","Lambda_c+","D~0"],
+#                                Source=Lb_fun.getFullName(), Substitutions={"B0 -> Lambda_c+ D0 pi-":"Lambda_b0", "B0 -> Lambda_c~- D0 pi+":"Lambda_b~0"})
+#Lb_DFT.addTool(Lb_fun)
+#LbTuple = LoKi__Hybrid__Dict2Tuple("Lb_tuple", Source=Lb_DFT.getFullName(), NumVar=len(Lb_vars))
+#LbTuple.addTool(Lb_DFT)
+#tuple_LcD0pi.B0.addTupleTool(LbTuple)
+
+tuple_LcD0pi.B0.ToolList += ["TupleToolDecayTreeFitter/PVFit0"]
+tuple_LcD0pi.B0.addTool(TupleToolDecayTreeFitter("PVFit0"))
+tuple_LcD0pi.B0.PVFit0.Verbose = True
+tuple_LcD0pi.B0.PVFit0.UpdateDaughters = True
+
+
+tuple_LcD0pi.B0.ToolList += ["TupleToolDecayTreeFitter/PVFit"]
+tuple_LcD0pi.B0.addTool(TupleToolDecayTreeFitter("PVFit"))
+tuple_LcD0pi.B0.PVFit.Verbose = True
+tuple_LcD0pi.B0.PVFit.constrainToOriginVertex = True
+tuple_LcD0pi.B0.PVFit.UpdateDaughters = True
+tuple_LcD0pi.B0.PVFit.daughtersToConstrain = ["Lambda_c+", "D0"]
+
+tuple_LcD0pi.B0.ToolList += ["TupleToolDecayTreeFitter/PVFitB0"]
+tuple_LcD0pi.B0.addTool(TupleToolDecayTreeFitter("PVFitB0"))
+tuple_LcD0pi.B0.PVFitB0.Verbose = True
+tuple_LcD0pi.B0.PVFitB0.constrainToOriginVertex = True
+tuple_LcD0pi.B0.PVFitB0.UpdateDaughters = True
+tuple_LcD0pi.B0.PVFitB0.daughtersToConstrain = ["Lambda_c+", "D0", "B0"]
+
+
+
+
+
+
+
+
+TISTOSToolConfig(tuple_LcD0pi.B0)
+TISTOSToolConfig(tuple_LcD0pi.Lc)
+TISTOSToolConfig(tuple_LcD0pi.D0)
+ResConfig(tuple_LcD0pi.B0)
+ResConfig(tuple_LcD0pi.Lc)
+ResConfig(tuple_LcD0pi.D0)
+tuple_LcD0pi.pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+tuple_LcD0pi.Lc_p.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+tuple_LcD0pi.Lc_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+tuple_LcD0pi.D0_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+tuple_LcD0pi.D0_pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+#TrackConfig(tuple_LcD0pi.pi)
+#TrackConfig(tuple_LcD0pi.Lc_p)
+#TrackConfig(tuple_LcD0pi.Lc_K)
+#TrackConfig(tuple_LcD0pi.Lc_pi)
+#TrackConfig(tuple_LcD0pi.D0_K)
+#TrackConfig(tuple_LcD0pi.D0_pi)
+
+
+
+
+
+loki_chic_B0 = tuple_LcD0pi.B0.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_chic')
+loki_chic_B0.Variables = {
+      "chic_M12": "M12",
+      #"K_IPCHI2": "CHILD(BPVIPCHI2(), 1)",
+      #"K2_IPCHI2": "CHILD(MIPCHI2DV(), 1)",###not working
+   }
+
+loki_chic_Lc = tuple_LcD0pi.Lc.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_chic')
+loki_chic_Lc.Variables = {
+      "chic_M": "M12",
+      #"K_IPCHI2": "CHILD(BPVIPCHI2(), 1)",
+      #"K2_IPCHI2": "CHILD(MIPCHI2DV(), 1)",###not working
+   }
+
+loki_chic_D0 = tuple_LcD0pi.D0.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_EvtTuple_chic')
+loki_chic_D0.Variables = {
+      "chic_M": "M12",
+      #"K_IPCHI2": "CHILD(BPVIPCHI2(), 1)",
+      #"K2_IPCHI2": "CHILD(MIPCHI2DV(), 1)",###not working
+   }
+seq_LcD0pi = SelectionSequence ( tuple_LcD0pi_sel.name()+'_SEQ' , tuple_LcD0pi_sel )
+
+
+
+
+
+#DaVinci().RootInTES = '/Event/Dimuon/'
+DaVinci().UserAlgorithms = [seq_LcD0pi.sequence()]  
+
+
+# from Configurables import CondDB
+# CondDB(LatestGlobalTagByDataType = year )
+# #CondDB().LocalTags["LHCBCOND"] = ["calo-20170505"]
+# #
+# #from Configurables import PhysConf
+# #PhysConf().CaloReProcessing=True
+
+# if year=="2016":
+#    inputpath = 'PFN:root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision16/BHADRON.MDST/00103400/0000/00103400_00001121_1.bhadron.mdst'
+#    #inputpath = 'PFN:root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision16/BHADRON.MDST/00103400/0001/00103400_00011422_1.bhadron.mdst'
+# elif year=='2011':
+#    inputpath = ''
+# elif year=='2012':
+#    inputpath = ''
+# elif year=='2017':
+#    inputpath = 'PFN:root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/LHCb/Collision17/BHADRONCOMPLETEEVENT.DST/00071907/0001/00071907_00011001_1.bhadroncompleteevent.dst'
+# elif year=='2018':
+#    inputpath = ''
+
+
+# if backend=="local":
+#    DaVinci().Input = [inputpath]
diff --git a/Lb2LcD0pi/info.yaml b/Lb2LcD0pi/info.yaml
new file mode 100644
index 0000000000..b9f16e1e79
--- /dev/null
+++ b/Lb2LcD0pi/info.yaml
@@ -0,0 +1,50 @@
+defaults:
+  application: DaVinci/v45r3
+  wg: BandQ
+  automatically_configure: yes
+  turbo: no
+  inform:
+    - chencheng.feng@cern.ch
+  options:
+    - Lb2LcD0pi.py
+  output: Lb2LcD0pi.root
+
+
+Lb2LcD0pi_2011_MagUp_jobs:
+  input:
+    bk_query: "/LHCb/Collision11/Beam3500GeV-VeloClosed-MagUp/Real Data/Reco14/Stripping21r1/90000000/BHADRON.MDST"
+Lb2LcD0pi_2012_MagUp_jobs:
+  input:
+    bk_query: "/LHCb/Collision12/Beam4000GeV-VeloClosed-MagUp/Real Data/Reco14/Stripping21/90000000/BHADRON.MDST"
+Lb2LcD0pi_2015_MagUp_jobs:
+  input:    
+    bk_query: "/LHCb/Collision15/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco15a/Stripping24r1/90000000/BHADRON.MDST"
+Lb2LcD0pi_2016_MagUp_jobs:
+  input:    
+    bk_query: "/LHCb/Collision16/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco16/Stripping28r2/90000000/BHADRON.MDST"
+Lb2LcD0pi_2017_MagUp_jobs:
+  input:    
+    bk_query: "/LHCb/Collision17/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco17/Stripping29r2/90000000/BHADRON.MDST"
+Lb2LcD0pi_2018_MagUp_jobs:
+  input:    
+    bk_query: "/LHCb/Collision18/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco18/Stripping34/90000000/BHADRON.MDST"
+
+
+Lb2LcD0pi_2011_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision11/Beam3500GeV-VeloClosed-MagDown/Real Data/Reco14/Stripping21r1/90000000/BHADRON.MDST"
+Lb2LcD0pi_2012_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision12/Beam4000GeV-VeloClosed-MagDown/Real Data/Reco14/Stripping21/90000000/BHADRON.MDST"
+Lb2LcD0pi_2015_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision15/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco15a/Stripping24r1/90000000/BHADRON.MDST"
+Lb2LcD0pi_2016_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision16/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco16/Stripping28r2/90000000/BHADRON.MDST"
+Lb2LcD0pi_2017_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision17/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco17/Stripping29r2/90000000/BHADRON.MDST"
+Lb2LcD0pi_2018_MagDown_jobs:
+  input:
+    bk_query: "/LHCb/Collision18/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco18/Stripping34/90000000/BHADRON.MDST"
-- 
GitLab


From 3da6e385067d8453d7cd1acd9a5d1cc5742d7363 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Thu, 17 Oct 2024 11:43:21 +0200
Subject: [PATCH 02/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index a4006363af..520bf92d96 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -27,7 +27,7 @@ DaVinci().Simulation   = False
 # 	CondDB(LatestGlobalTagByDataType = year )
 # 	DaVinci().Lumi = not DaVinci().Simulation
 
-
+##
 
 ###############################################################
 ######################## generation.py ########################
-- 
GitLab


From f76aab9360a0a81ad4dda919b3bf224a2b95283c Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Fri, 18 Oct 2024 10:43:35 +0200
Subject: [PATCH 03/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 125 ++++++++++++++++++++---------------------
 1 file changed, 61 insertions(+), 64 deletions(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index 520bf92d96..fff6c261e3 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -1,9 +1,9 @@
 year = "2016"
-# backend = "local"
-backend = "forAP" 
+backend = "forAP"
+#backend = "ganga" 
 
 if backend=="local":
-   nMax = 20000
+   nMax = 5000
 elif backend=="forAP":
    nMax = -1
 
@@ -11,23 +11,24 @@ elif backend=="forAP":
 ###############################################################
 ######################## dv_opts.py ########################
 ###############################################################
+
+
 from Configurables import DaVinci
-from Configurables import CondDB
 
-########## DaVinci configuration ############
-# DaVinci().InputType = 'DST'
+
+# DaVinci().InputType = 'MDST'
 DaVinci().TupleFile = "Lb2LcD0pi.root"             # Ntuple
 DaVinci().PrintFreq = 10000
 DaVinci().EvtMax = nMax        #Number of events
+#DaVinci().DataType = year
 DaVinci().Simulation   = False 
-# DaVinci().SkipEvents = 0                       # Events to skip
+#DaVinci().Lumi = not DaVinci().Simulation
+#DaVinci().SkipEvents = 0                       
+DaVinci().RootInTES  = '/Event/Bhadron'
+# Events to skip
+
 
-# if backend != 'forAP':
-# 	DaVinci().DataType = year
-# 	CondDB(LatestGlobalTagByDataType = year )
-# 	DaVinci().Lumi = not DaVinci().Simulation
 
-##
 
 ###############################################################
 ######################## generation.py ########################
@@ -64,6 +65,7 @@ from PhysConf.Selections import Selection
 from PhysConf.Filters import LoKi_Filters
 
 from Configurables import DaVinci
+from Configurables import GaudiSequencer
 
 
 # Load input particles
@@ -75,9 +77,6 @@ from StandardParticles import StdLooseResolvedPi0 as pi0resolved
 
 from collections import OrderedDict
 from MVADictHelpers import *
-import sys
-sys.path.append('.')
-#from dfrombtools import getMVAVars
 
 
 
@@ -153,9 +152,12 @@ def PVDTFConfig(branch):
 	   }
 
 
+
+
+
 def dau_vars():
-  return {"MIPCHI2"                : "MIPCHI2DV(PRIMARY)",
-          "MIP"                    : "MIPDV(PRIMARY)",
+  return {#"MIPCHI2"                : "MIPCHI2DV(PRIMARY)",
+          #"MIP"                    : "MIPDV(PRIMARY)",
           "KEY"                    : "KEY",
           "log_TRACK_VeloCHI2NDOF" : "log10(switch(TINFO(LHCb.Track.FitVeloNDoF,-1)>0,TINFO(LHCb.Track.FitVeloChi2,-1)/TINFO(LHCb.Track.FitVeloNDoF,-1),-1))",
           "log_TRACK_TCHI2NDOF"    : "log10(switch(TINFO(LHCb.Track.FitTNDoF,-1)>0,TINFO(LHCb.Track.FitTChi2,-1)/TINFO(LHCb.Track.FitTNDoF,-1),-1))",
@@ -219,14 +221,13 @@ def lorentz_vars(descriptor_template, ptetaphi = False):
 
 
 ################## END functions #################
-
+SeqPhys = GaudiSequencer("SeqPhys")
 
 
 
 # Unit
 
-l0_lines   = [ 'L0GlobalDecision'
-               ,'L0HadronDecision']
+l0_lines   = [ 'L0HadronDecision']
 
 hlt1_lines = [ 'Hlt1TrackMVADecision'
                , 'Hlt1TwoTrackMVADecision'
@@ -258,10 +259,10 @@ hlt2_lines = [ 'Hlt2Topo2BodyDecision'
 
 mtl = l0_lines + hlt1_lines + hlt2_lines
 
-tl = ['TupleToolKinematic', 'TupleToolPid', 'TupleToolEventInfo']
+tl = ["TupleToolKinematic", "TupleToolPid", "TupleToolANNPID","TupleToolEventInfo", "TupleToolTrackInfo","TupleToolRecoStats", "TupleToolTISTOS", "TupleToolGeometry", "TupleToolPrimaries", "TupleToolPropertime", "TupleToolDira", "TupleToolAngles", "TupleToolVtxIsoln", "TupleToolTrackPosition"]
 
 
-LcD0pi_line = '/Event/Bhadron/Phys/X2LcD0PiD02KPiBeauty2CharmLine/Particles'
+LcD0pi_line = 'Phys/X2LcD0PiD02KPiBeauty2CharmLine/Particles'
 
 
 #################################################################
@@ -273,16 +274,17 @@ LcD0pi_line = '/Event/Bhadron/Phys/X2LcD0PiD02KPiBeauty2CharmLine/Particles'
 
 FilterLcD0pi = FilterDesktop("FilterLcD0pi")
 DLcdaughter = { "D0" : OrderedDict({'K':1, 'pi':2}), "Lc" : OrderedDict({'p':1, 'K':2, 'pi':3}) }
-FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6.0*GeV ))"  #"((in_range(5.1*GeV,M,6.0*GeV)))" &\
-                       # (P>32*GeV) & (4*GeV<PT) & (PT<80*GeV) & (2<ETA) & (ETA<5) &\
-                       # (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
-                       # (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
-                       # (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
-                       # (CHILD(CHILD(PT,1),1)>300*MeV) & (CHILD(CHILD(PT,2),1)>150*MeV) & (CHILD(CHILD(PT,1),2)>150*MeV) &\
-                       # (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
-                       # (CHILD(DOCA(1,2),1)<0.3*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
-                       # (CHILD(PROBNNk,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) &\
-                       # (CHILD(BPVVD,1)>1.8*mm) & (CHILD(BPVVD,2)>2.0*mm) & ((CHILD(VFASPF(VZ),1) - VFASPF(VZ))>-3*mm) & ((CHILD(VFASPF(VZ),2) - VFASPF(VZ))>-2*mm))"
+FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6*GeV ))"
+                     #   (P>32*GeV) & (4*GeV<PT) & \
+                     #   (PT<80*GeV) & (2<ETA) & (ETA<5) &\
+                     #   (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
+                     #   (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
+                     #   (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
+                     #   (CHILD(CHILD(PT,1),1)>300*MeV) & (CHILD(CHILD(PT,2),1)>150*MeV) & (CHILD(CHILD(PT,1),2)>150*MeV) &\
+                     #   (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
+                     #   (CHILD(DOCA(1,2),1)<0.3*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
+                     #   (CHILD(PROBNNk,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) &\
+                     #   (CHILD(BPVVD,1)>1.8*mm) & (CHILD(BPVVD,2)>2.0*mm) & ((CHILD(VFASPF(VZ),1) - VFASPF(VZ))>-3*mm) & ((CHILD(VFASPF(VZ),2) - VFASPF(VZ))>-2*mm)"
 
 
 
@@ -291,6 +293,9 @@ LcD0pi_sel = Selection("Sel_LcD0pi",
                    RequiredSelections = [AutomaticData(Location=LcD0pi_line)]
                    )
 
+from Configurables import CheckPV
+checkpv = CheckPV()
+
 LcD0pi_sel = MomentumScaling (LcD0pi_sel )
 
 
@@ -357,33 +362,9 @@ tuple_LcD0pi.addTool(TupleToolTrackInfo)
 tuple_LcD0pi.addTool(TupleToolTrigger)
 
 
-# Event
-Event_Tuple = LoKi__Hybrid__EvtTupleTool("EventInfo")
-Event_Tuple.VOID_Variables = event_vars()
-
-tuple_LcD0pi.addTupleTool(Event_Tuple)
 
 ################Fit###############
 
-#LCFIT
-#Lc_vars = {"M":"M", "PT":"PT", "Y":"Y", "ETA":"ETA", "PHI":"PHI", "PVDTF_CHI2NDOF": "DTF_CHI2NDOF(True)"}
-#Lc_fun = LoKi__Hybrid__DictOfFunctors("Lc_functors",Variables=Lc_vars)
-#Lc_DTF = LoKi__Hybrid__DTFDict("DTF", constrainToOriginVertex=True, daughtersToConstrain=["Lambda_c+","Lambda_c~-","D0"], Source=Lc_fun.getFullName())
-#Lc_DTF.addTool(Lc_fun)
-#LcTuple = LoKi__Hybrid__Dict2Tuple("Lc_tuple", Source=Lc_DTF.getFullName(), NumVar=len(Lc_vars))
-#LcTuple.addTool(Lc_DTF)
-#tuple_LcD0pi.B0.addTupleTool(LcTuple)
-
-#LBFIT
-#Lb_vars = lorentz_vars(tuple_LcD0pi_Tree.Branches)
-#Lb_fun = LoKi__Hybrid__DictOfFunctors("Lb_functors",Variables=Lb_vars)
-#Lb_DFT = LoKi__Hybrid__DTFDict("Lb_DTF", constrainToOriginVertex=True, daughtersToConstrain=["Lambda_b0","Lambda_b~0","Lambda_c~-","Lambda_c+","D~0"],
-#                                Source=Lb_fun.getFullName(), Substitutions={"B0 -> Lambda_c+ D0 pi-":"Lambda_b0", "B0 -> Lambda_c~- D0 pi+":"Lambda_b~0"})
-#Lb_DFT.addTool(Lb_fun)
-#LbTuple = LoKi__Hybrid__Dict2Tuple("Lb_tuple", Source=Lb_DFT.getFullName(), NumVar=len(Lb_vars))
-#LbTuple.addTool(Lb_DFT)
-#tuple_LcD0pi.B0.addTupleTool(LbTuple)
-
 tuple_LcD0pi.B0.ToolList += ["TupleToolDecayTreeFitter/PVFit0"]
 tuple_LcD0pi.B0.addTool(TupleToolDecayTreeFitter("PVFit0"))
 tuple_LcD0pi.B0.PVFit0.Verbose = True
@@ -404,6 +385,19 @@ tuple_LcD0pi.B0.PVFitB0.constrainToOriginVertex = True
 tuple_LcD0pi.B0.PVFitB0.UpdateDaughters = True
 tuple_LcD0pi.B0.PVFitB0.daughtersToConstrain = ["Lambda_c+", "D0", "B0"]
 
+LcMassFit_Lb = tuple_LcD0pi.B0.addTupleTool('TupleToolDecayTreeFitter/LcMassFit')
+LcMassFit_Lb.UpdateDaughters = True
+LcMassFit_Lb.Verbose = True
+LcMassFit_Lb.constrainToOriginVertex = False
+LcMassFit_Lb.daughtersToConstrain = [ "Lambda_c+" ]
+
+LcFullFit_Lb = tuple_LcD0pi.B0.addTupleTool('TupleToolDecayTreeFitter/LcFullFit')
+LcFullFit_Lb.UpdateDaughters = True
+LcFullFit_Lb.Verbose = True
+LcFullFit_Lb.constrainToOriginVertex = True
+LcFullFit_Lb.daughtersToConstrain = [ "Lambda_c+" ]
+
+
 
 
 
@@ -417,18 +411,19 @@ TISTOSToolConfig(tuple_LcD0pi.D0)
 ResConfig(tuple_LcD0pi.B0)
 ResConfig(tuple_LcD0pi.Lc)
 ResConfig(tuple_LcD0pi.D0)
+
 tuple_LcD0pi.pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
 tuple_LcD0pi.Lc_p.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
 tuple_LcD0pi.Lc_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
 tuple_LcD0pi.D0_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
 tuple_LcD0pi.D0_pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
-#TrackConfig(tuple_LcD0pi.pi)
-#TrackConfig(tuple_LcD0pi.Lc_p)
-#TrackConfig(tuple_LcD0pi.Lc_K)
-#TrackConfig(tuple_LcD0pi.Lc_pi)
-#TrackConfig(tuple_LcD0pi.D0_K)
-#TrackConfig(tuple_LcD0pi.D0_pi)
-
+TrackConfig(tuple_LcD0pi.pi)
+TrackConfig(tuple_LcD0pi.Lc_p)
+TrackConfig(tuple_LcD0pi.Lc_K)
+TrackConfig(tuple_LcD0pi.Lc_pi)
+TrackConfig(tuple_LcD0pi.D0_K)
+TrackConfig(tuple_LcD0pi.D0_pi)
+PVDTFConfig(tuple_LcD0pi.B0)
 
 
 
@@ -456,7 +451,9 @@ loki_chic_D0.Variables = {
 seq_LcD0pi = SelectionSequence ( tuple_LcD0pi_sel.name()+'_SEQ' , tuple_LcD0pi_sel )
 
 
-
+#from Configurables import CheckPV
+#check1PV = CheckPV('Check1PV', MinPVs=1)
+#DaVinci().EventPreFilters=[check1PV]
 
 
 #DaVinci().RootInTES = '/Event/Dimuon/'
-- 
GitLab


From d46f5359ad4693366a388307b025fcc3a5661a43 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Fri, 18 Oct 2024 14:42:11 +0200
Subject: [PATCH 04/11] Update file info.yaml

---
 Lb2LcD0pi/info.yaml | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Lb2LcD0pi/info.yaml b/Lb2LcD0pi/info.yaml
index b9f16e1e79..c8022fbc07 100644
--- a/Lb2LcD0pi/info.yaml
+++ b/Lb2LcD0pi/info.yaml
@@ -1,5 +1,5 @@
 defaults:
-  application: DaVinci/v45r3
+  application: DaVinci/v46r11
   wg: BandQ
   automatically_configure: yes
   turbo: no
-- 
GitLab


From 2ebf279402d5e45932fbedd9e23fc323ab2690de Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Fri, 18 Oct 2024 14:44:30 +0200
Subject: [PATCH 05/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index fff6c261e3..6484a89a1b 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -48,7 +48,7 @@ from Configurables import TupleToolMCTruth, TupleToolMCBackgroundInfo
 from Configurables import LoKi__Hybrid__TupleTool, TupleToolVeto
 from Configurables import LoKi__Hybrid__EvtTupleTool,LoKi__Hybrid__DictOfFunctors, LoKi__Hybrid__Dict2Tuple, LoKi__Hybrid__DTFDict
 from Configurables import TupleToolDecayTreeFitter
-#from Configurables import LoKi__Hybrid__DictofFunctors,LoKi__Hybrid__DTFDict,LoKi__Hybrid__DictValue, LoKi__Hybrid__Dict2Tuple
+
 
 from DecayTreeTuple.Configuration import *
 from Configurables import SubstitutePID
-- 
GitLab


From 289261d619b6b0f3b231c5d2f3636be5c249a205 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Mon, 21 Oct 2024 08:34:57 +0200
Subject: [PATCH 06/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 7 ++++---
 1 file changed, 4 insertions(+), 3 deletions(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index 6484a89a1b..85295755b9 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -274,9 +274,10 @@ LcD0pi_line = 'Phys/X2LcD0PiD02KPiBeauty2CharmLine/Particles'
 
 FilterLcD0pi = FilterDesktop("FilterLcD0pi")
 DLcdaughter = { "D0" : OrderedDict({'K':1, 'pi':2}), "Lc" : OrderedDict({'p':1, 'K':2, 'pi':3}) }
-FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6*GeV ))"
-                     #   (P>32*GeV) & (4*GeV<PT) & \
-                     #   (PT<80*GeV) & (2<ETA) & (ETA<5) &\
+FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6*GeV ) &\
+                     (P>32*GeV) & (4*GeV<PT) & \
+                     (PT<80*GeV) & (2<ETA) & (ETA<5) &\
+                     (CHILD(PROBNNpi,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) )"
                      #   (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
                      #   (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
                      #   (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
-- 
GitLab


From 167389ca24cfbfefd11313c8fa43393a830dfbdc Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Mon, 21 Oct 2024 08:36:12 +0200
Subject: [PATCH 07/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 10 +++++-----
 1 file changed, 5 insertions(+), 5 deletions(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index 85295755b9..fa039814d5 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -413,11 +413,11 @@ ResConfig(tuple_LcD0pi.B0)
 ResConfig(tuple_LcD0pi.Lc)
 ResConfig(tuple_LcD0pi.D0)
 
-tuple_LcD0pi.pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
-tuple_LcD0pi.Lc_p.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
-tuple_LcD0pi.Lc_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
-tuple_LcD0pi.D0_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
-tuple_LcD0pi.D0_pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+# tuple_LcD0pi.pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+# tuple_LcD0pi.Lc_p.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+# tuple_LcD0pi.Lc_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+# tuple_LcD0pi.D0_K.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
+# tuple_LcD0pi.D0_pi.addTupleTool("LoKi::Hybrid::TupleTool/KLoKiTool").Variables  = dau_vars()
 TrackConfig(tuple_LcD0pi.pi)
 TrackConfig(tuple_LcD0pi.Lc_p)
 TrackConfig(tuple_LcD0pi.Lc_K)
-- 
GitLab


From f3dc9c4dee2c569ec7bd78cefa842ec33c217f64 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Mon, 21 Oct 2024 13:43:37 +0200
Subject: [PATCH 08/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 13 +++----------
 1 file changed, 3 insertions(+), 10 deletions(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index fa039814d5..76b77f9834 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -277,16 +277,9 @@ DLcdaughter = { "D0" : OrderedDict({'K':1, 'pi':2}), "Lc" : OrderedDict({'p':1,
 FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6*GeV ) &\
                      (P>32*GeV) & (4*GeV<PT) & \
                      (PT<80*GeV) & (2<ETA) & (ETA<5) &\
-                     (CHILD(PROBNNpi,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) )"
-                     #   (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
-                     #   (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
-                     #   (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
-                     #   (CHILD(CHILD(PT,1),1)>300*MeV) & (CHILD(CHILD(PT,2),1)>150*MeV) & (CHILD(CHILD(PT,1),2)>150*MeV) &\
-                     #   (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
-                     #   (CHILD(DOCA(1,2),1)<0.3*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
-                     #   (CHILD(PROBNNk,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) &\
-                     #   (CHILD(BPVVD,1)>1.8*mm) & (CHILD(BPVVD,2)>2.0*mm) & ((CHILD(VFASPF(VZ),1) - VFASPF(VZ))>-3*mm) & ((CHILD(VFASPF(VZ),2) - VFASPF(VZ))>-2*mm)"
-
+                     (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
+                     (CHILD(DOCA(1,2),1)<0.4*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
+                     (CHILD(PROBNNpi,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) )"
 
 
 LcD0pi_sel = Selection("Sel_LcD0pi",
-- 
GitLab


From 7fb89835363512c9a645dc189b3d62c5ed0eae0a Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Mon, 21 Oct 2024 13:44:50 +0200
Subject: [PATCH 09/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index 76b77f9834..89cd8b71c6 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -9,7 +9,7 @@ elif backend=="forAP":
 
 
 ###############################################################
-######################## dv_opts.py ########################
+######################## Lb2LcD0pi.py ########################
 ###############################################################
 
 
@@ -31,7 +31,7 @@ DaVinci().RootInTES  = '/Event/Bhadron'
 
 
 ###############################################################
-######################## generation.py ########################
+######################## Lb2LcD0pi.py ########################
 ###############################################################
 
 
-- 
GitLab


From cdf0fa425ca2baa5869005225ac4ed5b2cfcc574 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Tue, 22 Oct 2024 03:59:34 +0200
Subject: [PATCH 10/11] Update file Lb2LcD0pi.py

---
 Lb2LcD0pi/Lb2LcD0pi.py | 6 +++++-
 1 file changed, 5 insertions(+), 1 deletion(-)

diff --git a/Lb2LcD0pi/Lb2LcD0pi.py b/Lb2LcD0pi/Lb2LcD0pi.py
index 89cd8b71c6..1b7da5d50e 100644
--- a/Lb2LcD0pi/Lb2LcD0pi.py
+++ b/Lb2LcD0pi/Lb2LcD0pi.py
@@ -279,7 +279,11 @@ FilterLcD0pi.Code = "((M > 5.1*GeV) & ( M < 6*GeV ) &\
                      (PT<80*GeV) & (2<ETA) & (ETA<5) &\
                      (DOCA(1,2)<0.2*mm) & (DOCA(1,3)<0.25*mm) & (DOCA(2,3)<0.25*mm) &\
                      (CHILD(DOCA(1,2),1)<0.4*mm) & (CHILD(DOCA(1,3),1)<0.4*mm) & (CHILD(DOCA(2,3),1)<0.4*mm) & (CHILD(DOCA(1,2),2)<0.4*mm) &\
-                     (CHILD(PROBNNpi,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) )"
+                     (CHILD(PROBNNpi,3)>0.1) & (CHILD(CHILD(PROBNNk,1),2)*CHILD(CHILD(PROBNNpi,2),2)>0.01) & (BPVIPCHI2()<12) & (BPVVD>1.5*mm) &\
+                     (CHILD(P,1)>12*GeV) & (CHILD(P,2)>10*GeV) & (CHILD(P,3)>2.5*GeV) & (CHILD(PT,1)>1*GeV) & (CHILD(PT,2)>800*MeV) & (CHILD(PT,3)>150*MeV) &\
+                     (CHILD(CHILD(P,1),1)>4*GeV) & (CHILD(CHILD(P,2),1)>2.5*GeV) & (CHILD(CHILD(P,3),1)>1.5*GeV) &\
+                     (CHILD(CHILD(P,1),2)>2.5*GeV) & (CHILD(CHILD(P,2),2)>1.5*GeV) &\
+                     (CHILD(CHILD(PT,1),1)>300*MeV) & (CHILD(CHILD(PT,2),1)>150*MeV) & (CHILD(CHILD(PT,1),2)>150*MeV) )"
 
 
 LcD0pi_sel = Selection("Sel_LcD0pi",
-- 
GitLab


From f8043b176ff4134cd0019787df718dfa2804f5d7 Mon Sep 17 00:00:00 2001
From: Chencheng Feng <chencheng.feng@cern.ch>
Date: Wed, 23 Oct 2024 04:15:08 +0200
Subject: [PATCH 11/11] Update file info.yaml

---
 Lb2LcD0pi/info.yaml | 31 +------------------------------
 1 file changed, 1 insertion(+), 30 deletions(-)

diff --git a/Lb2LcD0pi/info.yaml b/Lb2LcD0pi/info.yaml
index c8022fbc07..d7e38ab735 100644
--- a/Lb2LcD0pi/info.yaml
+++ b/Lb2LcD0pi/info.yaml
@@ -10,41 +10,12 @@ defaults:
   output: Lb2LcD0pi.root
 
 
-Lb2LcD0pi_2011_MagUp_jobs:
-  input:
-    bk_query: "/LHCb/Collision11/Beam3500GeV-VeloClosed-MagUp/Real Data/Reco14/Stripping21r1/90000000/BHADRON.MDST"
-Lb2LcD0pi_2012_MagUp_jobs:
-  input:
-    bk_query: "/LHCb/Collision12/Beam4000GeV-VeloClosed-MagUp/Real Data/Reco14/Stripping21/90000000/BHADRON.MDST"
-Lb2LcD0pi_2015_MagUp_jobs:
-  input:    
-    bk_query: "/LHCb/Collision15/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco15a/Stripping24r1/90000000/BHADRON.MDST"
 Lb2LcD0pi_2016_MagUp_jobs:
   input:    
     bk_query: "/LHCb/Collision16/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco16/Stripping28r2/90000000/BHADRON.MDST"
-Lb2LcD0pi_2017_MagUp_jobs:
-  input:    
-    bk_query: "/LHCb/Collision17/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco17/Stripping29r2/90000000/BHADRON.MDST"
-Lb2LcD0pi_2018_MagUp_jobs:
-  input:    
-    bk_query: "/LHCb/Collision18/Beam6500GeV-VeloClosed-MagUp/Real Data/Reco18/Stripping34/90000000/BHADRON.MDST"
 
 
-Lb2LcD0pi_2011_MagDown_jobs:
-  input:
-    bk_query: "/LHCb/Collision11/Beam3500GeV-VeloClosed-MagDown/Real Data/Reco14/Stripping21r1/90000000/BHADRON.MDST"
-Lb2LcD0pi_2012_MagDown_jobs:
-  input:
-    bk_query: "/LHCb/Collision12/Beam4000GeV-VeloClosed-MagDown/Real Data/Reco14/Stripping21/90000000/BHADRON.MDST"
-Lb2LcD0pi_2015_MagDown_jobs:
-  input:
-    bk_query: "/LHCb/Collision15/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco15a/Stripping24r1/90000000/BHADRON.MDST"
+
 Lb2LcD0pi_2016_MagDown_jobs:
   input:
     bk_query: "/LHCb/Collision16/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco16/Stripping28r2/90000000/BHADRON.MDST"
-Lb2LcD0pi_2017_MagDown_jobs:
-  input:
-    bk_query: "/LHCb/Collision17/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco17/Stripping29r2/90000000/BHADRON.MDST"
-Lb2LcD0pi_2018_MagDown_jobs:
-  input:
-    bk_query: "/LHCb/Collision18/Beam6500GeV-VeloClosed-MagDown/Real Data/Reco18/Stripping34/90000000/BHADRON.MDST"
-- 
GitLab