14Create a full set of consistent geometry payloads for reduced CDC geometry from XML files.
24interestedPayloads = [
"GeoConfiguration",
"CDCGeometry"]
27shutil.rmtree(
"localdb", ignore_errors=
True)
31reducedCDCpath = basf2.create_path()
32reducedCDCpath.add_module(
"EventInfoSetter")
33reducedCDCpath.add_module(
"Gearbox")
34reducedCDCpath.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, 0, -1],
35 excludedComponents=[
'CDC'], additionalComponents=[
'CDCReduced'])
36basf2.process(reducedCDCpath)
41replacementPayloads = [
"GeoConfiguration",
"CDCGeometry"]
44line_match = re.compile(
r"^dbstore/(.*?) ([0-9a-f]+) ([0-9\-,]*)$")
46with open(
"localdb/database.txt")
as dbfile:
48 match = line_match.search(line)
49 name, revision, iov = match.groups()
51 if interestedPayloads
and name
not in interestedPayloads:
54 iov = tuple(int(e)
for e
in iov.split(
','))
56 if name
in replacementPayloads:
57 keep.add((name, str(revision)))
58 database_content.append(f
'dbstore/{name} {revision} 0,0,0,-1\n')
62 keep.add((name, str(revision)))
63 database_content.append(line)
66database_content.sort()
67with open(
"localdb/database.txt",
"w")
as dbfile:
68 dbfile.writelines(database_content)
71for filename
in os.scandir(
'localdb/'):
72 match = re.match(
r"dbstore_(.*?)_rev_(\d*).root", filename.name)
75 if match
and match.groups()
not in keep:
76 print(f
"Removing {filename.name}: not needed")
77 os.unlink(filename.path)
79 print(f
"Normalizing {filename.name} as '{match.group(1)}'")
80 subprocess.call([
"b2file-normalize",
"-i",
"-n", match.group(1), filename.path])