12Create a full set of consistent geometry payloads for nominal geometry, phase 2
13geometry, and early phase 3 geometry from XML files.
15Optionally one can give a list of payload names to keep only a subset of payloads
27interested = sys.argv[1:]
30shutil.rmtree(
"localdb", ignore_errors=
True)
34phase3.add_module(
"EventInfoSetter")
35phase3.add_module(
"Gearbox")
36phase3.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, 0, -1])
41postLS1.add_module(
"EventInfoSetter")
42postLS1.add_module(
"Gearbox")
43postLS1.add_module(
"Geometry", createPayloads=
True, payloadIov=[1004, 0, 1004, -1])
48phase2_detectors =
"BeamPipe PXD SVD ServiceGapsMaterial MICROTPC PINDIODE BEAMABORT HE3TUBE CLAWS FANGS PLUME QCSMONITOR".split()
49phase2 = basf2.create_path()
50phase2.add_module(
"EventInfoSetter")
51phase2.add_module(
"Gearbox")
52phase2.add_module(
"Geometry", createPayloads=
True, payloadIov=[1002, 0, 1002, -1],
53 excludedComponents=[
"BeamPipe",
"PXD",
"SVD",
"VXDService",
"ServiceGapsMaterial"],
54 additionalComponents=[e +
"-phase2" for e
in phase2_detectors])
59early3.add_module(
"EventInfoSetter")
60early3.add_module(
"Gearbox")
61early3.add_module(
"Geometry", createPayloads=
True, payloadIov=[1003, 0, 1003, -1],
62 excludedComponents=[
'PXD',
"ServiceGapsMaterial"],
63 additionalComponents=[
'PXD-earlyPhase3',
'ServiceGapsMaterial-earlyPhase3'])
69phase2 = [
"GeoConfiguration",
"PXDGeometryPar",
"SVDGeometryPar",
"BeamPipeGeo",
"ServiceGapsMaterialsPar"]
72early3 = [
"PXDGeometryPar"]
74line_match = re.compile(
r"^dbstore/(.*?) ([0-9a-f]+) ([0-9\-,]*)$")
76with open(
"localdb/database.txt")
as dbfile:
78 match = line_match.search(line)
79 name, revision, iov = match.groups()
81 if interested
and name
not in interested:
84 iov = tuple(int(e)
for e
in iov.split(
','))
87 keep.add((name, str(revision)))
88 database_content.append(f
'dbstore/{name} {revision} 0,0,0,-1\n')
89 if name
not in early3:
90 database_content.append(f
'dbstore/{name} {revision} 1003,0,1003,-1\n')
95 elif iov[0] == 1002
and name
not in phase2:
97 elif iov[0] == 1003
and name
not in early3:
101 keep.add((name, str(revision)))
102 database_content.append(line)
105database_content.sort()
106with open(
"localdb/database.txt",
"w")
as dbfile:
107 dbfile.writelines(database_content)
110for filename
in os.scandir(
'localdb/'):
111 match = re.match(
r"dbstore_(.*?)_rev_(\d*).root", filename.name)
114 if match
and match.groups()
not in keep:
115 print(f
"Removing {filename.name}: not needed")
116 os.unlink(filename.path)
118 print(f
"Normalizing {filename.name} as '{match.group(1)}'")
119 subprocess.call([
"b2file-normalize",
"-i",
"-n", match.group(1), filename.path])
safe_process(*args, **kwargs)