ATLAS Offline Software
jobOptions.py
Go to the documentation of this file.
1 """
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 """
4 
5 # Author: Will Buttinger
6 
7 # run this with:
8 # athena SUSYTools/jobOptions.py [athArgs] - [susyArgs]
9 # do: athena SUSYTools/jobOptions.py - --help
10 # to see help messages
11 # to run on the grid do:
12 # pathena SUSYTools/jobOptions.py --inDS list,of,ds --useContElementBoundary --addNthFieldOfINDSToLFN=2 - [susyArgs]
13 
14 from AthenaCommon.AthArgumentParser import AthArgumentParser
15 susyArgsParser = AthArgumentParser()
16 susyArgsParser.add_argument("--testCampaign",action="store",default=None,choices=["mc20e","mc23a","mc23d","data23","data22","data18"],help="Specify to select a test campaign")
17 susyArgsParser.add_argument("--testFormat",action="store",default="PHYS",choices=["PHYS","PHYSLITE"],help="Specify to select a test format")
18 susyArgsParser.add_argument("--accessMode",action="store",choices=["POOLAccess","ClassAccess"],default="POOLAccess",help="xAOD read mode - Class is faster, POOL is more robust")
19 susyArgsParser.add_argument("--configFile",action="store",default=None,help="Name of the SUSYTools config file, leave blank for auto-config")
20 susyArgsParser.add_argument("--prwFiles",action="store",nargs="+",default=None,help="Name of prw files")
21 susyArgsParser.add_argument("--lumicalcFiles",action="store",nargs="+",default=None,help="Name of lumicalc files")
22 susyArgsParser.add_argument("--noSyst",action="store_true",help="include to disable systematics")
23 susyArgsParser.add_argument("--fileOutput",default=None,help="Name of output file")
24 
25 susyArgs = susyArgsParser.parse_args()
26 
27 if susyArgs.testCampaign:
28  pTag = 'p6269' if ('data2' in susyArgs.testCampaign) else 'p6266'
29  inputDir = '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/SUSYTools'
30  inputFiles = {}
31  inputFiles['data18'] = f'data18_13TeV.39757132_{pTag}.{susyArgs.testFormat}.pool.root'
32  inputFiles['data22'] = f'data22_13p6TeV.39672246_{pTag}.{susyArgs.testFormat}.pool.root'
33  inputFiles['data23'] = f'data23_13p6TeV.39756993_{pTag}.{susyArgs.testFormat}.pool.root'
34  inputFiles['mc20e'] = f'DAOD_{susyArgs.testFormat}.mc20_13TeV.410470.FS_mc20e_{pTag}.{susyArgs.testFormat}.pool.root'
35  inputFiles['mc23a'] = f'mc23_13p6TeV.601229.FS_mc23a_{pTag}.{susyArgs.testFormat}.pool.root'
36  inputFiles['mc23d'] = f'mc23_13p6TeV.601229.FS_mc23d_{pTag}.{susyArgs.testFormat}.pool.root'
37  jps.AthenaCommonFlags.FilesInput = [f'{inputDir}/{inputFiles[susyArgs.testCampaign]}']
38  if susyArgs.fileOutput is None:
39  susyArgs.fileOutput = f"hist-Ath_{susyArgs.testCampaign}_DAOD_{susyArgs.testFormat}.root"
40 
41 # setup xAOD file reading
42 jps.AthenaCommonFlags.AccessMode = susyArgs.accessMode
43 # setup ROOT file outputting
44 if susyArgs.fileOutput: jps.AthenaCommonFlags.HistOutputs = [f"ANALYSIS:{susyArgs.fileOutput}"]
45 
46 print("INFO: Processing:",jps.AthenaCommonFlags.FilesInput())
47 print("INFO: Outputting:",jps.AthenaCommonFlags.HistOutputs())
48 
49 # read input file metadata: https://twiki.cern.ch/twiki/bin/viewauth/AtlasProtected/AthAnalysis#How_to_access_file_metadata_at_t
50 from PyUtils.MetaReader import read_metadata
51 inp_filename = jps.AthenaCommonFlags.FilesInput()[0]
52 metadata = read_metadata(inp_filename, None, 'peeker')[inp_filename]
53 isMC = 'IS_SIMULATION' in metadata['eventTypes']
54 isFastSim = isMC and ('ATLFASTII' in metadata['SimulationFlavour'].upper()) #full sim or atlfast
55 print("INFO: Format: "," isMC: ",isMC," isFastSim: ",isFastSim)
56 if isMC:
57  MCCampaign = metadata["mc_campaign"]
58 
59 # configure SUSYTools algorithm and its tool
60 susyAlg = CfgMgr.SUSYToolsAlg(DoSyst = isMC and not susyArgs.noSyst)
61 
62 if susyArgs.configFile:
63  susyAlg.SUSYTools.ConfigFile = susyArgs.configFile
64 else:
65  # select config file based on whether we are run3 or run2
66  if (isMC and ((MCCampaign in ["mc23a"]) or (MCCampaign in ["mc23d"]) )) or (not isMC and metadata["runNumbers"][0]>400000):
67  susyAlg.SUSYTools.ConfigFile = "SUSYTools/SUSYTools_Default_Run3.conf" # run3
68  else:
69  susyAlg.SUSYTools.ConfigFile = "SUSYTools/SUSYTools_Default.conf" # run2
70  if susyArgs.testFormat == "PHYSLITE":
71  STconfig_lite = str(susyAlg.SUSYTools.ConfigFile).replace(".conf","_LITE.conf")
72  susyAlg.SUSYTools.ConfigFile = STconfig_lite
73  susyAlg.SUSYTools.IsPHYSLITE = True
74 
75 print("INFO: Configuration file:",susyAlg.SUSYTools.ConfigFile)
76 
77 susyAlg.SUSYTools.DataSource = 0 if not isMC else (1 if not isFastSim else 2) # data/FS/atlfast
78 
79 print("INFO: Configuration SUSYTools.DataSource: ",susyAlg.SUSYTools.DataSource)
80 
81 if isMC:
82  if susyArgs.prwFiles:
83  susyAlg.SUSYTools.PRWConfigFiles = susyArgs.prwFiles
84  else:
85  susyAlg.SUSYTools.AutoconfigurePRWTool = True
86  susyAlg.SUSYTools.PRWUseCommonMCFiles = True
87  # set lumicalc info based on the campaign, if running on MC
88  if susyArgs.lumicalcFiles:
89  susyAlg.SUSYTools.PRWLumiCalcFiles = susyArgs.lumicalcFiles
90  else:
91  PRWLumiCalc = {}
92  PRWLumiCalc['mc20a'] = ['/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data16_13TeV/20180129/PHYS_StandardGRL_All_Good_25ns_297730-311481_OflLumi-13TeV-009.root',
93  '/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data15_13TeV/20170619/PHYS_StandardGRL_All_Good_25ns_276262-284484_OflLumi-13TeV-008.root']
94  PRWLumiCalc['mc20d'] = ['/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data17_13TeV/20180619/physics_25ns_Triggerno17e33prim.lumicalc.OflLumi-13TeV-010.root']
95  PRWLumiCalc['mc20e'] = ['/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data18_13TeV/20190318/ilumicalc_histograms_None_348885-364292_OflLumi-13TeV-010.root']
96  PRWLumiCalc['mc23a'] = ['/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data22_13p6TeV/20230207/ilumicalc_histograms_None_431810-440613_OflLumi-Run3-003.root']
97  PRWLumiCalc['mc23d'] = ['/cvmfs/atlas.cern.ch/repo/sw/database/GroupData/GoodRunsLists/data23_13p6TeV/20230828/ilumicalc_histograms_None_451587-456749_OflLumi-Run3-003.root']
98 
99  susyAlg.SUSYTools.PRWLumiCalcFiles = PRWLumiCalc[MCCampaign]
100 
101 
102 # schedule alg:
103 athAlgSeq += susyAlg
104 
105 include("AthAnalysisBaseComps/SuppressLogging.py") #Optional include to suppress as much athena output as possible. Keep at bottom of joboptions so that it doesn't suppress the logging of the things you have configured above
106 svcMgr+=CfgMgr.AthenaEventLoopMgr(IntervalInSeconds = 10,OutputLevel=INFO) # print progress in fixed period intervals
107 svcMgr.MessageSvc.Format = "% F%50W%S%7W%R%T %0W%M" #Creates more space for displaying tool names
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
python.MetaReader.read_metadata
def read_metadata(filenames, file_type=None, mode='lite', promote=None, meta_key_filter=None, unique_tag_info_values=True, ignoreNonExistingLocalFiles=False)
Definition: MetaReader.py:53
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
python.Include.include
include
Definition: Include.py:318
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
str
Definition: BTagTrackIpAccessor.cxx:11