ATLAS Offline Software
AODFixHelper.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2022 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 
13  #For the records: This regex matches 3 and 4 digit release numbers
14  #relPattern=re.compile("^Athena-(\d+(\.\d+){2,3}(\.\*)?)$")
15  #But in reality we should require AOD fixes only for three-digit release, used at the Tier0, like: Athena-22.0.89
16  relPattern=re.compile("^Athena-[0-9]{1,2}\.[0-9]{1,2}\.[0-9]{1,2}$") # noqa: W605
17 
18  for r in (rel1,rel2):
19  if not relPattern.match(r):
20  raise RuntimeError("Release number %s doesn't match the expected format"%r)
21 
22  inputRelease=flags.Input.Release
23  if not relPattern.match(inputRelease):
24  raise RuntimeError("Input release number %s doesn't match the expected format"%inputRelease)
25 
26 
27  #By Atlas convention, the first number denotes the major release, the second one the purpose (Tier0, Generation, ... )
28  #and the third one is the running version number.
29  #We request that the first two numbers are identical and the third one in range
30 
31  i1=rel1.rfind(".")
32  i2=rel2.rfind(".")
33  if rel1[:i1] != rel2[:i2]:
34  raise RuntimeError("Boundary releases not from the same release series, got %s and %s"%(rel1,rel2))
35 
36  iRel=inputRelease.rfind(".")
37  if rel1[:i1] != inputRelease[:iRel]:
38  msg.info("Input release not from the same release series.")
39  return False
40 
41  #convert last number to into for comparison
42  lower=int(rel1[i1+1])
43  upper=int(rel2[i2+1])
44  current=int(inputRelease[iRel+1])
45 
46  if (lower > upper):
47  raise RuntimeError("Lower boundary releases %s larger then upper boundary release %s" % (rel1,rel2))
48 
49 
50  if (current >= lower and current <= upper):
51  return True
52  else:
53  return False
54 
55 
56 
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
python.AODFixHelper.releaseInRange
def releaseInRange(flags, rel1, rel2)
Definition: AODFixHelper.py:9