예제 #1
0
def test_selection_with_same_Inputs_set_in_algo():
    sel02 = AutomaticData(Location='Phys/Sel02/Particles')
    sel03 = AutomaticData(Location='Phys/Sel03/Particles')
    alg0 = MockConfGenerator(
        Inputs=['Phys/Sel02/Particles', 'Phys/Sel03/Particles'])
    sel0 = Selection('Sel007',
                     Algorithm=alg0,
                     RequiredSelections=[sel02, sel03])
예제 #2
0
def test_VoidEventSelection():
    sel00 = AutomaticData(Location='Phys/Sel00x/Particles')
    ves00 = VoidEventSelection('VES00',
                               Code='Test (<Location>) > X',
                               RequiredSelection=sel00)
    assert sel00.outputLocation() == ves00.outputLocation()
    assert ves00.outputLocation() == 'Phys/Sel00x/Particles'
    assert ves00.algorithm().Code == "Test ('Phys/Sel00x/Particles') > X"
예제 #3
0
def test_selection_with_name_overlap_doesnt_raise():
    sel02 = AutomaticData(Location='Phys/Sel02/Particles')
    sel03 = AutomaticData(Location='Phys/Sel03/Particles')
    alg0 = MockConfGenerator()
    sel0 = Selection('Sel005', Algorithm=alg0)
    sel1 = Selection('Sel005Loose', Algorithm=alg0)
    assert sel0.outputLocation() == 'Phys/Sel005/Particles'
    assert sel1.outputLocation() == 'Phys/Sel005Loose/Particles'
예제 #4
0
def test_selection_with_different_Inputs_set_in_algo_raises():
    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    alg0 = MockConfGenerator(Inputs=['Phys/Sel00', 'Phys/Sel01'])
    raises(IncompatibleInputLocations,
           Selection,
           'Sel006',
           Algorithm=alg0,
           RequiredSelections=[sel02, sel03])
예제 #5
0
def test_clone_selection_with_new_Inputs():
    sel = test_instantiate_tree('0002')
    clone00 = AutomaticData(Location='Phys/Clone00/Particles')
    clone01 = AutomaticData(Location='Phys/Clone01/Particles')
    selClone = sel.clone(name='sel0_clone1',
                         RequiredSelections=[clone00, clone01])
    assert len(selClone.algorithm().Inputs) == 2
    assert selClone.algorithm().Inputs.count('Phys/Clone00/Particles') == 1
    assert selClone.algorithm().Inputs.count('Phys/Clone01/Particles') == 1
예제 #6
0
def test_mergedselection_with_existing_configurable_name_raises():
    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')
    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    selFilter = FilterDesktop('MergeFilter')
    raises(NameError,
           MergedSelection,
           'MergeFilter',
           RequiredSelections=[sel00, sel01, sel02, sel03])
예제 #7
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'
예제 #8
0
def test_instantiate_multi_sequencer():
    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')
    alg00 = MockConfGenerator()
    alg01 = MockConfGenerator()
    sel00 = Selection('100011', Algorithm=alg00, RequiredSelections=[sel00])
    sel01 = Selection('100012', Algorithm=alg01, RequiredSelections=[sel01])
    seq00 = SelectionSequence('Seq000', TopSelection=sel00)
    seq01 = SelectionSequence('Seq001', TopSelection=sel01)
    seq = MultiSelectionSequence('MultiSeq00z', Sequences=[seq00, seq01])
예제 #9
0
def test_dummy_selection():
    data0 = AutomaticData(Location='Phys/Data0')
    data1 = AutomaticData(Location='Phys/Data1')
    algo = MockConfGenerator()
    sel = Selection('Sel01', Algorithm=algo, RequiredSelections=[data0, data1])
    newData = dummy('NewSel01', sel)
    assert newData.selection().name() == 'NewSel01'
    assert newData.outputLocation() == newData.selection().outputLocation(
    ) == 'Phys/NewSel01/Particles'
    assert len(newData.members()) == 3
예제 #10
0
def test_outputLocation():
    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    assert sel00.outputLocation() == 'Phys/Sel00/Particles'
    alg0 = MockConfGenerator()
    sel0 = Selection('SomeName001', Algorithm=alg0)
    assert sel0.outputLocation() == 'Phys/SomeName001/Particles'
    sel1 = Selection('SomeName002',
                     OutputBranch='HLT2',
                     Algorithm=alg0,
                     Extension='HltParticles')
    assert sel1.outputLocation() == 'HLT2/SomeName002/HltParticles'
예제 #11
0
def test_dummy_mergedselection():
    data0 = AutomaticData(Location='Phys/Data0')
    data1 = AutomaticData(Location='Phys/Data1')
    mergedData = MergedSelection('MergedData01',
                                 RequiredSelections=[data0, data1])
    newData = dummy('NewMergedData', mergedData)
    assert newData.selection().name() == 'NewMergedData'
    assert newData.outputLocation() == newData.selection().outputLocation(
    ) == 'Phys/NewMergedData/Particles'
    assert len(newData.members()) == 1
    assert len(newData.members()[0].Members) == 3
예제 #12
0
def test_merged_selection_with_existing_selection_name_raises():

    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')

    sel0 = MergedSelection('MergedSel001', RequiredSelections=[sel00, sel01])

    raises(NameError,
           MergedSelection,
           'MergedSel001',
           RequiredSelections=[sel00])
예제 #13
0
def test_call_important_methods():
    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    sel01 = AutomaticData(Location='Phys/Sel01/Particles')
    seq00 = SelectionSequence('Seq00y', TopSelection=sel00)
    seq01 = SelectionSequence('Seq01y', TopSelection=sel01)
    seq = MultiSelectionSequence('MultiSeq00y', Sequences=[seq00, seq01])
    assert seq.outputLocations() == [
        'Phys/Sel00/Particles', 'Phys/Sel01/Particles'
    ]
    algs = seq.algorithms()
    seq = seq.sequence()
예제 #14
0
def test_tree_Inputs_propagated():

    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    sel01 = AutomaticData(Location='Phys/Sel01/Particles')
    alg0 = MockConfGenerator(Inputs=[])
    sel0 = Selection('Sel001',
                     Algorithm=alg0,
                     RequiredSelections=[sel00, sel01])
    assert len(alg0.Inputs) == 0
    assert len(sel0.algorithm().Inputs) == 2
    assert sel0.algorithm().Inputs.count('Phys/Sel00/Particles') == 1
    assert sel0.algorithm().Inputs.count('Phys/Sel01/Particles') == 1
예제 #15
0
def test_multiselectionsequence_with_existing_configurable_name_raises():

    fd = FilterDesktop('MultiSeq00')
    sel00 = AutomaticData(Location='Phys/Sel00')
    sel01 = AutomaticData(Location='Phys/Sel01')
    seq00 = SelectionSequence('SelSeq00x', TopSelection=sel00)
    seq01 = SelectionSequence('SelSeq01x', TopSelection=sel01)

    raises(NameError,
           MultiSelectionSequence,
           'MultiSeq00',
           Sequences=[seq00, seq01])
예제 #16
0
def makeMergedDiMuons(name_jpsi='FullDSTDiMuonJpsi2MuMuDetachedLine',
                      name_psi2s='FullDSTDiMuonPsi2MuMuDetachedLine'):

    from PhysSelPython.Wrappers import AutomaticData
    sel_jpsi = AutomaticData('/Event/AllStreams/Phys/%s/Particles' % name_jpsi)
    sel_psi2s = AutomaticData('/Event/AllStreams/Phys/%s/Particles' %
                              name_psi2s)
    #
    ## merged selectoon for J/psi & psi'
    #
    from PhysSelPython.Wrappers import MergedSelection
    return MergedSelection('SelPsisForBandQ',
                           RequiredSelections=[sel_jpsi, sel_psi2s])
예제 #17
0
    def __init__(self, NAME, CONFIG):

        # Required the explicit name/dconfig, no default allow
        LineBuilder.__init__(self, NAME, CONFIG)
        preambulo = CONFIG['preambulo']
        ditau_pcomb = CONFIG['ditau_pcomb']
        input_e = [AutomaticData(Location=CONFIG['TES_e'])]
        input_mu = [AutomaticData(Location=CONFIG['TES_mu'])]
        input_pi = [AutomaticData(Location=CONFIG['TES_pi'])]

        ## Make 4 selections of tau candidates first
        tau_cands = MergedSelection(
            'SelTauCand',
            [
                # tau_cands = [
                selection_tau_single(CONFIG['tau_e'], preambulo, input_e, 'e'),
                selection_tau_single(CONFIG['tau_mu'], preambulo, input_mu,
                                     'mu'),
                selection_tau_single(CONFIG['tau_h1'], preambulo, input_pi,
                                     'h1'),
                selection_tau_h3(CONFIG['tau_h3'], preambulo, input_pi),
            ])  # Need merge so that the selection is parallel, not sequential

        sels_ditau = {}  # Selections, indexed by dcname (for emu sharing)

        ## Loop over all lines, make groupping
        for linename, dcdict in lines_decays.iteritems():

            ## Make list of selections in single line
            sels = []
            for dcname, decay in dcdict.iteritems():
                if dcname in sels_ditau:  # for emu case
                    sel = sels_ditau[dcname]
                else:
                    dtype = dcname.split('_')[0]  # eh1_ss --> eh1
                    config = CONFIG['ditau_' + dtype]
                    sel = selection_ditau(config, preambulo, ditau_pcomb,
                                          dcname, decay, [tau_cands])
                    sels_ditau[dcname] = sel
                sels.append(sel)

            ## Finally, compose a stripping line, register
            self.registerLine(
                StrippingLine(
                    NAME + linename +
                    'Line',  # e.g., 'Ditau' + 'EXss' + 'Line'
                    prescale=CONFIG[linename + '_prescale'],
                    postscale=CONFIG[linename + '_postscale'],
                    selection=MergedSelection('Sel' + linename, sels),
                    checkPV=True,
                ))
예제 #18
0
def test_clone_selection_with_existing_selection_name_raises():

    sel02 = AutomaticData(Location='Phys/Sel02')
    sel03 = AutomaticData(Location='Phys/Sel03')
    alg0 = MockConfGenerator()
    sel0 = Selection('Sel004',
                     Algorithm=alg0,
                     RequiredSelections=[sel02, sel03])

    raises(NameError,
           sel0.clone,
           name='Sel004',
           Algorithm=alg0,
           RequiredSelections=[sel02, sel03])
    assert sel0.algorithm().Inputs == ['Phys/Sel02', 'Phys/Sel03']
예제 #19
0
def test_VoidEventSelection_code_integrity():

    sel00 = AutomaticData(Location='Phys/Sel00x/Particles')

    ves01 = VoidEventSelection('VES01',
                               Code='Test (<Location>) > X',
                               RequiredSelection=sel00)
    coderef = "Test ('Phys/Sel00x/Particles') > X"

    assert ves01.algorithm().Code == coderef

    ves02 = VoidEventSelection('VES02',
                               Code="Test (<Location>) > X",
                               RequiredSelection=sel00)
    assert ves02.algorithm().Code == coderef

    ves03 = VoidEventSelection('VES03',
                               Code="Test ('<Location>') > X",
                               RequiredSelection=sel00)
    assert ves03.algorithm().Code == coderef

    ves04 = VoidEventSelection('VES04',
                               Code='Test (\'<Location>\') > X',
                               RequiredSelection=sel00)
    assert ves04.algorithm().Code == coderef
예제 #20
0
def DisplPhiPhi(conf):

    inputs = [AutomaticData(Location=conf['input'])]

    dc = (
        "TOS('%(TisTosSpec)s','Hlt1TriggerTisTos')"
        "& (PT > %(PhiPT)s) "
        "& (MINTREE('K+'==ABSID,PT) > %(KPT)s) "
        "& (MINTREE('K+'==ABSID,BPVIPCHI2()) > %(KIPChi2)s) "
        "& (MAXTREE('K+'==ABSID,TRGHOSTPROB) < %(GhostProb)s) "
        "& (MINTREE('K+'==ABSID,PROBNNK) > %(KProbNNk)s) "
        "& (VFASPF(VCHI2PDOF) < %(VChi2)s) "
        "& (in_range( PDGM('phi(1020)') - %(PhiMassWindow)s , M , PDGM('phi(1020)') + %(PhiMassWindow)s ) )"
    ) % conf

    mc = ("(HASVERTEX)"
          "& (VFASPF(VCHI2) < %(VChi2)s) "
          "& (BPVVDCHI2 > %(FDChi2)s)") % conf

    ## TOS on HLT2 on-demand
    if 'TOS_HLT2' in conf:
        mc += '& (TOS("%(TOS_HLT2)s", "Hlt2TriggerTisTos"))' % conf

    return SimpleSelection(
        'DisplPhiPhi',
        CombineParticles,
        inputs,
        DecayDescriptor='B0 -> phi(1020) phi(1020)',
        DaughtersCuts={'phi(1020)': dc},
        MotherCut=mc,
    )
예제 #21
0
 def dimuon ( self ) :
     """
     Create heavy dimuons
     """
     #
     ups_name = 'HeavyDiMion'
     sel_name = 'Sel%sFor%s' % ( ups_name , self.name() )
     sel_tag  = '%s_Selection'
     sel      = self._selection( sel_tag )        
     if sel  : return sel
     #
     dimu_line = self[ 'DIMUONLINE']
     if dimu_line :
         ## list of lines 
         from PhysSelPython.Wrappers import AutomaticData 
         sel = AutomaticData( dimu_line ) 
         return self._add_selection ( sel_tag , sel ) 
     
     from GaudiConfUtils.ConfigurableGenerators import CombineParticles
     return self.make_selection (
         ups_name         ,
         CombineParticles ,
         [ self.muons() ] ,
         DecayDescriptor = " J/psi -> mu+ mu- " ,
         CombinationCut  = "in_range ( 6.5 * GeV , AM , 20 * GeV ) ", 
         MotherCut       = "chi2vx < 20" 
         )
예제 #22
0
    def __Dstar__(self, conf):
        """
        Get D*+
        """
        _dstar = AutomaticData(Location = 'Phys/StdLooseDstarWithD02KPi/Particles')

        return _dstar
예제 #23
0
    def __Pions__(self, conf):
        """
        Filter pions from StdAllNoPIDsPions or StdAllLoosePions
        """  

        _pions = None
        UseNoPIDsHadrons=conf['UseNoPIDsHadrons']
        if (UseNoPIDsHadrons == True):
            _pions = AutomaticData(Location = 'Phys/StdAllNoPIDsPions/Particles')
        else:
            _pions = AutomaticData(Location = 'Phys/StdAllLoosePions/Particles')
        _filter = FilterDesktop(Code = self.TrackCuts+" & "+self.HadronCuts)
        _sel = Selection("Selection_"+self.name+"_StdAllNoPIDsPions",
                         RequiredSelections = [ _pions ] ,
                         Algorithm = _filter)
        return _sel
예제 #24
0
 def __Pi0ForOmega__(self, conf):
     """
     Filter Pi0 from Std Pi0
     """
     _pi0resolved = AutomaticData(Location = 'Phys/StdLooseResolvedPi0/Particles')
     _pi0merged = AutomaticData(Location = 'Phys/StdLooseMergedPi0/Particles')
     _filter_pi0resolved = FilterDesktop(Code = self.__Pi0ForOmegaCuts__(conf) )
     _filter_pi0merged = FilterDesktop(Code = self.__Pi0ForOmegaCuts__(conf)  )
     _selpi0resolved = Selection("Selection_"+self.name+"_pi0foromegaresolved",
                                 RequiredSelections = [ _pi0resolved ] ,
                                 Algorithm = _filter_pi0resolved)
     _selpi0merged = Selection("Selection_"+self.name+"_pi0foromegamerged",
                               RequiredSelections = [ _pi0merged ] ,
                               Algorithm = _filter_pi0merged)
     _sel = MergedSelection("Selection_"+self.name+"_pi0foromega",
                            RequiredSelections = [ _selpi0resolved,_selpi0merged ])
     return _sel
예제 #25
0
 def __Lambda__(self, conf):
     """
     Filter Lambda from StdLooseLambda and StdLooseLambda
     """  
     _lambdadd = AutomaticData(Location = 'Phys/StdLooseLambdaDD/Particles')
     _lambdall = AutomaticData(Location = 'Phys/StdLooseLambdaLL/Particles')
     _filter_lambdadd = FilterDesktop(Code = self.__LambdaCuts__(conf))
     _filter_lambdall = FilterDesktop(Code = self.__LambdaCuts__(conf))        
     _sellambdadd = Selection("Selection_"+self.name+"_Lambdadd",
                          RequiredSelections = [ _lambdadd ] ,
                          Algorithm = _filter_lambdadd)
     _sellambdall = Selection("Selection_"+self.name+"_Lambdall",
                          RequiredSelections = [ _lambdall ] ,
                          Algorithm = _filter_lambdall)
     _sel = MergedSelection("Selection_"+self.name+"_Lambda",
                            RequiredSelections = [ _sellambdadd, _sellambdall ])
     return _sel
예제 #26
0
def test_instantiate_from_Selection_object() :
    selection = AutomaticData(Location = 'Phys/Selection/Particles')
    line = StrippingLine('SelectionLine', algos = [selection])
    assert line.name() == 'StrippingSelectionLine'
    assert line.subname() == 'SelectionLine'
    assert line.isAppended() == False
    assert line.outputLocation() == 'Phys/SelectionLine/Particles'
    assert line.selection() != None
    assert line.selection().outputLocation() == line.outputLocation()
예제 #27
0
def test_selection_with_existing_selection_name_raises():

    sel02 = AutomaticData(Location='Phys/Sel02/Particles')
    sel03 = AutomaticData(Location='Phys/Sel03/Particles')
    alg0 = MockConfGenerator()

    sel0 = Selection('Sel003',
                     Algorithm=alg0,
                     RequiredSelections=[sel02, sel03])
    raises(NameError,
           Selection,
           'Sel003',
           Algorithm=alg0,
           RequiredSelections=[sel02, sel03])

    assert sel0.algorithm().Inputs == [
        'Phys/Sel02/Particles', 'Phys/Sel03/Particles'
    ]
예제 #28
0
 def __Pi0__(self, conf):
     """
     Filter Pi0 from Std Pi0
     """  
     _pi0resolved = AutomaticData(Location = 'Phys/StdLooseResolvedPi0/Particles')
     _pi0merged = AutomaticData(Location = 'Phys/StdLooseMergedPi0/Particles')
     _filter_pi0resolved = FilterDesktop(Code = self.__Pi0Cuts__(conf) )
     #+ " & ( 250*MeV < MINTREE('gamma' == ID, PT))"  )
     _filter_pi0merged = FilterDesktop(Code = self.__Pi0Cuts__(conf)  )        
     _selpi0resolved = Selection("Selection_"+self.name+"_pi0resolved",
                          RequiredSelections = [ _pi0resolved ] ,
                          Algorithm = _filter_pi0resolved)
     _selpi0merged = Selection("Selection_"+self.name+"_pi0merged",
                          RequiredSelections = [ _pi0merged ] ,
                          Algorithm = _filter_pi0merged)
     _sel = MergedSelection("Selection_"+self.name+"_pi0",
                           RequiredSelections = [ _selpi0resolved,_selpi0merged ])
     return _sel
예제 #29
0
    def __Kshort__(self, conf):
        """
        Filter kshort from StdLooseKshort
        """  
        _ksdd = AutomaticData(Location = 'Phys/StdLooseKsDD/Particles')
        _ksll = AutomaticData(Location = 'Phys/StdLooseKsLL/Particles')
        _filter_ksdd = FilterDesktop(Code = self.__KsCuts__(conf))
        _filter_ksll = FilterDesktop(Code = self.__KsCuts__(conf))        
        _selksdd = Selection("Selection_"+self.name+"_Ksdd",
                             RequiredSelections = [ _ksdd ] ,
                             Algorithm = _filter_ksdd)
        _selksll = Selection("Selection_"+self.name+"_Ksll",
                             RequiredSelections = [ _ksll ] ,
                             Algorithm = _filter_ksll)

        _sel = MergedSelection("Selection_"+self.name+"_Kshort",
                               RequiredSelections = [ _selksdd, _selksll ])
        return _sel
예제 #30
0
def test_dummy_automaticdata():
    data = AutomaticData(Location='Phys/Data0')
    newData = dummy('NewData0', data)
    assert newData.selection().name() == 'NewData0'
    assert newData.outputLocation() == newData.selection().outputLocation(
    ) == 'Phys/NewData0/Particles'
    assert len(newData.members()) == 1
    print newData.members()[0].Members
    assert len(newData.members()[0].Members) == 2
예제 #31
0
파일: BuKMuMu_MC.py 프로젝트: goi42/lhcb
# Merge into one stream and run in flag mode
#
AllStreams = StrippingStream("Dimuon")

for line in lb.lines():
    if line.name() == 'StrippingB2XMuMu_Line':
        AllStreams.appendLines([line])


sc = StrippingConf( Streams = [ AllStreams ],
                    MaxCandidates = 2000
                    )



stripsel = AutomaticData(Location = "Phys/B2XMuMu_Line/Particles")


_stripfilter = FilterDesktop("stripfilter",
  		      Preambulo = ["from LoKiPhysMC.decorators import *","from LoKiPhysMC.functions import mcMatch"],
                      Code = "mcMatch('[B+]cc')")

Bu_Kmumu = Selection ("Sel"+name,
                     Algorithm = _stripfilter,
                     RequiredSelections = [stripsel])
seq = SelectionSequence("seq",
                      TopSelection = Bu_Kmumu)

tuple = DecayTreeTuple("Jpsi_Tuple")

tuple.Inputs = [stripsel.outputLocation()]