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-2024 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
60if athArgs.physlite:
61 if athArgs.run==3:
62 inputfile = {DataType.Data: 'ASG_TEST_FILE_LITE_RUN3_DATA',
63 DataType.FullSim: 'ASG_TEST_FILE_LITE_RUN3_MC',
64 DataType.FastSim: 'ASG_TEST_FILE_LITE_RUN3_MC_FASTSIM'}
65 elif athArgs.run==2:
66 inputfile = {DataType.Data: 'ASG_TEST_FILE_LITE_DATA',
67 DataType.FullSim: 'ASG_TEST_FILE_LITE_MC',
68 DataType.FastSim: 'ASG_TEST_FILE_LITE_MC_FASTSIM'}
69else:
70 if athArgs.run==3:
71 inputfile = {DataType.Data: 'ASG_TEST_FILE_RUN3_DATA',
72 DataType.FullSim: 'ASG_TEST_FILE_RUN3_MC',
73 DataType.FastSim: 'ASG_TEST_FILE_RUN3_MC_FASTSIM'}
74 elif athArgs.run==2:
75 inputfile = {DataType.Data: 'ASG_TEST_FILE_DATA',
76 DataType.FullSim: 'ASG_TEST_FILE_MC',
77 DataType.FastSim: 'ASG_TEST_FILE_MC_FASTSIM'}
78
79# Set up the reading of the input file:
80if athArgs.input_file:
81 flags.Input.Files = athArgs.input_file[:]
82else:
83 testFile = os.getenv(inputfile[dataType])
84 flags.Input.Files = [testFile]
85
86flags.Exec.FPE = 500
87flags.Exec.EventPrintoutInterval = 100
88if flags.PerfMon.doFullMonMT or flags.PerfMon.doFastMonMT:
89 flags.PerfMon.OutputJSON="perfmonmt_CPAnalysis.json"
90flags.lock()
91
92# Setup main services
93cfg = MainServicesCfg(flags)
94# Setup POOL reading
95cfg.merge(PoolReadCfg(flags))
96# Setup cutflow service
97cfg.merge(CutFlowSvcCfg(flags))
98
99# Setup the configuration
100cp_cfg = makeSequence(dataType, yamlPath=textConfig,
101 noSystematics=athArgs.no_systematics,
102 isPhyslite=athArgs.physlite,
103 autoconfigFromFlags=flags, onlyNominalOR=athArgs.onlyNominalOR,
104 forceEGammaFullSimConfig=True,
105 bleedingEdge=athArgs.bleeding_edge)
106# Add all algorithms from the sequence to the job.
107cfg.merge(cp_cfg)
108
109# Set up a histogram output file for the job:
110if textConfig:
111 outputFile = f"ANALYSIS DATAFILE='FullCPAlgorithmsTextConfigTest.{dataType.value}.hist.root' OPT='RECREATE'"
112else:
113 outputFile = f"ANALYSIS DATAFILE='FullCPAlgorithmsConfigTest.{dataType.value}.hist.root' OPT='RECREATE'"
114if athArgs.output_file:
115 outputFile = f"ANALYSIS DATAFILE='{athArgs.output_file}' OPT='RECREATE'"
116cfg.addService(CompFactory.THistSvc(Output=[outputFile]))
117
118cfg.printConfig() # For debugging
119
120# dump pickle
121if athArgs.dump_config:
122 with open(athArgs.dump_config, "wb") as f:
123 cfg.store(f)
124if flags.Exec.MaxEvents>0:
125 sc=cfg.run(flags.Exec.MaxEvents)
126else:
127 sc = cfg.run(500)
128sys.exit(sc.isFailure())
void print(char *figname, TCanvas *c1)
static std::string FindCalibFile(const std::string &logical_file_name)