48
49 if len(sys.argv)<2:
50 print(
"Please run\n%s <old-style.json>\n" % sys.argv[0].
split(
'/')[-1])
51 print(
"The old-style json file can be downloaded from the web using https://atlas-trigconf.cern.ch/bunchgroups?key=<key>&type=json")
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
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
std::vector< std::string > split(const std::string &s, const std::string &t=":")