Belle II Software development
RandomDisplacement.py
1#!/usr/bin/env python3
2
3
10
11# Generates random EKLM displacement data.
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# Random displacement for EKLM.
39displacementGenerator = KLMDisplacementGenerator()
40displacementGenerator.generateRandomDisplacement(
41 eklmAlignment, eklmSegmentAlignment, True, False)
42displacementGenerator.saveDisplacement(
43 eklmAlignment, eklmSegmentAlignment, 'EKLMDisplacement.root')
44
45# Zero displacement for BKLM.
46alignmentData = KLMAlignmentData(0, 0, 0, 0, 0, 0)
47index = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
48index2 = KLMChannelIndex(KLMChannelIndex.c_IndexLevelLayer)
49index = index2.beginBKLM()
50
51while (index != index2.endBKLM()):
52 module = index.getKLMModuleNumber()
53 bklmAlignment.setModuleAlignment(module, alignmentData)
54 index.increment()
55
56# Import the payloads.
57dbImporter.setIOV(0, 0, -1, -1)
58dbImporter.importAlignment(
59 bklmAlignment, eklmAlignment, eklmSegmentAlignment, True)