ATLAS Offline Software
Loading...
Searching...
No Matches
FullCPAlgorithmsTest_CA.py
Go to the documentation of this file.
1#! /bin/env python3
2# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3#
4# @author Tadej Novak
5# @author Teng Jian Khoo
6
7import sys
8import os
9from AnalysisAlgorithmsConfig.ConfigAccumulator import DataType
10from AnalysisAlgorithmsConfig.FullCPAlgorithmsTest import makeSequence
11from AthenaConfiguration.AllConfigFlags import initConfigFlags
12from AthenaConfiguration.ComponentFactory import CompFactory
13from AthenaConfiguration.MainServicesConfig import MainServicesCfg
14from AthenaPoolCnvSvc.PoolReadConfig import PoolReadCfg
15from EventBookkeeperTools.EventBookkeeperToolsConfig import CutFlowSvcCfg
16
17flags = initConfigFlags()
18athArgsParser = flags.getArgumentParser()
19athArgsParser.add_argument("--input-file", action="append", dest="input_file",
20 default=None,
21 help="Specify the input file")
22athArgsParser.add_argument("--output-file", action="store", dest="output_file",
23 default=None,
24 help="Specify the output file")
25athArgsParser.add_argument("--dump-config", action="store", dest="dump_config",
26 default=None,
27 help="Dump the config in a pickle file")
28athArgsParser.add_argument("--data-type", action="store", dest="data_type",
29 default="data",
30 help="Type of input to run over. Valid options are 'data', 'fullsim', 'fastsim'")
31athArgsParser.add_argument('--text-config', dest='text_config',
32 action='store', default=None,
33 help='Configure the job with the provided text configuration')
34athArgsParser.add_argument('--no-systematics', dest='no_systematics',
35 action='store_true', default=False,
36 help='Configure the job to with no systematics')
37athArgsParser.add_argument('--physlite', dest='physlite',
38 action='store_true', default=False,
39 help='Run the job on physlite')
40athArgsParser.add_argument('--run', action='store', dest='run',
41 default=2, type=int,
42 help='Run number for the inputs')
43athArgsParser.add_argument('--only-nominal-or', dest='onlyNominalOR',
44 action='store_true', default=False,
45 help='Only run overlap removal for nominal (skip systematics)')
46athArgsParser.add_argument('--bleeding-edge', dest='bleeding_edge',
47 action='store_true', default=False,
48 help='Run on the latest bleeding edge input (usually from the CI output)')
49athArgs = flags.fillFromArgs(parser=athArgsParser)
50
51dataType = DataType(athArgs.data_type)
52textConfig = athArgs.text_config
53
54if textConfig:
55 from PathResolver import PathResolver
56 textConfig = PathResolver.FindCalibFile(textConfig)
57
58print(f"Running on data type: {dataType.value}")
59
60inputfile = None
61if athArgs.physlite:
62 if athArgs.run==3:
63 inputfile = {DataType.Data: 'ASG_TEST_FILE_LITE_RUN3_DATA',
64 DataType.FullSim: 'ASG_TEST_FILE_LITE_RUN3_MC',
65 DataType.FastSim: 'ASG_TEST_FILE_LITE_RUN3_MC_FASTSIM'}
66 elif athArgs.run==2:
67 inputfile = {DataType.Data: 'ASG_TEST_FILE_LITE_DATA',
68 DataType.FullSim: 'ASG_TEST_FILE_LITE_MC',
69 DataType.FastSim: 'ASG_TEST_FILE_LITE_MC_FASTSIM'}
70else:
71 if athArgs.run==3:
72 inputfile = {DataType.Data: 'ASG_TEST_FILE_RUN3_DATA',
73 DataType.FullSim: 'ASG_TEST_FILE_RUN3_MC',
74 DataType.FastSim: 'ASG_TEST_FILE_RUN3_MC_FASTSIM'}
75 elif athArgs.run==2:
76 inputfile = {DataType.Data: 'ASG_TEST_FILE_DATA',
77 DataType.FullSim: 'ASG_TEST_FILE_MC',
78 DataType.FastSim: 'ASG_TEST_FILE_MC_FASTSIM'}
79
80# Set up the reading of the input file:
81if athArgs.input_file:
82 flags.Input.Files = athArgs.input_file[:]
83else:
84 if inputfile is None:
85 raise SystemExit(f"Unsupported --run value {athArgs.run}: only 2 and 3 are supported without --input-file")
86 testFile = os.getenv(inputfile[dataType])
87 flags.Input.Files = [testFile]
88
89flags.Exec.FPE = 500
90flags.Exec.EventPrintoutInterval = 100
91if flags.PerfMon.doFullMonMT or flags.PerfMon.doFastMonMT:
92 flags.PerfMon.OutputJSON="perfmonmt_CPAnalysis.json"
93flags.lock()
94
95# Setup main services
96cfg = MainServicesCfg(flags)
97# Setup POOL reading
98cfg.merge(PoolReadCfg(flags))
99# Setup cutflow service
100cfg.merge(CutFlowSvcCfg(flags))
101
102# Setup the configuration
103cp_cfg = makeSequence(dataType, yamlPath=textConfig,
104 noSystematics=athArgs.no_systematics,
105 isPhyslite=athArgs.physlite,
106 autoconfigFromFlags=flags, onlyNominalOR=athArgs.onlyNominalOR,
107 bleedingEdge=athArgs.bleeding_edge)
108# Add all algorithms from the sequence to the job.
109cfg.merge(cp_cfg)
110
111# Set up a histogram output file for the job:
112if textConfig:
113 outputFile = f"ANALYSIS DATAFILE='FullCPAlgorithmsTextConfigTest.{dataType.value}.hist.root' OPT='RECREATE'"
114else:
115 outputFile = f"ANALYSIS DATAFILE='FullCPAlgorithmsConfigTest.{dataType.value}.hist.root' OPT='RECREATE'"
116if athArgs.output_file:
117 outputFile = f"ANALYSIS DATAFILE='{athArgs.output_file}' OPT='RECREATE'"
118cfg.addService(CompFactory.THistSvc(Output=[outputFile]))
119
120cfg.printConfig() # For debugging
121
122# dump pickle
123if athArgs.dump_config:
124 with open(athArgs.dump_config, "wb") as f:
125 cfg.store(f)
126if flags.Exec.MaxEvents>0:
127 sc=cfg.run(flags.Exec.MaxEvents)
128else:
129 sc = cfg.run(500)
130sys.exit(sc.isFailure())
void print(char *figname, TCanvas *c1)
static std::string FindCalibFile(const std::string &logical_file_name)