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 150 --filesInput {inputFile} -- Trigger.CTP.UseEDMxAOD=False Trigger.L1.doeFex=True Trigger.L1.dojFex=True"
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
39 return h.GetEntries() == 0
40
41
42with tempfile.TemporaryDirectory() as tmp:
43 bsFile = "test.efex.raw" # os.path.join(tmp, 'test.efex.raw')
44 runMonCmd(inputFile = testFile,
45 outputBSFile=bsFile,
46 outputMonFile="monitoring.orig.root")
47 runMonCmd(inputFile=bsFile,outputMonFile="monitoring.root")
48
49
50# now c.f. the relevant histograms from the two monitoring files
51f1 = ROOT.TFile("monitoring.orig.root")
52f2 = ROOT.TFile("monitoring.root")
53hists = [
54 "h_L1_eEMRoI_LowPtCut_EtaPhiMap",
55 "h_L1_eTauRoI_LowPtCut_EtaPhiMap",
56 "h_L1_eEMxRoI_LowPtCut_EtaPhiMap",
57 "h_L1_eTauxRoI_LowPtCut_EtaPhiMap",
58 "h_jJ_EtaPhiMap",
59 "h_jTAU_EtaPhiMap",
60 "h_jEM_EtaPhiMap",
61]
62for h in hists:
63 h1 = f1.FindObjectAny(h)
64 if not h1:
65 print(f"Missing {h} from {f1.GetName()}")
66 exit(1)
67 h2 = f2.FindObjectAny(h)
68 if not h2:
69 print(f"Missing {h} from {f2.GetName()}")
70 exit(1)
71 if histoEmpty(h1):
72 print(f"{h} is empty in {f1.GetName()} - test needs more events to populate")
73 exit(1)
74 if histoEmpty(h2):
75 print(f"{h} is empty in {f2.GetName()} - test needs more events to populate")
76 exit(1)
77 if not histosEqual(h1,h2):
78 print(f"{h} histograms differ")
79 exit(1)
if(pathvar)
void print(char *figname, TCanvas *c1)
histosEqual(h1, h2, tolerance=1e-3)
runMonCmd(inputFile, outputBSFile=None, outputMonFile=None)