ATLAS Offline Software
Functions | Variables
generateBunchGroupSetFromOldKey Namespace Reference

Functions

def transform2 (oldbgs, bgsname, bgnames)
 
def main ()
 

Variables

 log
 
 CTPVersion
 
 BunchGroupPartitioning
 
 default_bgsname
 
 default_bgnames
 

Function Documentation

◆ main()

def generateBunchGroupSetFromOldKey.main ( )

Definition at line 47 of file generateBunchGroupSetFromOldKey.py.

47 def main():
48 
49  if len(sys.argv)<2:
50  print("Please run\n%s <old-style.json>\n" % sys.argv[0].split('/')[-1]) # noqa: ATL901
51  print("The old-style json file can be downloaded from the web using https://atlas-trigconf.cern.ch/bunchgroups?key=<key>&type=json") # noqa: ATL901
52  return 1
53 
54  inputFN = sys.argv[1]
55 
56  with open(inputFN) as fn:
57  inputJson = json.load(fn)
58 
59  oldBGS = inputJson[0]['code']
60 
61  if 'name' in inputJson[0]:
62  bgsname = inputJson[0]['name'] + " from Run2 key "
63  if 'bgkey' in inputJson[0]:
64  bgsname += str(inputJson[0]['bgkey'])
65  else:
66  bgsname = default_bgsname
67 
68  if 'bgnames' in inputJson[0]:
69  bgnames = inputJson[0]['bgnames']
70  # replace 0 - BCRVETO with BCRVETO
71  for i in range(len(bgnames)):
72  if bgnames[i].find(" - "):
73  bgnames[i] = bgnames[i].split(" - ", 1)[1]
74  else:
75  bgnames = default_bgnames
76 
77  newBGS = transform2(oldBGS,bgsname,bgnames)
78 
79  outputFN = inputFN.replace(".json",".newstyle.json")
80  newBGS.writeJSON(outputFN)
81 
82 
83 

◆ transform2()

def generateBunchGroupSetFromOldKey.transform2 (   oldbgs,
  bgsname,
  bgnames 
)

Definition at line 37 of file generateBunchGroupSetFromOldKey.py.

37 def transform2(oldbgs,bgsname,bgnames):
38  newbgs = BunchGroupSet(bgsname)
39  for idx,bg in enumerate(oldbgs):
40  newbg = BunchGroupSet.BunchGroup(name = bgnames[idx], internalNumber = idx)
41  for b in bg:
42  newbg.addBunch(b)
43  newbg.normalize()
44  newbgs.addBunchGroup(newbg)
45  return newbgs
46 

Variable Documentation

◆ BunchGroupPartitioning

generateBunchGroupSetFromOldKey.BunchGroupPartitioning

Definition at line 14 of file generateBunchGroupSetFromOldKey.py.

◆ CTPVersion

generateBunchGroupSetFromOldKey.CTPVersion

Definition at line 13 of file generateBunchGroupSetFromOldKey.py.

◆ default_bgnames

generateBunchGroupSetFromOldKey.default_bgnames

Definition at line 18 of file generateBunchGroupSetFromOldKey.py.

◆ default_bgsname

generateBunchGroupSetFromOldKey.default_bgsname

Definition at line 16 of file generateBunchGroupSetFromOldKey.py.

◆ log

generateBunchGroupSetFromOldKey.log

Definition at line 11 of file generateBunchGroupSetFromOldKey.py.

find
std::string find(const std::string &s)
return a remapped string
Definition: hcg.cxx:135
generateBunchGroupSetFromOldKey.main
def main()
Definition: generateBunchGroupSetFromOldKey.py:47
plotBeamSpotVxVal.range
range
Definition: plotBeamSpotVxVal.py:195
generateBunchGroupSetFromOldKey.transform2
def transform2(oldbgs, bgsname, bgnames)
Definition: generateBunchGroupSetFromOldKey.py:37
Trk::open
@ open
Definition: BinningType.h:40
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38