ATLAS Offline Software
Tools/Campaigns/python/Utils.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2 from AthenaConfiguration.Enums import FlagEnum
3 class Campaign(FlagEnum):
4  Unknown = ''
5  MC16a = 'mc16a'
6  MC16d = 'mc16d'
7  MC16e = 'mc16e'
8  MC20a = 'mc20a'
9  MC20d = 'mc20d'
10  MC20e = 'mc20e'
11  MC21a = 'mc21a'
12  MC23a = 'mc23a'
13  MC23c = 'mc23c'
14  MC23d = 'mc23d'
15  MC23e = 'mc23e'
16  PhaseII = 'phaseII'
17 
18 # Campaign run numbers (only latest campaigns that do not have metadata present)
19 campaign_runs = {
20  284500: Campaign.MC20a,
21  300000: Campaign.MC20d,
22  310000: Campaign.MC20e,
23  410000: Campaign.MC21a,
24 }
25 
26 # Function to get the campaign
27 def getMCCampaign(files):
28  # Auto-configure from file
29  from AthenaConfiguration.AutoConfigFlags import GetFileMD
30  metadata = GetFileMD(files)
31  mc_campaign = Campaign(metadata.get('mc_campaign', ''))
32  project_name = metadata.get('project_name', '')
33  run_numbers = metadata.get('runNumbers', [])
34 
35  if mc_campaign is not Campaign.Unknown:
36  return mc_campaign
37 
38  if run_numbers:
39  mc_campaign = campaign_runs.get(run_numbers[0], Campaign.Unknown)
40 
41  # MC-equivalent projects for data
42  if 'data24' in project_name:
43  return Campaign.MC23e
44  elif 'data23' in project_name:
45  return Campaign.MC23c
46  elif 'data22' in project_name:
47  return Campaign.MC21a
48  elif 'data18' in project_name:
49  return Campaign.MC20e
50  elif 'data17' in project_name:
51  return Campaign.MC20d
52  elif 'data16' in project_name or 'data15' in project_name:
53  return Campaign.MC20a
54 
55  return mc_campaign
python.AutoConfigFlags.GetFileMD
def GetFileMD(filenames, allowEmpty=True)
Definition: AutoConfigFlags.py:51
python.Utils.Campaign
Definition: Tools/Campaigns/python/Utils.py:3
python.Utils.getMCCampaign
def getMCCampaign(files)
Definition: Tools/Campaigns/python/Utils.py:27