Skip to content
Snippets Groups Projects

changes for running online

Merged Rosen Matev requested to merge rm-align-online into master
Compare and Show latest version
2 files
+ 70
3
Compare changes
  • Side-by-side
  • Inline
Files
2
@@ -29,6 +29,72 @@ from PyConf.Algorithms import PrKalmanFilter_Velo, TrackSelectionMerger
from PyConf.Tools import TrackLinearExtrapolator
from DDDB.CheckDD4Hep import UseDD4Hep
from functools import partial
from pathlib import Path
from datetime import datetime
try:
import OnlineEnvBase as OnlineEnv
from MooreOnlineConf.utils import load_opts
with open(OnlineEnv.__file__) as f:
# "#Auto generated RunInfo options for partition:LHCbA activity:Alignment|Rich1 2022.11.23 18:55:39.313"
line = f.readline()
assert "generated RunInfo options" in line
dt = ' '.join(line.rsplit(" ", 2)[-2:]).rsplit(".", 1)[0]
tag = datetime.strptime(dt, "%Y.%m.%d %H:%M:%S").strftime("%Y%m%d%H%M%S")
with open(Path(OnlineEnv.__file__).parent / "RunList.opts") as f:
runs = sorted(load_opts(f)["DeferredRuns"])
with open(Path(OnlineEnv.__file__).parent / "NodeList.opts") as f:
nodes = sorted(load_opts(f)["NodeList"])
if not runs:
raise ValueError("DeferredRuns is empty")
if not nodes:
raise ValueError("NodeList is empty")
activity = OnlineEnv.Activity.removeprefix("Alignment|")
data_id = runs[0] if len(runs) == 1 else f"{runs[0]}-{runs[-1]}"
prefix = Path()
if not OnlineEnv.PartitionName.startswith("TEST"):
prefix = Path("/calib/align")
output_path = prefix / activity / "analyzer" / data_id
tag_path = output_path / "tag"
probe_tag = None
try:
with open(tag_path) as f:
probe_tag = f.read().strip()
except FileNotFoundError:
shutil.rmtree(output_path, ignore_errors=True)
# back up the output path if necessary
try:
if probe_tag is not None and probe_tag != tag:
output_path.rename(output_path.with_suffix("." + probe_tag))
except OSError as e:
import errno
if e.errno == errno.ENOTEMPTY:
pass # another worker already renamed the directory
raise
output_path.mkdir(parents=True, exist_ok=True)
utgid = os.environ["UTGID"]
local_tag_path = tag_path.with_suffix("." + utgid)
with open(local_tag_path, "w") as f:
f.write(tag + "\n")
local_tag_path.replace(tag_path)
print(f"Will write analyzer output to {output_path}")
derivfile = str(output_path / f"derivatives-{utgid}.out")
histofile = str(output_path / f"histograms-{utgid}.root")
except ImportError:
derivfile = "humb-vp-halves-modules-derivs"
histofile = "testmonitoringhist.root"
if UseDD4Hep:
overlay_path = "./OverlayRoot"
@@ -55,12 +121,12 @@ VPRight: !<!alignment>
rotation: [0.0 * rad, 0.0 * rad, 0.0 * rad]
""".strip())
options.histo_file = histofile
# options.set_input_and_conds_from_testfiledb(
# 'upgrade_Sept2022_minbias_0fb_md_xdigi')
# options.evt_max = 100
# options.event_store = 'EvtStoreSvc'
# options.ntuple_file = "testmonitoring.root"
# options.histo_file = "testmonitoringhist.root"
# options.data_flow_file = 'dd4hep_dataflownew.pdf'
# options.control_flow_file = 'dd4hep_controlflownew.pdf'
@@ -143,7 +209,7 @@ constraints.append(
"VPInternal : VP/VPLeft/Module..WithSupport: Tx Ty Tz Rx Ry Rz Szx Szy")
with createAlignAlgorithm.bind(
outputDataFile="humb-vp-halves-modules-derivs",
outputDataFile=derivfile,
updateInFinalize=False,
onlineMode=True,
outputlevel=1,
Loading