Loading [MathJax]/extensions/tex2jax.js
ATLAS Offline Software
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Modules Pages
AODFixHelper.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
2 
3 import re
4 from AthenaCommon.Logging import logging
5 
6 #Helper method to determine if the input release is in particular release range.
7 #The boundaries rel1 and rel2 are inclusive.
8 
9 def releaseInRange(flags,rel1,rel2):
10  msg=logging.getLogger("releaseInRange")
11 
12  #This regex matches 3 and 4 digit release numbers
13  #It also matches only something that start with Athena-xx
14  relPattern=re.compile(r"^Athena-(\d+(\.\d+){2,3}(\.\*)?)$")
15 
16  for r in (rel1,rel2):
17  if not relPattern.match(r):
18  raise RuntimeError("Release number %s doesn't match the expected format"%r)
19 
20  inputRelease=flags.Input.Release
21 
22  # protection against AOD with very old releases or not read correctly by MetaReader.py
23  if inputRelease == "" or not inputRelease.startswith("Athena-"):
24  msg.debug("flags.Input.Release is read as empty or it does not start with 'Athena-'")
25  return False
26 
27  if not relPattern.match(inputRelease):
28  raise RuntimeError("Input release number %s doesn't match the expected format"%inputRelease)
29 
30  # convert 3 digits releases to 4 digits
31  if rel1.count(".") == 2: rel1=f"{rel1}.0"
32  if rel2.count(".") == 2: rel2=f"{rel2}.0"
33  if inputRelease.count(".") == 2: inputRelease=f"{inputRelease}.0"
34 
35  #By Atlas convention, the first number denotes the major release, the second one the purpose (Tier0, Generation, ... )
36  #the third one is the running version number, the fourth one the patch number
37  #We request that the first two numbers are identical and the (third*10000 + forth) ones are in range
38 
39  def identifyMajorAndMinorRel(rel):
40  idx = rel.rfind(".", 0, rel.rfind("."))
41  return rel[:idx]
42 
43  def mangleRunningAndPatch(rel):
44  rel_split = rel.split(".")
45  return int(rel_split[2])*10000 + int(rel_split[3]) # running*10000 should be safely high enough
46 
47  if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(rel2):
48  raise RuntimeError("Boundary releases not from the same release series, got %s and %s"%(rel1,rel2))
49 
50  if identifyMajorAndMinorRel(rel1) != identifyMajorAndMinorRel(inputRelease):
51  msg.info("Input release not from the same release series.")
52  return False
53 
54  #convert number to int for comparison
55  lower=mangleRunningAndPatch(rel1)
56  upper=mangleRunningAndPatch(rel2)
57  current=mangleRunningAndPatch(inputRelease)
58 
59  if (lower > upper):
60  raise RuntimeError("Lower boundary releases %s larger then upper boundary release %s" % (rel1,rel2))
61 
62  if (current >= lower and current <= upper):
63  return True
64  else:
65  return False
python.AODFixHelper.releaseInRange
def releaseInRange(flags, rel1, rel2)
Definition: AODFixHelper.py:9
python.CaloAddPedShiftConfig.int
int
Definition: CaloAddPedShiftConfig.py:45