Belle II Software development
ImportAlignment.py
1#!/usr/bin/env python3
2
3
10
11# Import KLM alignment and displacement payloads.
12
13import sys
14import basf2
15from ROOT import Belle2 # noqa: make the Belle2 namespace available
16from ROOT.Belle2 import KLMDatabaseImporter, BKLMAlignment, EKLMAlignment, \
17 EKLMSegmentAlignment, KLMAlignmentData, \
18 KLMElementNumbers, KLMChannelIndex
19
20basf2.set_log_level(basf2.LogLevel.INFO)
21
22mc = False
23if (len(sys.argv) >= 2):
24 if (sys.argv[1] == 'mc'):
25 mc = True
26
27dbImporter = KLMDatabaseImporter()
28
29bklmAlignment = BKLMAlignment()
30eklmAlignment = EKLMAlignment()
31eklmSegmentAlignment = EKLMSegmentAlignment()
32
33alignmentData = KLMAlignmentData(0, 0, 0, 0, 0, 0)
34
35index = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
36index2 = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
37
38while (index != index2.end()):
39 module = index.getKLMModuleNumber()
40 if (index.getSubdetector() == KLMElementNumbers.c_BKLM):
41 bklmAlignment.setModuleAlignment(module, alignmentData)
42 else:
43 eklmAlignment.setModuleAlignment(module, alignmentData)
44 index.increment()
45
46index.setIndexLevel(KLMChannelIndex.c_IndexLevelStrip)
47index2.setIndexLevel(KLMChannelIndex.c_IndexLevelStrip)
48index = index2.beginEKLM()
49index.useEKLMSegments()
50while (index != index2.endEKLM()):
51 segment = index.getEKLMSegmentNumber()
52 eklmSegmentAlignment.setSegmentAlignment(segment, alignmentData)
53 index.increment()
54
55if (mc):
56 dbImporter.setIOV(0, 0, 0, -1)
57 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
58 eklmSegmentAlignment)
59 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
60 eklmSegmentAlignment, True)
61
62 dbImporter.setIOV(1002, 0, 1002, -1)
63 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
64 eklmSegmentAlignment)
65 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
66 eklmSegmentAlignment, True)
67
68 dbImporter.setIOV(1003, 0, 1003, -1)
69 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
70 eklmSegmentAlignment)
71 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
72 eklmSegmentAlignment, True)
73
74else:
75 dbImporter.setIOV(0, 0, -1, -1)
76 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
77 eklmSegmentAlignment)
78 dbImporter.importAlignment(bklmAlignment, eklmAlignment,
79 eklmSegmentAlignment, True)