Belle II Software development
FixedModuleDisplacement.py
1#!/usr/bin/env python3
2
3
10
11# Generates EKLM displacement data with fixed module displacement.
12
13import basf2
14from ROOT import Belle2 # noqa: make the Belle2 namespace available
15from ROOT.Belle2 import KLMDatabaseImporter, BKLMAlignment, EKLMAlignment, \
16 EKLMSegmentAlignment, KLMAlignmentData, \
17 KLMChannelIndex, KLMDisplacementGenerator
18
19# Create main path
20main = basf2.create_path()
21basf2.set_log_level(basf2.LogLevel.INFO)
22
23# EventInfoSetter
24main.add_module('EventInfoSetter')
25
26# Gearbox
27main.add_module('Gearbox')
28
29# Process the main path
30basf2.process(main)
31
32dbImporter = KLMDatabaseImporter()
33
34bklmAlignment = BKLMAlignment()
35eklmAlignment = EKLMAlignment()
36eklmSegmentAlignment = EKLMSegmentAlignment()
37
38# Fixed displacement for EKLM modules, zero displacement for EKLM segments.
39displacementGenerator = KLMDisplacementGenerator()
40displacementGenerator.fillZeroDisplacements(
41 eklmAlignment, eklmSegmentAlignment)
42displacementGenerator.generateFixedModuleDisplacement(1, 0, 0)
43displacementGenerator.saveDisplacement(
44 eklmAlignment, eklmSegmentAlignment, 'EKLMDisplacement.root')
45
46# Zero displacement for BKLM.
47alignmentData = KLMAlignmentData(0, 0, 0, 0, 0, 0)
48index = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
49index2 = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
50index = index2.beginBKLM()
51
52while (index != index2.endBKLM()):
53 module = index.getKLMModuleNumber()
54 bklmAlignment.setModuleAlignment(module, alignmentData)
55 index.increment()
56
57# Import the payloads.
58dbImporter.setIOV(0, 0, -1, -1)
59dbImporter.importAlignment(
60 bklmAlignment, eklmAlignment, eklmSegmentAlignment, True)