Skip to content

Commit 7154e69

Browse files
Benedikt Volkelsawenzel
authored andcommitted
Centralise isActive function for detectors
1 parent 4b753ef commit 7154e69

3 files changed

Lines changed: 19 additions & 12 deletions

File tree

MC/bin/o2dpg_qc_finalization_workflow.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717

1818
sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils'))
1919

20-
from o2dpg_workflow_utils import createTask, dump_workflow
20+
from o2dpg_workflow_utils import createTask, dump_workflow, isActive
2121

2222
def getDPL_global_options(bigshm=False, noIPC=None):
2323
common="-b --run --driver-client-backend ws:// "

MC/bin/o2dpg_sim_workflow.py

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@
3030

3131
sys.path.append(join(dirname(__file__), '.', 'o2dpg_workflow_utils'))
3232

33-
from o2dpg_workflow_utils import createTask, dump_workflow, adjust_RECO_environment
33+
from o2dpg_workflow_utils import createTask, dump_workflow, adjust_RECO_environment, isActive, activate_detector
3434
from o2dpg_qc_finalization_workflow import include_all_QC_finalization
3535
from o2dpg_sim_config import create_sim_config
3636

@@ -178,21 +178,13 @@ def load_external_config(configfile):
178178
activeDetectors = anchorConfig.get('o2-ctf-reader-workflow-options',{}).get('onlyDet','all')
179179
# convert to set/hashmap
180180
activeDetectors = { det:1 for det in activeDetectors.split(",") }
181-
182-
# see if a detector is in list of activeDetectors
183-
def isActive(detID):
184-
"""
185-
detID == the usual detID string (3 letters)
186-
"""
187-
if "all" in activeDetectors:
188-
return True
189-
return detID in activeDetectors
181+
for det in activeDetectors:
182+
activate_detector(det)
190183

191184
def addWhenActive(detID, needslist, appendstring):
192185
if isActive(detID):
193186
needslist.append(appendstring)
194187

195-
196188
def retrieve_sor(run_number):
197189
"""
198190
retrieves start of run (sor)

MC/bin/o2dpg_workflow_utils.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,21 @@
44
import json
55

66

7+
# List of active detectors
8+
ACTIVE_DETECTORS = ["all"]
9+
10+
def activate_detector(det):
11+
try:
12+
# first of all remove "all" if a specific detector is passed
13+
ind = ACTIVE_DETECTORS.index("all")
14+
del ACTIVE_DETECTORS[ind]
15+
except ValueError:
16+
pass
17+
ACTIVE_DETECTORS.append(det)
18+
19+
def isActive(det):
20+
return "all" in ACTIVE_DETECTORS or det in ACTIVE_DETECTORS
21+
722
def relativeCPU(n_rel, n_workers):
823
# compute number of CPUs from a given number of workers
924
# n_workers and a fraction n_rel

0 commit comments

Comments
 (0)