ATLAS Offline Software
Loading...
Searching...
No Matches
test_eFEX_BSEncoding.py
Go to the documentation of this file.
1#!/usr/bin/env python
2
3#
4# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
5#
6
7
8# this test we will run the main job once to produce a raw file, then
9# run it a second time to process that raw file
10# then compare the monitoring histograms
11
12
13import tempfile
14import os
15import ROOT
16
17testFile = "/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/TrigP1Test/data24_13p6TeV.00475321.physics_Main.daq.RAW._lb0247._SFO-11._0006.data_150evt"
18#testFile = "/eos/atlas/atlascerngroupdisk/det-l1calo/OfflineSoftware/TestFiles/data24_13p6TeV/data24_13p6TeV.00477048.physics_Main.daq.RAW._lb0821._SFO-20._0001.data"
19
20def runMonCmd(inputFile,outputBSFile=None,outputMonFile=None):
21 cmdString = f"l1calo-ath-mon --evtMax 10 --filesInput {inputFile}" # -- Trigger.L1.doeFex=True" # need topo atm for TrigCompositeContainer to trigger bs encoder
22 if outputMonFile: cmdString += f" Output.HISTFileName={outputMonFile}"
23 if outputBSFile:
24 if os.path.exists(outputBSFile): os.remove(outputBSFile)
25 cmdString += f" Output.BSFileName=\"{outputBSFile}\""
26 print("Executing: " + cmdString)
27 os.system(cmdString)
28
29
30def histosEqual(h1, h2, tolerance=1e-3):
31 for bin in range(h1.GetNcells()):
32 if( abs(h1.GetBinContent(bin)-h2.GetBinContent(bin))>tolerance ):
33 print(f"Bin {bin} difference: {h1.GetBinContent(bin)} vs {h2.GetBinContent(bin)}")
34 return False
35 return True
36
37
38with tempfile.TemporaryDirectory() as tmp:
39 bsFile = "test.efex.raw" # os.path.join(tmp, 'test.efex.raw')
40 runMonCmd(inputFile = testFile,
41 outputBSFile=bsFile,
42 outputMonFile="monitoring.orig.root")
43 runMonCmd(inputFile=bsFile,outputMonFile="monitoring.root")
44
45
46# now c.f. the relevant histograms from the two monitoring files
47f1 = ROOT.TFile("monitoring.orig.root")
48f2 = ROOT.TFile("monitoring.root")
49hists = ["h_L1_eEMRoI_LowPtCut_EtaPhiMap","h_L1_eTauRoI_LowPtCut_EtaPhiMap","h_L1_eEMxRoI_LowPtCut_EtaPhiMap","h_L1_eTauxRoI_LowPtCut_EtaPhiMap"]
50for h in hists:
51 h1 = f1.FindObjectAny(h)
52 if not h1:
53 print(f"Missing {h} from {f1.GetName()}")
54 exit(1)
55 h2 = f2.FindObjectAny(h)
56 if not h2:
57 print(f"Missing {h} from {f2.GetName()}")
58 exit(1)
59 if not histosEqual(h1,h2):
60 print(f"{h} histograms differ")
61 exit(1)
void print(char *figname, TCanvas *c1)
histosEqual(h1, h2, tolerance=1e-3)
runMonCmd(inputFile, outputBSFile=None, outputMonFile=None)