コード例 #1
0
def test_automatic_data():
    sel00 = AutomaticData(Location='Phys/Sel00x')
    assert sel00.name() == 'Phys_Sel00x'
    assert sel00.algorithm().name() == 'SelFilterPhys_Sel00x'
    assert sel00.outputLocation() == 'Phys/Sel00x'

    sel00 = AutomaticData(Location='Phys/Sel00x/Particles')
    assert sel00.name() == 'Phys_Sel00x_Particles'
    assert sel00.algorithm().name() == 'SelFilterPhys_Sel00x_Particles'
    assert sel00.outputLocation() == 'Phys/Sel00x/Particles'
コード例 #2
0
def test_sequencer_sequence():
    _sel00 = AutomaticData(Location='Phys/Sel00')
    _sel01 = AutomaticData(Location='Phys/Sel01')
    _sel02 = AutomaticData(Location='Phys/Sel02')
    _sel03 = AutomaticData(Location='Phys/Sel03')

    sel01 = Selection('000110',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel00, _sel01])
    sel02 = Selection('000111',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel02, _sel03])
    sel03 = Selection('000112',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[sel01, sel02])

    presel0 = MockConfGenerator()
    presel1 = MockConfGenerator()
    postsel0 = MockConfGenerator()
    postsel1 = MockConfGenerator()

    presels = [presel0, presel1]
    postsels = [postsel0, postsel1]
    seq = SelectionSequence('Seq0002',
                            TopSelection=sel03,
                            EventPreSelector=presels,
                            PostSelectionAlgs=postsels,
                            sequencerType=DummySequencer)

    seqAlgos = seq.sequence().Members

    ref_algos = [
        presel0, presel1,
        _sel00.algorithm(),
        _sel01.algorithm(),
        _sel02.algorithm(),
        _sel03.algorithm(),
        sel02.algorithm(),
        sel01.algorithm(),
        sel03.algorithm(), postsel0, postsel1
    ]

    assert len(seqAlgos) == 11

    assert presels == ref_algos[:len(presels)]

    assert postsels == ref_algos[len(ref_algos) - len(postsels):]

    for sel in [sel01, sel02, sel03]:
        assert sel.algorithm() in ref_algos[len(presels):len(ref_algos) -
                                            len(postsels)]
コード例 #3
0
def test_merged_selection():
    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    sel01 = AutomaticData(Location='Phys/Sel01/Particles')
    ms = MergedSelection('Merge00And01', RequiredSelections=[sel00, sel01])
    assert ms.name() == 'Merge00And01'
    assert ms.requiredSelections() == [
    ]  # should not export its required selections. Algos contained internally.
    assert ms.outputLocation() == 'Phys/Merge00And01/Particles'
    assert [alg.name() for alg in ms._algos] == [
        'SelFilterPhys_Sel00_Particles', 'SelFilterPhys_Sel01_Particles',
        'Merge00And01'
    ]
    assert ms._algos == [
        sel00.algorithm(),
        sel01.algorithm(),
        ms._sel.algorithm()
    ]
コード例 #4
0
def test_clone_sequence():
    _sel00 = AutomaticData(Location='Phys/Sel00')
    _sel01 = AutomaticData(Location='Phys/Sel01')
    _sel02 = AutomaticData(Location='Phys/Sel02')
    _sel03 = AutomaticData(Location='Phys/Sel03')

    sel01 = Selection('00120',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel00, _sel01])
    sel02 = Selection('00121',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[_sel02, _sel03])
    sel03 = Selection('00122',
                      Algorithm=MockConfGenerator(),
                      RequiredSelections=[sel01, sel02])

    presel0 = MockConfGenerator()
    presel1 = MockConfGenerator()
    postsel0 = MockConfGenerator()
    postsel1 = MockConfGenerator()

    presels = [presel0, presel1]
    postsels = [postsel0, postsel1]

    seq = SelectionSequence('Seq03',
                            TopSelection=sel03,
                            EventPreSelector=presels,
                            PostSelectionAlgs=postsels,
                            sequencerType=DummySequencer)

    clone = seq.clone(name='clone')

    seqAlgos = clone.sequence().Members

    ref_algos = [
        presel0, presel1,
        _sel00.algorithm(),
        _sel01.algorithm(),
        _sel02.algorithm(),
        _sel03.algorithm(),
        sel02.algorithm(),
        sel01.algorithm(),
        sel03.algorithm(), postsel0, postsel1
    ]

    assert len(seqAlgos) == len(ref_algos)
    assert presels == seqAlgos[:len(presels)]
    assert postsels == seqAlgos[len(ref_algos) - len(postsels):]
    # sel03 must come just before the post selection algos.
    assert sel03.algorithm() == ref_algos[len(ref_algos) - (len(presels) + 1)]
    # order of sel01 and sel02 doesn't matter.
    for sel in [sel01, sel02]:
        assert sel.algorithm() in ref_algos[len(presels):len(ref_algos) -
                                            len(postsels)]

    seqAlgos = seq.algorithms()

    assert len(seqAlgos) == len(ref_algos)
    assert presels == seqAlgos[:len(presels)]
    assert postsels == seqAlgos[len(ref_algos) - len(postsels):]

    for sel in [sel01, sel02, sel03]:
        assert sel.algorithm() in ref_algos[len(presels):len(ref_algos) -
                                            len(postsels)]
コード例 #5
0
def test_multi_sequencer_sequences():
    _sel00 = AutomaticData(Location='Phys/Sel00')
    _sel01 = AutomaticData(Location='Phys/Sel01')
    _sel02 = AutomaticData(Location='Phys/Sel02')
    _sel03 = AutomaticData(Location='Phys/Sel03')

    sel00_01 = Selection('0000110',
                         Algorithm=MockConfGenerator(),
                         RequiredSelections=[_sel00, _sel01])
    sel02_03 = Selection('0000111',
                         Algorithm=MockConfGenerator(),
                         RequiredSelections=[_sel02, _sel03])
    selA = Selection('000112A',
                     Algorithm=MockConfGenerator(),
                     RequiredSelections=[sel00_01, sel02_03])

    _sel04 = AutomaticData(Location='Phys/Sel04')
    _sel05 = AutomaticData(Location='Phys/Sel05')
    _sel06 = AutomaticData(Location='Phys/Sel06')
    _sel07 = AutomaticData(Location='Phys/Sel07')
    sel04_05 = Selection('0000112',
                         Algorithm=MockConfGenerator(),
                         RequiredSelections=[_sel04, _sel05])
    sel06_07 = Selection('0000113',
                         Algorithm=MockConfGenerator(),
                         RequiredSelections=[_sel06, _sel07])
    selB = Selection('000112B',
                     Algorithm=MockConfGenerator(),
                     RequiredSelections=[sel04_05, sel06_07])

    presel0 = MockConfGenerator()
    presel1 = MockConfGenerator()
    presel2 = MockConfGenerator()
    presel3 = MockConfGenerator()

    postsel0 = MockConfGenerator()
    postsel1 = MockConfGenerator()
    postsel2 = MockConfGenerator()
    postsel3 = MockConfGenerator()

    preselsA = [presel0, presel1]
    postselsA = [postsel0, postsel1]
    preselsB = [presel2, presel3]
    postselsB = [postsel2, postsel3]

    seqA = SelectionSequence('Seq0002A',
                             TopSelection=selA,
                             EventPreSelector=preselsA,
                             PostSelectionAlgs=postselsA)
    seqB = SelectionSequence('Seq0002B',
                             TopSelection=selB,
                             EventPreSelector=preselsB,
                             PostSelectionAlgs=postselsB)

    multiSeq = MultiSelectionSequence('MultiSeqAB',
                                      Sequences=[seqA, seqB],
                                      sequencerType=DummySequencer)

    assert multiSeq.outputLocations() == [
        selA.outputLocation(), selB.outputLocation()
    ]

    print 'algos in seqA', len(seqA.algorithms())
    print 'algos in seqB', len(seqB.algorithms())

    seqAlgos = multiSeq.sequence().Members
    seqAlgosA = seqAlgos[0].Members
    seqAlgosB = seqAlgos[1].Members
    assert len(seqAlgos) == len(multiSeq._sequences)
    assert len(multiSeq.algorithms()) == len(seqAlgosA) + len(seqAlgosB)

    ref_algosA = [
        presel0, presel1,
        _sel00.algorithm(),
        _sel01.algorithm(),
        _sel02.algorithm(),
        _sel03.algorithm(),
        sel02_03.algorithm(),
        sel00_01.algorithm(),
        selA.algorithm(), postsel0, postsel1
    ]

    ref_algosB = [
        presel2, presel3,
        _sel04.algorithm(),
        _sel05.algorithm(),
        _sel06.algorithm(),
        _sel07.algorithm(),
        sel06_07.algorithm(),
        sel04_05.algorithm(),
        selB.algorithm(), postsel2, postsel3
    ]

    assert len(seqAlgos) == 2

    assert preselsA == seqAlgosA[:len(preselsA)]
    assert preselsB == seqAlgosB[:len(preselsB)]
    # selA must be just before postsels
    assert selA.algorithm() == ref_algosA[len(ref_algosA) -
                                          (len(postselsA) + 1)]
    assert postselsA == seqAlgosA[len(ref_algosA) - len(postselsA):]
    assert postselsB == seqAlgosB[len(ref_algosB) - len(postselsB):]
    # selB must be just before postsels
    assert selB.algorithm() == ref_algosB[len(ref_algosB) -
                                          (len(postselsB) + 1)]

    # order doesn't matter
    for sel in [sel04_05, sel06_07]:
        assert sel.algorithm() in ref_algosB[len(preselsB):len(ref_algosB) -
                                             len(postselsB)]
    for sel in [sel00_01, sel02_03]:
        assert sel.algorithm() in ref_algosA[len(preselsA):len(ref_algosA) -
                                             len(postselsA)]