Skip to content
Snippets Groups Projects

adding additional functions to check the output of 2022 data sprucing

Merged Tianwen Zhou requested to merge tizhou_testexclspruce into master
Compare and
18 files
+ 858
0
Compare changes
  • Side-by-side
  • Inline
Files
18
###############################################################################
# (c) Copyright 2019-2021 CERN for the benefit of the LHCb Collaboration #
# (c) Copyright 2019-2023 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". #
@@ -8,32 +8,44 @@
# granted to it by virtue of its status as an Intergovernmental Organization #
# or submit itself to any jurisdiction. #
###############################################################################
"""Test excl sprucing over 2022 data.
"""Test sprucing over 2022 data.
"""
import argparse
import cppyy
import GaudiPython as GP
LHCb = GP.gbl.LHCb
from GaudiConf import IOExtension
from Hlt2Conf.lines.DiMuonNoIP import all_lines as hlt2_DiMuonNoIP_lines
from Hlt2Conf.lines.charmonium_to_dimuon import all_lines as hlt2_charmonium_to_dimuon_lines
from Hlt2Conf.lines.bnoc import all_lines as hlt2_bnoc_lines
from Hlt2Conf.lines.semileptonic import all_lines as hlt2_sl_lines
from Hlt2Conf.lines.rd import all_lines as hlt2_rd_lines
from Hlt2Conf.lines.qee import all_lines as hlt2_qee_lines
from Hlt2Conf.lines.charm import all_lines as hlt2_charm_lines
from Hlt2Conf.lines.bandq import all_lines as hlt2_bandq_lines
from Hlt2Conf.lines.b_to_open_charm import all_lines as hlt2_b2oc_lines
from Hlt2Conf.lines.b_to_charmonia import all_lines as hlt2_b2cc_lines
from Hlt2Conf.lines.qee import sprucing_lines as qee_lines
from Hlt2Conf.lines.rd import sprucing_lines as rd_lines
from Hlt2Conf.lines.semileptonic import sprucing_lines as sl_lines
from Hlt2Conf.lines.bandq import sprucing_lines as bandq_lines
from Hlt2Conf.lines.b_to_open_charm import sprucing_lines as b2oc_lines
from Hlt2Conf.lines.b_to_charmonia import sprucing_lines as b2cc_lines
from Hlt2Conf.check_output import (
check_particlesandrelations,
check_decreports,
)
from PyConf.application import configured_ann_svc
from GaudiConf.reading import do_unpacking
from Configurables import (
ApplicationMgr,
CondDB,
LHCbApp,
IODataManager,
HistogramPersistencySvc,
)
from GaudiConf import IOExtension
import argparse
from GaudiConf.reading import unpack_rawevent, hlt_decisions
from PyConf.application import configured_ann_svc
import cppyy
from Hlt2Conf.check_output import check_decreports
from Hlt2Conf.lines.b_to_open_charm import sprucing_lines as b2oc_lines
from Hlt2Conf.lines.rd import sprucing_lines as rd_lines
from Hlt2Conf.lines.b_to_open_charm import all_lines as hlt2_b2oc_lines
from Hlt2Conf.lines.rd import all_lines as hlt2_rd_lines
import GaudiPython as GP
LHCb = GP.gbl.LHCb
def error(msg):
@@ -42,8 +54,12 @@ def error(msg):
def spruce_lines_running(wg):
linedict = {
"b2cc": b2cc_lines,
"b2oc": b2oc_lines,
"bandq": bandq_lines,
"qee": qee_lines,
"rd": rd_lines,
"sl": sl_lines,
}
return [item for item in list(linedict[wg].keys())]
@@ -51,12 +67,20 @@ def spruce_lines_running(wg):
def hlt2_lines_running(wg):
linedict = {
"b2oc": hlt2_b2oc_lines,
"bandq": hlt2_bandq_lines,
"b2cc": hlt2_b2cc_lines,
"sl": hlt2_sl_lines,
"charm": hlt2_charm_lines,
"qee": hlt2_qee_lines,
"rd": hlt2_rd_lines,
"bnoc": hlt2_bnoc_lines,
"charmtodimuon": hlt2_charmonium_to_dimuon_lines,
"dimuonnoip": hlt2_DiMuonNoIP_lines
}
return [item for item in list(linedict[wg].keys())]
#Argument parser
# Argument parser
parser = argparse.ArgumentParser()
parser.add_argument('input', type=str, help='Input filename')
parser.add_argument('manifest', type=str, help='JSON manifest dump')
@@ -66,49 +90,29 @@ parser.add_argument(
args = parser.parse_args()
assert args.job_type == "excl" or args.job_type == "pass", "job type is pass for Turbo process or excl for Spruce process"
print("input ", args.input)
print("manifest ", args.manifest)
print("job_type ", args.job_type)
print("stream ", args.stream)
##Prepare application
# Prepare application
LHCbApp(
DataType="Upgrade",
Simulation=True,
DDDBtag="dddb-20171126",
CondDBtag="sim-20171127-vc-md100",
Simulation=False,
)
CondDB(Upgrade=True)
# settings for passthrough data. Only one fired line of first evt is checked in a test.
#mymanifest = "pass_" + args.stream + "_PackedLocations.json"
process = "Turbo" if args.job_type == "pass" else "Spruce"
#algs = do_unpacking(cfg, input_process=input_process, stream=args.stream)
unpack = [
unpack_rawevent(
bank_types=['ODIN', 'HltDecReports', 'DstData'],
stream=args.stream,
input_process=process,
configurables=True,
)
]
hlt2 = [
hlt_decisions(
stream=args.stream,
input_process=process,
source="Hlt2",
output_loc="/Event/Hlt2/DecReports")
]
spruce = [
hlt_decisions(
input_process=process,
stream=args.stream,
source="Spruce",
output_loc="/Event/Spruce/DecReports")
]
algs = unpack + hlt2 + spruce
algs = do_unpacking(
cfg=None,
input_process=process,
stream=args.stream,
simulation=False,
raw_event_format=0.3)
mgr = ApplicationMgr(TopAlg=algs)
mgr.ExtSvc += [configured_ann_svc(json_file=args.manifest)]
@@ -126,61 +130,89 @@ TES = appMgr.evtsvc()
# changed in newer cppyy. Proper fix should go into Gaudi
cppyy.gbl.DataSvcHelpers.RegistryEntry.__bool__ = lambda x: True
raweventloc = '/Event/' + args.stream
raweventloc = f'/Event/{args.stream}/RawEvent'
nevents = 5
for ii in range(nevents):
appMgr.run(1)
TES.dump()
nevt = 1
for i in range(nevt):
print('Checking next event.')
appMgr.run(1)
if not TES['/Event']:
break
if ii == 0:
TES.dump()
#print("Looking in RawEvent ", raweventloc)
# Check that detector RawBanks are propagated
Rich_banks = TES[raweventloc].banks(LHCb.RawBank.Rich)
print("Rich_banks ", Rich_banks.size())
if Rich_banks.size() != 0:
error("Expected no RICH rawbanks in streams")
Muon_banks = TES[raweventloc].banks(LHCb.RawBank.Muon)
print("Muon_banks ", Muon_banks.size())
if Muon_banks.size() == 0:
error("Expected Muon rawbanks in all streams")
# Check HLT2 DstData bank is persisted through the Sprucing, together with checks of other banks
#RawBank numbers can be found here: https://gitlab.cern.ch/lhcb/LHCb/-/blob/master/Event/DAQEvent/include/Event/RawBank.h
if args.job_type == "excl":
dstdata_banks = TES[raweventloc].banks(LHCb.RawBank.DstData)
print("DstData bank ", dstdata_banks.size())
if dstdata_banks.size() == 0:
error("Expected number of DstData rawbanks > 0")
hltdecrepo_banks = TES[raweventloc].banks(LHCb.RawBank.HltDecReports)
print("HltDecReports bank ", hltdecrepo_banks.size())
if hltdecrepo_banks.size() != 3:
error("Expected number of HltDecReports rawbanks == 3")
hltselrepo_banks = TES[raweventloc].banks(LHCb.RawBank.HltSelReports)
print("HltSelReports bank ", hltselrepo_banks.size())
if hltselrepo_banks.size() != 1:
error("Expected number of HltSelReports rawbanks == 1")
odin_banks = TES[raweventloc].banks(LHCb.RawBank.ODIN)
print("ODIN bank ", odin_banks.size())
if odin_banks.size(
) == 0: # number of ODIN rawbanks should equal to 1 exactly, but in this situation it is set to > 0 to pass the test due to a bug, which will be solved later.
error("Expected number of ODIN rawbanks > 0")
if args.job_type == "pass":
dstdata_banks = TES[raweventloc].banks(LHCb.RawBank.DstData)
print("DstData bank ", dstdata_banks.size())
if dstdata_banks.size() == 0:
error("Expected number of DstData rawbanks > 0")
hltdecrepo_banks = TES[raweventloc].banks(LHCb.RawBank.HltDecReports)
print("HltDecReports bank ", hltdecrepo_banks.size())
if hltdecrepo_banks.size() != 3:
error("Expected number of HltDecReports rawbanks == 3")
hltselrepo_banks = TES[raweventloc].banks(LHCb.RawBank.HltSelReports)
print("HltSelReports bank ", hltselrepo_banks.size())
if hltselrepo_banks.size() != 1:
error("Expected number of HltSelReports rawbanks == 1")
odin_banks = TES[raweventloc].banks(LHCb.RawBank.ODIN)
print("ODIN bank ", odin_banks.size())
if odin_banks.size(
) == 0: # number of ODIN rawbanks should equal to 1 exactly, but in this situation it is set to > 0 to pass the test due to a bug, which will be solved later.
error("Expected number of ODIN rawbanks > 0")
'''
# for future use
hltlumisum_banks = TES[raweventloc].banks(LHCb.RawBank.HltLumiSummary)
print("HltLumiSummary bank ", hltlumisum_banks.size())
hltroutingbits_banks = TES[raweventloc].banks(LHCb.RawBank.HltRoutingBits)
print("HltRoutingBits bank ", hltroutingbits_banks.size())
'''
# Check dec reports
if "b2oc" in args.stream:
if args.job_type == "excl":
dec_to_check = spruce_lines_running('b2oc')
else:
dec_to_check = hlt2_lines_running('b2oc')
pass_dec_check = ["Passb2oc"]
elif "rd" in args.stream:
if args.job_type == "excl":
dec_to_check = spruce_lines_running('rd')
else:
dec_to_check = hlt2_lines_running('rd')
pass_dec_check = ["Passrd"]
if args.job_type == "excl":
dec_to_check = spruce_lines_running(args.stream)
else:
dec_to_check = hlt2_lines_running(args.stream)
pass_dec_check = ["Pass" + args.stream]
if args.job_type == 'pass':
hlt2decisions = check_decreports(TES, decs=dec_to_check)
hlt2_fired = [k for k, v in hlt2decisions.items() if v]
print("Fired ", hlt2_fired)
## ToDo : reimplement the particles checks
#for k, v in hlt2decisions.items():
# if v:
# prefix = '/Event/HLT2/' + k
# check_particlesandrelations(TES, prefix)
print("Hlt2 Fired ", hlt2_fired)
# the particles checks reimplemented
for k in hlt2_fired:
prefix = '/Event/HLT2/' + k
check_particlesandrelations(TES, prefix.removesuffix("Decision"))
sprucedecisions = check_decreports(
TES, decs=pass_dec_check, stage='Spruce')
passfired = [k for k, v in sprucedecisions.items() if v]
print("Fired ", passfired)
print("spruce Fired ", passfired)
elif args.job_type == "excl":
sprucedecisions = check_decreports(
TES, decs=dec_to_check, stage='Spruce')
sprucefired = [k for k, v in sprucedecisions.items() if v]
print("Fired ", sprucefired)
#for k, v in sprucedecisions.items():
# if v:
# prefix = '/Event/Spruce/' + k
# check_particlesandrelations(TES, prefix)
for k in sprucefired:
prefix = '/Event/Spruce/' + k
print(prefix, prefix.removesuffix("Decision"))
check_particlesandrelations(TES, prefix.removesuffix("Decision"))
appMgr.run(1)
Loading