diff --git a/SL_bp_Dstst_e_iso_study/DV.py b/SL_bp_Dstst_e_iso_study/DV.py
new file mode 100644
index 0000000000000000000000000000000000000000..9558885c127158a2923309a18abd9110ae718c2a
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/DV.py
@@ -0,0 +1,463 @@
+import sys,os,math
+from PyConf.reading import get_pvs, get_rec_summary, get_particles
+from PyConf.Algorithms import ThOrParticleSelection
+import Functors as F
+from FunTuple import FunctorCollection
+from FunTuple import FunTuple_Particles as Funtuple
+from DaVinci.algorithms import create_lines_filter
+from DaVinci import Options,make_config
+import FunTuple.functorcollections as FC
+from DaVinciMCTools import MCTruthAndBkgCat
+from Hlt2Conf.algorithms_thor import ParticleCombiner, ParticleFilter
+from Hlt2Conf.algorithms_thor import ParticleContainersMerger
+from Functors.grammar import Functor
+from Hlt2Conf.standard_particles import make_has_rich_long_pions,make_has_rich_up_pions,make_has_rich_down_pions
+import numpy as np
+from Hlt2Conf.lines.semileptonic.isolationMVA import mva_functor_e_inclusive,mva_functor_mu_inclusive
+from .MC_Matcher import trail_seeker
+
+_BPVCORRM = Functor('_BPVCORRM', 'Composite::CorrectedMass','Compute the corrected mass')
+_allpv_FDVEC     = (F.ENDVERTEX_POS @ F.FORWARDARG1 - F.TOLINALG @ F.POSITION @ F.FORWARDARG0)
+_allpv_NORMEDDOT = F.NORMEDDOT.bind(F.THREEMOMENTUM @ F.FORWARDARG1, _allpv_FDVEC)
+ALLPV_CHI2      = lambda Vertices: F.MAP(F.CHI2) @ F.TES(Vertices)
+ALLPV_CHI2DOF   = lambda Vertices: F.MAP(F.CHI2DOF) @ F.TES(Vertices)
+ALLPV_IPCHI2    = lambda Vertices: F.MAP(F.IPCHI2).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_FDCHI2    = lambda Vertices: F.MAP(F.VTX_FDCHI2).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_DIRA      = lambda Vertices: F.MAP(_allpv_NORMEDDOT).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_CORRM     = lambda Vertices: F.MAP(_BPVCORRM).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_LTIME     = lambda Vertices: F.MAP(F.VTX_LTIME).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_DLS       = lambda Vertices: F.MAP(F.VTX_DLS).bind(F.TES(Vertices), F.FORWARDARGS)
+ALLPV_FD_COORDINATE   = lambda coordinate, Vertices: F.MAP(coordinate @ _allpv_FDVEC).bind(F.TES(Vertices), F.FORWARDARGS)
+
+TRUE_ID_IS = lambda id, mctruth: (F.VALUE_OR(0) @ mctruth(F.ABS @ F.PARTICLE_ID) == id)
+
+def make_Bst(B, pions,lepton, hadron_candidate_id,v2_pvs,do_truth_matching = True):
+    if do_truth_matching == True :
+        #filter B keeping only true D0 and true leptons
+        MCTRUTH_B = MCTruthAndBkgCat(B, name='MCTRUTH_Bu')
+        Dz_child  = F.CHILD(1, F.FORWARDARG0) #get the first child of B*- which is D0
+        lep_child = F.CHILD(2, F.FORWARDARG0) #get the second child of B*- which is lepton
+        Dz_truth_cut  = TRUE_ID_IS(hadron_candidate_id, MCTRUTH_B) @ Dz_child #require that D0 is true
+        lep_truth_cut = F.require_any(TRUE_ID_IS(11, MCTRUTH_B) @ lep_child , TRUE_ID_IS(13, MCTRUTH_B) @ lep_child) #require that lepton is true i.e. electron or muon
+        cut_b    = F.require_all(Dz_truth_cut, lep_truth_cut) #make a cut
+        signal_B = ParticleFilter(Input=B, Cut=F.FILTER(cut_b), name='signal_Dzmu') #filter the B candidates
+    else : signal_B = B
+
+    hadron_cut = F.IS_ABS_ID('D0')  # Getting the hadron candidates
+
+    code_hadron = F.FILTER(hadron_cut) @ F.GET_CHILDREN()
+    hadron_TES = ThOrParticleSelection(
+        name="hadron_iso",
+        InputParticles=signal_B,
+        Functor=code_hadron).OutputSelection
+
+    lepton_cut = F.IS_ABS_ID(f'{lepton}-')
+    code_lepton = F.FILTER(lepton_cut) @ F.GET_CHILDREN()
+    lepton_TES = ThOrParticleSelection(
+        name="lepton_iso",
+        InputParticles=signal_B,
+        Functor=code_lepton).OutputSelection
+
+
+    #combine to make [B*- -> D0 lep-]cc
+    Bstm_1 = ParticleCombiner(
+        Inputs=[hadron_TES, lepton_TES],
+        name=f'Bstm_1_{lepton}',
+        DecayDescriptor=f'[B*- -> D0 {lepton}-]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=F.ALL,
+        ParticleCombiner="ParticleVertexFitter",
+        #PrimaryVertices=v2_pvs
+        #OutputLevel=1
+    )
+    #combine to make [B*+ -> D0 lep+]cc
+    Bstm_2 = ParticleCombiner(
+        Inputs=[hadron_TES, lepton_TES],
+        name=f'Bstm_2_{lepton}',
+        DecayDescriptor=f'[B*+ -> D0 {lepton}+]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=F.ALL,
+        ParticleCombiner="ParticleVertexFitter",
+        #PrimaryVertices=v2_pvs
+        #OutputLevel=1
+    )
+    Bstm = ParticleContainersMerger([Bstm_1, Bstm_2], name = f'Bstm_combiner_{lepton}')
+
+    D0_child   = F.CHILD(1, F.CHILD(1,F.FORWARDARG0))
+    Epi_child = F.CHILD(2, F.FORWARDARG0)
+
+    #D* mass - D0 mass cut
+    cut_combine = F.require_all(((F.MASS @ ((F.FOURMOMENTUM @ D0_child)+(F.FOURMOMENTUM @ Epi_child))) - (F.MASS @ D0_child))<160)
+
+    #combine to make [B*0 -> B*- pi+]cc
+    Bst_1 = ParticleCombiner(
+        Inputs=[Bstm, pions],
+        name=f'Bst_1_{lepton}',
+        DecayDescriptor='[B*0 -> B*- pi+]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=F.ALL,
+        ParticleCombiner="ParticleVertexFitter",
+        PrimaryVertices=v2_pvs
+        #OutputLevel=1
+    )
+    #combine to make [B*0 -> B*- pi-]cc
+    Bst_2 = ParticleCombiner(
+        Inputs=[Bstm, pions],
+        name=f'Bst_2_{lepton}',
+        DecayDescriptor='[B*0 -> B*- pi-]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=F.ALL,
+        ParticleCombiner="ParticleVertexFitter",
+        PrimaryVertices=v2_pvs
+        #OutputLevel=1
+    )
+    #merge the two Bst candidates
+    Bst = ParticleContainersMerger([Bst_1, Bst_2], name = f'Bst_combiner_{lepton}')
+    return Bst
+
+def get_functors(MCTRUTH, v2_pvs, rec_summary):
+	#define common variables for all fields (composite and basic)
+	vars_common  = FunctorCollection()
+	#all pvs: ip, ipchi2. The PV positions are stored in event variables
+	vars_common['ALLPV_IP[pv_indx]']     = F.ALLPV_IP(v2_pvs)
+	vars_common['ALLPV_IPCHI2[pv_indx]'] = ALLPV_IPCHI2(v2_pvs)
+	#best pv: x, y, z, ip, ipchi2
+	vars_common['BPV_X']          = F.BPVX(v2_pvs)
+	vars_common['BPV_Y']          = F.BPVY(v2_pvs)
+	vars_common['BPV_Z']          = F.BPVZ(v2_pvs)
+	vars_common['BPV_IP']         = F.BPVIP(v2_pvs)
+	vars_common['BPV_IPCHI2']     = F.BPVIPCHI2(v2_pvs)
+	vars_common['BPV_CHI2']       = F.CHI2 @ F.BPV(v2_pvs)
+	vars_common['BPV_CHI2DOF']    = F.CHI2DOF @ F.BPV(v2_pvs)
+	#particle id, key, truekey. The trueid is stored in MCHierarchy
+	vars_common['ID']            = F.PARTICLE_ID
+	vars_common['KEY']           = F.OBJECT_KEY
+
+	#get charge, min ip and min ipchi2
+	vars_common['CHARGE']        = F.CHARGE
+	vars_common['MINIP']         = F.MINIP(v2_pvs)
+	vars_common['MINIPCHI2']     = F.MINIPCHI2(v2_pvs)
+	#reco kinematics
+	vars_common += FC.Kinematics()
+	vars_common['ETA']           = F.ETA
+	vars_common['PHI']           = F.PHI
+	if MCTRUTH != 'None':
+		#mc vars
+		vars_common['BKGCAT'] = MCTRUTH.BkgCat
+		vars_common['TRUEKEY']       = F.VALUE_OR(-1) @ MCTRUTH(F.OBJECT_KEY)
+		vars_common += FC.MCKinematics(mctruth_alg = MCTRUTH)
+		vars_common['TRUEETA'] = MCTRUTH(F.ETA)
+		vars_common['TRUEPHI'] = MCTRUTH(F.PHI)
+		#type of the origin vertex
+		vars_common['MC_VTX_TYPE'] = MCTRUTH(F.VALUE_OR(-1) @ F.MC_VTX_TYPE @ F.MC_ORIGINVERTEX)
+		#make some helper functions
+		MCMOTHER_ID  = lambda n: F.VALUE_OR(0)  @ MCTRUTH(F.MC_MOTHER(n, F.PARTICLE_ID))
+		MCMOTHER_KEY = lambda n: F.VALUE_OR(-1) @ MCTRUTH(F.MC_MOTHER(n, F.OBJECT_KEY ))
+		vars_common["TRUEID"] = F.VALUE_OR(0) @ MCTRUTH(F.PARTICLE_ID)
+		vars_common["MCKEY"] = F.VALUE_OR(0) @ MCTRUTH(F.OBJECT_KEY)
+		vars_common["MC_MOTHER_ID"] = MCMOTHER_ID(1)
+		vars_common["MC_MOTHER_KEY"] = MCMOTHER_KEY(1)
+		for i in range(2,14):
+		  prefix = "MC_GD_MOTHER_{}".format(i)
+		  vars_common[f"{prefix}_ID"]  = MCMOTHER_ID(i)
+		  vars_common[f"{prefix}_KEY"] = MCMOTHER_KEY(i)
+
+	#variables for composite particles
+	vars_composite  = FunctorCollection()
+	#end vertex position and end vertex chi2
+	vars_composite['ENDVERTEX_POS_']  = F.ENDVERTEX_POS
+	vars_composite['ENDVERTEX_CHI2']  = F.CHI2 @ F.ENDVERTEX
+	vars_composite['ENDVERTEX_CHI2DOF']  = F.CHI2DOF @ F.ENDVERTEX
+	#all pvs: dira, fd, fdchi2
+	vars_composite['ALLPV_DIRA[pv_indx]']   = ALLPV_DIRA(v2_pvs)
+	vars_composite['ALLPV_FD_X[pv_indx]']   = ALLPV_FD_COORDINATE(F.X_COORDINATE, v2_pvs)
+	vars_composite['ALLPV_FD_Y[pv_indx]']   = ALLPV_FD_COORDINATE(F.Y_COORDINATE, v2_pvs)
+	vars_composite['ALLPV_FD_Z[pv_indx]']   = ALLPV_FD_COORDINATE(F.Z_COORDINATE, v2_pvs)
+	vars_composite['ALLPV_FDCHI2[pv_indx]'] = ALLPV_FDCHI2(v2_pvs)
+	vars_composite['ALLPV_CORRM[pv_indx]']  = ALLPV_CORRM(v2_pvs)
+	vars_composite['ALLPV_LTIME[pv_indx]']  = ALLPV_LTIME(v2_pvs)
+	vars_composite['ALLPV_DLS[pv_indx]']    = ALLPV_DLS(v2_pvs)
+	#best pv: dira, fd, fdchi2, corrm, ltime, dls
+	vars_composite['BPV_DIRA']    = F.BPVDIRA(v2_pvs)
+	vars_composite['BPV_FD_']     = F.BPVFDVEC(v2_pvs)
+	vars_composite['BPV_FDCHI2']  = F.BPVFDCHI2(v2_pvs)
+	vars_composite['BPV_CORRM']   = F.BPVCORRM(v2_pvs)
+	vars_composite['BPV_LTIME']   = F.BPVLTIME(v2_pvs)
+	vars_composite['BPV_DLS']     = F.BPVDLS(v2_pvs)
+
+	#mc composite vertex information
+	if MCTRUTH != 'None': vars_composite += FC.MCVertexInfo(mctruth_alg = MCTRUTH)
+	#Compute maximum DOCA and maximum DOCACHI2. Since there are 
+	# only two daughters of B0 particles, the maximum DOCA/DOCACHI2 is 
+	# the DOCA/DOCACHI2 see below.
+	vars_composite['MAX_DOCA'] = F.MAXDOCA
+	vars_composite['MAX_DOCACHI2'] = F.MAXDOCACHI2
+	vars_composite['MAX_SDOCA'] = F.MAXSDOCA
+	vars_composite['MAX_SDOCACHI2'] = F.MAXSDOCACHI2
+
+	#variables for basics
+	vars_basic  = FunctorCollection()
+	vars_basic['TRACKTYPE']    = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKTYPE @ F.TRACK
+	vars_basic['TRACKHISTORY'] = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKHISTORY @ F.TRACK
+	vars_basic['TRACKFLAG']    = F.VALUE_OR(-1) @ F.CAST_TO_INT @ F.TRACKFLAG @ F.TRACK
+	vars_basic['TRACKNDOF']    = F.VALUE_OR(-1) @ F.NDOF @ F.TRACK
+	vars_basic['TRACKCHI2']    = F.CHI2 @ F.TRACK
+	vars_basic['TRACKCHI2DOF'] = F.CHI2DOF @ F.TRACK
+	vars_basic['GHOSTPROB'] = F.GHOSTPROB
+	vars_basic['NHITS'] = F.VALUE_OR(-1) @F.NHITS @ F.TRACK
+	vars_basic['NUTHITS'] = F.VALUE_OR(-1) @F.NUTHITS @ F.TRACK
+	vars_basic['NVPHITS'] = F.VALUE_OR(-1) @F.NVPHITS @ F.TRACK
+	vars_basic['NFTHITS'] = F.VALUE_OR(-1) @ F.NFTHITS @ F.TRACK
+	vars_basic['TRACKHASUT'] = F.VALUE_OR(-1) @ F.TRACKHASUT @ F.TRACK
+	vars_basic['TRACKHASVELO'] = F.VALUE_OR(-1) @ F.TRACKHASVELO @ F.TRACK
+	vars_basic['PIDpi'] = F.PID_PI
+	vars_basic['PIDk']  = F.PID_K
+	vars_basic['PIDp']  = F.PID_P
+	vars_basic['PIDe']  = F.PID_E
+	vars_basic['PIDmu'] = F.PID_MU
+	vars_basic['PROBNNe'] = F.PROBNN_E
+	vars_basic['PROBNNpi'] = F.PROBNN_PI
+	vars_basic['PROBNNk'] = F.PROBNN_K
+	vars_basic['PROBNNmu'] = F.PROBNN_MU
+	vars_basic['PROBNNp'] = F.PROBNN_P
+	vars_basic['PROBNNghost'] = F.PROBNN_GHOST
+	if MCTRUTH != 'None': vars_basic += FC.MCVertexInfo(mctruth_alg = MCTRUTH)
+
+	#variables for event
+	#Collection includes tis_tos, nPVs,nHits/clusters,BUNCHCROSSING and GPS var
+	evt_collections = [
+		FC.EventInfo(),
+		FC.RecSummary(),
+	]
+	evt_vars = FunctorCollection({})
+	evt_vars['ALLPV_X[pv_indx]']      = F.ALLPVX(v2_pvs)
+	evt_vars['ALLPV_Y[pv_indx]']      = F.ALLPVY(v2_pvs)
+	evt_vars['ALLPV_Z[pv_indx]']      = F.ALLPVZ(v2_pvs)
+	evt_vars['ALLPV_CHI2[pv_indx]']   = ALLPV_CHI2(v2_pvs)
+	evt_vars['ALLPV_CHI2DOF[pv_indx]']= ALLPV_CHI2DOF(v2_pvs)
+
+	for coll in evt_collections:evt_vars += coll
+
+	vars_brems = FunctorCollection({})
+	vars_brems.update({"HASBREM": F.HASBREM})
+	#vars_brems.update({"HASBREMADDED": F.HASBREMADDED})
+	vars_brems.update({"BREMENERGY": F.BREMENERGY})
+	vars_brems.update({"BREMBENDCORR": F.BREMBENDCORR})
+	vars_brems.update({"BREMPIDE": F.BREMPIDE})
+	vars_brems.update({"ECALPIDE": F.ECALPIDE})
+	vars_brems.update({"ECALPIDMU": F.ECALPIDMU})
+	vars_brems.update({"HCALPIDE": F.HCALPIDE})
+	vars_brems.update({"HCALPIDMU": F.HCALPIDMU})
+	vars_brems.update({"ELECTRONSHOWEREOP": F.ELECTRONSHOWEREOP})
+	vars_brems.update({"ELECTRONSHOWERDLL": F.ELECTRONSHOWERDLL})
+	vars_brems.update({"CLUSTERMATCH": F.CLUSTERMATCH_CHI2})
+	vars_brems.update({"ELECTRONMATCH": F.ELECTRONMATCH_CHI2})
+	vars_brems.update({"BREMHYPOMATCH": F.BREMHYPOMATCH_CHI2})
+	vars_brems.update({"ELECTRONENERGY": F.ELECTRONENERGY})
+	vars_brems.update({"BREMHYPOENERGY": F.BREMHYPOENERGY})
+	vars_brems.update({"BREMHYPODELTAX": F.BREMHYPODELTAX})
+	#vars_brems.update({"BREMTRACKBASEDENERGY": F.BREMTRACKBASEDENERGY})
+	vars_brems.update({"INBREM": F.INBREM})
+	vars_brems.update({"INECAL": F.INECAL})
+	vars_brems.update({"PT_WITH_BREM": F.PT_WITH_BREM})
+	vars_brems.update({"P_WITH_BREM": F.P_WITH_BREM})
+
+	#return all functors
+	functors = (vars_common, vars_composite, vars_basic, evt_vars,vars_brems)
+	return functors
+
+def get_fitting_variable(v2_pvs,D0,lep):
+
+	B_dis = np.array([F.END_VX-F.BPVX(v2_pvs),F.END_VY-F.BPVY(v2_pvs),F.END_VZ-F.BPVZ(v2_pvs)])
+	B_dis_mag = F.SQRT @ (B_dis[0]**2+B_dis[1]**2+B_dis[2]**2)
+	B_Mod_P = F.ABS @ ((5279.65/F.MASS)*F.PZ/(B_dis[2]/B_dis_mag))
+	B_Mod_E = F.SQRT @ (B_Mod_P**2 + 5279.65**2)
+	B_4P = np.array([B_Mod_P*B_dis[0]/B_dis_mag,B_Mod_P*B_dis[1]/B_dis_mag,B_Mod_P*B_dis[2]/B_dis_mag,B_Mod_E])
+	D_4P = np.array([F.PX @ D0,F.PY @ D0,F.PZ @ D0,F.ENERGY @ D0])
+	lep_4P = np.array([F.PX @ lep,F.PY @ lep,F.PZ @ lep,F.ENERGY @ lep])
+
+	vars_fitting = FunctorCollection({})
+	vars_fitting["Mod_P"] = B_Mod_P
+	vars_fitting['missing_m2'] = (B_4P[3]-D_4P[3]-lep_4P[3])**2-(B_4P[0]-D_4P[0]-lep_4P[0])**2-(B_4P[1]-D_4P[1]-lep_4P[1])**2-(B_4P[2]-D_4P[2]-lep_4P[2])**2
+	vars_fitting['q2'] = (B_4P[3]-D_4P[3])**2-(B_4P[0]-D_4P[0])**2-(B_4P[1]-D_4P[1])**2-(B_4P[2]-D_4P[2])**2
+	B_Beta = B_Mod_P/B_Mod_E
+	B_gamma = 1/F.SQRT @ (1-B_Beta**2)
+
+	B_Lorentz = [[B_gamma,-1*B_gamma*B_4P[0]/B_4P[3],-1*B_gamma*B_4P[1]/B_4P[3],-1*B_gamma*B_4P[2]/B_4P[3]],[-1*B_gamma*B_4P[0]/B_4P[3],1+(B_gamma-1)*((B_4P[0]/B_4P[3])/B_Beta)*((B_4P[0]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[0]/B_4P[3])/B_Beta)*((B_4P[1]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[0]/B_4P[3])/B_Beta)*((B_4P[2]/B_4P[3])/B_Beta)],[-1*B_gamma*B_4P[1]/B_4P[3],(B_gamma-1)*((B_4P[0]/B_4P[3])/B_Beta)*((B_4P[1]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[1]/B_4P[3])/B_Beta)*((B_4P[1]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[1]/B_4P[3])/B_Beta)*((B_4P[2]/B_4P[3])/B_Beta)],[-1*B_gamma*B_4P[2]/B_4P[3],(B_gamma-1)*((B_4P[0]/B_4P[3])/B_Beta)*((B_4P[2]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[1]/B_4P[3])/B_Beta)*((B_4P[2]/B_4P[3])/B_Beta),(B_gamma-1)*((B_4P[2]/B_4P[3])/B_Beta)*((B_4P[2]/B_4P[3])/B_Beta)]]
+	vars_fitting['lep_E_Brest'] = (B_Lorentz[0][0]*lep_4P[3]+B_Lorentz[0][1]*lep_4P[0]+B_Lorentz[0][2]*lep_4P[1]+B_Lorentz[0][3]*lep_4P[2])
+	return(vars_fitting)
+
+def tuple_Bst(Bst,lepton,line, MCTRUTH, v2_pvs, rec_summary):
+    #get functors
+    functors = get_functors(MCTRUTH, v2_pvs, rec_summary)
+    vars_common = functors[0]
+    vars_composite = functors[1]
+    vars_basic = functors[2]
+    evt_vars = functors[3]
+    vars_brems = functors[4]
+
+    #variables for B0 field
+    vars_Bst  = FunctorCollection()
+    B_child   = F.CHILD(1, F.FORWARDARG0)
+    D0_child   = F.CHILD(1, F.CHILD(1,F.FORWARDARG0))
+    Lep_child   = F.CHILD(1, F.CHILD(2,F.FORWARDARG0))
+    Epi_child = F.CHILD(2, F.FORWARDARG0)
+    bpv_pi    = F.BPV(v2_pvs).bind(Epi_child)
+    #diff in vtx chi2 with and without extra particle
+    vars_Bst['DELTA_ENDVERTEX_CHI2']    = (F.CHI2 @ F.ENDVERTEX) - (F.CHI2 @ F.ENDVERTEX.bind(B_child))
+    #IP and IPChi2 of extra particle wrt to B0 end vertex
+    vars_Bst['Epi_IP_WRT_B0ENDVERTEX']     = F.IP.bind(F.TOLINALG @ F.POSITION @ F.ENDVERTEX @ F.FORWARDARG0  , Epi_child)
+    vars_Bst['Epi_IPCHI2_WRT_B0ENDVERTEX'] = F.IPCHI2.bind(F.ENDVERTEX @ F.FORWARDARG0  , Epi_child)
+    #IP and IPChi2 of extra particle wrt to Bm end vertex
+    vars_Bst['Epi_IP_WRT_BmENDVERTEX']     = F.IP.bind(F.TOLINALG @ F.POSITION @ F.ENDVERTEX @ B_child  , Epi_child)
+    vars_Bst['Epi_IPCHI2_WRT_BmENDVERTEX'] = F.IPCHI2.bind(F.ENDVERTEX @ B_child  , Epi_child)
+    #angle between extra particle and Bm
+    vars_Bst['Epi_COSANGLE_Bm']         = F.COSANGLE.bind(F.THREEMOMENTUM @ B_child, F.THREEMOMENTUM @ Epi_child)
+    #diff in fd chi2 with and without extra particle
+    vars_Bst['Delta_BPV_of_Epi_FDCHI2']   = F.VTX_FDCHI2.bind(bpv_pi, F.FORWARDARGS) - F.VTX_FDCHI2.bind(bpv_pi, B_child)
+    vars_Bst['BPV_of_Epi_FDCHI2']         = F.VTX_FDCHI2.bind(bpv_pi, F.FORWARDARGS)
+    #IP chi2 of extra particle wrt PV and SV of B0
+    vars_Bst['Epi_IP_WRT_B0BPV']         = F.IP.bind(F.TOLINALG @ F.POSITION @ F.BPV(v2_pvs) @ F.FORWARDARG0, Epi_child)
+    vars_Bst['Epi_IPCHI2_WRT_B0BPV']     = F.IPCHI2.bind(F.BPV(v2_pvs) @ F.FORWARDARG0, Epi_child)
+    #IP chi2 of extra particle wrt PV and SV of Bm
+    vars_Bst['Epi_IP_WRT_BmBPV']         = F.IP.bind(F.TOLINALG @ F.POSITION @ F.BPV(v2_pvs) @ B_child, Epi_child)
+    vars_Bst['Epi_IPCHI2_WRT_BmBPV']     = F.IPCHI2.bind(F.BPV(v2_pvs) @ B_child, Epi_child)
+    #DOCA and DOCACHI2 b/w Lb and extra particle
+    vars_Bst['DOCA12']       = F.DOCA(1, 2)
+    vars_Bst['DOCA12_CHI2_12']  = F.DOCACHI2(1, 2)
+    #vars_Bst['SDOCA12']      = F.SDOCA(1, 2)
+    #vars_Bst['SDOCA_CHI2_12'] = F.SDOCACHI2(1, 2)
+    #DOCACHI2 of extra particle wrt to mother i.e. B0
+    vars_Bst['MTDOCACHI2_1'] = F.MTDOCACHI2(1, v2_pvs)
+    vars_Bst['MTDOCACHI2_2'] = F.MTDOCACHI2(2, v2_pvs)
+    vars_Bst['Delta_M'] = F.ABS @ ((F.MASS @ ((F.FOURMOMENTUM @ D0_child)+(F.FOURMOMENTUM @ Epi_child))) - (F.MASS @ D0_child))
+    #vars_Bst['iso_mva'] = mva_functor_mu_inclusive(v2_pvs)[0]
+    if MCTRUTH != 'None': 
+        vars_Bst += trail_seeker(MCTRUTH)
+    elif MCTRUTH == 'None':
+        vars_Bst['iso_mva'] = mva_functor_mu_inclusive(v2_pvs)[0]
+
+    #define fields
+    fit_vars = get_fitting_variable(v2_pvs,D0_child,Lep_child)
+    #TIS and TOS
+    Hlt1_decisions = ['Hlt1TrackMVA',
+    'Hlt1TwoTrackMVA',
+    'Hlt1D2KK',
+    'Hlt1D2KPi',
+    'Hlt1D2PiPi',
+    'Hlt1KsToPiPi',
+    'Hlt1TrackMuonMVA',
+    'Hlt1SingleHighPtMuon',
+    'Hlt1TrackElectronMVA',
+    'Hlt1SingleHighPtElectron',
+    'Hlt1DiElectronDisplaced',
+    'Hlt1DiPhotonHighMass',
+    'Hlt1Pi02GammaGamma',
+    'Hlt1DiElectronHighMass_SS',
+    'Hlt1DiElectronHighMass']
+    variables_tistos_hlt1 = FC.HltTisTos(selection_type="Hlt1", trigger_lines=Hlt1_decisions, data=Bst)
+    evt_vars += FC.SelectionInfo(selection_type="Hlt1", trigger_lines=Hlt1_decisions)
+
+    Hlt2_decisions = ['Hlt2SLB_BuToD0MuNu_D0ToKPi',
+    'Hlt2SLB_BuToD0MuNu_D0ToKPi_FakeMuon',
+    'Hlt2SLB_BuToD0ENu_D0ToKPi',
+    'Hlt2SLB_BuToD0ENu_D0ToKPi_FakeElectron',
+    'Hlt2SLB_B0ToDpTauNu_DpToKPiPi_TauToENuNu',
+    'Hlt2SLB_B0ToDpTauNu_DpToKPiPi_TauToMuNuNu',
+    'Hlt2SLB_BuToD0TauNu_D0ToKPi_TauToENuNu',
+    'Hlt2SLB_BuToD0TauNu_D0ToKPi_TauToMuNuNu',
+    'Hlt2SLB_BuToD0TauNu_D0ToKPi_FakeMuon',
+    'Hlt2SLB_BuToD0TauNu_D0ToKPi_FakeElectron',
+    'Hlt2SLB_myBuToD0ENu_D0ToKPi',
+    'Hlt2Topo2Body',
+    'Hlt2Topo3Body']
+
+    variables_tistos_hlt2 = FC.HltTisTos(selection_type="Hlt2", trigger_lines=Hlt2_decisions, data=Bst)
+    evt_vars += FC.SelectionInfo(selection_type="Hlt2", trigger_lines=Hlt2_decisions)
+
+
+    #define fields
+    fields = {}
+    fields['B0']    = f'[B*0 ->  (B*- ->  ([D0 -> K- pi+]CC)  {lepton}-)  [pi+]CC]CC'
+    fields['Bm']    = f'[B*0 -> ^(B*- ->  ([D0 -> K- pi+]CC)  {lepton}-)  [pi+]CC]CC'
+    fields['D0']    = f'[B*0 ->  (B*- -> ^([D0 -> K- pi+]CC)  {lepton}-)  [pi+]CC]CC'
+    fields['Lep']   = f'[B*0 ->  (B*- ->  ([D0 -> K- pi+]CC) ^{lepton}-)  [pi+]CC]CC'
+    fields['Epi']   = f'[B*0 ->  (B*- ->  ([D0 -> K- pi+]CC)  {lepton}-) ^[pi+]CC]CC'
+    fields['Km']   = f'[B*0 ->  (B*- ->  ([D0 -> ^K- pi+]CC)  {lepton}-) [pi+]CC]CC'
+    fields['pip']   = f'[B*0 ->  (B*- ->  ([D0 -> K- ^pi+]CC)  {lepton}-) [pi+]CC]CC'
+
+    #add variables
+    variables = {}
+    variables["ALL"] = vars_common + variables_tistos_hlt1 + variables_tistos_hlt2
+    variables["B0"]  = vars_composite + vars_Bst + fit_vars
+    variables["Bm"]  = vars_composite
+    variables["D0"]  = vars_composite
+    variables["Lep"] = vars_basic + vars_brems
+    variables["Epi"] = vars_basic
+    variables["Km"] = vars_basic
+    variables["pip"] = vars_basic
+
+    #define tuple
+    my_tuple = Funtuple(
+        name=f"Tuple",
+        tuple_name="DecayTree",
+        fields=fields,
+        variables=variables,
+        event_variables=evt_vars,
+        store_multiple_cand_info=True,
+        inputs=Bst)
+
+    return my_tuple
+
+def get_extra_pions():
+	"""
+	Note this function in DaVinci requires:
+	https://gitlab.cern.ch/lhcb/Moore/-/merge_requests/3203
+	and it's related LHCb, DaVinci and Rec MRs
+	"""
+	long_pions = make_has_rich_long_pions()
+	up_pions = make_has_rich_up_pions()
+	down_pions = make_has_rich_down_pions()
+	return ParticleContainersMerger([long_pions, up_pions, down_pions],
+									name='Pions_combiner')
+
+#def main(options):
+def main(options: Options,line = '', lep='',data_or_mc='mc'):
+
+    #define filer
+    my_filter = create_lines_filter(name="Filter", lines=[line])
+
+    #get data and extra particles
+    Bm = get_particles(f"/Event/Spruce/{line}/Particles")
+    extra_particles = get_extra_pions()
+    #extra_particles = get_particles(f"/Event/Spruce/{line}/{line}_extra_tracks/Particles")
+
+    #get v2_pvs and rec_summary
+    v2_pvs  = get_pvs()
+    rec_summary = get_rec_summary()
+    hadron_candidate_id = 421
+    #make B0 candidate
+    Bst = make_Bst(Bm, extra_particles,lep,hadron_candidate_id,v2_pvs,False)
+
+    if data_or_mc == 'mc':
+        MCTRUTH_Bst = MCTruthAndBkgCat(Bst, name='MCTRUTH_Bst')
+        tuple_file = tuple_Bst(Bst,lep,line, MCTRUTH_Bst, v2_pvs, rec_summary)
+    elif data_or_mc == 'data':
+        tuple_file = tuple_Bst(Bst,lep,line, 'None', v2_pvs, rec_summary)
+    else:
+        raise ValueError(f"Decay channel {decay_channel} not supported")
+    #define algorithms
+    user_algorithms = {}
+    user_algorithms['Alg'] = [my_filter, tuple_file]
+
+    return make_config(options, user_algorithms)
+
+def test(options: Options):
+	return main(options=options, line='Hlt2_Test_line',lep='e',data_or_mc='data')
+
+def MC_SLB_BuToDststENu(options: Options):
+	return main(options=options, line='SpruceSLB_myBuToD0ENu_D0ToKPi',lep='e',data_or_mc='mc')
+
+def MC_SLB_BuToDststTauNu_TauToENuNu(options: Options):
+	return main(options=options, line='SpruceSLB_myBuToD0ENu_D0ToKPi',lep='e',data_or_mc='mc')
+
diff --git a/SL_bp_Dstst_e_iso_study/Hlt1.py b/SL_bp_Dstst_e_iso_study/Hlt1.py
new file mode 100644
index 0000000000000000000000000000000000000000..eeabcc4913969696ef5d4bd3643c01259a77c9a1
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/Hlt1.py
@@ -0,0 +1,18 @@
+###############################################################################
+# (c) Copyright 2022 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.                                       #
+###############################################################################
+from Moore import Options
+from Moore.config import run_allen
+from RecoConf.hlt1_allen import allen_gaudi_config as allen_sequence
+
+def main(options: Options):
+    with allen_sequence.bind(sequence="hlt1_pp_matching_no_ut_1000KHz"):
+        return run_allen(options)
+
diff --git a/SL_bp_Dstst_e_iso_study/Hlt2.py b/SL_bp_Dstst_e_iso_study/Hlt2.py
new file mode 100644
index 0000000000000000000000000000000000000000..be2bda5d70807b4af7300106a18fd732c1c48b5a
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/Hlt2.py
@@ -0,0 +1,155 @@
+###############################################################################
+# (c) Copyright 2022 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.                                       #
+###############################################################################
+"""
+Stolen and adapted from Hlt/Hlt2Conf/options/hlt2_pp_expected_24_without_UT.py from v55r7.
+"""
+from Moore import Options,options, run_moore, config
+from Hlt2Conf.algorithms_thor import ParticleContainersMerger
+from Hlt2Conf.lines.semileptonic.builders import sl_line_prefilter
+from Hlt2Conf.lines.semileptonic.builders.base_builder import make_candidate
+from Hlt2Conf.lines.semileptonic.builders.charm_hadron_builder import make_d0_tokpi
+from GaudiKernel.SystemOfUnits import MeV, GeV,mm
+from Hlt2Conf.algorithms_thor import ParticleCombiner
+from Hlt2Conf.settings.defaults import get_default_hlt1_filter_code_for_hlt2
+from Hlt2Conf.lines.semileptonic import all_lines as slb_lines  
+from Hlt2Conf.lines.topological_b import all_lines as topo_lines
+from Moore.config import Hlt2Line,register_line_builder
+from Moore.streams import Stream, Streams, DETECTORS
+from RecoConf.event_filters import require_gec
+from RecoConf.global_tools import stateProvider_with_simplified_geom, trackMasterExtrapolator_with_simplified_geom
+from RecoConf.hlt2_global_reco import reconstruction as hlt2_reconstruction, make_light_reco_pr_kf_without_UT
+from RecoConf.reconstruction_objects import reconstruction,make_pvs
+from RecoConf.decoders import default_ft_decoding_version,default_VeloCluster_source
+from RecoConf.hlt2_tracking import (
+    make_TrackBestTrackCreator_tracks,
+    make_PrKalmanFilter_noUT_tracks,
+    make_PrKalmanFilter_Velo_tracks,
+    make_PrKalmanFilter_Seed_tracks,
+)
+from Hlt2Conf.standard_particles import (
+    make_long_electrons_with_brem,
+    make_has_rich_long_pions, 
+    make_has_rich_up_pions, 
+    make_has_rich_down_pions)
+import Functors as F
+from Functors.math import in_range
+import sys
+
+#things to control
+SUFFIX_NAME = '_BToDzl'
+HLT2LINE = f'Hlt2SLB_myBuToD0ENu_D0ToKPi'
+CHARM_MASS = 1864.84 #D0 mass
+CHARM_BUILDER_NAME = 'Dz2KPi_combiner'
+B_BUILDER_NAME     = 'BToDzl_combiner'
+
+def get_charm_cuts():
+    #make loose cuts for D0
+    delta_mass   = 80. #80.0
+    make_d0tokpi_cuts  = {}
+    make_d0tokpi_cuts['comb_m_min']            = (CHARM_MASS - delta_mass) * MeV
+    make_d0tokpi_cuts['comb_m_max']            = (CHARM_MASS + delta_mass) * MeV
+    make_d0tokpi_cuts['comb_docachi2_max']     = 5.
+    make_d0tokpi_cuts['vchi2pdof_max']         = 6   #6 (Now) 6/4 (v55r7 e/taue)
+    make_d0tokpi_cuts['bpvfdchi2_min']         = 25  #25 (Now)
+    make_d0tokpi_cuts['bpvdira_min']           = 0.99  #0.99 (Now) 0.99/0.999 (v55r7 e/taue)
+    make_d0tokpi_cuts['comb_pt_min']           = None #None (Now) None/2000 * MeV (v55r7 e/taue)
+    make_d0tokpi_cuts['comb_pt_any_min']       = None #None (Now) None/800 * MeV (v55r7 e/taue)
+    make_d0tokpi_cuts['comb_pt_sum_min']       = None #None (Now) None/2.5 * GeV (v55r7 e/taue)
+    make_d0tokpi_cuts['comb_doca_max']         = None #None (Now) None/0.1 mm (v55r7 e/taue)
+    make_d0tokpi_cuts['daughter_pt_min']       = 600 * MeV #600 * MeV (Now) 750 * MeV (v55r7)
+    make_d0tokpi_cuts['daughter_mipchi2_min']  = 9. #10. (Now) 10./9. (v55r7 e/taue)
+    make_d0tokpi_cuts['kaon_pid']              = (F.PID_K > 0.) #(F.PID_K > 0.) (Now) (F.PID_K > 4.) (v55r7) 
+    make_d0tokpi_cuts['pion_pid']              = (F.PID_K < 2.)
+    return make_d0tokpi_cuts
+
+def get_electron_cuts():
+    #make loose cuts for electron and tauonic muon
+    make_electron_cuts = {}
+    make_electron_cuts["p_min"]           = 3. * GeV #3. * GeV (Now) 5. *GeV (v55r7)
+    make_electron_cuts["pt_min"]          = 300. * MeV #300. * MeV (Now) 500. * MeV (v55r7)
+    make_electron_cuts["mipchi2_min"]     = 9. #9. (Now) 9./16. (v55r7 e/taue) 
+    make_electron_cuts["mip_min"]         = None #0.
+    make_electron_cuts["pid"]             = (F.PID_E > 0.) 
+    make_electron_cuts["make_particles"]  = make_long_electrons_with_brem  #does not require in calo
+    return make_electron_cuts
+
+def make_b():
+    make_d0tokpi_cuts = get_charm_cuts()
+    make_electron_cuts= get_electron_cuts()
+    pvs = make_pvs()
+    with make_candidate.bind(p_min=15. * GeV): 
+        dzs = make_d0_tokpi(**make_d0tokpi_cuts, name = CHARM_BUILDER_NAME)
+    electrons = make_candidate(**make_electron_cuts, name = "Electron_maker")
+
+    cut_vertex = F.require_all(F.CHI2DOF<9,F.BPVDIRA(pvs) >0.999,in_range(0 * MeV, F.MASS, 10000 * MeV))
+
+    rs_btodze  =  ParticleCombiner(
+        Inputs=[dzs, electrons],
+        name=f'rs_{B_BUILDER_NAME}_e',
+        DecayDescriptor='[B- -> D0 e-]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=cut_vertex)
+
+    ws_btodze  =  ParticleCombiner(
+        Inputs=[dzs, electrons],
+        name=f'ws_{B_BUILDER_NAME}_e',
+        DecayDescriptor='[B+ -> D0 e+]cc',
+        CombinationCut=F.ALL,
+        CompositeCut=cut_vertex)
+
+    return ParticleContainersMerger([rs_btodze,ws_btodze])
+
+@register_line_builder(slb_lines)
+def hlt2_mybutod0enu_d0tokpi_line(name=HLT2LINE,prescale=1):
+    Bcands = make_b()
+    return Hlt2Line(name=name, prescale=prescale,persistreco=True, algs=sl_line_prefilter() + [Bcands])
+
+def pass_through_line(name="Hlt2Passthrough"):
+    """Return a HLT2 line that performs no selection but runs and persists the reconstruction
+    """
+    return Hlt2Line(name=name, prescale=1, algs=[], persistreco=True)
+
+from Hlt2Conf.lines.topological_b import *
+
+def _make_lines():
+    ret = []     
+    for line_dict in [slb_lines]: 
+        for line_name, builder in line_dict.items() : 
+            if "D0ToKPi" in line_name and "TauToPiPiPi" not in line_name and "Bc" not in line_name: 
+                print(line_name)
+                ret.append(builder())
+    ret += [twobody_line(),threebody_line(),pass_through_line()]
+    return ret   
+
+def make_streams():
+    streams = [
+        Stream(lines=_make_lines(), routing_bit=98, detectors=DETECTORS)
+    ]
+    return Streams(streams=streams)
+
+public_tools = [
+    trackMasterExtrapolator_with_simplified_geom(),
+    stateProvider_with_simplified_geom(),
+]
+
+def main(options: Options):
+    # NOTE: the TBTC does not apply a chi2 cut because it is applied by the PrKF
+    with reconstruction.bind(from_file=False),\
+         hlt2_reconstruction.bind(make_reconstruction=make_light_reco_pr_kf_without_UT),\
+         require_gec.bind(skipUT=True),\
+         default_VeloCluster_source.bind(bank_type="VPRetinaCluster"),\
+         make_TrackBestTrackCreator_tracks.bind(max_ghost_prob=0.7, max_chi2ndof=sys.float_info.max),\
+         make_PrKalmanFilter_Velo_tracks.bind(max_chi2ndof=5.),\
+         make_PrKalmanFilter_noUT_tracks.bind(max_chi2ndof=4.),\
+         make_PrKalmanFilter_Seed_tracks.bind(max_chi2ndof=6.),\
+         get_default_hlt1_filter_code_for_hlt2.bind(code=r"Hlt1(?!PassthroughLargeEvent).*Decision"):
+        return run_moore(options, make_streams, public_tools=[])
+
diff --git a/SL_bp_Dstst_e_iso_study/MC_Matcher.py b/SL_bp_Dstst_e_iso_study/MC_Matcher.py
new file mode 100644
index 0000000000000000000000000000000000000000..e3b279805b24fb3c9f3bce2fe8827e98c23a5e25
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/MC_Matcher.py
@@ -0,0 +1,26 @@
+from FunTuple import FunctorCollection
+import Functors as F
+def trail_seeker(MCTRUTH):
+	mcMatch = lambda decay_descriptor: (F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor)))
+	mcMatch_both = lambda decay_descriptor1,decay_descriptor2: (F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor1))+F.HAS_VALUE @ MCTRUTH(F.FIND_MCDECAY(decay_descriptor2)))
+	
+	variables = FunctorCollection({
+		'IS_Dtaunu':mcMatch_both("[B0 -> D*(2010)- tau+ nu_tau]CC","[B~0 -> D*(2010)- tau+ nu_tau]CC"),
+		'IS_Denu':mcMatch_both("[B0 -> D*(2010)- e+ nu_e]CC","[B~0 -> D*(2010)- e+ nu_e]CC"),	
+		'IS_Dstar_2460enu':mcMatch_both("[B0 -> D*(2640)- e+ nu_e]CC","[B~0 -> D*(2640)- e+ nu_e]CC"),
+		'IS_D_2Senu':mcMatch_both("[B0 -> D(2S)- e+ nu_e]CC","[B~0 -> D(2S)- e+ nu_e]CC"),
+		'IS_Dstar_2460_2enu':mcMatch_both("[B0 -> D*_2(2460)- e+ nu_e]CC","[B~0 -> D*_2(2460)- e+ nu_e]CC"),
+		'IS_D_2460_1enu':mcMatch_both("[B0 -> D_1(2420)- e+ nu_e]CC","[B~0 -> D_1(2420)- e+ nu_e]CC"),
+		'IS_Dstar_0taunu':mcMatch_both("[B0 -> D*_0- tau+ nu_tau]CC","[B~0 -> D*_0- tau+ nu_tau]CC"),
+		'IS_D_H_1taunu':mcMatch_both("[B0 -> D_1(H)- tau+ nu_tau]CC","[B~0 -> D_1(H)- tau+ nu_tau]CC"),
+		'IS_D_2420_1taunu':mcMatch_both("[B0 -> D_1(2420)- tau+ nu_tau]CC","[B~0 -> D_1(2420)- tau+ nu_tau]CC"),
+		'IS_Dstar_2460_2taunu':mcMatch_both("[B0 -> D*_2(2460)- tau+ nu_tau]CC","[B~0 -> D*_2(2460)- tau+ nu_tau]CC"),
+		'IS_Dstar0_2640enu':mcMatch("[B- -> D*(2640)0 e- nu_e~]CC"),	
+		'IS_D0_2Senu':mcMatch("[B- -> D(2S)0 e- nu_e~]CC"),	
+		'IS_Dstar0_2460_2enu':mcMatch("[B- -> D*_2(2460)0 e- nu_e~]CC"),	
+		'IS_D0_2460_1enu':mcMatch("[B- -> D_1(2420)0 e- nu_e~]CC"),	
+		'IS_D0_H_1taunu':mcMatch("[B- -> D_1(H)0 tau- nu_tau~]CC"),	
+		'IS_D0_2420_1taunu':mcMatch("[B- -> D_1(2420)0 tau- nu_tau~]CC"),	
+		'IS_Dstar0_2460_2taunu':mcMatch("[B- -> D*_2(2460)0 tau- nu_tau~]CC"),	
+		})
+	return(variables)
diff --git a/SL_bp_Dstst_e_iso_study/Spruce.py b/SL_bp_Dstst_e_iso_study/Spruce.py
new file mode 100644
index 0000000000000000000000000000000000000000..964714aba8759d2d16fdcd41f7e0e2a4a8ee770d
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/Spruce.py
@@ -0,0 +1,58 @@
+###############################################################################
+# (c) Copyright 2022 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.                                       #
+###############################################################################
+#Example follows from hlt2_with_hlt1_decision.py
+from Moore import Options,options, run_moore, config
+from Hlt2Conf.lines.semileptonic.builders import sl_line_prefilter
+from Moore.config import SpruceLine,register_line_builder
+from .Hlt2 import make_b
+from Moore.streams import DETECTORS, Stream, Streams
+from PyConf.application import configure_input, configure, default_raw_event
+from RecoConf.global_tools import stateProvider_with_simplified_geom
+from RecoConf.reconstruction_objects import reconstruction
+from PyConf.reading import reconstruction as reco_spruce, upfront_reconstruction as upfront_spruce
+from RecoConf.decoders import default_ft_decoding_version
+from Hlt2Conf.lines.semileptonic.spruce_semileptonic import spruce_butod0munu_d0tokpi_line,spruce_butod0taunu_d0tokpi_tautomununu_line
+from Hlt2Conf.lines.semileptonic.HbToHcTauNu_TauToLNuNu import make_butod0taunu_d0tokpi_tautolnunu
+from Hlt2Conf.lines.semileptonic.HbToHcLNu import make_butod0lnu_d0tokpi
+from Moore.persistence.hlt2_tistos import list_of_full_stream_lines
+from Hlt2Conf.lines.semileptonic import all_lines as slb_lines
+from Hlt2Conf.lines.topological_b import all_lines as topo_lines
+from Hlt2Conf.lines.semileptonic import sprucing_lines as slb_sprucing_lines
+def lines_for_tistos():
+    """
+    Nikole Comment : 
+    This TISTOS part is only needed for exclusive Sprucing 
+    and it saves the candidates of the FULL HLT2 lines that fired for each event. 
+    You need to make sure its only FULL HLT2 lines in the lines_for_tistos 
+    and they are the ones you care about ie. RD inclusive lines
+    """
+    return [linename for line_dict in [slb_lines,topo_lines] for linename in line_dict.keys()]
+
+@register_line_builder(slb_sprucing_lines)
+def spruce_mybutod0enu_d0tokpi_line(name='SpruceSLB_myBuToD0ENu_D0ToKPi',prescale=1):
+    Bcands = make_b()
+    return SpruceLine(name=name,  hlt2_filter_code=[
+    f"{name.replace('Spruce','Hlt2')}Decision",
+    "Hlt2Topo2BodyDecision", "Hlt2Topo3BodyDecision"]
+    ,prescale=prescale,persistreco=True, algs=sl_line_prefilter() + [Bcands])
+
+def make_full_streams():
+    lines = [builder() for builder in slb_sprucing_lines.values()]
+    streams = [Stream(lines=lines, detectors=[])]
+    return Streams(streams=streams)
+
+def main(options: Options):
+    public_tools = [stateProvider_with_simplified_geom()]
+    with reconstruction.bind(from_file=True, spruce=True),\
+      reco_spruce.bind(simulation=True),\
+      upfront_spruce.bind(simulation=True),\
+      list_of_full_stream_lines.bind(lines=lines_for_tistos()):
+        return run_moore(options, make_full_streams, public_tools=public_tools)
diff --git a/SL_bp_Dstst_e_iso_study/info.yaml b/SL_bp_Dstst_e_iso_study/info.yaml
new file mode 100644
index 0000000000000000000000000000000000000000..cbd0d3554c17f8fa44664305ebb48160690800cc
--- /dev/null
+++ b/SL_bp_Dstst_e_iso_study/info.yaml
@@ -0,0 +1,112 @@
+defaults:
+  inform:
+    - ching-hua.li@cern.ch
+  wg: SL
+
+{%- set evttype_lines_and_leptons = [
+  ('12685400','SLB_BuToDststENu','bp_dstst_e'),
+  ('12883000','SLB_BuToDststTauNu_TauToENuNu','bp_dstst_taue'),
+] %}
+
+{%- set polarity_variables = [
+  ('MagDown','sim-20231017-vc-md100'),
+  ('MagUp','sim-20231017-vc-mu100'),
+]%}
+{%- for polarity, cond_tag in polarity_variables %}
+  {%- for evttype, line, dk in evttype_lines_and_leptons %}
+HLT1_{{dk}}_{{ polarity }}:
+  application: "Moore/v55r7@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  #application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  input:
+    bk_query: "/MC/Dev/Beam6800GeV-expected-2024-{{polarity}}-Nu7.6-25ns-Pythia8/Sim10c/{{evttype}}/DIGI"
+    dq_flags:
+      - OK
+    n_test_lfns: 1
+  output: hlt1.dst
+  options:
+    entrypoint: SL_bp_Dstst_e_iso_study.Hlt1:main
+    extra_options:
+      input_raw_format: 0.3
+      conddb_tag: {{cond_tag}}
+      dddb_tag: dddb-20231017
+      input_type: ROOT
+      output_type: ROOT
+      simulation: True
+      data_type: "Upgrade"
+      scheduler_legacy_mode: False
+      compression:
+        algorithm: ZSTD
+        level: 1
+        max_buffer_size: 1048576
+      #evt_max: 1000 
+
+HLT2_{{dk}}_{{ polarity }}:
+  application: "Moore/v55r7p3@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  #application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  input:
+    job_name: HLT1_{{dk}}_{{ polarity }}
+  output: hlt2.dst
+  options:
+    entrypoint: SL_bp_Dstst_e_iso_study.Hlt2:main
+    extra_options:
+      input_raw_format: 0.5
+      conddb_tag: {{cond_tag}}
+      dddb_tag: dddb-20231017
+      input_type: ROOT
+      output_type: ROOT
+      simulation: True
+      data_type: "Upgrade"
+      scheduler_legacy_mode: False
+      output_manifest_file: "HLT2.tck.json" 
+      compression:
+        algorithm: ZSTD
+        level: 1
+        max_buffer_size: 1048576
+      #evt_max: 1000
+SPRUCE_{{dk}}_{{ polarity }}:
+  application: "Moore/v55r7p3@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  #application: "Moore/v55r8@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  input:
+    job_name: HLT2_{{dk}}_{{ polarity }}
+  output: spruce.dst
+  options:
+    entrypoint: SL_bp_Dstst_e_iso_study.Spruce:main
+    extra_options:
+      input_raw_format: 0.5
+      conddb_tag: {{cond_tag}}
+      dddb_tag: dddb-20231017
+      input_type: ROOT
+      output_type: ROOT
+      simulation: True
+      data_type: "Upgrade"
+      scheduler_legacy_mode: False
+      input_process: "Hlt2"
+      input_manifest_file: "HLT2.tck.json"
+      output_manifest_file: "SPRUCE.tck.json" 
+      compression:
+        algorithm: ZSTD
+        level: 1
+        max_buffer_size: 1048576
+      #evt_max: 1000
+DV_{{dk}}_{{ polarity }}:
+  application: "DaVinci/v64r5@x86_64_v3-el9-gcc13+detdesc-opt+g"
+  input:
+    job_name: SPRUCE_{{dk}}_{{ polarity }}
+  output: NTuple.root
+  options:
+    entrypoint: SL_bp_Dstst_e_iso_study.DV:MC_{{line}}
+    extra_options:
+      input_raw_format: 0.5
+      conddb_tag: {{cond_tag}}
+      dddb_tag: dddb-20231017
+      input_type: ROOT
+      simulation: True
+      data_type: "Upgrade"
+      #geometry_version: run3/2024.Q1.2-v00.00
+      input_process: "Spruce"
+      input_manifest_file: "SPRUCE.tck.json"
+      #evt_max: 1000
+
+  {%- endfor %}
+{%- endfor %}
+