ATLAS Offline Software
Loading...
Searching...
No Matches
cmd-l1calo-dq-test.py
Go to the documentation of this file.
1#!/usr/bin/env python
2# Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3
4import ROOT
5import argparse
6import subprocess
7
8if __name__=="__main__":
9
10 parser = argparse.ArgumentParser(prog="l1calo-dq-test",description="Runs the DQ algorithm for a given histogram",formatter_class=argparse.ArgumentDefaultsHelpFormatter
11 )
12 parser.add_argument("run",help="run number")
13 parser.add_argument("hist",help="hist path and name")
14 args = parser.parse_args()
15
16 xx = [f for f in subprocess.run(['l1calo-dq-file',args.run],stdout=subprocess.PIPE).stdout.decode("utf-8").split('\n') if f!='']
17 if len(xx)==0:
18 print("ERROR, could not get file for run",args.run)
19 exit(1)
20 f = ROOT.TFile(xx[0])
21 #h = f.FindObjectAny(args.hist)
22 h = f.Get("run_"+args.run+"/"+args.hist)
23 if not h:
24 print("Cannot find histogram:",args.hist)
25 exit(1)
26 print("INPUT HISTOGRAM:",h)
27
28 import os
29 cFile = ROOT.TFile(os.path.expandvars("$BuildArea/$CMTCONFIG/data/DataQualityConfigurations/collisions_run.hcfg"))
30 conf = cFile.Get("top_level").GetNode(args.hist.rsplit('/',1)[0]).GetAssessor(args.hist)
31 cItr = conf.GetAllAlgPars()
32 c = ROOT.dqm_algorithms.tools.SimpleAlgorithmConfig()
33 print("DQ ALGORITHM:",conf.GetAlgName())
34 exec(f"a = ROOT.dqm_algorithms.{conf.GetAlgName()}()")
35 print("DQ CONFIGURATION:")
36 while (x := cItr.Next()):
37 print(" ",x.GetName(),"=",x.GetValue())
38 c.addParameter(x.GetName(),x.GetValue())
39 cItr = conf.GetAllAlgStrPars()
40 while (x := cItr.Next()):
41 print(" ",x.GetName(),"=",x.GetValue())
42 c.addGenericParameter(x.GetName(),x.GetValue())
43
44 r = a.execute("testAlg",h,c) # noqa: F821
45
46 print("RESULTS:")
47 print("---------------------")
48 print("Status=",r.status_)
49 print(r.tags_)
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177