12Create a full set of consistent geometry payloads for reduced CDC geometry from XML files.
22interestedPayloads = [
"GeoConfiguration",
"CDCGeometry"]
25shutil.rmtree(
"localdb", ignore_errors=
True)
29reducedCDCpath = basf2.create_path()
30reducedCDCpath.add_module(
"EventInfoSetter")
31reducedCDCpath.add_module(
"Gearbox")
32reducedCDCpath.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, 0, -1],
33 excludedComponents=[
'CDC'], additionalComponents=[
'CDCReduced'])
34basf2.process(reducedCDCpath)
39replacementPayloads = [
"GeoConfiguration",
"CDCGeometry"]
42line_match = re.compile(
r"^dbstore/(.*?) ([0-9a-f]+) ([0-9\-,]*)$")
44with open(
"localdb/database.txt")
as dbfile:
46 match = line_match.search(line)
47 name, revision, iov = match.groups()
49 if interestedPayloads
and name
not in interestedPayloads:
52 iov = tuple(int(e)
for e
in iov.split(
','))
54 if name
in replacementPayloads:
55 keep.add((name, str(revision)))
56 database_content.append(f
'dbstore/{name} {revision} 0,0,0,-1\n')
60 keep.add((name, str(revision)))
61 database_content.append(line)
64database_content.sort()
65with open(
"localdb/database.txt",
"w")
as dbfile:
66 dbfile.writelines(database_content)
69for filename
in os.scandir(
'localdb/'):
70 match = re.match(
r"dbstore_(.*?)_rev_(\d*).root", filename.name)
73 if match
and match.groups()
not in keep:
74 print(f
"Removing {filename.name}: not needed")
75 os.unlink(filename.path)
77 print(f
"Normalizing {filename.name} as '{match.group(1)}'")
78 subprocess.call([
"b2file-normalize",
"-i",
"-n", match.group(1), filename.path])