Skip to content
Snippets Groups Projects
Commit 956de0bf authored by Nicole Skidmore's avatar Nicole Skidmore
Browse files

Merge branch 'follow_Moore2418' into 'master'

Remake DaVinci input files

See merge request !928
parents 67bb792d cc21bc72
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!928Remake DaVinci input files
Pipeline #5832231 failed
Showing
with 38 additions and 33 deletions
......@@ -91,7 +91,7 @@ def main(options: Options):
print(F.PT.code_repr())
# Define the TES location (see previous example for explanation)
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles")
# Define a filter (see previous example for explanation)
......
......@@ -96,7 +96,7 @@ def main(options: Options):
}
# Load data from dst onto a TES
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles")
# Add a filter
......
......@@ -94,7 +94,7 @@ def main(options: Options):
}
# Load data from dst onto a TES
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles")
# Add a filter
......
......@@ -116,8 +116,8 @@ def main(options: Options):
selection_type = (
"Hlt2" # User defined and will be used as prefix for TBranch in the root file
)
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line2 = "Hlt2BsToJpsiPhi_JPsi2ee_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
turbo_line2 = "Hlt2B2CC_BuToJpsiKplus_JpsiToMuMu_Prompt"
line_names = [f"{turbo_line}Decision", f"{turbo_line2}"]
selinfo = FC.SelectionInfo(selection_type=selection_type, trigger_lines=line_names)
print(selinfo)
......
......@@ -52,7 +52,7 @@ def main(options: Options):
from DaVinciMCTools import MCTruthAndBkgCat
# Load data from dst onto a TES
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles")
# Define an algorithm that builds a map i.e. one-to-one relation b/w Reco Particle -> Truth MC Particle.
MCTRUTH = MCTruthAndBkgCat(input_data, name="MCTruthAndBkgCat_tuto")
......
......@@ -65,7 +65,7 @@ def main(options: Options):
}
# Load data from dst onto a TES (See Example7)
turbo_line = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data = get_particles(f"/Event/HLT2/{turbo_line}/Particles")
# get kinematic functors
......
......@@ -29,16 +29,16 @@ def main(options: Options):
"mum": "B_s0 -> (J/psi(1S) -> mu+ ^mu-) (phi(1020) ->K+ K-)",
}
fields2 = {
"Bs": "B_s0 -> (J/psi(1S) -> e+ e-) (phi(1020) ->K+ K-)",
"ep": "B_s0 -> (J/psi(1S) -> ^e+ e-) (phi(1020) ->K+ K-)",
"em": "B_s0 -> (J/psi(1S) -> e+ ^e-) (phi(1020) ->K+ K-)",
"B": "[B+ -> (J/psi(1S) -> mu+ mu- ) K+]CC",
"Jpsi": "[B+ -> ^(J/psi(1S) -> mu+ mu- ) K+]CC",
"Kp": "[B+ -> (J/psi(1S) -> mu+ mu- ) ^K+]CC",
}
# Define variables dictionary "field name" -> Collections of functor
variables = {"ALL": FC.Kinematics()}
# Load data from dst onto a TES
turbo_line1 = "Hlt2BsToJpsiPhi_JPsi2MuMu_PhiToKK_Line"
turbo_line1 = "Hlt2B2CC_BsToJpsiPhi_Detached"
input_data1 = get_particles(f"/Event/HLT2/{turbo_line1}/Particles")
my_filter1 = create_lines_filter("HDRFilter_SeeNoEvil1", lines=[f"{turbo_line1}"])
mytuple1 = Funtuple(
......@@ -50,7 +50,7 @@ def main(options: Options):
)
# If running over several sprucing lines (e.g. for calibration) one can define multiple instances of FunTuple
turbo_line2 = "Hlt2BsToJpsiPhi_JPsi2ee_PhiToKK_Line"
turbo_line2 = "Hlt2B2CC_BuToJpsiKplus_JpsiToMuMu_Prompt"
input_data2 = get_particles(f"/Event/HLT2/{turbo_line2}/Particles")
my_filter2 = create_lines_filter("HDRFilter_SeeNoEvil2", lines=[f"{turbo_line2}"])
mytuple2 = Funtuple(
......
......@@ -44,7 +44,7 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty:
raise Exception(f"File {ntuple}: ntuple does not contain any branches")
if df.shape != (30, 22):
if df.shape != (41, 22):
causes.append("Ntuple not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuple
......
......@@ -45,7 +45,7 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty:
causes.append(f"File {ntuple}: ntuple does not contain any branches")
if df.shape != (30, 50):
if df.shape != (41, 50):
causes.append("Ntuple not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuple
......
......@@ -45,12 +45,18 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty:
causes.append(f"File {ntuple}: ntuple does not contain any branches")
if df.shape != (30, 26):
if df.shape != (41, 26):
causes.append("Ntuple not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuple
if df_has_nan(df):
causes.append("Ntuple contains NaN entries")
# Check there are no NaN values in the ntuple except where expected.
from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
l_branches_with_nans = ['Bs_phi_mass_kk', 'Bs_phi_mass_kpi'] # MASSWITHHYPOTHESES variables
l_test = list_fields_with_nan(ntuple, "TDirectoryName/TTreeName")
if sorted(l_test) != sorted(l_branches_with_nans):
causes.append("Unexpected list of branches with NaN values")
# Checks PIDs are correctly assigned
if not ( (df["Bs_Kp_ID"].abs() == 321).all() and (df["Bs_jpsi_ID"].abs() == 443).all() and (df["Bs_phi_ID"].abs() == 333).all() ):
......
......@@ -45,7 +45,7 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty:
causes.append(f"File {ntuple}: ntuple does not contain any branches")
if df.shape != (30, 12):
if df.shape != (41, 12):
causes.append("Ntuple not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuple
......
......@@ -45,28 +45,27 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty:
causes.append(f"File {ntuple}: ntuple does not contain any branches")
if df.shape != (30, 39):
if df.shape != (41, 39):
causes.append("Ntuple not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuple except where expected
from DaVinciTests.QMTest.check_helpers import list_fields_with_nan
l_branches_with_nans = ['Bs_TRUEP', 'Jpsi_TRUEP', 'Phi_TRUEP', 'Mup_TRUEP', 'Mum_TRUEP', 'Kp_TRUEEPHI', 'Kp_TRUEP', 'Km_TRUEP']
l_branches_with_nans = ['Bs_TRUEP', 'Phi_TRUEP']
l_test = list_fields_with_nan(ntuple, 'TDirectoryName/TTreeName')
if sorted(l_test) != sorted(l_branches_with_nans):
causes.append("Unexpected list of branches with NaN values")
# Checks PIDs are correctly assigned
if not ((df.filter(regex=("[B|J|P].*TRUEID"))==0).all().all() # no matched MC
and ( (df["Km_TRUEID"].abs()==0).sum() + (df["Kp_TRUEID"].abs()==0).sum() == 14 )
and ( (df["Mum_TRUEID"].abs()==0).sum() + (df["Mup_TRUEID"].abs()==0).sum() == 3 )
):
causes.append("Ntuple contains unexpected TRUEID values")
if ((df.filter(regex=("[B|J|P].*TRUEID"))==0).all().all() or (df.filter(regex=("[K|Mu].*TRUEID"))==0).all().all()): # If all TRUEIDS are 0 something is wrong
causes.append("Ntuple contains unexpected TRUEID values") # no matched MC
if not ((df["Km_TRUEID"]).sum() + (df["Kp_TRUEID"]).sum() + (df["Mum_TRUEID"]).sum() + (df["Mup_TRUEID"]).sum() == 0 ): # ABS(TRUEID) should be consistent for particles and particles in final state
causes.append("Ntuple contains unexpected TRUEID values")
# Check background categories
if not ((df.filter(regex=("[B|J|P].*BKGCAT"))!=0).all().all()
and (df.filter(regex=("[K|Mu].*BKGCAT"))==-1).all().all() # for kaons and muons, all entries are -1
):
causes.append("Ntuple contains unexpected BKGCAT values")
if not (df.filter(regex=("[K|Mu].*BKGCAT"))==-1).all().all() or ((df.filter(regex=("[B|J|P].*BKGCAT"))!=0).all().all()): #Should have some true signal and K and Mu have BKGCAT=-1
causes.append("Ntuple contains unexpected BKGCAT values")
print('Test successfully completed!')
os.system(f"rm {ntuple}")
......
......@@ -43,7 +43,7 @@ df = get_pandas_dataframe(ntuple, 'TDirectoryName/TTreeName')
# Check ntuple structure
if df.empty: raise Exception(f"File {ntuple}: ntuple does not contain any branches. Please check.")
assert df.shape == (30, 48)
assert df.shape == (41, 48)
# Check there are no NaN values in the ntuple
if df_has_nan(df):
......
......@@ -48,9 +48,9 @@ if df1.empty:
causes.append(f"File {ntuple}: ntuple 'TDirectoryName1/TTreeName1' does not contain any branches")
if df2.empty:
causes.append(f"File {ntuple}: ntuple 'TDirectoryName2/TTreeName2' does not contain any branches")
if df1.shape != (30, 23):
if df1.shape != (41, 23):
causes.append("Ntuple 'TDirectoryName1/TTreeName1' not with expected number of entries and/or branches")
if df2.shape != (13, 23):
if df2.shape != (26, 23):
causes.append("Ntuple 'TDirectoryName2/TTreeName2' not with expected number of entries and/or branches")
# Check there are no NaN values in the ntuples
......
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