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