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