Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions CLDConfig/CLDReconstruction.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
from k4FWCore import ApplicationMgr, IOSvc
from k4FWCore.parseArgs import parser
import sys
sys.path.append('.')
base_dir = os.path.dirname(__file__)
sys.path.append(base_dir)
from py_utils import SequenceLoader, parse_collection_patch_file
from k4MarlinWrapper.io_helpers import IOHandlerHelper

Expand Down Expand Up @@ -58,7 +59,7 @@
"OutputModeChoices": ["LCIO", "EDM4hep"] #, "both"] FIXME: both is not implemented yet
}

REC_COLLECTION_CONTENTS_FILE = "collections_rec_level.txt" # file with the collections to be patched in when writing from LCIO to EDM4hep
REC_COLLECTION_CONTENTS_FILE = f"{base_dir}/collections_rec_level.txt" # file with the collections to be patched in when writing from LCIO to EDM4hep

geoservice = GeoSvc("GeoSvc")
geoservice.detectors = [reco_args.compactFile]
Expand Down Expand Up @@ -90,6 +91,7 @@
global_vars={"CONFIG": CONFIG, "geoservice": geoservice, "reco_args": reco_args,
"BEAM_SPOT_SIZES": BEAM_SPOT_SIZES,
},
base_dir=base_dir,
)

io_handler = IOHandlerHelper(algList, iosvc)
Expand Down
15 changes: 13 additions & 2 deletions CLDConfig/ParticleFlow/Pandora.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,17 @@
from Configurables import MarlinProcessorWrapper

import sys
import os
from pathlib import Path


dir_path = Path(os.path.dirname(__file__))
cwd = Path.cwd()

help_only = "-h" in sys.argv or "--help" in sys.argv
if cwd != dir_path.parent and not help_only:
print(f"Running Pandora is only possible when k4run is called from the directory: {dir_path.parent}")
sys.exit(1)


MyDDMarlinPandoraParameters = {
Expand Down Expand Up @@ -112,7 +123,7 @@
if CONFIG["CalorimeterIntegrationTimeWindow"] == "10ns":

MyDDMarlinPandora.Parameters |= {
"PandoraSettingsXmlFile": ["PandoraSettingsCLD/PandoraSettingsDefault.xml"],
"PandoraSettingsXmlFile": [f"{dir_path}/../PandoraSettingsCLD/PandoraSettingsDefault.xml"],
Comment thread
Zehvogel marked this conversation as resolved.
"SoftwareCompensationWeights": ["2.40821", "-0.0515852", "0.000711414", "-0.0254891", "-0.0121505", "-1.63084e-05", "0.062149", "0.0690735", "-0.223064"],
"ECalToMipCalibration": ["175.439"],
"HCalToMipCalibration": ["45.6621"],
Expand All @@ -131,7 +142,7 @@
elif CONFIG["CalorimeterIntegrationTimeWindow"] == "400ns":

MyDDMarlinPandora.Parameters |= {
"PandoraSettingsXmlFile": ["PandoraSettingsCLD/PandoraSettingsDefault_400nsCalTimeWindow.xml"],
"PandoraSettingsXmlFile": [f"{dir_path}/../PandoraSettingsCLD/PandoraSettingsDefault_400nsCalTimeWindow.xml"],
"SoftwareCompensationWeights": ["2.43375", "-0.0430951", "0.000244914", "-0.145478", "-0.00044577", "-8.37222e-05", "0.237484", "0.243491", "-0.0713701"],
"ECalToMipCalibration": ["175.439"],
"HCalToMipCalibration": ["49.7512"],
Expand Down
11 changes: 7 additions & 4 deletions CLDConfig/py_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,6 @@
import os
from typing import Union, Optional, Dict, Any, List
import importlib.util
import importlib.abc
from importlib.machinery import SourceFileLoader


Expand Down Expand Up @@ -78,7 +77,10 @@ class SequenceLoader:
"""

def __init__(
self, alg_list: list, global_vars: Optional[Dict[str, Any]] = None
self,
alg_list: list,
global_vars: Optional[Dict[str, Any]] = None,
base_dir: Optional[str] = None,
) -> None:
"""Initialize the SequenceLoader

Expand All @@ -93,9 +95,11 @@ def __init__(
variables for the sequences. Defaults to None. The keys in this
dictionary will be the available variables in the imported
module and the values will be the values of these variables.
base_dir (Optional[str]): path from which the sequences will be loaded.
"""
self.alg_list = alg_list
self.global_vars = global_vars
self.base_dir = base_dir or "."

def load(self, sequence: str) -> None:
"""Loads a sequence algorithm from a specified Python file and appends
Expand All @@ -118,7 +122,7 @@ def load(self, sequence: str) -> None:
sequence of algorithms that is defined in `TrackingDigiSequence` in
that file to the alg_list
"""
filename = f"{sequence}.py"
filename = f"{self.base_dir}/{sequence}.py"
seq_name = f"{sequence.split('/')[-1]}Sequence"

seq_module = import_from(
Expand All @@ -130,7 +134,6 @@ def load(self, sequence: str) -> None:
self.alg_list.extend(seq)



def parse_collection_patch_file(patch_file: Union[str, os.PathLike]) -> List[str]:
"""Parse a collection patch file such that it can be used by the
PatchCollections processor.
Expand Down
Loading