4folderPath =
"/TRIGGER/L1Calo/V1/Calibration/"
11from statistics
import median
12from coldpie
import cool
14from itertools
import chain
16from AthenaConfiguration
import TestDefaults
19parser = argparse.ArgumentParser(description=
'Check what conditions are defined for MC',formatter_class=argparse.ArgumentDefaultsHelpFormatter)
20parser.add_argument(
"--db",nargs=
'+',default=[
"COOLOFL_TRIGGER/OFLP200"],help=
"specify sqlite files to check local")
21parser.add_argument(
"--globalTag",nargs=
'+',default=[TestDefaults.defaultConditionsTags.RUN4_MC],help=
"what globaltag to use. if use sqlite file will become blank")
23args = parser.parse_args()
27from AthenaConfiguration.RunToTimestampData
import RunToTimestampDict
30RunToTimestampDict = {k: v
for k, v
in RunToTimestampDict.items()
if k > 313000}
36 from pathlib
import Path
38 r'^\s*(\d+)\s*:\s*\d+\s*,?\s*#\s*(.*)$'
41 for line
in Path(filename).read_text().splitlines():
42 m = pattern.match(line)
44 run_number = int(m.group(1))
45 comment = m.group(2).
strip()
46 comments[run_number] = comment
50from AthenaConfiguration
import RunToTimestampData
54RunToTimestampDict[350000] = 1625100000; comments[350000] =
"MC21 pp (RUN-4; mu = 0)"
55RunToTimestampDict[350060] = 1625110000; comments[350060] =
"MC21 pp (RUN-4; mu = 60)"
56RunToTimestampDict[350140] = 1625120000; comments[350140] =
"MC21 pp (RUN-4; mu = 140)"
57RunToTimestampDict[350200] = 1625130000; comments[350200] =
"MC21 pp (RUN-4; mu = 200)"
58RunToTimestampDict[510000] = 1763227800; comments[510000] =
"MC23 for 2025 heavy ion (PbPb) run"
59RunToTimestampDict[520900] = 1779789600; comments[520900] =
"MC23 for 2026 heavy ion (PbPb) run"
61RunToTimestampDict[495000] = 1747346400; comments[495000] =
"MC23g 2025-2026"
64dbSvc = cool.DatabaseSvcFactory.databaseService()
72 globalTagList = list(args.globalTag)
74 if os.path.exists(dbName):
76 dbName = f
"sqlite://;schema={dbName};dbname=OFLP200"
77 globalTagList = [
"sqlite"]
80 db = dbSvc.openDatabase(dbName)
82 globalTags = db.getFolderSet(
"/").listTags()
83 for globalTag
in globalTagList:
85 if globalTag !=
"sqlite" and globalTag
not in globalTags:
86 exit(f
"GlobalTag {args.globalTag} missing")
88 allGlobalTags.add(globalTag)
90 for folder
in db.listAllNodes():
91 if not folder.startswith(folderPath):
continue
92 folder = db.getFolder(folder)
93 folderName = folder.fullPath().
split(
"/")[-1]
94 if folderName
not in summaries: summaries[folderName] = {}
96 ftag = folder.resolveTag(globalTag)
if globalTag!=
"sqlite" else ""
100 print(folder.fullPath(),
":",ftag)
102 objs = list(folder.browseObjects(0,9223372036854775807,cool.ChannelSelection.all(),ftag))
105 timePair = (globalTag,int(o.since()*1e-9),int(o.until()*1e-9))
106 if timePair
not in iovs: iovs[timePair] = {}
107 channelId = o.channelId()
109 for s
in o.payload().specification():
111 b = o.payload().field(s.name()).data()
112 if type(b)== coral.Blob:
114 record.update(json.loads(b.read(b.size())))
117 iovs[timePair][channelId] = record
121 for k1, d1
in iovs.items():
122 hashVal = hashlib.sha256(json.dumps(d1, sort_keys=
True).encode()).hexdigest()
123 if hashVal
in summaries[folderName]:
125 summaries[folderName][hashVal][0] += [k1]
128 df = pd.DataFrame.from_dict(d1, orient=
"index")
130 for col
in df.columns:
134 if isinstance(s.iat[0], list):
135 values = list(chain.from_iterable(s))
138 sumStr = f
"{min(values)}|{median(values)}|{max(values)}" if min(values)!=
max(values)
else f
"{min(values)}"
139 summary[col] = {
"summary":sumStr}
141 summary = pd.DataFrame(summary).T
143 summaries[folderName][hashVal] = [[k1], summary]
148for folder,fSummaries
in summaries.items():
149 if len(fSummaries)==0:
continue
152 for i,s
in fSummaries.items():
153 allSummaries[i[:5]] = s[1]
155 {name: df[
"summary"]
for name, df
in allSummaries.items()},
163for k,v
in RunToTimestampDict.items():
165 record[
"Campaign"] = str(k) +
":" + comments[k]
166 for folder,fSummaries
in summaries.items():
168 for globalTag
in sorted(list(allGlobalTags)):
169 for h,s
in fSummaries.items():
170 for tag,since,until
in s[0]:
171 if tag==globalTag
and since<=v
and until>v:
173 record[folder] =
"|".join(setNum)
176df = pd.DataFrame(records).set_index(
"Campaign")
177df = df.sort_values(by=df.columns.tolist())
179print(
"\n Summary Table:")
180print(sorted(list(allGlobalTags)))
183lines = text.splitlines()
189print(
"\n".join(header))
193for i, (_, row)
in enumerate(df.iterrows()):
195 prev = df.iloc[i - 1]
196 if not (row == prev).all():
197 print(
"-" * len(lines[0]))
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")