ATLAS Offline Software
Loading...
Searching...
No Matches
generateBunchGroupSetFromOldKey Namespace Reference

Functions

 transform2 (oldbgs, bgsname, bgnames)
 main ()

Variables

 log = logging.getLogger("generateBunchGroupSetFromOldKey")
 CTPVersion
 BunchGroupPartitioning
str default_bgsname = "generateBunchGroupSetFromOldKey"
list default_bgnames

Function Documentation

◆ main()

generateBunchGroupSetFromOldKey.main ( )

Definition at line 47 of file generateBunchGroupSetFromOldKey.py.

47def 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
void print(char *figname, TCanvas *c1)
std::string find(const std::string &s)
return a remapped string
Definition hcg.cxx:138
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177
int main()
Definition hello.cxx:18

◆ transform2()

generateBunchGroupSetFromOldKey.transform2 ( oldbgs,
bgsname,
bgnames )

Definition at line 37 of file generateBunchGroupSetFromOldKey.py.

37def 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

list generateBunchGroupSetFromOldKey.default_bgnames
Initial value:
1= [
2 "BCRVETO",
3 "Paired",
4 "Calreq",
5 "Empty",
6 "UnpairedIsolated",
7 "UnpairedNonisolated",
8 "EmptyAfterFilled",
9 "Unpaired",
10 "NotUsed",
11 "NotUsed",
12 "NotUsed",
13 "NotUsed",
14 "NotUsed",
15 "NotUsed",
16 "NotUsed",
17 "NotUsed"
18]

Definition at line 18 of file generateBunchGroupSetFromOldKey.py.

◆ default_bgsname

str generateBunchGroupSetFromOldKey.default_bgsname = "generateBunchGroupSetFromOldKey"

Definition at line 16 of file generateBunchGroupSetFromOldKey.py.

◆ log

generateBunchGroupSetFromOldKey.log = logging.getLogger("generateBunchGroupSetFromOldKey")

Definition at line 11 of file generateBunchGroupSetFromOldKey.py.