Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-08-02 07:47:52

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