14Create a full set of consistent geometry payloads for nominal geometry, phase 2
15geometry, and early phase 3 gometry from XML files.
17Optionally one can give a list of payload names to keep only a subset of payloads
29interested = sys.argv[1:]
32shutil.rmtree(
"localdb", ignore_errors=
True)
36phase3.add_module(
"EventInfoSetter")
37phase3.add_module(
"Gearbox")
38phase3.add_module(
"Geometry", createPayloads=
True, payloadIov=[0, 0, 0, -1])
43postLS1.add_module(
"EventInfoSetter")
44postLS1.add_module(
"Gearbox")
45postLS1.add_module(
"Geometry", createPayloads=
True, payloadIov=[1004, 0, 1004, -1])
50phase2_detectors =
"BeamPipe PXD SVD ServiceGapsMaterial MICROTPC PINDIODE BEAMABORT HE3TUBE CLAWS FANGS PLUME QCSMONITOR".split()
51phase2 = basf2.create_path()
52phase2.add_module(
"EventInfoSetter")
53phase2.add_module(
"Gearbox")
54phase2.add_module(
"Geometry", createPayloads=
True, payloadIov=[1002, 0, 1002, -1],
55 excludedComponents=[
"BeamPipe",
"PXD",
"SVD",
"VXDService",
"ServiceGapsMaterial"],
56 additionalComponents=[e +
"-phase2" for e
in phase2_detectors])
61early3.add_module(
"EventInfoSetter")
62early3.add_module(
"Gearbox")
63early3.add_module(
"Geometry", createPayloads=
True, payloadIov=[1003, 0, 1003, -1],
64 excludedComponents=[
'PXD',
"ServiceGapsMaterial"],
65 additionalComponents=[
'PXD-earlyPhase3',
'ServiceGapsMaterial-earlyPhase3'])
71phase2 = [
"GeoConfiguration",
"PXDGeometryPar",
"SVDGeometryPar",
"BeamPipeGeo",
"ServiceGapsMaterialsPar"]
74early3 = [
"PXDGeometryPar"]
76line_match = re.compile(
r"^dbstore/(.*?) ([0-9a-f]+) ([0-9\-,]*)$")
78with open(
"localdb/database.txt")
as dbfile:
80 match = line_match.search(line)
81 name, revision, iov = match.groups()
83 if interested
and name
not in interested:
86 iov = tuple(int(e)
for e
in iov.split(
','))
89 keep.add((name, str(revision)))
90 database_content.append(f
'dbstore/{name} {revision} 0,0,0,-1\n')
91 if name
not in early3:
92 database_content.append(f
'dbstore/{name} {revision} 1003,0,1003,-1\n')
97 elif iov[0] == 1002
and name
not in phase2:
99 elif iov[0] == 1003
and name
not in early3:
103 keep.add((name, str(revision)))
104 database_content.append(line)
107database_content.sort()
108with open(
"localdb/database.txt",
"w")
as dbfile:
109 dbfile.writelines(database_content)
112for filename
in os.scandir(
'localdb/'):
113 match = re.match(
r"dbstore_(.*?)_rev_(\d*).root", filename.name)
116 if match
and match.groups()
not in keep:
117 print(f
"Removing {filename.name}: not needed")
118 os.unlink(filename.path)
120 print(f
"Normalizing {filename.name} as '{match.group(1)}'")
121 subprocess.call([
"b2file-normalize",
"-i",
"-n", match.group(1), filename.path])
def safe_process(*args, **kwargs)