Skip to content
Snippets Groups Projects
Commit d39f23c5 authored by Davide Fazzini's avatar Davide Fazzini Committed by Eduardo Rodrigues
Browse files

Removing set_hltAnn_svc function from DaVinci.algorithms

parent 68f949aa
No related branches found
No related tags found
2 merge requests!1103Draft: Add AnalysisHelpers to DaVinci Stack,!630Removing set_hltAnn_svc function from DaVinci.algorithms
......@@ -13,10 +13,11 @@ High level configuration tools for DaVinci.
"""
from PyConf.application import ComponentConfig, configure, configure_input
from PyConf.Algorithms import EventAccounting
from GaudiConf import reading
from DaVinci.configOptions import (check_options, set_job_options,
set_args_options, set_input_file_options)
from DaVinci.algorithms import (setup_algorithms, define_fsr_writer,
set_hltAnn_svc, apply_filters_and_unpacking)
apply_filters_and_unpacking)
from DaVinci.config import davinci_control_flow, prepare_davinci_nodes
......@@ -95,7 +96,7 @@ def add_davinci_configurables(options):
config = configure_input(options)
if options.annsvc_config:
set_hltAnn_svc(config, options.annsvc_config)
config.update(reading.set_hltAnn_svc(options.annsvc_config))
dvMainFlow.update(
apply_filters_and_unpacking(options, userAlgs, unpack_only_mc))
......
......@@ -9,9 +9,8 @@
# or submit itself to any jurisdiction. #
###############################################################################
import os, sys, importlib, json, XRootD.client
import os, sys, importlib
from GaudiKernel.ProcessJobOptions import importOptions
from PyConf.components import setup_component
from PyConf.Algorithms import (LoKi__HDRFilter as HDRFilter, LoKi__VoidFilter
as VoidFilter)
from DaVinci.configOptions import get_option_value
......@@ -266,9 +265,7 @@ def unpack_locations(options, unpack_only_mc):
if unpack_only_mc:
reading_algs += reading.mc_unpackers(
process=process,
filtered_mc=False,
configurables=False)
process=process, filtered_mc=False, configurables=False)
else:
reading_algs += [
unpack_raw_event,
......@@ -316,72 +313,6 @@ def get_hlt_reports(options, source=''):
return dec_reports
def get_hltAnn_dict(annsvc_config):
"""
Extracts Hlt ANN dictionary from the given location.
Args:
- annsvc_config: path to the .json file containing the HltAnnSvc configuration
Returns:
- Dict with all the HLT2 locations.
"""
tck = {}
if "root://eoslhcb.cern.ch//" in annsvc_config:
with XRootD.client.File() as f:
status, _ = f.open(annsvc_config)
if not status.ok:
raise RuntimeError(
f"could not open {annsvc_config}: {status.message}")
status, data = f.read()
if not status.ok:
raise RuntimeError(
f"could not read {annsvc_config}: {status.message}")
tck = json.loads(data.decode('utf-8'))
elif annsvc_config:
with open(os.path.expandvars(annsvc_config)) as f:
tck = json.load(f)
return tck
def set_hltAnn_svc(config, annsvc_config):
"""
Configures the Hlt ANN service to read correctly the spruced locations using the HltAnnSvc
configuration of the HLT2 application.
Args:
- config: dict of configured Configurable instances.
- annsvc_config: path to the .json file containing the HltAnnSvc configuration.
"""
tck = get_hltAnn_dict(annsvc_config)
if tck:
ann_config = tck["HltANNSvc/HltANNSvc"]
hlt2_sel_ids = {
str(k): v
for k, v in ann_config["Hlt2SelectionID"].items()
}
spruce_sel_ids = {
str(k): v
for k, v in ann_config["SpruceSelectionID"].items()
}
packed_object_locs = {
str(k): v
for k, v in ann_config["PackedObjectLocations"].items()
}
if config:
config.add(
setup_component(
"HltANNSvc",
Hlt2SelectionID=hlt2_sel_ids,
SpruceSelectionID=spruce_sel_ids,
PackedObjectLocations=packed_object_locs))
else:
config.add(setup_component("HltANNSvc"))
def ConfiguredFuntuple(config):
"""
Function for the FunTuple configuration and instantiation of the related HDR filter.
......
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