Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-01-09 09:26:48

0001 import acts
0002 import pytest
0003 
0004 from acts.examples import Sequencer
0005 from helpers import alignmentEnabled
0006 
0007 
0008 @pytest.mark.skipif(not alignmentEnabled, reason="Alignment module is not set up")
0009 def test_alignmentdecorator_io_mode(capfd):
0010     """This tests the alignment decorator in IO mode,
0011     i.e. with a given pre-defined alignment store"""
0012 
0013     from acts.examples.alignment import AlignmentDecorator, GeoIdAlignmentStore
0014 
0015     alignDecoConfig = AlignmentDecorator.Config()
0016 
0017     # Create a dummy alignment store
0018     geoId = acts.GeometryIdentifier(volume=1, layer=2)
0019     trf = acts.Transform3(acts.Vector3(0.0, 0.0, 0.0))
0020     geoIdMap = {}
0021     geoIdMap[geoId] = trf
0022     alignmentStore = GeoIdAlignmentStore(geoIdMap)
0023     alignDecoConfig.iovStores = [((10, 20), alignmentStore)]
0024     alignDecoConfig.garbageCollection = True
0025     alignDecoConfig.gcInterval = 20
0026 
0027     alignDeco = AlignmentDecorator(alignDecoConfig, acts.logging.DEBUG)
0028 
0029     sequencer = Sequencer(
0030         events=100,
0031         numThreads=4,
0032         logLevel=acts.logging.INFO,
0033     )
0034 
0035     sequencer.addContextDecorator(alignDeco)
0036     sequencer.run()
0037     if capfd is not None:
0038         out, err = capfd.readouterr()
0039         # Check that the alignment store is decorated for events 10 to 20
0040         for event in range(10, 20):
0041             assert (
0042                 f"Decorating AlgorithmContext with alignment store for event {event}"
0043                 in out
0044             )
0045         # Count that there is only one garbage collection call
0046         assert out.count("Garbage collection: removing alignment store") == 1
0047 
0048 
0049 @pytest.mark.skipif(not alignmentEnabled, reason="Alignment module is not set up")
0050 def test_alignmentdecorator_gen_mode(capfd):
0051 
0052     from acts.examples.alignment import (
0053         AlignmentDecorator,
0054         AlignmentGeneratorGlobalShift,
0055         AlignmentGeneratorGlobalRotation,
0056         GeoIdAlignmentStore,
0057     )
0058 
0059     """This tests the alignment decorator in generative mode"""
0060     alignDecoConfig = AlignmentDecorator.Config()
0061 
0062     # Create some nominal store
0063     geoId0 = acts.GeometryIdentifier(volume=1, layer=2)
0064     trf0 = acts.Transform3(acts.Vector3(0.0, 0.0, 10.0))
0065     geoId1 = acts.GeometryIdentifier(volume=1, layer=4)
0066     trf1 = acts.Transform3(acts.Vector3(0.0, 0.0, 20.0))
0067     geoIdMap = {}
0068     geoIdMap[geoId0] = trf0
0069     geoIdMap[geoId1] = trf1
0070     alignDecoConfig.nominalStore = GeoIdAlignmentStore(geoIdMap)
0071 
0072     gShift = AlignmentGeneratorGlobalShift()
0073     gShift.shift = acts.Vector3(0.0, 0.0, 100.0)
0074 
0075     gRot = AlignmentGeneratorGlobalRotation()
0076     gRot.axis = acts.Vector3(1.0, 0.0, 0.0)
0077     gRot.angle = 0.15
0078 
0079     alignDecoConfig.iovGenerators = [((10, 20), gShift), ((50, 75), gRot)]
0080     alignDecoConfig.garbageCollection = True
0081     alignDecoConfig.gcInterval = 20
0082 
0083     alignDeco = AlignmentDecorator(alignDecoConfig, acts.logging.VERBOSE)
0084 
0085     sequencer = Sequencer(
0086         events=100,
0087         numThreads=1,
0088         logLevel=acts.logging.INFO,
0089     )
0090 
0091     sequencer.addContextDecorator(alignDeco)
0092     sequencer.run()
0093     # Count that the alignment store is decorated 37 times
0094     out, err = capfd.readouterr()
0095     assert out.count("Decorating AlgorithmContext with alignment store") == 37