Esempio n. 1
0
    def add_mc_unbiased_sequence(self, decayDesc, arrow = '==>',
                                 toolList = ["TupleToolPropertime",
                                             "TupleToolKinematic",
                                             "TupleToolGeometry",
                                             "TupleToolEventInfo",
                                             "TupleToolPrimaries",
                                             "TupleToolPid",
                                             "TupleToolANNPID",
                                             "TupleToolTrackInfo",
                                             "TupleToolRecoStats",],
                                 mcToolList = ['TupleToolMCTruth',
                                               'TupleToolMCBackgroundInfo',
                                               'MCTupleToolPrompt'],
                                 L0List = [],
                                 HLT1List = [],
                                 HLT2List = [],
                                 strippingList = []) :
        decayDescCC = decayDesc.copy()
        decayDescCC.cc = True

        sel = build_mc_unbiased_selection(decayDesc, arrow)
        selseq = SelectionSequence(decayDesc.get_full_alias() + '_MCSeq',
                                   TopSelection = sel)
        seq = selseq.sequence()
        seq.Members.insert(0, CheckPV())
        dtt = DecayTreeTuple(decayDesc.get_full_alias() + '_MCTuple',
                             Decay = decayDesc.to_string(carets = True),
                             Inputs = [sel.outputLocation()], 
                             ToolList = [])
        dtt.addBranches(decayDesc.branches())
        headBranch = getattr(dtt, decayDesc.get_alias())

        dtt.configure_tools(toolList = toolList,
                            mcToolList = mcToolList,
                            L0List = L0List,
                            HLT1List = HLT1List,
                            HLT2List = HLT2List,
                            strippingList = strippingList,
                            headBranch = headBranch)

        lokituple = headBranch.addTupleTool('LoKi::Hybrid::TupleTool')
        lokituple.Preambulo = ['from LoKiPhysMC.decorators import *',
                               'from LoKiPhysMC.functions import mcMatch']
        mcmatch = 'switch(mcMatch({0!r}), 1, 0)'.format(decayDescCC.to_string(carets = False,
                                                                              arrow = '==>'))
        lokituple.Variables = {'mcMatch' : mcmatch}


        seq.Members.append(dtt)
        self.UserAlgorithms.append(seq)

        mcdtt = MCDecayTreeTuple(decayDesc.get_full_alias() + '_MCDecayTreeTuple')
        mcdtt.addBranches(decayDesc.branches())
        mcdtt.Decay = decayDescCC.to_string(arrow = arrow, carets = True)
        mcdtt.ToolList += filter(lambda t : t.startswith('MC'), mcToolList)
        self.UserAlgorithms.append(mcdtt)

        return seq
Esempio n. 2
0
def make_mc_unbiased_seq(desc, arrow = '==>', refitpvs = True) :
    '''Make a selection sequence for the given decay descriptor that has no cuts besides
    truth matching.'''
    desc = desc.copy()
    desc.clear_aliases()
    sel = build_mc_unbiased_selection(desc, arrow, refitpvs)
    selseq = SelectionSequence(desc.get_full_alias() + '_MCUnbiasedSeq',
                               TopSelection = sel)
    seq = selseq.sequence()
    seq.Members.insert(0, CheckPV())
    return seq, selseq
Esempio n. 3
0
    def add_mc_unbiased_sequence(self, decayDesc, arrow = '==>',
                                 toolList = ["TupleToolPropertime",
                                             "TupleToolKinematic",
                                             "TupleToolGeometry",
                                             "TupleToolEventInfo",
                                             "TupleToolPrimaries",
                                             "TupleToolPid",
                                             "TupleToolANNPID",
                                             "TupleToolTrackInfo",
                                             "TupleToolRecoStats",],
                                 mcToolList = ['TupleToolMCTruth',
                                               'TupleToolMCBackgroundInfo',
                                               'MCTupleToolPrompt'],
                                 L0List = [],
                                 HLT1List = [],
                                 HLT2List = [],
                                 strippingList = []) :
        sel = build_mc_unbiased_selection(decayDesc, arrow)
        selseq = SelectionSequence(decayDesc.get_full_alias() + '_MCSeq',
                                   TopSelection = sel)
        seq = selseq.sequence()
        seq.Members.insert(0, CheckPV())
        dtt = DecayTreeTuple(decayDesc.get_full_alias() + '_MCTuple',
                             Decay = decayDesc.to_string(carets = True),
                             Inputs = [sel.outputLocation()], 
                             ToolList = [])
        dtt.addBranches(decayDesc.branches())
        headBranch = getattr(dtt, decayDesc.get_alias())

        dtt.configure_tools(toolList = toolList,
                            mcToolList = mcToolList,
                            L0List = L0List,
                            HLT1List = HLT1List,
                            HLT2List = HLT2List,
                            strippingList = strippingList,
                            headBranch = headBranch)

        lokituple = headBranch.addTupleTool('LoKi::Hybrid::TupleTool')
        lokituple.Preambulo = ['from LoKiPhysMC.decorators import *',
                               'from LoKiPhysMC.functions import mcMatch']
        mcmatch = 'switch(mcMatch({0!r}), 1, 0)'.format(decayDesc.to_string(carets = False,
                                                                            arrow = '==>'))
        lokituple.Variables = {'mcMatch' : mcmatch}


        seq.Members.append(dtt)
        self.UserAlgorithms.append(seq)

        mcdtt = MCDecayTreeTuple(decayDesc.get_full_alias() + '_MCDecayTreeTuple')
        mcdtt.Decay = decayDesc.to_string(arrow = arrow, carets = True)
        self.UserAlgorithms.append(mcdtt)

        return seq
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)]
Esempio n. 5
0
def add_tuples():
    '''Make ntuples for the D0->hhpi0 stripping lines. Assumes the data settings have already
    been configured in DaVinci.'''

    # Normal data
    stream = 'Charm.mdst'
    simulation = DaVinci().getProp('Simulation')
    # For restripping
    if DaVinci().getProp('ProductionType') == 'Stripping':
        stream = 'CharmCompleteEvent.dst'
    # For MC.
    elif simulation:
        stream = 'AllStreams.dst'

    fulldst = stream.endswith('.dst')
    streamname = '.'.join(stream.split('.')[:-1])

    tuples = []
    seqs = []
    for line in get_line_docs():
        stripdata = StrippingData(line.name,
                                  stream=(streamname if fulldst else None))
        if not simulation:
            stripdata = MomentumScaling(stripdata)
        lineconfig = line.tuple_config()
        del lineconfig['Inputs']
        dttsel = TupleSelection(line.name + 'Tuple', [stripdata], **lineconfig)
        dtt = dttsel.algorithm()
        dtt.addBranches(line.branches)
        tuples.append(dtt)
        add_tools(dtt)
        seq = SelectionSequence(line.name + 'Seq', TopSelection=dttsel)
        DaVinci().UserAlgorithms += [seq.sequence()]
    #DaVinci(**line.davinci_config(stream))
    DaVinci().StrippingStream = streamname

    DaVinci().TupleFile = 'DaVinciTuples.root'
    if DaVinci().getProp('Simulation'):
        for dtt in tuples:
            add_mc_tools(dtt)
    else:
        DaVinci().Lumi = True

    return tuples
Esempio n. 6
0
def oneTosMonitor(name="None", input=None, calo=False):

    from PhysSelPython.Wrappers import Selection, SelectionSequence
    from Configurables import TisTosParticleTagger, ParticleMonitor, PrintDecayTree
    Tosser = TisTosParticleTagger(name + "Tosser")
    Tosser.TisTosSpecs = {name + "Decision%TOS": 0}
    Tosser.ProjectTracksToCalo = calo
    Tosser.CaloClustForCharged = calo

    s1 = Selection("TOSPresel" + name,
                   Algorithm=Tosser,
                   RequiredSelections=[input])

    tools = ["MomentumPlotTool"]
    if ('Muon' in name): tools += ["MuonPlotTool"]
    plotter = ParticleMonitor(name + "TosMoni", PlotTools=tools)
    # Make things a bit faster
    if ('L0Hadron' in name): plotter.MotherCut = "PT>1*GeV"
    else: plotter.MotherCut = "PT>0.5*GeV"
    s2 = Selection("TOSSel" + name, Algorithm=plotter, RequiredSelections=[s1])
    ss = SelectionSequence("TOSSeq" + name, TopSelection=s2)
    return ss.sequence()
Esempio n. 7
0
    def __apply_configuration__(self) :

        from Configurables import ( GaudiSequencer, CombineParticles )
        from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand

        if not self.isPropertySet("Sequencer") :
            raise RuntimeError("ERROR : Sequence not set")
        seq = self.getProp("Sequencer")

        if self.getProp("RunSelection") :

            # STD particles
            from StandardParticles import StdLooseMuons

            # J/psi -> mu mu
            JPsiMuMuName               = self.__sel_name__
            JPsiMuMu                   = CombineParticles(JPsiMuMuName)
            JPsiMuMu.DecayDescriptor   = "J/psi(1S) -> mu+ mu- "
            JPsiMuMu.CombinationCut    = "(ADAMASS('J/psi(1S)') < 150*MeV)"
            JPsiMuMu.MotherCut         = "(ADMASS('J/psi(1S)') < 130*MeV) & (VFASPF(VCHI2/VDOF)<6) & (PT > 2500*MeV)"
            JPsiMuMu.DaughtersCuts     = {"mu+" : "(PT>1400*MeV)"\
                                          "& (P>5*GeV)"\
                                          "& (TRCHI2DOF<2.0)"\
                                          "& (PPINFO(LHCb.ProtoParticle.MuonBkgLL,-10000)<-2.5)"\
                                          "& (PPINFO(LHCb.ProtoParticle.MuonMuLL,-10000)>-10)"}
            self.setOptions(JPsiMuMu)
            JPsiMuMuSel = Selection( JPsiMuMuName+'Sel',
                                     Algorithm = JPsiMuMu,
                                     RequiredSelections = [StdLooseMuons] )

            # Selection Sequence
            selSeq = SelectionSequence( self.__sel_name__+'Seq', TopSelection = JPsiMuMuSel )

            # Run the selection sequence.
            seq.Members += [selSeq.sequence()]

        # Particle Monitoring plots
        if self.getProp("RunMonitors") :

            from Configurables import ( ParticleMonitor )
            plotter =  ParticleMonitor(self.__sel_name__+"Plots")
            if self.getProp("RunSelection") : 
                plotter.Inputs      = [ 'Phys/'+self.__sel_name__+'Sel' ]
            else:
                musel = "(PT>1400*MeV) & (P>5*GeV) & (TRCHI2DOF<2.0) & "\
                        "(PPINFO(LHCb.ProtoParticle.MuonBkgLL,-10000)<-2.5) & "\
                        "(PPINFO(LHCb.ProtoParticle.MuonMuLL,-10000)>-10)"
                _code = "( ( INTREE( ('mu+'==ID) & "+musel+" ) ) | ( INTREE( ('mu-'==ID) & "+musel+" ) ) )"
                from Configurables import FilterDesktop
                filter = FilterDesktop( name = self.__sel_name__+"RICHFiltered",
                                        Code = _code,
                                        Inputs = self.getProp("Candidates") )
                plotter.Inputs = [ 'Phys/'+filter.name() ]
                seq.Members += [filter]
            plotter.PeakCut     = "(ADMASS('J/psi(1S)')<20*MeV)" # Considering sigma = 13
            plotter.SideBandCut = "(ADMASS('J/psi(1S)')>20*MeV)" # Considering sigma = 13
            plotter.PlotTools   = self.getProp("PlotTools") 
            self.setOptions(plotter)
            seq.Members += [plotter]

        # Make a DST ?
        if self.getProp("MakeSelDST"):

            # Prescale
            from Configurables import DeterministicPrescaler
            scaler = DeterministicPrescaler( self.__sel_name__+'PreScale',
                                             AcceptFraction = self.getProp("DSTPreScaleFraction") )
            seq.Members += [scaler]
            # Write the DST
            MyDSTWriter = SelDSTWriter( self.__sel_name__+"DST",
                                        SelectionSequences = [ selSeq ],
                                        OutputPrefix = self.__sel_name__ )
            seq.Members += [MyDSTWriter.sequence()]

        # MC Performance checking ?
        if self.getProp("MCChecks") :

            from Configurables import ParticleEffPurMoni
            mcPerf = ParticleEffPurMoni(JPsiMuMuName+"MCPerf")
            mcPerf.Inputs = ['Phys/'+self.__sel_name__+'Sel']
            self.setOptions(mcPerf)
            seq.Members += [mcPerf]

        # Ntuple ?
        if self.getProp("MakeNTuple") :

            from Configurables import ( DecayTreeTuple,
                                        TupleToolDecay,
                                        LoKi__Hybrid__FilterCriterion,
                                        LoKi__Hybrid__TupleTool,
                                        TupleToolMCBackgroundInfo,
                                        BackgroundCategory,
                                        TupleToolTrigger,
                                        TupleToolMCTruth,
                                        MCTupleToolKinematic,
                                        MCTupleToolHierarchy,
                                        TupleToolVtxIsoln,
                                        TupleToolP2VV
                                        )
            
            JPsiMuMuTree = DecayTreeTuple( JPsiMuMuName + 'Tuple')
            JPsiMuMuTree.Inputs = [ 'Phys/'+JPsiMuMuName]
            JPsiMuMuTree.Decay = 'J/psi(1S) ->  ^mu+ ^mu- '
            
            # set some names for ntuple branchs
            MyBranch_jpsi  = "jpsi"
            MyBranch_mup   = "mup"
            MyBranch_mum   = "mum"
            
            # label the branches for the particle tools
            JPsiMuMuTree.Branches = {
                MyBranch_jpsi  : "J/psi(1S) : J/psi(1S) ->  mu+ mu- ",
                MyBranch_mup   : "J/psi(1S) ->  ^mu+ mu- ",
                MyBranch_mum   : "J/psi(1S) ->  mu+ ^mu- ",
                }
            
            JPsiMuMuTree.ToolList = [
                "TupleToolEventInfo"
                , "TupleToolGeneration"
                , "TupleToolMCTruth"
                , "TupleToolMCBackgroundInfo"
                , "MCTupleToolKinematic"
                , "TupleToolPrimaries"
                , "TupleToolVtxIsoln"
                , "TupleToolTrackInfo"
                , "TupleToolPid"
                , "TupleToolGeometry"
                , "TupleToolKinematic"
                , "TupleToolPropertime"
                , "TupleToolPid"
                , "TupleToolPrimaries"
                , "TupleToolTrigger"
                ]
            
            JPsiMuMuTree.addTool(BackgroundCategory())
            JPsiMuMuTree.BackgroundCategory.SoftPhotonCut = 2000
            JPsiMuMuTree.OutputLevel = INFO
            JPsiMuMuTree.addTool(TupleToolTrigger())
            JPsiMuMuTree.TupleToolTrigger.VerboseL0 = True
            JPsiMuMuTree.addTool(TupleToolMCTruth())
            JPsiMuMuTree.TupleToolMCTruth.addTool(MCTupleToolKinematic())
            JPsiMuMuTree.TupleToolMCTruth.addTool(MCTupleToolHierarchy())
            JPsiMuMuTree.TupleToolMCTruth.ToolList = [
                "MCTupleToolKinematic" ,
                "MCTupleToolHierarchy"
                ]
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StoreKineticInfo = True
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StoreVertexInfo = True
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StorePropertimeInfo = False
            JPsiMuMuTree.addTool(TupleToolVtxIsoln( OutputLevel = 6 ))
            JPsiMuMuTree.TupleToolVtxIsoln.IP = 2.0
            JPsiMuMuTree.TupleToolVtxIsoln.InputParticles = [ "Phys/StdLooseMuons"]
            
            seq.Members += [JPsiMuMuTree]
            
            JPsiMuMuTree.NTupleLUN = "JPSIMUMU"
            
            from Configurables import NTupleSvc
            NTupleSvc().Output = ["JPSIMUMU DATAFILE='JpsiMuMu_Presel.root'  TYP='ROOT'  OPT='NEW'"]
Esempio n. 8
0
class strippingLine:
    """
    Class to store information about stripping line that I will need to make nTuple
    """
    def __init__(self,name, lineName, dec, branches):
        self.name = name
        self.lineName = lineName
        self.dec = dec 
        self.branches = branches 
        self.lineLocation = "Phys/"+lineName+"/Particles"
        
         
    def select(self):
        """
        Get data and selection
        """

        from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand, AutomaticData
        # from StandardParticles import StdLooseMuons, StdLooseKaons
        from Configurables import FilterDesktop, CombineParticles, OfflineVertexFitter, LoKi__HDRFilter 
        from GaudiKernel.PhysicalConstants import c_light

        evtPreselectors = []

        if dataSample.isPrescaled != False:
            if dataSample.isPrescaled == True:
                dataSample.isPrescaled = 0.1
            prescaler =  DeterministicPrescaler("Prescaler", AcceptFraction = dataSample.isPrescaled)
            evtPreselectors.append(prescaler)


        # # Stripping filter
        strippingFilter = LoKi__HDRFilter( 'StripPassFilter', Code="HLT_PASS('Stripping"+self.lineName+"Decision')", Location="/Event/Strip/Phys/DecReports" )
        evtPreselectors.append(strippingFilter)


        stripped_data = AutomaticData(Location = self.lineLocation)
        
        # Trigger selection
        from Configurables import TisTosParticleTagger
        _tisTosFilter = TisTosParticleTagger( self.name + "Triggered" )
        _tisTosFilter.TisTosSpecs = { 'L0Global%TUS' : 0,
                                      'L0Global%TIS' : 0,
                                      }
        for trigger in trigger_list:
            for tistos in ['TIS', 'TUS']:
                _tisTosFilter.TisTosSpecs['{0}%{1}'.format(trigger, tistos)] = 0
        
        triggered_data =  Selection( self.name+'TriggerSelection',
                                     Algorithm = _tisTosFilter,
                                     RequiredSelections = [ stripped_data ],
                                     )
        
        Candidate_selection = stripped_data #triggered_data 
        
        self.sequence = SelectionSequence('Seq'+self.name,
                                          TopSelection = Candidate_selection,
                                          EventPreSelector = evtPreselectors)
        
    def makeTuple(self):
        """
        Make tuple
        """

        from Configurables import FitDecayTrees, DecayTreeTuple, TupleToolDecayTreeFitter, TupleToolDecay, TupleToolTrigger, TupleToolTISTOS, TupleToolPropertime, PropertimeFitter, TupleToolKinematic, TupleToolGeometry, TupleToolEventInfo, TupleToolPrimaries, TupleToolPid, TupleToolTrackInfo, TupleToolRecoStats, TupleToolMCTruth,  LoKi__Hybrid__TupleTool, LoKi__Hybrid__EvtTupleTool
        

        tuple = DecayTreeTuple('Tuple'+self.name) # I can put as an argument a name if I use more than a DecayTreeTuple
        tuple.Inputs = [ self.sequence.outputLocation() ]
        tuple.Decay = self.dec
        tuple.ToolList = ['TupleToolKinematic',
                          'TupleToolEventInfo', 
                          'TupleToolTrackInfo',
                          'TupleToolPid',
                          'TupleToolGeometry', 
                          'TupleToolAngles', # Helicity angle
                          # 'TupleToolPropertime', #proper time TAU of reco particles
                          ]

        
        tuple.InputPrimaryVertices = '/Event/Charm/Rec/Vertex/Primary'


        # Other event infos
        tuple.addTupleTool('LoKi::Hybrid::EvtTupleTool/LoKi_Evt')
        tuple.LoKi_Evt.VOID_Variables = {
            #"nSPDHits" :  " CONTAINS('Raw/Spd/Digits')  " ,
            'nTracks' :  " CONTAINS ('Charm/Rec/Track/Best') "  ,
            }
        
        # # Other variables
        # tuple.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_All')
        # tuple.LoKi_All.Variables = {
        #     'BPVIPCHI2' : 'BPVIPCHI2()',
        #     'BPVDIRA' : 'BPVDIRA',
        #     'BPVLTFITCHI2' : 'BPVLTFITCHI2()',           
        #     } 
        
        tuple.addBranches(self.branches)
        
        tuple.phi.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_phi")
        tuple.phi.LoKi_phi.Variables =  {
            'DOCAMAX' : 'DOCAMAX',
            "MassDiff_Phi" : "DMASS('phi(1020)')",
            "BPVDIRA" : "BPVDIRA",
            "IPS_Phi" : "MIPCHI2DV(PRIMARY)",
            "VFASPF_CHI2DOF" : "VFASPF(VCHI2/VDOF)",
            "VFASPF_CHI2" : "VFASPF(VCHI2)",
            "BPVIPCHI2" : "BPVIPCHI2()",
            "ADOCA" : "DOCA(1,2)",
            "ADOCACHI2" : "DOCACHI2(1,2)",

            "DTF_CHI2_PV"   : "DTF_CHI2( True, 'phi(1020)' )",
            "DTF_NDOF_PV"   : "DTF_NDOF( True, 'phi(1020)' )",
            "DTF_M_PV"      : "DTF_FUN ( M, True, 'phi(1020)' )",
            "DTF_M_Ks1_PV"    : "DTF_FUN ( CHILD(M,1), True, 'phi(1020)' )",
            "DTF_M_Ks2_PV"    : "DTF_FUN ( CHILD(M,2), True, 'phi(1020)' )",
           
            # "DTF_CTAU_Ks1"    : "DTF_CTAU(1, False, 'phi(1020)' )",
            # "DTF_CTAU_Ks2"    : "DTF_CTAU(2, False, 'phi(1020)' )",
            
           
            }
        

        def mySharedConf_Ks(branch):
            atool=branch.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_Ks')
            atool.Variables =  {
                "BPVDIRA" : "BPVDIRA",
                "VFASPF_CHI2DOF" : "VFASPF(VCHI2/VDOF)",
                "VFASPF_CHI2" : "VFASPF(VCHI2)",
                "BPVIPCHI2" : "BPVIPCHI2()",
                "BPVVD" : "BPVVD",
                "BPVVDCHI2" : "BPVVDCHI2",
                "ADOCA" : "DOCA(1,2)",
                "ADOCACHI2" : "DOCACHI2(1,2)",
                'BPVLTIME' : 'BPVLTIME()',
                }
            PropertimeTool = branch.addTupleTool("TupleToolPropertime/Propertime_Ks")
            

        mySharedConf_Ks(tuple.Ks1)
        mySharedConf_Ks(tuple.Ks2)

        def mySharedConf_pi(branch):
            atool=branch.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_pi')
            atool.Variables =  {
                'TRCHI2DOF' : 'TRCHI2DOF',
                'TRGHOSTPROB' : 'TRGHOSTPROB',
                }

        mySharedConf_pi(tuple.pi1)
        mySharedConf_pi(tuple.pi2)     
        mySharedConf_pi(tuple.pi3)
        mySharedConf_pi(tuple.pi4) 

        
        # Triggers:   
        tuple.phi.addTupleTool('TupleToolTISTOS/TISTOS')
        tuple.phi.TISTOS.TriggerList = trigger_list
        tuple.phi.TISTOS.VerboseL0   = True
        tuple.phi.TISTOS.VerboseHlt1 = True
        tuple.phi.TISTOS.VerboseHlt2 = True
        
                
        if dataSample.isMC:
            from Configurables import MCDecayTreeTuple, MCTupleToolKinematic, TupleToolMCTruth, MCTupleToolHierarchy, MCTupleToolReconstructed, MCTupleToolAngles, TupleToolMCBackgroundInfo
            tuple.addTupleTool('TupleToolMCTruth/MCTruth')
            tuple.MCTruth.ToolList = ['MCTupleToolKinematic',
                                      'MCTupleToolHierarchy',
                                      'MCTupleToolReconstructed',
                                      'MCTupleToolAngles',
                                      ]
            tuple.phi.addTupleTool( "TupleToolMCBackgroundInfo")

        
        self.sequence.sequence().Members += [tuple]
Esempio n. 9
0
    RequiredSelections=strippingSels
)

selSeq = SelectionSequence('SelSeq', TopSelection=selSub)

# Create an ntuple to capture D*+ decays from the new selection
from Configurables import DecayTreeTuple
dtt = DecayTreeTuple('TupleDstToD0pi_D0Topipi')
dtt.Inputs = [selSeq.outputLocation()]
# note the redefined decay of the D0
dtt.Decay = '[D*(2010)+ -> ^(D0 -> ^pi- ^pi+) ^pi+]CC'

# add our new selection and the tuple into the sequencer
from Configurables import GaudiSequencer, DaVinci
seq = GaudiSequencer('MyTupleSeq')
seq.Members += [selSeq.sequence()]
seq.Members += [dtt]
DaVinci().appendToMainSequence([seq])

# from previous file
from PhysConf.Filters import LoKi_Filters
fltrs = LoKi_Filters(STRIP_Code = "(HLT_PASS_RE('StrippingFullDSTDiMuonJpsi2MuMuDetachedLineDecision'))" )

DaVinci().Simulation   = False
DaVinci().EvtMax = -1                        # Number of events
DaVinci().EventPreFilters = fltrs.filters('Filter')
DaVinci().UserAlgorithms = [ seq, tuple  ]
from Configurables import CondDB
#CondDB(UseOracle = True)
#importOptions("$APPCONFIGOPTS/DisableLFC.py")
#CondDB().IgnoreHeartBeat = True
Esempio n. 10
0
userAlgos.Members = []
#userAlgos=[]
if  IsMC:
  from Configurables import TrackSmearState as SMEAR
  smear = SMEAR('StateSmear')
  userAlgos.Members.append(smear)
else:
  #
  from Configurables import CheckPV
  checkpv = CheckPV("CheckPV")
  checkpv.MinPVs = 1
  userAlgos.Members.append(checkpv)
  from Configurables import TrackScaleState as SCALER
  scaler = SCALER('StateScale')
  userAlgos.Members.append(scaler)  
userAlgos.Members.append(selSeq.sequence())
userAlgos.Members.append(tuple)
  
#from Configurables import HltSelReportsDecoder, HltVertexReportsDecoder, HltDecReportsDecoder
#userAlgos.Members.append( HltSelReportsDecoder() )
#userAlgos.Members.append( HltVertexReportsDecoder() )
#userAlgos.Members.append( HltDecReportsDecoder() )

from Configurables import EventTuple
etuple = EventTuple()
userAlgos.Members.append( etuple )

myTupleName = 'BsphiKK.root'

dv = DaVinci( 
    HistogramFile = 'dummy.root',
Esempio n. 11
0
        "LoKi_nOThits": "CONTAINS('Raw/OT/Times')",
        "LoKi_nNeutrals": "CONTAINS('Rec/ProtoP/Neutrals')",
        "LoKi_nCharged": "CONTAINS('Rec/ProtoP/Charged')"
    }

    #HRC tool
    tool = tupalg.addTupleTool("TupleToolHerschel")

## for debugging:
from SelPy.graph import graph
for tup in tuples:
    graph(tup, format='png')

from PhysSelPython.Wrappers import SelectionSequence
#seq  = SelectionSequence ( 'LbKSSEQ' , tupLbKS )
#dv.UserAlgorithms += [ seq.sequence() ]
#seq  = SelectionSequence ( 'LbKstSEQ' , tupLbKst )
#dv.UserAlgorithms += [ seq.sequence() ]
#seq  = SelectionSequence ( 'LbKSJpsipKSEQ' , tupLbKS_jpsipk )
#dv.UserAlgorithms += [ seq.sequence() ]
#seq  = SelectionSequence ( 'LbKstJpsipKSEQ' , tupLbKst_jpsipk )
#dv.UserAlgorithms += [ seq.sequence() ]

from Configurables import HCRawBankDecoder
decoder = HCRawBankDecoder()
DaVinci().UserAlgorithms += [decoder]

for tup in tuples:
    seq = SelectionSequence(tup.name() + '_SEQ', tup)
    dv.UserAlgorithms += [seq.sequence()]
Esempio n. 12
0
# #----Selection /\b -> J/psi /\-------------------
# _Lb2JpsiL = CombineParticles( "_Lb2JpsiL",
#                               DecayDescriptor = "[Lambda_b0 -> J/psi(1S) Lambda0]cc",
#                               CombinationCut = "AM < 6000. * MeV",
#                               
#                               ReFitPVs        = True )

# Lb2JpsiL  = Selection( "Lb2JpsiL",
#                       Algorithm          = _Lb2JpsiL ,
#                       RequiredSelections = [ Jpsi2MuMu, FilterL ] )

### Gaudi sequence
# SeqL2ppi = SelectionSequence("SeqL2ppi", TopSelection = L2ppi)
# seq = SeqL2ppi.sequence()
SeqFilterL = SelectionSequence("SeqFilterL", TopSelection = FilterL)
seq = SeqFilterL.sequence()

#--------------------------------------------------------------------------
# Configure DaVinci
#-------------------------------------------------------------------------
from Configurables import DaVinci

# DaVinci().appendToMainSequence( [sc.sequence() ] )   # Append the stripping selection sequence to DaVinci

from Configurables import  OfflineVertexFitter

from Configurables import  DecayTreeTuple, MCDecayTreeTuple
importOptions("Xb2JpsiXTreeMC.py")


tuple = DecayTreeTuple( "L2ppiTree" )
Esempio n. 13
0
def configure(datafiles,
              catalogs=[],
              castor=False,
              params={}):
    """
    Job configuration 
    """

    ## needed for job configuration
    from Configurables import DaVinci

    the_year = "2011"

    from BenderTools.Parser import hasInFile

    if params:
        the_year = params['Year']
        logger.info('Year is set from params to be %s ' % the_year)
    else:
        if hasInFile(datafiles, 'Collision11'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Collision12'):
            the_year = '2012'
        elif hasInFile(datafiles, 'Stripping17'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping13'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping15'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping19'):
            the_year = '2012'
        elif hasInFile(datafiles, 'Stripping20'):
            the_year = '2012'
        logger.info('Year is set from files  to be %s ' % the_year)

    #
    # check
    #
    if '2011' == the_year and hasInFile(datafiles, 'Collision12'):
        raise AttributeError, 'Invalid Year %s ' % the_year
    if '2012' == the_year and hasInFile(datafiles, 'Collision11'):
        raise AttributeError, 'Invalid Year %s ' % the_year

    logger.info('Use the Year = %s ' % the_year)

    #
    Jpsi_location = '/Event/Dimuon/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles'
    #

    # Read only fired events to speed up
    from PhysConf.Filters import LoKi_Filters
    fltrs = LoKi_Filters(
        STRIP_Code="HLT_PASS_RE('Stripping.*DiMuonJpsi2MuMuDeta.*')",
        VOID_Code="""
        0.5 < CONTAINS('%s')
        """ % Jpsi_location
    )
    #
    # protection agains ``corrupted'' Stripping 17b DIMUON.DST
    fltrs_0 = LoKi_Filters(
        VOID_Code="""
        ( EXISTS ( '/Event/DAQ/RawEvent') | EXISTS('/Event/Trigger/RawEvent' ) ) 
        & EXISTS ( '/Event/Strip/Phys/DecReports') 
        """
    )

    davinci = DaVinci(
        EventPreFilters=fltrs_0.filters(
            'Filters0') + fltrs.filters('Filters'),
        DataType=the_year,
        InputType='DST',
        Simulation=False,
        PrintFreq=1000,
        EvtMax=-1,
        #
        HistogramFile='Bcc1_Histos.root',
        TupleFile='Bcc1.root',
        #
        Lumi=True,
        #
    )

    from Configurables import CondDB
    CondDB(LatestGlobalTagByDataType=the_year)

    # ------- decoding set-up start ----------
    ## from BenderTools.MicroDST import uDstConf
    ## uDstConf ( rootInTES )
    # ------- decoding set-up end  -----------

    #
    # dimuon locations in DIMUON.DST
    #
    from PhysSelPython.Wrappers import AutomaticData
    jpsi = AutomaticData(Location=Jpsi_location)
    #
    # get the prompt charm
    #
    from StrippingSelections.StrippingPromptCharm import StrippingPromptCharmConf as PC
    #
    # ======================================
    pc = PC('PromptCharm', {
        'TrackCuts'       : """
        ( TRCHI2DOF   < 4   ) &
        ( TRGHOSTPROB < 0.5 ) &           
        ( PT > 250 * MeV    ) &
        in_range  ( 2 , ETA , 5 ) 
        """ ,
        'KaonCuts': ' & in_range ( 3.2 * GeV , P , 100 * GeV ) & ( 2 < PIDK  - PIDpi ) ',
        'PionCuts': ' & in_range ( 3.2 * GeV , P , 100 * GeV ) & ( 0 < PIDpi - PIDK  ) ',
    }
    )

    pions = pc.pions()
    kaons = pc.kaons()

    Preambulo = [
        # shortcut for chi2 of vertex fit
        'chi2vx = VFASPF(VCHI2) ',
        # shortcut for the c*tau
        "from GaudiKernel.PhysicalConstants import c_light",
        # use the embedded cut for chi2(LifetimeFit)<9 !!!
        "ctau   = BPVLTIME ( 9 ) * c_light "  # ATTENTION, 9 is here!
    ]

    from GaudiConfUtils.ConfigurableGenerators import CombineParticles

    # ========================================================================
    # B -> J/psi + K pi pi
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    bc_Kpp = CombineParticles(
        DecayDescriptor='[B+ -> J/psi(1S) K+ pi+ pi-]cc',
        #
        Preambulo=Preambulo,
        DaughtersCuts={
            "J/psi(1S)": " in_range( 3.096 * GeV - 45 * MeV , M , 3.096 * GeV + 45 * MeV ) "
        },
        #
        CombinationCut="""
        in_range ( 5.0 * GeV , AM ,  5.6 * GeV ) 
        """ ,
        #
        MotherCut="""
        in_range  ( 5.1 * GeV , M , 5.5 * GeV ) &
        ( PT      > 1 * GeV          ) &
        ( chi2vx  <  49              ) &
        in_range ( 150 * micrometer , ctau , 1000 * micrometer ) 
        """ ,
        #
        ParticleCombiners={'': 'LoKi::VertexFitter'},
        ReFitPVs=True
    )
    #
    from PhysSelPython.Wrappers import Selection
    Bc_Kpp = Selection(
        'PsiKpp',
        Algorithm=bc_Kpp,
        RequiredSelections=[jpsi, pions, kaons]
    )

    # ========================================================================
    # B -> J/psi + K
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    bc_K = CombineParticles(
        DecayDescriptor='[ B+ -> J/psi(1S) K+ ]cc',
        #
        Preambulo=Preambulo,
        DaughtersCuts={
            "J/psi(1S)": " in_range( 3.096 * GeV - 45 * MeV , M , 3.096 * GeV + 45 * MeV ) "
        },
        #
        CombinationCut="""
        in_range ( 5.0 * GeV , AM ,  5.6 * GeV ) 
        """ ,
        #
        MotherCut="""
        in_range  ( 5.1 * GeV , M , 5.5 * GeV ) &
        ( PT      > 1 * GeV          ) &
        ( chi2vx  <  16              ) &
        in_range ( 150 * micrometer , ctau , 1000 * micrometer ) 
        """ ,
        ParticleCombiners={'': 'LoKi::VertexFitter'},
        ReFitPVs=True
    )
    #
    Bc_K = Selection(
        'PsiK',
        Algorithm=bc_K,
        RequiredSelections=[jpsi, kaons]
    )

    from PhysSelPython.Wrappers import SelectionSequence
    Seq_Kpp = SelectionSequence("PSIKPP", TopSelection=Bc_Kpp)
    Seq_K = SelectionSequence("PSIK", TopSelection=Bc_K)

    from Configurables import GaudiSequencer
    davinci.UserAlgorithms = [
        GaudiSequencer(
            'K', Members=[Seq_K  .sequence(), 'B2PsiK']),
        GaudiSequencer('KPP', Members=[Seq_Kpp.sequence(), 'B2PsiKpp'])
    ]

    #
    # come back to Bender
    #
    setData(datafiles, catalogs, castor)

    #
    # start Gaudi
    #
    gaudi = appMgr()

    #
    algKpp = B2Kpp(
        'B2PsiKpp',  # Algorithm name ,
        Inputs=[Seq_Kpp.outputLocation()]
    )
    algK = B2K(
        'B2PsiK',  # Algorithm name ,
        Inputs=[Seq_K  .outputLocation()]
    )

    return SUCCESS
    'SelSeq_DstToD0pi',
    TopSelection=dst_sel
)

dtt_dst = DecayTreeTuple('TupleDstToD0pi_D0ToKpi_PersistReco')
dtt_dst.addTupleTool('TupleToolTrackInfo')
dtt_dst.Inputs = dst_selseq.outputLocations()
dtt_dst.Decay = '[D*(2010)+ -> ^(D0 -> ^K- ^pi+) ^pi+]CC'
dtt_dst.addBranches({
    'Dst': '[D*(2010)+ -> (D0 -> K- pi+) pi+]CC',
    'Dst_pi': '[D*(2010)+ -> (D0 -> K- pi+) ^pi+]CC',
    'D0': '[D*(2010)+ -> ^(D0 -> K- pi+) pi+]CC',
    'D0_K': '[D*(2010)+ -> (D0 -> ^K- pi+) pi+]CC',
    'D0_pi': '[D*(2010)+ -> (D0 -> K- ^pi+) pi+]CC',
})

dstar_hybrid = dtt_dst.Dst.addTupleTool('LoKi::Hybrid::TupleTool/LoKi_Dstar')

dstar_hybrid.Variables = {
    'dstar_delta_mass': 'M - CHILD(M,1)',
  }

DaVinci().UserAlgorithms = [dtt, dst_selseq.sequence(), dtt_dst]
DaVinci().DataType ='2016'

DaVinci().EvtMax=1000

DaVinci().TupleFile = 'PersistRecoTuple2.root'


                    "L0LocalPi0Decision",
                    "L0GlobalPi0Decision",
                    "L0MuonDecision",
                    "Hlt2Topo2BodyBBDTDecision",
                    "Hlt2Topo3BodyBBDTDecision",
                    "Hlt2Topo4BodyBBDTDecision",
                    "Hlt2RadiativeTopoTrackTOSDecision",
                    "Hlt2RadiativeTopoPhotonL0Decision",
                    "Hlt2TopoRad2BodyBBDTDecision",
                    "Hlt2TopoRad2plus1BodyBBDTDecision",
                    "Hlt2Topo2BodySimpleDecision",
                    "Hlt2Topo3BodySimpleDecision",
                    "Hlt2Topo4BodySimpleDecision"]

Gseq=GaudiSequencer('MyTupleSeq')
Gseq.Members += [Buseq.sequence()]
Gseq.Members += [tuple]
DaVinci().InputType='DST'
DaVinci().appendToMainSequence([Gseq])
#DaVinci().UserAlgorithms+=[tuple]
DaVinci().TupleFile="Output.root"
DaVinci().HistogramFile="histos.root"
DaVinci().DataType='2012'
DaVinci().EvtMax=50
DaVinci().PrintFreq=1000
DaVinci().MoniSequence=[tuple]
DaVinci().Simulation=True
DaVinci.DDDBtag='dddb-20130929-1'
DaVinci.CondDBtag='sim-20130522-1-vc-md100'

from GaudiConf import IOHelper
Esempio n. 16
0
from PhysSelPython.Wrappers import SelectionSequence
rd_SEQ = SelectionSequence  ( 'DATA'  , rd_selection )


###################### DAVINCI SETTINGS ############################################

lum = True
sim = False

if MODE == 'MC':
    lum = False
    sim = True

daVinci = DaVinci (
      EvtMax             = EVTMAX
    , RootInTES          = rootInTES
    , InputType          = "MDST"
    , TupleFile          = "DVTuples1.root"
    , HistogramFile      = 'DVHistos.root'
    , DataType           = "2011"
    , Simulation         = sim
    , Lumi               = lum
    , UserAlgorithms     =  [rd_SEQ.sequence()]
    )

MessageSvc().Format = "% F%60W%S%7W%R%T %0W%M"

###################################################################################
####################### THE END ###################################################
###################################################################################
Esempio n. 17
0
    def __apply_configuration__(self):

        from Configurables import (GaudiSequencer, CombineParticles,
                                   FilterDesktop)
        from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand

        if not self.isPropertySet("Sequencer"):
            raise RuntimeError("ERROR : Sequence not set")
        seq = self.getProp("Sequencer")

        if self.getProp("RunSelection"):

            # STD particles
            from StandardParticles import StdNoPIDsPions

            # Filter Pi Tracks
            pionFilterName = self.__sel_name__ + "_PiFilter"
            pionfilter = FilterDesktop(pionFilterName)
            pionfilter.Code = "(ISLONG) & (TRCHI2DOF < 5) & (P > 2*GeV) & (MIPCHI2DV(PRIMARY) > 30)"
            self.setOptions(pionfilter)
            pionfilterSel = Selection(pionFilterName + 'Sel',
                                      Algorithm=pionfilter,
                                      RequiredSelections=[StdNoPIDsPions])

            # Make the KS0
            ks02pipi = CombineParticles(self.__sel_name__)
            ks02pipi.DecayDescriptor = "KS0 -> pi+ pi-"
            ks02pipi.CombinationCut = "(ADAMASS('KS0') < 200*MeV) & (AMAXDOCA('') < 0.6*mm)"
            ks02pipi.MotherCut = "(ADMASS('KS0') < 100*MeV) & (VFASPF(VCHI2/VDOF) < 10) & (MIPDV(PRIMARY) < 0.75) & (BPVVDCHI2 > 150) & (MIPCHI2DV(PRIMARY) < 100) & ( ADWM( 'Lambda0' , WM( 'p+' , 'pi-') ) > 8*MeV ) & ( ADWM( 'Lambda0' , WM( 'pi+' , 'p~-') ) > 8*MeV )"
            self.setOptions(ks02pipi)
            ks02pipiSel = Selection(self.__sel_name__ + 'Sel',
                                    Algorithm=ks02pipi,
                                    RequiredSelections=[pionfilterSel])

            # Selection Sequence
            selSeq = SelectionSequence(self.__sel_name__ + 'Seq',
                                       TopSelection=ks02pipiSel)

            # Run the selection sequence.
            seq.Members += [selSeq.sequence()]

        # Particle Monitoring plots
        if self.getProp("RunMonitors"):

            from Configurables import ParticleMonitor
            plotter = ParticleMonitor(self.__sel_name__ + "Plots")
            if self.getProp("RunSelection"):
                plotter.Inputs = ['Phys/' + self.__sel_name__ + 'Sel']
            else:
                plotter.Inputs = self.getProp("Candidates")
            plotter.PeakCut = "(ADMASS('KS0')<7*MeV)"
            plotter.SideBandCut = "(ADMASS('KS0')>7*MeV)"
            plotter.PlotTools = self.getProp("PlotTools")
            self.setOptions(plotter)
            seq.Members += [plotter]

        # Make a DST ?
        if self.getProp("MakeSelDST"):

            # Prescale
            from Configurables import DeterministicPrescaler
            scaler = DeterministicPrescaler(
                self.__sel_name__ + 'PreScale',
                AcceptFraction=self.getProp("DSTPreScaleFraction"))
            seq.Members += [scaler]
            # Write the DST
            MyDSTWriter = SelDSTWriter(self.__sel_name__ + "DST",
                                       SelectionSequences=[selSeq],
                                       OutputPrefix=self.__sel_name__)
            seq.Members += [MyDSTWriter.sequence()]

        # MC Performance checking ?
        if self.getProp("MCChecks"):

            from Configurables import ParticleEffPurMoni

            #mcPerfPi = ParticleEffPurMoni("StdNoPIDsPionsMCPerf")
            #mcPerfPi.Inputs = ["Phys/StdNoPIDsPions"]
            #mcPerfPi.OutputLevel = DEBUG
            #seq.Members += [mcPerfPi]

            #mcPerfPiFilt = ParticleEffPurMoni(pionFilterName+"MCPerf")
            #mcPerfPiFilt.Inputs = ["Phys/"+pionFilterName]
            #seq.Members += [mcPerfPiFilt]

            mcPerfD = ParticleEffPurMoni(ks02pipiName + "MCPerf")
            mcPerfD.Inputs = ["Phys/" + ks02pipiName]
            self.setOptions(mcPerfD)
            seq.Members += [mcPerfD]

        # Ntuple ?
        if self.getProp("MakeNTuple"): pass
Esempio n. 18
0
#----Selection /\->p+ pi-

AllLambda0 = MergedSelection( "AllLambda0", RequiredSelections = [Lambda0LL, Lambda0DD])

_FilterL = FilterDesktop("_FilterL")
_FilterL.Code = "(ADMASS('Lambda0') < 30.*MeV)"\
                  "& (VFASPF(VCHI2/VDOF) < 12.0)"

FilterL = Selection( "FilterL",
                      Algorithm          = _FilterL ,
                      RequiredSelections = [ AllLambda0 ] )

### Gaudi sequence
SeqL = SelectionSequence("SeqL", TopSelection = FilterL)
seq = SeqL.sequence()

#--------------------------------------------------------------------------
# Configure DaVinci
#-------------------------------------------------------------------------
from Configurables import DaVinci

# DaVinci().appendToMainSequence( [sc.sequence() ] )   # Append the stripping selection sequence to DaVinci

from Configurables import  OfflineVertexFitter

from Configurables import  DecayTreeTuple, MCDecayTreeTuple
importOptions("Xb2JpsiXTree.py")


tuple = DecayTreeTuple( "LTree" )
Esempio n. 19
0


#---- Refit vertices with Jpsi mass constraint----------------
#_Lb2JpsipK.addTool( OfflineVertexFitter() )
#_Lb2JpsipK.VertexFitters.update( { "" : "OfflineVertexFitter"} )
#_Lb2JpsipK.OfflineVertexFitter.applyDauMassConstraint = True


Lb2JpsipK  = Selection( "Lb2JpsipK ",
                      Algorithm          = _Lb2JpsipK ,
                      RequiredSelections = [ Jpsi2MuMu, FilterL ] )

### Gaudi sequence
SeqLb2JpsipK = SelectionSequence("SeqLb2JpsipK", TopSelection = Lb2JpsipK)
seq = SeqLb2JpsipK.sequence()

#--------------------------------------------------------------------------
# Configure DaVinci
#-------------------------------------------------------------------------
from Configurables import DaVinci

from Configurables import  OfflineVertexFitter

from Configurables import  DecayTreeTuple, MCDecayTreeTuple
importOptions("Xb2JpsiXTree.py")


tuple = DecayTreeTuple( "Lb2JpsiLTree" )
tuple.Inputs = [ SeqLb2JpsipK.outputLocation() ]
Esempio n. 20
0
recMus_seq = SelectionSequence('recMus_Seq', TopSelection=recMus)

Jpsi_seq = SelectionSequence('Jpsi_Seq', TopSelection=recJpsi)
D0_seq = SelectionSequence('D0_Seq', TopSelection=recD0)
Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp)
Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs)
Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc)
D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi)

# Turbo/DaVinci configuration.
from Configurables import DstConf, TurboConf, DaVinci
DaVinci().Simulation = True
DaVinci().appendToMainSequence([genPF, genJB, recPF, recJB])
#DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()])
DaVinci().appendToMainSequence([
    Jpsi_seq.sequence(),
    D0_seq.sequence(),
    Dp_seq.sequence(),
    Ds_seq.sequence(),
    Lc_seq.sequence(),
    D02K3pi_seq.sequence()
])
DaVinci().DataType = '2016'
#DaVinci().EventPreFilters = fltrs.filters ('Filters')

# Configure the BDT tagger.
from Configurables import LoKi__BDTTag
tagger = LoKi__BDTTag()
tagger.NbvSelect = False
tagger.Backwards = True
Esempio n. 21
0
tupleB.TupleToolANNPID.ANNPIDTunes = ['MC12TuneV2', 'MC12TuneV3']

dstWriter = SelDSTWriter('BuKmumuDSTWriter',
                         SelectionSequences=sc.activeStreams(),
                         OutputFileSuffix='Stripped')

from Configurables import DaVinci
DaVinci().TupleFile = "BuKMuMu.root"
DaVinci().EvtMax = -1
DaVinci().DataType = '2012'
DaVinci().Simulation = True
DaVinci().Lumi = not DaVinci().Simulation

_myseq = GaudiSequencer("myseq")
_myseq.Members += [eventNodeKiller, sc.sequence()]  #redo the stripping
_myseq.Members += [SeqB.sequence()]  # make B candidates (muon channel)
#_myseq.Members += [tuple]
_myseq.Members += [tupleB]  # put stuff in a Tuple
DaVinci().UserAlgorithms = [_myseq]  # run the whole thing
DaVinci().MainOptions = ""
"""
#we should put this back later if we want to smear stuff
from Configurables import TrackSmeared
TrackSmeared("TrackSmearing").smearBest = True
TrackSmeared("TrackSmearing").Scale = 0.5
TrackSmearingSeq = GaudiSequencer("TrackSmearingSeq")
TrackSmearingSeq.Members = [ TrackSmeared("TrackSmearing") ]
"""
#try to do it like in the starterkit
"""
Esempio n. 22
0
    TrackSmeared("TrackSmearing").InputLocation = "Rec/Track/Best"
    #TrackSmeared("TrackSmearing").OutputLocation = "Best"
    TrackSmeared("TrackSmearing").smear = True
    TrackSmeared("TrackSmearing").makePlots = True
    TrackSmeared("TrackSmearing").OutputLevel = 3
    TrackSmeared("TrackSmearing").smearBest = True
    TrackSmeared("TrackSmearing").smearProto = True
    TrackSmearingSeq = GaudiSequencer("TrackSmearingSeq")
    TrackSmearingSeq.Members = [ TrackSmeared("TrackSmearing") ]
    




DaVinci().UserAlgorithms += [ TrackSmearingSeq,
    _seqPions.sequence()
    ,decaytuple
    ,_seqKaons.sequence()
    ,decaytuple4
    ,_seqMuons.sequence()
    ,decaytuple5
    ]

#if not Data:
#    DaVinci().UserAlgorithms += [ 
#        _seqPions2.sequence()
#        ,decaytuple2
#        ,_seqKaons2.sequence()
#        ,decaytuple3
#        ,_seqMuons2.sequence()
#        ]
Esempio n. 23
0
def execute(simulation=True,
            turbo=True,
            decay_descriptor="J/psi(1S) -> mu- mu+"):
    # Configure all the unpacking, algorithms, tags and input files
    appConf = ApplicationMgr()
    appConf.ExtSvc+= ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

    ConfigTarFileAccessSvc().File = 'config.tar'
    
    dv = DaVinci()
    dv.DataType = "2012"

    lhcbApp = LHCbApp()
    lhcbApp.Simulation = simulation
    CondDB().Upgrade = False
    
    dtt = DecayTreeTuple("Early2015")
    if turbo:
        tesla_prefix = "Hlt2DiMuonJPsi"
        dtt.Inputs = ["/Event/"+tesla_prefix+"/Particles"]
        dtt.InputPrimaryVertices = "/Event/"+tesla_prefix+"/Primary"
        dtt.WriteP2PVRelations = False

    else:
        LHCbApp().DDDBtag = "dddb-20140729"
        polarity = "u"
        LHCbApp().CondDBtag = "sim-20140730-vc-m%s100"%polarity
        muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles")

        jpsi = CombineParticles('MyJPsi')
        jpsi.DecayDescriptors = [decay_descriptor]
        jpsi.CombinationCut = "(AM < 7100.0 *GeV)"
        jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"}
        jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)"
        
        code = """
('J/psi(1S)' == ID) &
in_range(2.990*GeV, M, 3.210*GeV) &
DECTREE('%s') &
CHILDCUT(1, HASMUON & ISMUON) &
CHILDCUT(2, HASMUON & ISMUON) &
(MINTREE('mu+' == ABSID, PT) > 700*MeV) &
(MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) &
(MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) &
(VFASPF(VPCHI2) > 0.5/100) &
(abs(BPV(VZ)) <  0.5*meter) &
(BPV(vrho2) < (10*mm)**2)
"""%(decay_descriptor)
        # similar to the HLT2 line
        code = """
(ADMASS('J/psi(1S)')< 120*MeV) &
DECTREE('%s') &
(PT>0*MeV) &
(MAXTREE('mu-'==ABSID,TRCHI2DOF) < 4) &
(MINTREE('mu-'==ABSID,PT)> 0*MeV) &
(VFASPF(VCHI2PDOF)< 25)
"""%(decay_descriptor)
        filter_jpsi = FilterDesktop("MyFilterJPsi",
                                    Code=code,
                                    Preambulo=["vrho2 = VX**2 + VY**2"],
                                    ReFitPVs=True,
                                    #IgnoreP2PVFromInputLocations=True,
                                    #WriteP2PVRelations=True
                                    )
        
        jpsi_sel = Selection("SelMyJPsi", Algorithm=jpsi, RequiredSelections=[muons])
        filter_jpsi_sel = Selection("SelFilterMyJPsi",
                                    Algorithm=filter_jpsi,
                                    RequiredSelections=[jpsi_sel])
        jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel)
        dtt.Inputs = [jpsi_seq.outputLocation()]
    
    # Overwriting default list of TupleTools
    dtt.ToolList = ["TupleToolKinematic",
                    "TupleToolPid",
                    "TupleToolEventInfo",
                    "TupleToolMCBackgroundInfo",
                    "TupleToolMCTruth",
                    #"MCTupleToolHierarchy",
                    #"MCTupleToolPID",
                    "TupleToolGeometry",
                    "TupleToolTISTOS",
                    # with turbo this crashes
                    #"TupleToolTrackInfo",
                    "TupleToolTrigger",
                    ]
    tlist = ["L0HadronDecision", "L0MuonDecision",
             "L0DiMuonDecision", "L0ElectronDecision",
             "L0PhotonDecision",
             "Hlt1DiMuonHighMassDecision", "Hlt1DiMuonLowMassDecision",
             "Hlt1TrackMuonDecision", "Hlt1TrackAllL0Decision",
             "Hlt2DiMuonJPsiDecision", "Hlt2SingleMuonDecision",
             ]
    
    dtt.addTool(TupleToolTrigger, name="TupleToolTrigger")
    dtt.addTool(TupleToolTISTOS, name="TupleToolTISTOS")
    # Get trigger info
    dtt.TupleToolTrigger.Verbose = True
    dtt.TupleToolTrigger.TriggerList = tlist
    dtt.TupleToolTISTOS.Verbose = True
    dtt.TupleToolTISTOS.TriggerList = tlist

    from Configurables import TupleToolMCTruth, MCTupleToolHierarchy
    dtt.addTool(TupleToolMCBackgroundInfo,
                name="TupleToolMCBackgroundInfo")
    dtt.TupleToolMCBackgroundInfo.Verbose = True
    dtt.addTool(MCTupleToolHierarchy,
                name="MCTupleToolHierarchy")
    dtt.MCTupleToolHierarchy.Verbose = True
    dtt.addTool(TupleToolMCTruth,
                name="TupleToolMCTruth")
    dtt.TupleToolMCTruth.Verbose = True

    if turbo:
        assoc_seq = TeslaTruthUtils.associateSequence(tesla_prefix, False)
        ChargedPP2MC(tesla_prefix+"ProtoAssocPP").OutputLevel = 1
        
        assoc_seq.Members.insert(0, PatLHCbID2MCParticle())

        from Configurables import MuonCoord2MCParticleLink
        muon_coords = MuonCoord2MCParticleLink("TeslaMuonCoordLinker")
        assoc_seq.Members.insert(1, muon_coords)
    
        TrackAssociator("TeslaAssocTr").DecideUsingMuons = True
        
        relations = TeslaTruthUtils.getRelLoc(tesla_prefix)

    else:
        relations = "Relations/Rec/ProtoP/Charged"


    TeslaTruthUtils.makeTruth(dtt,
                              relations,
                              ["MCTupleToolKinematic",
                               "MCTupleToolHierarchy",
                               "MCTupleToolPID",
                               ]
                              )
    
    
    dtt.Decay = mark(2, mark(3, decay_descriptor)) #"J/psi(1S) -> ^mu- ^mu+"
    
    dtt.addBranches({"X": "^(%s)"%(decay_descriptor),
                     "muplus": mark(3, decay_descriptor),#"J/psi(1S) -> mu- ^mu+",
                     "muminus": mark(2, decay_descriptor),#"J/psi(1S) -> ^mu- mu+",
                     })
    
    x_preamble = ["DZ = VFASPF(VZ) - BPV(VZ)",
                  ]
    x_vars = {"ETA": "ETA",
              "Y": "Y",
              "PHI": "PHI",
              "VPCHI2": "VFASPF(VPCHI2)",
              "DELTAZ": "DZ",
              # DZ * M / PZ / c with c in units of mm/s
              # XXX should this be the PDG mass or measured mass?
              #"TZ": "DZ*M / PZ / 299792458000.0", #seconds
              "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)", #ps
              "minpt": "MINTREE('mu+' == ABSID, PT)",
              "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)",
              "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)",
              }
    muon_vars = {"ETA": "ETA",
                 "Y": "Y",
                 "PHI": "PHI",
                 "CHARGE": "Q",
                 "CLONEDIST": "CLONEDIST",
                 "TRCHI2DOF": "TRCHI2DOF",
                 }
    
    loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X")
    loki_X.Variables = x_vars
    loki_X.Preambulo = x_preamble
    
    loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus")
    loki_mup.Variables = muon_vars
    #dtt.muplus.addTupleTool("TupleToolGeometry")
    
    loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus")
    loki_mum.Variables = muon_vars
    #dtt.muminus.addTupleTool("TupleToolGeometry")
    
    dv.TupleFile = "DVNtuples.root"
    if turbo:
        dv.UserAlgorithms = [assoc_seq, dtt]

    else:
        assocpp = ChargedPP2MC("TimsChargedPP2MC")
        assocpp.OutputLevel = 1
        dv.UserAlgorithms = [jpsi_seq.sequence(), assocpp, dtt]
Esempio n. 24
0
    RequiredSelections=strippingSels
)
# in order to add the selection into the program make a sequence
selSeq = SelectionSequence('SelSeq', TopSelection=selSub)


# Create an ntuple to capture D*+ decays from the new selection
dtt = DecayTreeTuple('TupleDstToD0pi_D0Topipi')
dtt.Inputs = [selSeq.outputLocation()]
dtt.Decay = '[D*(2010)+ -> ^(D0 -> ^pi- ^pi+) ^pi+]CC'

# Configure DaVinci

# add our new selection and the tuple into the sequencer
seq = GaudiSequencer('MyTupleSeq')
seq.Members += [selSeq.sequence()]
seq.Members += [dtt]
DaVinci().appendToMainSequence([seq])

DaVinci().InputType = 'DST'
DaVinci().TupleFile = 'DVntuple.root'
DaVinci().PrintFreq = 1000
DaVinci().DataType = '2016'
DaVinci().Simulation = True
# Only ask for luminosity information when not using simulated data
DaVinci().Lumi = not DaVinci().Simulation
DaVinci().EvtMax = -1

# Use the local input data
IOHelper().inputFiles([
    './00062514_00000001_7.AllStreams.dst'
Esempio n. 25
0
    # )
    if 'sel' in t:
        sel = t['sel']  #
        dstp = DataOnDemand(t['line'])
        cutter = FilterDesktop(t['name'] + 'selector', Code=sel)
        selection = Selection(t['name'] + 'selection',
                              Algorithm=cutter,
                              RequiredSelections=[dstp])

        selseq = SelectionSequence(t['name'] + 'selectionsequence',
                                   TopSelection=selection)

        t['tuple'].Inputs = [selection.outputLocation()]

        sequencer = GaudiSequencer('{0}SelectionSequencer'.format(t['name']),
                                   Members=[selseq.sequence(), t['tuple']])
        tuple_members.append(sequencer)
    else:
        tuple_members.append(t['tuple'])
    if is_mc():
        gen_members.append(t['gen'])

# Run the ntuple creation as a sequence, but don't worry about whether each
# ntuple gets filled
tuple_seq = GaudiSequencer('TupleSequencer',
                           Members=tuple_members,
                           IgnoreFilterPassed=True)

if is_mc():
    gen_seq = GaudiSequencer('GenTupleSequencer',
                             Members=gen_members,
Esempio n. 26
0
Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp)
Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs)
Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc)
D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi)

##########################

# Turbo/DaVinci configuration.
from Configurables import DstConf, TurboConf, DaVinci

DaVinci().Simulation = False
DaVinci().Lumi = True
DaVinci().TupleFile = "LumiTuple.root"
#DaVinci().appendToMainSequence([genPF, genJB, recPF, recJB])
DaVinci().appendToMainSequence([recPF, recJB])
DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()])
DaVinci().appendToMainSequence([
    Jpsi_seq.sequence(),
    D0_seq.sequence(),
    Dp_seq.sequence(),
    Ds_seq.sequence(),
    Lc_seq.sequence(),
    D02K3pi_seq.sequence()
])
##TODO adding recSVs and recMus changes the daughters of jet objects from smart poniters to Particles
DaVinci().DataType = '2018'
DaVinci().EventPreFilters = fltrs.filters('Filters')

from Configurables import LumiIntegrateFSR, LumiIntegratorConf

LumiIntegrateFSR('IntegrateBeamCrossing').SubtractBXTypes = ['None']
Esempio n. 27
0
def configure(datafiles,
              catalogs=[],
              castor=False,
              params={}):
    """
    Job configuration 
    """

    ## needed for job configuration
    from Configurables import DaVinci

    the_year = "2011"

    from BenderTools.Parser import hasInFile

    if params:
        the_year = params['Year']
        logger.info('Year is set from params to be %s ' % the_year)
    else:
        if hasInFile(datafiles, 'Collision11'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Collision12'):
            the_year = '2012'
        elif hasInFile(datafiles, 'Collision13'):
            the_year = '2013'
        elif hasInFile(datafiles, 'Stripping17'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping13'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping15'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping19'):
            the_year = '2012'
        elif hasInFile(datafiles, 'Stripping20r1'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping20r1p1'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping20r0p1'):
            the_year = '2012'
        elif hasInFile(datafiles, 'MC11'):
            the_year = '2011'
        logger.info('Year is set from files  to be %s ' % the_year)

    #
    # check
    #
    if '2011' == the_year and hasInFile(datafiles, 'Collision12'):
        raise AttributeError, 'Invalid Year %s ' % the_year
    if '2012' == the_year and hasInFile(datafiles, 'Collision11'):
        raise AttributeError, 'Invalid Year %s ' % the_year

    logger.info('Use the Year = %s ' % the_year)

    W_Location = '/Event/AllStreams/Phys/WMuLine/Particles'
    from PhysSelPython.Wrappers import AutomaticData
    W_Strip = AutomaticData(Location=W_Location)

    EW_preambulo = [
        "pion_cuts  = in_range ( 300 * MeV , PT , 10 * GeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 5 ) & ( TRGHOSTPROB < 0.5 ) & ( PERR2/P2 < 0.05**2 ) ",
        "ptCone_    =  SUMCONE (   0.25 , PT , '/Event/Phys/StdAllLoosePions/Particles'               )",
        "ptCone_2   =  SUMCONE (   0.25 , PT , '/Event/Phys/StdAllLoosePions/Particles'   , pion_cuts )",
        "etCone_    =  SUMCONE (   0.25 , PT , '/Event/Phys/StdLooseAllPhotons/Particles'             )",
        "ptCone     =    SINFO (  55001 , ptCone_  , True ) ",
        "ptCone2    =    SINFO (  55003 , ptCone_2 , True ) ",
        "etCone     =    SINFO (  55002 , etCone_  , True ) ",
    ]

    # ========================================================================
    # good W
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    gW = FilterDesktop(
        Preambulo=EW_preambulo,
        Code="""
        in_range ( 15 * GeV , PT , 100 * GeV ) &
        ( -1e+10 * GeV < ptCone  ) &
        ( -1e+10 * GeV < ptCone2 ) &
        ( -1e+10 * GeV < etCone  ) 
        """
    )
    from PhysSelPython.Wrappers import Selection
    W_Data = Selection(
        'W',
        Algorithm=gW,
        RequiredSelections=[W_Strip]
    )

    from PhysSelPython.Wrappers import SelectionSequence
    seq = SelectionSequence("Wseq", TopSelection=W_Data)

    # counters
    from Configurables import LoKi__CounterAlg as CounterAlg
    cnt = CounterAlg(
        'CharmEWCounters',
        Location="Counters/CharmEW",
        Preambulo=[
            "from LoKiPhys.decorators import *",
            "from LoKiCore.functions  import *",
            "pion_cuts  = in_range ( 300 * MeV , PT , 120 * GeV ) & ( CLONEDIST > 5000 ) & ( TRCHI2DOF < 5 ) ",
            "gamma_cuts = in_range ( 300 * MeV , PT ,  10 * GeV )  ",
            "pions      = SOURCE ( '/Event/Phys/StdAllNoPIDsPions/Particles'  ,  pion_cuts ) ",
            "gammas     = SOURCE ( '/Event/Phys/StdLooseAllPhotons/Particles' , gamma_cuts ) ",
        ],
        Variables={
            "px_c": " pions  >> sum ( PX ) ",
            "py_c": " pions  >> sum ( PY ) ",
            "px_g": " gammas >> sum ( PX ) ",
            "py_g": " gammas >> sum ( PY ) ",
            "n_c": " pions  >> SIZE       ",
            "g_c": " gammas >> SIZE       ",
        }
    )
    from Configurables import DataOnDemandSvc
    dod = DataOnDemandSvc()
    dod.AlgMap['/Event/Counters/CharmEW'] = cnt

    # ========================================================================
    # prefilters for drastical speedup in the reading of input data
    # ========================================================================
    from PhysConf.Filters import LoKi_Filters
    fltrs = LoKi_Filters(
        STRIP_Code=" HLT_PASS_RE ( 'Stripping.*WMuLine.*Decision' ) "
    )

    davinci = DaVinci(
        EventPreFilters=fltrs.filters('Filters'),  # PREFILTERS
        DataType=the_year,
        InputType='DST',
        Simulation=True,
        PrintFreq=10000,
        EvtMax=-1,
        #
        HistogramFile='MCW_Histos.root',
        TupleFile='MCW.root',
        #
    )

    # connect to DaVinci
    from Configurables import GaudiSequencer
    davinci.UserAlgorithms = [
        GaudiSequencer('MySeq', Members=[seq.sequence(), 'MCW'])
    ]

    #
    # take care abotu DB-tags:
    #
    # try to get the tags from Rec/Header
    from BenderTools.GetDBtags import getDBTags
    tags = getDBTags(
        datafiles[0],
        castor
    )
    logger.info('Extract tags from DATA : %s' % tags)
    if tags.has_key('DDDB') and tags['DDDB']:
        davinci.DDDBtag = tags['DDDB']
        logger.info('Set DDDB    %s ' % davinci.DDDBtag)
    if tags.has_key('CONDDB') and tags['CONDDB']:
        davinci.CondDBtag = tags['CONDDB']
        logger.info('Set CONDDB  %s ' % davinci.CondDBtag)
    if tags.has_key('SIMCOND') and tags['SIMCOND']:
        davinci.CondDBtag = tags['SIMCOND']
        logger.info('Set SIMCOND %s ' % davinci.CondDBtag)

    #
    # remove excessive printout
    #
    from Configurables import MessageSvc
    msg = MessageSvc()
    msg.setError += ['HcalDet.Quality',
                     'EcalDet.Quality',
                     'MagneticFieldSvc',
                     'PropertyConfigSvc',
                     'ToolSvc.L0DUConfig',
                     'ToolSvc.L0CondDBProvider',
                     'L0MuonFromRaw',
                     'IntegrateBeamCrossing']

    #
    # come back to Bender
    #
    setData(datafiles, catalogs, castor)

    #
    # start Gaudi
    #
    gaudi = appMgr()

    #
    # more silence
    #
    _a = gaudi.tool('ToolSvc.L0DUConfig')
    _a.OutputLevel = 4

    alg = MCW(
        'MCW',
        Inputs=[seq.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged']
    )

    return SUCCESS
Esempio n. 28
0
tuple_postprocess(tp_B0_ws_Mu)

tp_B0_ws_Pi = tuple_initialize(
    'TupleB0WSPi',
    seq_B0_ws_Pi,
    '${b0}[B~0 -> ${dst}(D*(2010)- -> ${d0}(D0 -> ${k}K- ${pi}pi+) ${spi}pi-) ${mu}mu-]CC'
)
tuple_postprocess(tp_B0_ws_Pi)


################################################
# Add selection & tupling sequences to DaVinci #
################################################

if has_flag('CUTFLOW', 'BARE'):
    DaVinci().UserAlgorithms += [seq_Bminus.sequence(), seq_B0.sequence(),
                                 # ntuples
                                 tp_Bminus, tp_B0]

elif DaVinci().Simulation and not has_flag('GHOST'):
    DaVinci().UserAlgorithms += [seq_Bminus.sequence(), seq_B0.sequence(),
                                 # ntuples
                                 tp_Bminus, tp_B0]

else:
    DaVinci().UserAlgorithms += [seq_Bminus.sequence(),
                                 seq_Bminus_ws.sequence(),
                                 seq_B0.sequence(),
                                 seq_B0_ws_Mu.sequence(),
                                 seq_B0_ws_Pi.sequence(),
                                 # ntuples
Esempio n. 29
0


#---- Refit vertices with Jpsi mass constraint----------------
#_Lb2JpsipK.addTool( OfflineVertexFitter() )
#_Lb2JpsipK.VertexFitters.update( { "" : "OfflineVertexFitter"} )
#_Lb2JpsipK.OfflineVertexFitter.applyDauMassConstraint = True


Lb2JpsiL  = Selection( "Lb2JpsiL",
                      Algorithm          = _Lb2JpsiL ,
                      RequiredSelections = [ Jpsi2MuMu, FilterL ] )

### Gaudi sequence
SeqLb2JpsiL = SelectionSequence("SeqLb2JpsiL", TopSelection = Lb2JpsiL)
seq = SeqLb2JpsiL.sequence()

#--------------------------------------------------------------------------
# Configure DaVinci
#-------------------------------------------------------------------------
from Configurables import DaVinci

DaVinci().appendToMainSequence( [sc.sequence() ] )   # Append the stripping selection sequence to DaVinci

from Configurables import  OfflineVertexFitter

from Configurables import  DecayTreeTuple, MCDecayTreeTuple
importOptions("Xb2JpsiXTreeMC.py")


tuple = DecayTreeTuple( "Lb2JpsiLTree" )
Esempio n. 30
0
from Configurables import MCMatchObjP2MCRelator
merge = MergeEvent()
merge.addTool(MCMatchObjP2MCRelator, name='MyRelator')
merge.MyRelator.RelTableLocations = ['/Event/NewEvent/Relations/NewEvent/Rec/ProtoP/Charged']
#merge.OutputLevel = 1


evtAlgs = GaudiSequencer("EventAlgs",
                         Members=[seqD2KKPiMain.sequence(),
                                  RegisterAddr(AddressesFile='eventaddr.txt'),
                                  makeparts,
                                  seqD2KKPiOther.sequence(),
                                  merge,
                                  createEvent,
                                  StoreExplorerAlg('Explorer'),
                                  selASelectionSequence.sequence(),
                                  selBSelectionSequence.sequence(),
                                  selABSelectionSequence.sequence(),
                                  fitD2KKP,
                                  fakebstuple
                                  ])


from Configurables import DaVinci
DaVinci().EvtMax = 20000
DaVinci().PrintFreq = 1
DaVinci().SkipEvents = 0
DaVinci().DataType = "2011"
DaVinci().DDDBtag = "MC11-20111102"
DaVinci().CondDBtag = "sim-20121025-vc-mu100"
DaVinci().HistogramFile = "meta.root"
def configure ( datafiles , catalogs = [] , castor = False ) :
    """
    Job configuration
    """

    from Configurables           import DaVinci       ## needed for job configuration
    from Configurables           import EventSelector ## needed for job configuration
    
    from Configurables import MessageSvc
    msg = MessageSvc()
    msg.setError += [ 'HcalDet.Quality'   ,
                      'EcalDet.Quality'   ,
                      'MagneticFieldSvc'  ,
                      'PropertyConfigSvc' ]


##     # =========================================================================
##     ## 0) Rerun stripping if MC is nt MC/2011 or MC/2012 
##     # =========================================================================
##     if   '2012' == the_year : 
##         import StrippingArchive.Stripping20.StrippingDiMuonNew              as DiMuon 
##         import StrippingSettings.Stripping20.LineConfigDictionaries_BandQ   as LineSettings
##     elif '2011' == the_year :
##         import StrippingArchive.Stripping20r1.StrippingDiMuonNew            as DiMuon 
##         import StrippingSettings.Stripping20r1.LineConfigDictionaries_BandQ as LineSettings

##     config  = LineSettings.FullDSTDiMuon['CONFIG']
##     name    = 'FullDST'
##     builder = DiMuon.DiMuonConf ( name , config )

##     ## selection
##     jpsi  = builder.SelJpsi2MuMuDetached


    # =========================================================================
    ## 0) Otherwise use existing stripping ilne 
    # =========================================================================
    
    from PhysSelPython.Wrappers import AutomaticData
    jpsi_location = 'FullDSTDiMuonJpsi2MuMuDetachedLine'
    jpsi = AutomaticData ( Location = '/Event/AllStreams/Phys/%s/Particles' % jpsi_location )

    
    # =============================================================================
    from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf    as PsiX
    
    # =============================================================================
    ## 1) redefine stripping configurations 
    # ============================================================================= 
    
    #
    ## redefine psi(') -> mu+ mu-
    # 
    def _psi_ ( self ) :
        """
        psi(') -> mu+ mu- 
        """
        return jpsi
    
    PsiX  . psi = _psi_
    
    logger.warning ( "Redefine PsiX .psi" )
    
    # =============================================================================
    ## 2) unify the pion& kaon  selections 
    # =============================================================================
    _PionCut_  = """
    ( CLONEDIST   > 5000   ) & 
    ( TRCHI2DOF   < 4      ) &
    ( TRGHOSTPROB < 0.4    ) &
    ( PT          > 200 * MeV               ) & 
    in_range ( 2          , ETA , 4.9       ) &
    in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
    HASRICH                  &
    ( PROBNNpi     > 0.15  ) &
    ( MIPCHI2DV()  > 9.    )
    """
    _KaonCut_  = """
    ( CLONEDIST   > 5000   ) & 
    ( TRCHI2DOF   < 4      ) & 
    ( TRGHOSTPROB < 0.4    ) & 
    ( PT          > 200 * MeV               ) & 
    in_range ( 2          , ETA , 4.9       ) &
    in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
    HASRICH                  &
    ( PROBNNk      > 0.15  ) &
    ( MIPCHI2DV()  > 9.    ) 
    """ 
    
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    _alg_pi  = FilterDesktop (
        ##
        Code = _PionCut_ ,
        ##
        )
    
    from PhysSelPython.Wrappers  import Selection
    from StandardParticles       import StdAllNoPIDsPions as input_pions 
    pions  = Selection (
        "SelPiForBQ"                       ,
        Algorithm          =  _alg_pi      ,
        RequiredSelections = [ input_pions ]  
        )
    
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    _alg_k  = FilterDesktop (
        ##
        Code = _KaonCut_ ,
        ##
        )
    
    from PhysSelPython.Wrappers  import Selection
    from StandardParticles       import StdAllNoPIDsKaons as input_kaons 
    kaons  = Selection (
        "SelKForBQ"      ,
        Algorithm          =   _alg_k      ,
        RequiredSelections = [ input_kaons ]  
        )
    
    
    def _kaons_   ( self ) : return kaons 
    def _pions_   ( self ) : return pions 
    
    #
    ## get the selections 
    #
    
    for s in [ PsiX ]  :
        s.pions   = _pions_
        s.kaons   = _kaons_
        
    logger.warning ( "Redefine PsiX.kaons          " )
    logger.warning ( "Redefine PsiX.kaons          " )

        
    psix   = PsiX   ( 'PsiX'  , {} )


    for s in [ psix.psi_pi() ] :
        
        a = s.algorithm ()
        a.ParticleCombiners = { '' : 'LoKi::VertexFitter:PUBLIC' } 
        
        
    from PhysSelPython.Wrappers import      SelectionSequence    
    sel_seq = SelectionSequence ( 'B2PsiPi'   , psix . psi_pi   () )
    

    the_year = '2012'
    davinci = DaVinci (
        DataType      = the_year ,
        InputType     = 'DST'    ,
        Simulation    = True     ,
        PrintFreq     = 1000     ,
        EvtMax        = -1       , 
        HistogramFile = 'DVHistos.root' ,
        TupleFile     = 'DVNtuples.root' ,
        Lumi          = True ,
        ##
        # MC : 
        ## SIMCOND : 'Sim08-20130503-1', 'Sim08-20130503-1-vc-md100'
        #
        DDDBtag   = "Sim08-20130503-1"         ,
        CondDBtag = "Sim08-20130503-1-vc-md100"    
        )
    
    
    my_name = "Bplus"
    from Configurables import GaudiSequencer
    
    davinci.UserAlgorithms = [ sel_seq.sequence() , my_name ] 
    
    setData ( datafiles , catalogs , castor )
    
    gaudi = appMgr()
    
    print 'seq.outputLocation()= ', sel_seq.outputLocation()    # Phys/SelPsi3KPiForPsiX/Particles
    alg = Jpsi_mu(
        my_name               ,   ## Algorithm name
        Inputs = [
        sel_seq.outputLocation()
        ] ,
        PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ]
        )

    return SUCCESS 
Esempio n. 32
0
Jpsi_seq = SelectionSequence('Jpsi_Seq', TopSelection=recJpsi)
D0_seq = SelectionSequence('D0_Seq', TopSelection=recD0)
Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp)
Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs)
Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc)
D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi)

##########################

# Turbo/DaVinci configuration.
from Configurables import DstConf, TurboConf, DaVinci
DaVinci().Simulation = False
DaVinci().Lumi = True
DaVinci().TupleFile = "LumiTuple.root"
DaVinci().appendToMainSequence([W_seq.sequence()])
DaVinci().appendToMainSequence([recPF, recJB])
#DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()])
DaVinci().appendToMainSequence([
    Jpsi_seq.sequence(),
    D0_seq.sequence(),
    Dp_seq.sequence(),
    Ds_seq.sequence(),
    Lc_seq.sequence(),
    D02K3pi_seq.sequence()
])
##TODO adding recSVs and recMus changes the daughters of jet objects from smart poniters to Particles
DaVinci().DataType = '2018'
DaVinci().EventPreFilters = fltrs.filters('Filters')

from Configurables import LumiIntegrateFSR, LumiIntegratorConf
Esempio n. 33
0
def execute(inputdata=None,
            simulation=True,
            decay_descriptor="J/psi(1S) -> mu- mu+"):
    # Configure all the unpacking, algorithms, tags and input files
    appConf = ApplicationMgr()
    appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

    dv = DaVinci()
    dv.DataType = "2012"

    lhcbApp = LHCbApp()
    lhcbApp.Simulation = simulation
    CondDB().Upgrade = False
    # don't really need tags for looking around
    #LHCbApp().DDDBtag = t['DDDB']
    #LHCbApp().CondDBtag  = t['CondDB']

    muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles")

    jpsi = CombineParticles('MyJPsi')
    jpsi.DecayDescriptors = [decay_descriptor]
    jpsi.CombinationCut = "(AM < 7100.0 *GeV)"
    jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"}
    jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)"

    code = """
('J/psi(1S)' == ID) &
in_range(2.990*GeV, M, 3.210*GeV) &
DECTREE('%s') &
CHILDCUT(1, HASMUON & ISMUON) &
CHILDCUT(2, HASMUON & ISMUON) &
(MINTREE('mu+' == ABSID, PT) > 700*MeV) &
(MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) &
(MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) &
(VFASPF(VPCHI2) > 0.5/100) &
(abs(BPV(VZ)) <  0.5*meter) &
(BPV(vrho2) < (10*mm)**2)
""" % (decay_descriptor)
    filter_jpsi = FilterDesktop("MyFilterJPsi",
                                Code=code,
                                Preambulo=["vrho2 = VX**2 + VY**2"],
                                ReFitPVs=True)

    jpsi_sel = Selection("SelMyJPsi",
                         Algorithm=jpsi,
                         RequiredSelections=[muons])
    filter_jpsi_sel = Selection("SelFilterMyJPsi",
                                Algorithm=filter_jpsi,
                                RequiredSelections=[jpsi_sel])
    jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel)

    dtt = DecayTreeTuple("Early2015")
    dtt.Inputs = [jpsi_seq.outputLocation()]
    # Overwriting default list of TupleTools
    # XXX need to add TisTosTool with sensible lines
    dtt.ToolList = [
        "TupleToolKinematic",
        "TupleToolPid",
        "TupleToolMCBackgroundInfo",
    ]
    dtt.Decay = mark(2, mark(3, decay_descriptor))  #"J/psi(1S) -> ^mu- ^mu+"
    dtt.addBranches({
        "X": "^(%s)" % (decay_descriptor),
        "muplus": mark(3, decay_descriptor),  #"J/psi(1S) -> mu- ^mu+",
        "muminus": mark(2, decay_descriptor),  #"J/psi(1S) -> ^mu- mu+",
    })

    x_preamble = [
        "DZ = VFASPF(VZ) - BPV(VZ)",
    ]
    x_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "VPCHI2": "VFASPF(VPCHI2)",
        "DELTAZ": "DZ",
        # DZ * M / PZ / c with c in units of mm/s
        # XXX should this be the PDG mass or measured mass?
        #"TZ": "DZ*M / PZ / 299792458000.0", #seconds
        "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)",  #ps
        "minpt": "MINTREE('mu+' == ABSID, PT)",
        "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)",
        "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)",
    }
    muon_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "CHARGE": "Q",
        "CLONEDIST": "CLONEDIST",
        "TRCHI2DOF": "TRCHI2DOF",
    }

    loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X")
    loki_X.Variables = x_vars
    loki_X.Preambulo = x_preamble

    loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus")
    loki_mup.Variables = muon_vars
    loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus")
    loki_mum.Variables = muon_vars

    dv.UserAlgorithms = [jpsi_seq.sequence(), dtt]
    dv.TupleFile = "DVNtuples.root"

    if isinstance(inputdata, list):
        IOHelper('ROOT').inputFiles(inputdata)
Esempio n. 34
0
from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence

BMassSel = AutomaticData(
    Location='/Event/Bhadron/Phys/B02D0PiPiD2HHBeauty2CharmLine/Particles')

_bmassFilter = FilterDesktop(
    'bmassFilter', Code='(M<6000.*MeV) & (BPVIPCHI2()<15) & (BPVDIRA>0.9999)')

BMassFilterSel = Selection(name='BMassFilterSel',
                           Algorithm=_bmassFilter,
                           OutputBranch=teslocation + 'Phys',
                           RequiredSelections=[BMassSel])

BMassSeq = SelectionSequence('SeqBMass', TopSelection=BMassFilterSel)

BMassseq = BMassSeq.sequence()

### Tuple part
tuple = DecayTreeTuple()

tuple.RootInTES = teslocation
tuple.Inputs = ['Phys/BMassFilterSel/Particles']
#tuple.Inputs = [ '/Event/Bhadron/Phys/B02D0KPiD2HHBeauty2CharmLine/Particles' ]

tuple.ToolList += [
    "TupleToolGeometry", "TupleToolRecoStats", "TupleToolKinematic",
    "TupleToolPrimaries", "TupleToolEventInfo", "TupleToolTrackInfo",
    "TupleToolAngles", "TupleToolPid", "TupleToolPropertime",
    "TupleToolTrigger", "TupleToolRICHPid", "TupleToolMuonPid",
    "TupleToolProtoPData"
]
Esempio n. 35
0
DaVinci().TupleFile = "SmrdPions.root"
DaVinci().EvtMax = 10
DaVinci().HistogramFile = "DVHistos.root"
DaVinci().DataType = '2010'
DaVinci().Simulation = True


# MC Options
DaVinci().DDDBtag = 'head-20101206'
DaVinci().CondDBtag = "sim-20101210-vc-md100"






DaVinci().UserAlgorithms += [ 
    TrackSmearingSeq
    ,SmrdLoosePions
    ,_seqPions.sequence()
    ,decaytuple
    ,_seqPions2.sequence()
    ,decaytuple2
    ]
    

DaVinci().MainOptions  = ""

EventSelector().Input = ["DATAFILE='PFN:castor:/castor/cern.ch/grid/lhcb/MC/MC10/ALLSTREAMS.DST/00008895/0000/00008895_00000025_1.allstreams.dst' TYP='POOL_ROOTTREE' OPT='READ'"] 

Esempio n. 36
0
def patchBrunel():
    """
        Instantiate the options to run Brunel with raw data

        @author M.Frank
  """
    import GaudiConf.DstConf
    import Brunel.Configuration
    import OnlineEnv

    brunel = Brunel.Configuration.Brunel()
    brunel.OnlineMode = True
    try:
        brunel.DDDBtag = OnlineEnv.DDDBTag
    except:
        print "DDDBTag not found, use default"

    try:
        brunel.CondDBtag = OnlineEnv.CondDBTag
    except:
        print "CondDBTag not found, use default"

    ##print '[ERROR]', OnlineEnv.DDDBTag, OnlineEnv.CondDBTag

    conddb = CondDB()
    conddb.IgnoreHeartBeat = True
    #
    # Adjust to pickup the proper online conditions
    #
    import ConditionsMap
    conddb.setProp('RunChangeHandlerConditions',
                   ConditionsMap.RunChangeHandlerConditions)
    conddb.setProp('EnableRunChangeHandler', True)

    brunel.DataType = "2015"
    brunel.UseDBSnapshot = True  # Try it
    brunel.WriteFSR = False  # This crashes Jaap's stuff

    conddb = CondDB()
    conddb.Online = True
    #
    # Adjust to pickup the proper online conditions from ConditionsMap
    #
    conddb.RunChangeHandlerConditions = ConditionsMap.RunChangeHandlerConditions
    conddb.setProp('EnableRunChangeHandler', True)

    # Enabled data-on-demand
    Gaudi.ApplicationMgr().ExtSvc += ["DataOnDemandSvc"]

    ################################################################################
    #                                                                              #
    # Set up PID monitoring sequence                                               #
    #                                                                              #
    ################################################################################

    # The sequencer to run all the monitoring in
    seq = GaudiSequencer("PIDMoniSeq")

    pidSeq = GaudiSequencer("RichPIDSelections")

    brunel.setOtherProps(RichPIDQCConf(), ['OutputLevel', 'Context'])
    RichPIDQCConf().setProp("CalibSequencer", pidSeq)

    seq.Members += [pidSeq]

    ################################################################################
    #                                                                              #
    # Configure the muon efficiency monitor                                        #
    #                                                                              #
    ################################################################################

    muEffMoni = MuEffMonitor("MuEffMonitor")

    muEffMoni.addTool(TrackMasterExtrapolator, name="MuEffExtrap")
    muEffMoni.Extrapolator = muEffMoni.MuEffExtrap

    muEffMoni.MuEffExtrap.ApplyMultScattCorr = True
    muEffMoni.MuEffExtrap.ApplyEnergyLossCorr = True
    muEffMoni.MuEffExtrap.MaterialLocator = "SimplifiedMaterialLocator"
    muEffMoni.MuEffExtrap.OutputLevel = 6

    muEffMoni.nSigma1X = [11., 8., 7., 7.]
    muEffMoni.nSigma1Y = [6., 5., 5., 5.]
    muEffMoni.nSigmaX = [5., 5., 5., 5.]
    muEffMoni.nSigmaY = [5., 5., 5., 5.]

    muEffMoni.RequiredStations = 4
    muEffMoni.MomentumCut = 3000.0
    muEffMoni.nSigmaFidVol = 3.0

    muEffMoni.UseCalo = True
    muEffMoni.EecalMax = 1500.0
    muEffMoni.EhcalMax = 5000.0
    muEffMoni.EhcalMin = 1000.0

    muEffMoni.Chi2ProbTrMin = 0.01
    muEffMoni.Chi2MuMin = 10.0
    muEffMoni.nSigmaXother = 2.0
    muEffMoni.nSigmaYother = 2.0

    muEffMoni.HistoLevel = "OfflineFull"

    seq.Members += [muEffMoni]

    ################################################################################
    #                                                                              #
    # Configure the muon pid monitor                                               #
    #                                                                              #
    ################################################################################

    from Configurables import MuIDMonitor, CombineParticles
    from Configurables import FilterDesktop
    from StandardParticles import StdNoPIDsPions, StdNoPIDsProtons, StdNoPIDsMuons
    from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand

    MuPidMoniSeq_Lambda = GaudiSequencer("MuPidMoniSeq_Lambda")
    MuPidMoniSeq_Jpsi = GaudiSequencer("MuPidMoniSeq_Jpsi")

    #
    # Make pions and protons
    #

    PionsFilter = FilterDesktop("PionsFilter")
    PionsFilter.Code = "(P>3000*MeV) & (PT>100*MeV) & (TRCHI2DOF<2) & (ISLONG) & (MIPCHI2DV(PRIMARY)>9)"
    PionsFilterSel = Selection("PionsFilterSel",
                               Algorithm=PionsFilter,
                               RequiredSelections=[StdNoPIDsPions])

    ProtonsFilter = FilterDesktop("ProtonsFilter")
    ProtonsFilter.Code = "(P>3000*MeV) & (PT>100*MeV) & (TRCHI2DOF<2) & (ISLONG) & (MIPCHI2DV(PRIMARY)>9)"
    ProtonsFilterSel = Selection("ProtonsFilterSel",
                                 Algorithm=ProtonsFilter,
                                 RequiredSelections=[StdNoPIDsProtons])
    #
    # Make Lambda_0
    #

    LambdaMonitor = CombineParticles("LambdaMonitor")
    LambdaMonitor.DecayDescriptor = "[Lambda0 -> p+ pi-]cc"
    LambdaMonitor.CombinationCut = "(ADAMASS('Lambda0')<10*MeV)"
    LambdaMonitor.MotherCut = "(50<BPVVDZ) & (600>BPVVDZ) & (BPVDIRA>0.9999995)  & (CHILDCUT((PT>0.2*GeV),1) | CHILDCUT((PT>0.2*GeV),2)) & (ADWM('KS0', WM('pi+', 'pi-')) > 20*MeV)"

    LambdaMonitorSel = Selection(
        "LambdaMonitorSel",
        Algorithm=LambdaMonitor,
        RequiredSelections=[PionsFilterSel, ProtonsFilterSel])

    LambdaMonitorSeq = SelectionSequence("LambdaMonitorSeq",
                                         TopSelection=LambdaMonitorSel)

    MuPidMoniSeq_Lambda.Members += [LambdaMonitorSeq.sequence()]

    #
    # Make muons and J/psi
    #

    mucocut = '(0.5<PPINFO(LHCb.ProtoParticle.InAccMuon,-1)) & (P>3*GeV) & (PT>800*MeV) & (TRCHI2DOF<3) & (ISLONG)'

    tag1cuts = " (CHILDCUT(ISMUON,1)) & (CHILDCUT((P>6*GeV),1)) & (CHILDCUT((PT>1.5*GeV),1)) "
    tag2cuts = " (CHILDCUT(ISMUON,2)) & (CHILDCUT((P>6*GeV),2)) & (CHILDCUT((PT>1.5*GeV),2)) "

    probe2cuts = " ( (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)<1000*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)<4000*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)>-10*MeV),2)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)>1000*MeV),2)) ) "
    probe1cuts = " ( (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)<1000*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)<4000*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloEcalE,-10000)>-10*MeV),1)) & (CHILDCUT((PPINFO(LHCb.ProtoParticle.CaloHcalE,-10000)>1000*MeV),1)) )  "

    child1cuts = tag1cuts + " & " + probe2cuts

    child2cuts = tag2cuts + " & " + probe1cuts

    MuonsFilter = FilterDesktop("MuonsFilter")
    MuonsFilter.Code = mucocut
    MuonsFilterSel = Selection("MuonsFilterSel",
                               Algorithm=MuonsFilter,
                               RequiredSelections=[StdNoPIDsMuons])

    JpsiMonitor = CombineParticles("JpsiMonitor")
    JpsiMonitor.DecayDescriptor = "J/psi(1S) -> mu+ mu-"
    JpsiMonitor.CombinationCut = "(ADAMASS('J/psi(1S)')<300*MeV)"
    JpsiMonitor.MotherCut = "(VFASPF(VCHI2/VDOF)<20) & ( " + child1cuts + " | " + child2cuts + " ) "

    JpsiMonitor.OutputLevel = 6

    JpsiMonitorSel = Selection("JpsiMonitorSel",
                               Algorithm=JpsiMonitor,
                               RequiredSelections=[MuonsFilterSel])

    JpsiMonitorSeq = SelectionSequence("JpsiMonitorSeq",
                                       TopSelection=JpsiMonitorSel)

    MuPidMoniSeq_Jpsi.Members += [JpsiMonitorSeq.sequence()]

    #
    # Monitoring muon mis-id with Lambda_0
    #

    MuIDLambdaPlot = MuIDMonitor("MuIDLambdaPlot")
    MuIDLambdaPlot.Inputs = [LambdaMonitorSel.outputLocation()]
    MuIDLambdaPlot.OutputLevel = 6

    MuIDLambdaPlot.MassMean = 1115.68
    MuIDLambdaPlot.MassWindow = 20.
    MuIDLambdaPlot.EffMassWin = 2.

    MuIDLambdaPlot.JpsiAnalysis = 0
    MuIDLambdaPlot.LambdaAnalysis = 1
    MuIDLambdaPlot.HitInFoi = 1

    MuIDLambdaPlot.PreSelMomentum = 3000.  # MuonID preselection momentum (MeV/c)
    MuIDLambdaPlot.MomentumCuts = [6000., 10000.
                                   ]  # MuonID momentum cut ranges (MeV/c)

    # MuonID FOI parameters

    MuIDLambdaPlot.FOIfactor = 1.

    MuIDLambdaPlot.XFOIParameter1 = [
        5.5, 4.0, 3.3, 2.8, 5.2, 3.6, 2.4, 2.4, 5.7, 4.4, 2.8, 2.3, 5.1, 3.1,
        2.3, 2.1, 5.8, 3.4, 2.6, 2.8
    ]

    MuIDLambdaPlot.XFOIParameter2 = [
        11., 3., 1., 1., 31., 28., 21., 17., 30., 31., 27., 22., 28., 33., 35.,
        47., 31., 39., 56., 151.
    ]

    MuIDLambdaPlot.XFOIParameter3 = [
        0.20, 0.08, 0.03, 0.1, 0.06, 0.08, 0.10, 0.15, 0.04, 0.06, 0.09, 0.12,
        0.08, 0.15, 0.23, 0.36, 0.07, 0.14, 0.24, 0.49
    ]

    MuIDLambdaPlot.YFOIParameter1 = [
        2.8, 1.7, -153., 1.9, 3.3, 2.1, 1.7, 1.6, 3.6, 2.8, 1.9, 1.8, 4.4, 3.3,
        2.2, 2.2, 4.8, 3.9, 2.6, 2.3
    ]

    MuIDLambdaPlot.YFOIParameter2 = [
        3., 2., 156., 0., 17., 15., 9., 5., 26., 25., 16., 15., 30., 49., 57.,
        92., 32., 55., 96., 166.
    ]

    MuIDLambdaPlot.YFOIParameter3 = [
        0.03, 0.02, 0.00, 0.09, 0.13, 0.19, 0.19, 0.24, 0.11, 0.19, 0.21, 0.32,
        0.10, 0.22, 0.30, 0.52, 0.08, 0.20, 0.34, 0.52
    ]

    #
    # Parameters of the Landau functions
    #

    MuIDLambdaPlot.distMuon = [
        0.311, 1.349, 0.524, 0.0020, 17., 10.6, 0.04, 4.1, 1.64
    ]
    MuIDLambdaPlot.distPion = [
        11., -12., 0.2029, -0.026, 0.06, 0.59, 0.008, -29., 41.
    ]

    MuPidMoniSeq_Lambda.Members += [MuIDLambdaPlot]

    #
    # Monitoring muon id with J/psi
    #

    MuIDJpsiPlot = MuIDMonitor("MuIDJpsiPlot")
    MuIDJpsiPlot.Inputs = [JpsiMonitorSel.outputLocation()]
    MuIDJpsiPlot.OutputLevel = 6

    MuIDJpsiPlot.MassMean = 3096.91
    MuIDJpsiPlot.MassWindow = 300.
    MuIDJpsiPlot.EffMassWin = 20.

    MuIDJpsiPlot.JpsiAnalysis = 1
    MuIDJpsiPlot.LambdaAnalysis = 0
    MuIDJpsiPlot.HitInFoi = 1

    MuIDJpsiPlot.PreSelMomentum = MuIDLambdaPlot.PreSelMomentum
    MuIDJpsiPlot.MomentumCuts = MuIDLambdaPlot.MomentumCuts

    # MuonID FOI parameters

    MuIDJpsiPlot.FOIfactor = MuIDLambdaPlot.FOIfactor
    MuIDJpsiPlot.XFOIParameter1 = MuIDLambdaPlot.XFOIParameter1
    MuIDJpsiPlot.XFOIParameter2 = MuIDLambdaPlot.XFOIParameter2
    MuIDJpsiPlot.XFOIParameter3 = MuIDLambdaPlot.XFOIParameter3
    MuIDJpsiPlot.YFOIParameter1 = MuIDLambdaPlot.YFOIParameter1
    MuIDJpsiPlot.YFOIParameter2 = MuIDLambdaPlot.YFOIParameter2
    MuIDJpsiPlot.YFOIParameter3 = MuIDLambdaPlot.YFOIParameter3

    #
    # Parameters of the Landau functions
    #

    MuIDJpsiPlot.distMuon = MuIDLambdaPlot.distMuon
    MuIDJpsiPlot.distPion = MuIDLambdaPlot.distPion

    MuPidMoniSeq_Jpsi.Members += [MuIDJpsiPlot]
    MuPidMoniSeq_Jpsi.IgnoreFilterPassed = True
    MuPidMoniSeq_Lambda.IgnoreFilterPassed = True

    seq.Members += [MuPidMoniSeq_Lambda, MuPidMoniSeq_Jpsi]

    # set the options

    class __MonAdd:
        def __init__(self, s):
            self.seq = s

        def addMonitors(self):
            # Append to processing
            GaudiSequencer("PhysicsSeq").Members += [self.seq]

    mon = __MonAdd(seq)
    Gaudi.appendPostConfigAction(mon.addMonitors)

    EventLoopMgr().OutputLevel = MSG_DEBUG  #ERROR
    EventLoopMgr().Warnings = False

    brunel.UseDBSnapshot = True  # try it
    Brunel.Configuration.Brunel.configureOutput = dummy
    HistogramPersistencySvc().OutputFile = ""
    HistogramPersistencySvc().OutputLevel = MSG_ERROR
    print brunel
    return brunel
Esempio n. 37
0
from Configurables import DaVinci, FilterDesktop, DecayTreeTuple
from PhysSelPython.Wrappers import Selection, SelectionSequence, TupleSelection
import StandardParticles

alg = FilterDesktop('pions')
alg.Code = 'ALL'
sel = Selection('pions_sel',
                Algorithm=alg,
                RequiredSelections=[StandardParticles.StdAllNoPIDsPions])

tuplesel = TupleSelection('pions_tuple_sel',
                          Decay='[pi+]cc',
                          RequiredSelection=sel)

selseq = SelectionSequence('pions_seq', TopSelection=tuplesel)
DaVinci().UserAlgorithms.append(selseq.sequence())
DaVinci().TupleFile = 'DVTuples.root'
Esempio n. 38
0
                                        'Ks2' : '[D_s+ -> (phi(1020) -> (KS0 -> pi+ pi-) ^(KS0 -> pi+ pi-)) pi+]CC',
                                        'pi1' : '[D_s+ -> (phi(1020) -> (KS0 -> ^pi+ pi-) (KS0 -> pi+ pi-)) pi+]CC',
                                        'pi2' : '[D_s+ -> (phi(1020) -> (KS0 -> pi+ ^pi-) (KS0 -> pi+ pi-)) pi+]CC',
                                        'pi3' : '[D_s+ -> (phi(1020) -> (KS0 -> pi+ pi-) (KS0 -> ^pi+ pi-)) pi+]CC',
                                        'pi4' : '[D_s+ -> (phi(1020) -> (KS0 -> pi+ pi-) (KS0 -> pi+ ^pi-)) pi+]CC',
                                        'pis' : '[D_s+ -> (phi(1020) -> (KS0 -> pi+ pi-) (KS0 -> pi+ pi-)) ^pi+]CC',
                                          }

  mcTuple.addBranches(mcTuple.Branches)
  mcTuple.ToolList = ['MCTupleToolKinematic',
                        'TupleToolEventInfo',
                        'MCTupleToolHierarchy',
                        "TupleToolMCBackgroundInfo",
                      ]

Ds_sequence.sequence().Members += [tuple]



from Configurables import DaVinci

#Name of tuple file you want to write out.
DaVinci().TupleFile = "Phi2KsKs.root"
DaVinci().EvtMax = 10000
DaVinci().DataType = '2012'
DaVinci().Simulation = isMC

#This is very useful to make sure you didn't accidently miss some data. 
#Adds tuple in same file with lumi (units are pb-1).
DaVinci().Lumi = not isMC
def configure ( inputdata        ,    ## the list of input files  
                catalogs = []    ,    ## xml-catalogs (filled by GRID)
                castor   = False ,    ## use the direct access to castor/EOS ? 
                params   = {}    ) :

    ## configure  Track <--> MC relation table  
    import LoKiPhysMC.Track2MC_Configuration
    import LoKiMC.MC
    
    ## import DaVinci 
    from Configurables import DaVinci, GaudiSequencer
    ## delegate the actual configurtaion to DaVinci 
    dv = DaVinci ( DataType   = '2011' ,
                   InputType  = 'MDST',
                   Lumi = True,
                   Simulation = True,
                   DDDBtag="MC11-20111102",
                   CondDBtag="sim-20111111-vc-md100",
                   HistogramFile = "mcd02kpi_tracks7_histo.root",
                   TupleFile = "mcd02kpi_tracks7_ntuple.root",
                   PrintFreq = 1000)
    

    from Configurables import DecayTreeTuple, FilterDesktop, TupleToolGeometry, CombineParticles
    from Configurables import MCDecayTreeTuple, TupleToolMCTruth, MCTupleToolHierarchy
    from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence, DataOnDemand
    from Configurables import CheckPV
    

    # First using CombineParticle to create the D0
    ################################################################################
    #from StandardParticles import  StdAllNoPIDsPions, StdAllNoPIDsKaons
    _pions = DataOnDemand(Location='Phys/StdAllNoPIDsPions/Particles')
    _kaons = DataOnDemand(Location='Phys/StdAllNoPIDsKaons/Particles')

    _d2kpi = CombineParticles("d2kpi")
    _d2kpi.DecayDescriptor = "[D0 -> K- pi+]cc"
    _d2kpi.DaughtersCuts = { "K-"  : "(PT > 500.0) & (0.0 < PIDK)",
                             "pi+" : "(PT > 500.0) & (5.0 > PIDK)",
                             "K+"  : "(PT > 500.0) & (0.0 < PIDK)",
                             "pi-" : "(PT > 500.0) & (5.0 > PIDK) " }
    _d2kpi.MotherCut = "(VFASPF(VCHI2/VDOF)<10)"
    _d2kpi.CombinationCut = "(ADAMASS('D0') < 50.0)"
    _d2kpi.Preambulo = [ 
        "from LoKiPhysMC.decorators import *" ,
        "from PartProp.Nodes import CC"      ]
    #_d2kpi.ReFitPVs = True

    SelD2KPi = Selection( "SelD2KPi",
                          Algorithm= _d2kpi,
                          RequiredSelections=[_pions,_kaons] ) 
    
    SeqD2KPi = SelectionSequence('SeqD2KPi',TopSelection = SelD2KPi)

    
    # Now the CheckPV method to filter algorithms
    c = CheckPV("OnePV")
    c.MinPVs = 1

    # And a sequencer to put them together
    gseq = GaudiSequencer()
    gseq.Members = [ c, SeqD2KPi.sequence() ]
    
    ## define the input data
    setData  ( inputdata , catalogs , castor )
    
    ## get/create application manager
    gaudi = appMgr() 
    
    #
    ## modify/update the configuration:
    #
    
    ## (1) create the algorithm
    alg = TrackFilter( 'TrackFilter' )
    
    #seq = createSequencer()
    ## (2) replace the list of top level algorithm by
    #     new list, which contains only *THIS* algorithm
    gaudi.setAlgorithms( [ gseq, alg ] )
             
    return SUCCESS
Esempio n. 40
0
muons = DataOnDemand('Phys/StdLooseMuons')
jPsiSel = Selection("jPsiSel", Algorithm=JPsi, RequiredSelections=[muons])
mumuSel = Selection("mumuSel", Algorithm=MuMu, RequiredSelections=[muons])
jPsiNBSel = Selection("jPsiNBSel",
                      Algorithm=jPsiNB,
                      RequiredSelections=[jPsiSel])
mumuNBSel = Selection("mumuNBSel",
                      Algorithm=mumuNB,
                      RequiredSelections=[mumuSel])

SelSeqJPsi = SelectionSequence("SeqJPsi", TopSelection=jPsiNBSel)
SelSeqMuMu = SelectionSequence("SeqMuMu", TopSelection=mumuNBSel)
SelSeqMuMuAll = SelectionSequence("SeqMuMuAll", TopSelection=mumuSel)

SeqJPsi = SelSeqJPsi.sequence()
SeqMuMu = SelSeqMuMu.sequence()
SeqMuMuAll = SelSeqMuMuAll.sequence()

########################################################################
#
# NTupling
#
from Configurables import DecayTreeTuple

tupleMuMu = DecayTreeTuple("tupleMuMu")
tupleMuMu.InputLocations = [SelSeqMuMu.outputLocation()]
tupleMuMu.Decay = "J/psi(1S) -> ^mu+ ^mu-"
tupleMuMu.ToolList += [
    "TupleToolGeometry", "TupleToolKinematic", "TupleToolPrimaries",
    "TupleToolTrackInfo", "TupleToolPid", "TupleToolEventInfo",
Esempio n. 41
0
def configure(datafiles, catalogs=[], params={}, castor=False):
    """
    Configure the job
    """
    from Configurables           import DaVinci       ## needed for job configuration
    from Configurables           import EventSelector ## needed for job configuration
    
    from Configurables import MessageSvc
    msg = MessageSvc()
    msg.setError += [ 'HcalDet.Quality'   ,
                      'EcalDet.Quality'   ,
                      'MagneticFieldSvc'  ,
                      'PropertyConfigSvc' ]

    from PhysSelPython.Wrappers import AutomaticData
    jpsi_location = 'FullDSTDiMuonJpsi2MuMuDetachedLine'
    jpsi = AutomaticData(
        Location='/Event/AllStreams/Phys/%s/Particles' % jpsi_location)

    
    # =============================================================================
    from StrippingSelections.StrippingPsiXForBandQ import PsiX_BQ_Conf as PsiX

    ## 1) redefine stripping configurations
    def _psi_(self):
        """
        psi(') -> mu+ mu-
        """
        return jpsi

    PsiX.psi = _psi_

    logger.warning("Redefine PsiX .psi")

    ## 2) unify the pion& kaon  selections
    # =============================================================================
    _PionCut_ = """
    ( CLONEDIST   > 5000   ) &
    ( TRCHI2DOF   < 4      ) &
    ( TRGHOSTPROB < 0.4    ) &
    ( PT          > 200 * MeV               ) &
    in_range ( 2          , ETA , 4.9       ) &
    in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
    HASRICH                  &
    ( PROBNNpi     > 0.15  ) &
    ( MIPCHI2DV()  > 9.    )
    """
    _KaonCut_ = """
    ( CLONEDIST   > 5000   ) &
    ( TRCHI2DOF   < 4      ) &
    ( TRGHOSTPROB < 0.4    ) &
    ( PT          > 200 * MeV               ) &
    in_range ( 2          , ETA , 4.9       ) &
    in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
    HASRICH                  &
    ( PROBNNk      > 0.15  ) &
    ( MIPCHI2DV()  > 9.    )
    """

    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    _alg_pi = FilterDesktop(
        ##
        Code=_PionCut_,
        ##
    )

    from PhysSelPython.Wrappers import Selection
    from StandardParticles import StdAllNoPIDsPions as input_pions
    pions = Selection(
        "SelPiForBQ",
        Algorithm=_alg_pi,
        RequiredSelections=[input_pions]
    )

    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    _alg_k = FilterDesktop(
        ##
        Code=_KaonCut_,
        ##
    )

    from PhysSelPython.Wrappers import Selection
    from StandardParticles import StdAllNoPIDsKaons as input_kaons
    kaons = Selection(
        "SelKForBQ",
        Algorithm=_alg_k,
        RequiredSelections=[input_kaons]
    )

    def _kaons_(self):
        return kaons

    def _pions_(self):
        return pions

    #
    ## get the selections
    #

    for s in [PsiX]:
        s.pions = _pions_
        s.kaons = _kaons_

    logger.warning("Redefine PsiX.kaons          ")
    logger.warning("Redefine PsiX.kaons          ")

    psix = PsiX('PsiX', {})

    for s in [psix.psi_3Kpi()]:
        a = s.algorithm()
        a.ParticleCombiners = {'': 'LoKi::VertexFitter:PUBLIC'}

    from PhysSelPython.Wrappers import SelectionSequence
    sel_seq = SelectionSequence('B2Psi3Kpi', psix . psi_3Kpi())


    davinci = DaVinci(
        InputType     = 'DST'    ,
        Simulation    = True     ,
        PrintFreq     = 1000     ,
        EvtMax        = -1       , 
        Lumi          = True     ,
        DataType = params['Year'],
        DDDBtag = params['DDDB'],
        CondDBtag = params['SIMCOND'],
        # HistogramFile = 'DVHistos.root' ,
        TupleFile     = 'DVNtuples.root' ,
    )
    

    my_name = "Bplus"
    from Configurables import GaudiSequencer
    
    davinci.UserAlgorithms = [ sel_seq.sequence() , my_name ] 
    
    setData ( datafiles , catalogs , castor )
    
    gaudi = appMgr()

    print 'seq.outputLocation()= ', sel_seq.outputLocation()    # Phys/SelPsi3KPiForPsiX/Particles
    # create local algorithm:
    alg = MCAnalysisAlgorithm(
        my_name,
        Inputs = [
        sel_seq.outputLocation()
        ] ,
        PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ]
    )

    return SUCCESS
Esempio n. 42
0


#---- Refit vertices with Jpsi mass constraint----------------
#_Lb2JpsipK.addTool( OfflineVertexFitter() )
#_Lb2JpsipK.VertexFitters.update( { "" : "OfflineVertexFitter"} )
#_Lb2JpsipK.OfflineVertexFitter.applyDauMassConstraint = True


Lb2JpsiS  = Selection( "Lb2JpsiS",
                      Algorithm          = _Lb2JpsiS ,
                      RequiredSelections = [ Jpsi2MuMu, S2L0g, FilterL ] )

### Gaudi sequence
SeqLb2JpsiS = SelectionSequence("SeqLb2JpsiS", TopSelection = Lb2JpsiS)
seq = SeqLb2JpsiS.sequence()

#--------------------------------------------------------------------------
# Configure DaVinci
#-------------------------------------------------------------------------
from Configurables import DaVinci

from Configurables import  OfflineVertexFitter

from Configurables import  DecayTreeTuple, MCDecayTreeTuple
importOptions("Xb2JpsiXTree.py")


tuple = DecayTreeTuple( "Lb2JpsiSTree" )
tuple.Inputs = [ SeqLb2JpsiS.outputLocation() ]
Esempio n. 43
0
########################################################################
#
# Selections
#
from PhysSelPython.Wrappers import Selection, DataOnDemand
from PhysSelPython.Wrappers import MergedSelection
from PhysSelPython.Wrappers import SelectionSequence

noPIDsKaons = DataOnDemand(Location = 'Phys/StdNoPIDsKaons')

BhhSel       = Selection("BhhSel"       , Algorithm = Bhh       , RequiredSelections = [noPIDsKaons])
BhhNBSel     = Selection("BhhNBSel"     , Algorithm = BhhNB     , RequiredSelections = [ BhhSel ] )

SelSeqBhh    = SelectionSequence("SeqBhh"     , TopSelection = BhhNBSel)
SeqBhh       = SelSeqBhh.sequence()

########################################################################
#
# NTupling
#
from Configurables import DecayTreeTuple
tupleBhh                =  DecayTreeTuple("tupleBhh")
tupleBhh.InputLocations = [SelSeqBhh.outputLocation()]
tupleBhh.Decay          = "B_s0 -> K+ K-"
tupleBhh.ToolList      += [
    "TupleToolGeometry"
    , "TupleToolKinematic"
    , "TupleToolPrimaries"
    , "TupleToolTrackInfo"
    , "TupleToolPid"
TurboConf().PersistReco = True

pions = DataOnDemand('Phys/StdAllNoPIDsPions/Particles')
ks0 = CombineParticles('Ks0Topipi',
                        DecayDescriptors=['[KS0 -> pi+ pi+]cc'],
                        CombinationCut=("AM < 320*MeV"), #parent
                        MotherCut="ALL")
ks0_sel = Selection(
    'Sel_Ks0Topipi',
    Algorithm=ks0,
    RequiredSelections=[pions]
)
ks0_selseq = SelectionSequence(
    'SelSeq_Ks0Topipi',
    TopSelection=ks0_sel
)

dtt_ks0 = DecayTreeTuple('TupleKs0Topipi')
dtt_ks0.Inputs = ks0_selseq.outputLocations()
dtt_ks0.Decay = '[KS0 -> ^pi+ ^pi+]CC'
dtt_ks0.addBranches({
    'Ks0': '[KS0 -> pi+ pi+]CC',
    'pi1': '[KS0 -> ^pi+ pi+]CC',
    'pi2': '[KS0 -> pi+ ^pi+]CC'
})

DaVinci().UserAlgorithms = [ks0_selseq.sequence(), dtt_ks0]
DaVinci().DataType = '2016'
DaVinci().EvtMax = 1000
DaVinci().TupleFile = 'PersistRecoTuple_ks0_pipi.root'
    "M": ('mass in MeV_%1%_%2%_%3%', 2.8 * Units.GeV, 3.2 * Units.GeV)
}
_jpsiFilter.addTool(PlotTool("OutputPlots"))
_jpsiFilter.OutputPlots.Histos = {
    "P/1000": ('momentum', 0, 150),
    "PT/1000": ('pt_%1%', 0, 5, 750),
    "M": ('mass in MeV_%1%_%2%_%3%', 2.8 * Units.GeV, 3.2 * Units.GeV)
}
#

JpsiFilterSel = Selection(name='JpsiFilterSel',
                          Algorithm=_jpsiFilter,
                          RequiredSelections=[JpsiSel])

JpsiSeq = SelectionSequence('SeqJpsi', TopSelection=JpsiFilterSel)
seq = JpsiSeq.sequence()

dv = DaVinci()
dv.PrintFreq = 10
dv.HistogramFile = "DVHistos_Strip.root"
dv.EvtMax = -1
dv.DataType = "MC09"
dv.Simulation = True
dv.RedoMCLinks = False
dv.UserAlgorithms = [seq]
dv.InputType = 'DST'
# MC09
#dv.Input = ["   DATAFILE='castor://castorlhcb.cern.ch:9002/?svcClass=lhcbdata&castorVersion=2&path=/castor/cern.ch/grid/lhcb/MC/MC09/DST/00004879/0000/00004879_00000001_1.dst' TYP='POOL_ROOTTREE' OPT='READ'"]
dv.Input = [
    "DATAFILE='PFN:/castor/cern.ch/user/j/jpalac/StripDST/MC09/DaVinci_v24r3p1/Sel.Jpsi.dst'  TYP='POOL_ROOTTREE' OPT='READ'"
]
Esempio n. 46
0
        "TupleToolMCBackgroundInfo",
    ]


from Configurables import DaVinci

# Name of tuple file you want to write out.
DaVinci().TupleFile = "JPsi2KsKs.root"
DaVinci().EvtMax = -1
DaVinci().DataType = "2012"
DaVinci().Simulation = isMC

# This is very useful to make sure you didn't accidently miss some data.
# Adds tuple in same file with lumi (units are pb-1).
DaVinci().Lumi = not isMC

# These database tags are used to specify the relevent conditions for your dataset.
# They can normally be found on the bookkeeping.

from Configurables import CondDB

# Here is a trick we just use the latest tags for 2012 data rather than hardocding them in
# , which is what we want to run on.
CondDB().LatestGlobalTagByDataType = "2012"

# Here we actually tell DaVinci what to run, this will often have a
#'selection seuqence' before the ntuple stage.
DaVinci().appendToMainSequence([seq.sequence(), tuple])
if isMC:
    DaVinci().UserAlgorithms += [mcTuple]
Esempio n. 47
0
tuple.Kaon.ToolList += ["TupleToolL0Calo/KaonL0Calo"]
tuple.Kaon.KaonL0Calo.WhichCalo="HCAL"

tuple.piplus.addTool(TupleToolL0Calo,name="piplusL0Calo")
tuple.piplus.ToolList += ["TupleToolL0Calo/piplusL0Calo"]
tuple.piplus.piplusL0Calo.WhichCalo="HCAL"

tuple.piminus.addTool(TupleToolL0Calo,name="piminusL0Calo")
tuple.piminus.ToolList += ["TupleToolL0Calo/piminusL0Calo"]
tuple.piminus.piminusL0Calo.WhichCalo="HCAL"

etuple=EventTuple()
etuple.ToolList=["TupleToolEventInfo"]

Gseq=GaudiSequencer('MyTupleSeq')
Gseq.Members += [BuKFilteredSel_Seq.sequence()]
Gseq.Members.append(etuple)
Gseq.Members += [tuple]
#DaVinci().EventPreFilters = fltrs.filters ('Filters')
DaVinci().InputType='DST'
#DaVinci().appendToMainSequence([Gseq])
DaVinci().UserAlgorithms+=[Gseq]
DaVinci().TupleFile="Output.root"
DaVinci().HistogramFile="histos.root"
DaVinci().DataType='2012'
DaVinci().Lumi=True
DaVinci().EvtMax=-1
DaVinci().PrintFreq=1000
DaVinci().MoniSequence=[tuple]
DaVinci().Simulation=False
}
d0_comb = "(AMAXDOCA('') < 0.2*mm) & (ADAMASS('D0') < 100*MeV)"
# We can split long selections across multiple lines
d0_mother = ('(VFASPF(VCHI2/VDOF)< 9)'
             '& (BPVDIRA > 0.9997)'
             "& (ADMASS('D0') < 70*MeV)")

d0 = CombineParticles('Combine_D0',
                      DecayDescriptor='([D0 -> pi- K+]CC)',
                      DaughtersCuts=d0_daughters,
                      CombinationCut=d0_comb,
                      MotherCut=d0_mother)

d0_sel = Selection('Sel_D0', Algorithm=d0, RequiredSelections=[Pions, Kaons])

dstar_daughters = {'pi+': '(TRCHI2DOF < 3) & (PT > 100*MeV)'}
dstar_comb = "(ADAMASS('D*(2010)+') < 400*MeV)"
dstar_mother = ("(abs(M-MAXTREE('D0'==ABSID,M)-145.42) < 10*MeV)"
                '& (VFASPF(VCHI2/VDOF)< 9)')
dstar_sel = SimpleSelection('Sel_Dstar',
                            ConfigurableGenerators.CombineParticles,
                            [d0_sel, Pions],
                            DecayDescriptor='[D*(2010)+ -> D0 pi+]cc',
                            DaughtersCuts=dstar_daughters,
                            CombinationCut=dstar_comb,
                            MotherCut=dstar_mother)

dstar_seq = SelectionSequence('Dstar_Seq', TopSelection=dstar_sel)

DaVinci().UserAlgorithms += [dstar_seq.sequence()]
Esempio n. 49
0
tuple.Tau.addTupleTool('TupleToolTISTOS/TISTOS')
tuple.Tau.TISTOS.VerboseL0   = True
tuple.Tau.TISTOS.VerboseHlt1 = True
tuple.Tau.TISTOS.VerboseHlt2 = True
tuple.Tau.TISTOS.TriggerList = L0_list + HLT1_list + HLT2_list


if dataSample.isMC:
    from Configurables import MCDecayTreeTuple, MCTupleToolKinematic, TupleToolMCTruth
    tuple.addTupleTool('TupleToolMCTruth/MCTruth')
    tuple.MCTruth.ToolList = ['MCTupleToolKinematic',
                              'MCTupleToolHierarchy',
                              ]
    tuple.Tau.addTupleTool( "TupleToolMCBackgroundInfo")

tau_sequence.sequence().Members += [tuple]

############################################################
## D tuple
############################################################

if dataSample.isNormalization:
    
    DTuple = DecayTreeTuple('DTuple')
    DTuple.Inputs = [ D_sequence.outputLocation() ]
    DTuple.Decay = dec_D
    DTuple.ToolList = ['TupleToolKinematic',
                      'TupleToolEventInfo',
                      'TupleToolTrackInfo',
                      'TupleToolPid',
                      'TupleToolGeometry', 
Esempio n. 50
0
#CondDB(UseOracle = True, IgnoreHeartBeat = True)

############################################
#from Configurables import *
from Configurables import LHCbApp
LHCbApp().XMLSummary='summary.xml'

from Configurables import DataOnDemandSvc
from Configurables import L0SelReportsMaker, L0DecReportsMaker
DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker( OutputLevel = 4 )
DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker( OutputLevel = 4 )

if myDecayType and IsMC:
    BsPhiRho_Sequence = GaudiSequencer("BsPhiRho_Sequence")
    SeqBsPhiRho = SelectionSequence("SeqBsPhiRho", TopSelection = selSeq)
    BsPhiRho_Sequence.Members += [SeqBsPhiRho.sequence()]
    BsPhiRho_Sequence.Members += [smear]
    BsPhiRho_Sequence.Members += [tuple]
    userAlgos.append(BsPhiRho_Sequence)
elif not myDecayType and IsMC:
    userAlgos.append( smear )
    userAlgos.append( tuple )
elif not IsMC:
    MySequencer.Members += [scaler]
    MySequencer.Members += [tuple]
    userAlgos.append(MySequencer)

from Configurables import EventTuple
etuple = EventTuple()
userAlgos.append( HltSelReportsDecoder() )
userAlgos.append( HltVertexReportsDecoder() )
Esempio n. 51
0
def configure(datafiles, catalogs=[], params={}, castor=False):
    """
    Configure the job
    """
    from Configurables           import DaVinci       ## needed for job configuration

    ## get the builder
    from StrippingSelections.StrippingPsiXForBandQ  import PsiX_BQ_Conf as  PSIX

    ## for MC it is better to exclude PID/DLL/PROBNN cuts
    builder_configuration = {
        # 'PionCut'   : """
        # ( PT          > 200 * MeV ) &
        'PionCut'   : """
        ( CLONEDIST   > 5000      ) &
        """
        # ( TRGHOSTPROB < 0.5       ) &
        # ( TRCHI2DOF   < 4         ) &
        # in_range ( 2          , ETA , 5         ) &
        # in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
        # HASRICH                     &
        # ( PROBNNpi     > 0.1      )
        #( MIPCHI2DV()  > 4        )
        ,
        # ( PT          > 200 * MeV ) &
        'KaonCut'   : """
        ( CLONEDIST   > 5000      ) &
        ( TRGHOSTPROB < 0.5       ) &
        ( TRCHI2DOF   < 4         ) &
        in_range ( 2          , ETA , 5         ) &
        in_range ( 3.2 * GeV  , P   , 150 * GeV ) &
        HASRICH                     &
        ( PROBNNk      > 0.1      )
        """
        # ( MIPCHI2DV()  > 4        )
    }


    def _kaons_     ( self ) :
        """
        Kaons for   B -> psi X lines
        """
        from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
        ## from StandardParticles                     import StdAllLooseKaons as inpts
        from StandardParticles                     import StdNoPIDsKaons   as inpts
        ##
        return self.make_selection (
            'Kaon'                 ,
            FilterDesktop          ,
            [ inpts ]              ,
            Code = self['KaonCut'] ,
        )


    def _pions_    ( self ) :
        """
        Pions for   B -> psi X lines
        """
        from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
        ## from StandardParticles                     import StdAllLoosePions as inpts
        from StandardParticles                     import StdNoPIDsPions   as inpts
        ##
        return self.make_selection (
            'Pion'                 ,
            FilterDesktop          ,
            [ inpts ]              ,
            Code = self['PionCut'] ,
        )

    jpsi_name = 'FullDSTDiMuonJpsi2MuMuDetachedLine'
    psi2_name = 'FullDSTDiMuonPsi2MuMuDetachedLine'

    from PhysSelPython.Wrappers import AutomaticData
    jpsi  = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % jpsi_name )
    psi2s = AutomaticData ( '/Event/AllStreams/Phys/%s/Particles' % psi2_name )
    #
    ## merged selectoon for J/psi & psi'
    #
    from PhysSelPython.Wrappers import MergedSelection
    psis = MergedSelection (
        'SelDetachedPsisForBandQ' ,
        RequiredSelections = [ jpsi ]
    )

    def _psi_ ( self ) :
        """
        psi(') -> mu+ mu-
        """
        return psis


    PSIX.pions = _pions_
    PSIX.kaons = _kaons_
    PSIX.psi   = _psi_

    ## use builder
    builder = PSIX ( 'PsiX' , builder_configuration  )



    from PhysSelPython.Wrappers import SelectionSequence

    psi3k      = SelectionSequence ( 'Psi3K'       , builder.psi_3K   () )
    psi3kpi    = SelectionSequence ( 'Psi3Kpi'     , builder.psi_3Kpi () )

    from PhysConf.Filters import LoKi_Filters
    fltrs   = LoKi_Filters (
        STRIP_Code = """
            HLT_PASS_RE('Stripping.*FullDSTDiMuonJpsi2MuMuDetachedLine.*')
        """
    )

    davinci = DaVinci(
        EventPreFilters = fltrs.filters('WG'),
        InputType     = 'DST'    ,
        Simulation    = True     ,
        PrintFreq     = 1000     ,
        EvtMax        = -1       ,
        Lumi          = True     ,
        DataType = params['Year'],
        DDDBtag = params['DDDB'],
        CondDBtag = params['SIMCOND'],
        # HistogramFile = 'DVHistos.root' ,
        TupleFile     = 'output_kpipi.root' ,
    )

    from Configurables import GaudiSequencer
    # seq   = GaudiSequencer('SEQ1', Members=[psi3k.sequence()])
    seq   = GaudiSequencer('SEQ2', Members=[psi3kpi.sequence()])


    my_name = "Bplus"


    davinci.UserAlgorithms = [ my_name ]

    setData ( datafiles , catalogs , castor )

    gaudi = appMgr()

    from StandardParticles import StdAllNoPIDsPions, StdAllNoPIDsKaons

    # create local algorithm:
    alg = MCAnalysisAlgorithm(
        my_name,
        Inputs = [
            StdAllNoPIDsPions.outputLocation(),
            StdAllNoPIDsKaons.outputLocation(),
            '/Event/AllStreams/Phys/%s/Particles' % jpsi_name
        ] ,
        PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ],
        ReFitPVs = True
    )

    return SUCCESS
Esempio n. 52
0
def configure(
        inputdata,  ## the list of input files  
        catalogs=[],  ## xml-catalogs (filled by GRID)
        castor=False,  ## use the direct access to castor/EOS ? 
        params={}):

    ## import DaVinci
    from Configurables import DaVinci

    decay = '[(D0 =>  K-  mu+ nu_mu) && ~(D0 --> K- (pi0|eta) mu+ nu_mu ... )]CC'
    decay_K = '[(D0 => ^K-  mu+ nu_mu) && ~(D0 --> K- (pi0|eta) mu+ nu_mu ... )]CC'
    decay_mu = '[(D0 =>  K- ^mu+ nu_mu) && ~(D0 --> K- (pi0|eta) mu+ nu_mu ... )]CC'

    from PhysConf.Filters import LoKi_Filters
    fltrs = LoKi_Filters(MC_Code="has ( MCDECTREE('%s') )" % decay,
                         MC_Preambulo=["from LoKiCore.functions import has"])

    ## delegate the actual configuration to DaVinci
    dv = DaVinci(DataType='2012',
                 EventPreFilters=fltrs.filters('MC-filter'),
                 InputType='DST',
                 Simulation=True,
                 TupleFile='Xuhao.root',
                 DDDBtag='Sim08-20130503-1',
                 CondDBtag='Sim08-20130503-1-vc-md100')

    ##
    ## reconstruct D0 -> K mu candidates
    ##
    from StandardParticles import StdAllLooseKaons as kaons
    from StandardParticles import StdAllLooseMuons as muons

    from PhysSelPython.Wrappers import SimpleSelection
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    #
    true_kaons = SimpleSelection(
        'MCTrueKaon',  ## selection name 
        FilterDesktop,  ## algorithm type
        [kaons],  ## input/required selection
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        Code="mcMatch ('%s', 2 )" % decay_K)
    #
    true_muons = SimpleSelection(
        'MCTrueMuon',  ## selection name 
        FilterDesktop,  ## algorithm type
        [muons],  ## input/required selection
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        Code="mcMatch ('%s', 2 )" % decay_mu)

    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    sel_D0 = SimpleSelection(
        'SelD0',  ## name 
        CombineParticles,  ## algorithm type 
        [true_muons, true_kaons],  ## input/required selections 
        ## the decays to be reconstructed
        DecayDescriptor='[D0 -> K- mu+]cc',
        ## combination cut : mass window
        CombinationCut="""
        in_range ( 1 *  GeV ,  AM , 2 * GeV )
        """,
        ##      mother cut : require good vertex & some separation
        MotherCut="""
        ( VFASPF( VCHI2 ) <  10 ) &
        ( BPVVDCHI2       >   9 )  
        """,
    )

    from PhysSelPython.Wrappers import SelectionSequence
    SEQ_D0 = SelectionSequence('TRUED0', sel_D0)

    alg1_name = 'Lines'
    ## add the name of Bender algorithm into User sequence sequence
    from Configurables import GaudiSequencer
    seq_lines = GaudiSequencer('SEQ_lines',
                               Members=[SEQ_D0.sequence(), alg1_name])

    alg2_name = 'TisTosAlg'
    ## add the name of Bender algorithm into User sequence sequence
    from Configurables import GaudiSequencer
    seq_tistos = GaudiSequencer('SEQ_tistos',
                                Members=[SEQ_D0.sequence(), alg2_name])

    dv.UserAlgorithms = [seq_lines, seq_tistos]

    ## define the input data
    setData(inputdata, catalogs, castor)

    from BenderTools.Utils import silence, totalSilence
    silence()
    totalSilence()

    ## get/create application manager
    gaudi = appMgr()

    alg1 = Lines(alg1_name, Inputs=[SEQ_D0.outputLocation()])
    alg2 = Tistos(alg2_name, Inputs=[SEQ_D0.outputLocation()])

    return SUCCESS
Esempio n. 53
0
Jpsi_seq = SelectionSequence('Jpsi_Seq', TopSelection=recJpsi)
D0_seq = SelectionSequence('D0_Seq', TopSelection=recD0)
Dp_seq = SelectionSequence('Dp_Seq', TopSelection=recDp)
Ds_seq = SelectionSequence('Ds_Seq', TopSelection=recDs)
Lc_seq = SelectionSequence('Lc_Seq', TopSelection=recLc)
D02K3pi_seq = SelectionSequence('D2K3pi0_Seq', TopSelection=recD02K3pi)

##########################

# Turbo/DaVinci configuration.
from Configurables import DstConf, TurboConf, DaVinci
DaVinci().Simulation = False
DaVinci().Lumi = True
DaVinci().TupleFile = "LumiTuple.root"
DaVinci().appendToMainSequence([Z_seq.sequence()])
DaVinci().appendToMainSequence([recPF, recJB])
#DaVinci().appendToMainSequence([recSVs_seq.sequence(), recMus_seq.sequence()])
DaVinci().appendToMainSequence([Jpsi_seq.sequence(), D0_seq.sequence(), Dp_seq.sequence(), Ds_seq.sequence(),  Lc_seq.sequence(), D02K3pi_seq.sequence()])
##TODO adding recSVs and recMus changes the daughters of jet objects from smart poniters to Particles
DaVinci().DataType = '2017'
DaVinci().EventPreFilters = fltrs.filters ('Filters')

from Configurables import LumiIntegrateFSR, LumiIntegratorConf
LumiIntegrateFSR('IntegrateBeamCrossing').SubtractBXTypes = ['None']

# Configure the BDT tagger.
from Configurables import LoKi__BDTTag
tagger = LoKi__BDTTag()
tagger.NbvSelect = False
tagger = LoKi__BDTTag("Backwards")
Esempio n. 54
0
    def __apply_configuration__(self):

        from Configurables import (GaudiSequencer, CombineParticles,
                                   OfflineVertexFitter)
        from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand

        seq = self.getProp("Sequencer")
        if seq == None: raise RuntimeError("ERROR : Sequence not set")

        if self.getProp("RunSelection"):

            # STD particles
            from StandardParticles import StdNoPIDsPions, StdNoPIDsKaons

            # phi -> K+ K-
            Phi2KKName = self.__sel_name__ + "_Phi2KK"
            Phi2KK = CombineParticles(Phi2KKName)
            Phi2KK.DecayDescriptor = "phi(1020) -> K+ K-"
            Phi2KK.CombinationCut = "(ADAMASS('phi(1020)')<75*MeV)"
            Phi2KK.MotherCut = "(ADMASS('phi(1020)')<50*MeV) & (BPVVDCHI2>60) & (MIPDV(PRIMARY)<0.5) & (VFASPF(VCHI2) < 20)"
            Phi2KK.DaughtersCuts = {
                "K+":
                "(PT>300*MeV) & (P>2*GeV) & (MIPDV(PRIMARY) < 0.5) &  (BPVIPCHI2() > 20)",
                "K-":
                "(PT>300*MeV) & (P>2*GeV) & (MIPDV(PRIMARY) < 0.5) &  (BPVIPCHI2() > 20)"
            }
            self.setOptions(Phi2KK)
            Phi2KKSel = Selection(Phi2KKName + 'Sel',
                                  Algorithm=Phi2KK,
                                  RequiredSelections=[StdNoPIDsKaons])

            # Bs -> J/psi phi
            Ds2piPhiName = self.__sel_name__
            Ds2piPhi = CombineParticles(Ds2piPhiName)
            Ds2piPhi.DecayDescriptor = "[D_s+ -> pi+ phi(1020)]cc"
            Ds2piPhi.addTool(OfflineVertexFitter)
            Ds2piPhi.ParticleCombiners.update({"": "OfflineVertexFitter"})
            Ds2piPhi.OfflineVertexFitter.useResonanceVertex = True
            Ds2piPhi.CombinationCut = "(ADAMASS('D_s+')<75*MeV)"
            Ds2piPhi.MotherCut = "(ADMASS('D_s+')<50*MeV) & (BPVDIRA>0.9999) & (BPVVDCHI2>85) & (MIPDV(PRIMARY)<0.1) &  (VFASPF(VCHI2) < 10)"
            Ds2piPhi.DaughtersCuts = {
                "pi+":
                "(PT>300*MeV) & (P>2*GeV) & (MIPDV(PRIMARY) >0.1) & (BPVIPCHI2() > 20)"
            }
            self.setOptions(Ds2piPhi)
            Ds2piPhiSel = Selection(
                Ds2piPhiName + 'Sel',
                Algorithm=Ds2piPhi,
                RequiredSelections=[Phi2KKSel, StdNoPIDsPions])

            # Selection Sequence
            selSeq = SelectionSequence(self.__sel_name__ + 'Seq',
                                       TopSelection=Ds2piPhiSel)

            # Run the selection sequence.
            seq.Members += [selSeq.sequence()]

        # Particle Monitoring plots
        if self.getProp("RunMonitors"):

            from Configurables import ParticleMonitor
            plotter = ParticleMonitor(self.__sel_name__ + "Plots")
            if self.getProp("RunSelection"):
                plotter.Inputs = ['Phys/' + self.__sel_name__ + 'Sel']
            else:
                plotter.Inputs = self.getProp("Candidates")
            plotter.PeakCut = "(ADMASS('D_s+')<100*MeV)"
            plotter.SideBandCut = "(ADMASS('D_s+')>100*MeV)"
            plotter.PlotTools = self.getProp("PlotTools")
            self.setOptions(plotter)
            seq.Members += [plotter]

        # Make a DST ?
        if self.getProp("MakeSelDST"):

            # Prescale
            from Configurables import DeterministicPrescaler
            scaler = DeterministicPrescaler(
                self.__sel_name__ + 'PreScale',
                AcceptFraction=self.getProp("DSTPreScaleFraction"))
            seq.Members += [scaler]
            # Write the DST
            MyDSTWriter = SelDSTWriter(self.__sel_name__ + "DST",
                                       SelectionSequences=[selSeq],
                                       OutputPrefix=self.__sel_name__)
            seq.Members += [MyDSTWriter.sequence()]

        # MC Performance checking ?
        if self.getProp("MCChecks"):

            from Configurables import ParticleEffPurMoni
            mcPerf = ParticleEffPurMoni(Ds2piPhiName + "MCPerf")
            mcPerf.Inputs = ['Phys/' + self.__sel_name__ + 'Sel']
            self.setOptions(mcPerf)
            seq.Members += [mcPerf]

        # Ntuple ?
        if self.getProp("MakeNTuple"):

            outputLevel = INFO

            from Configurables import (
                DecayTreeTuple, TupleToolDecay, TupleToolMCTruth,
                TupleToolMCBackgroundInfo, TupleToolGeometry,
                TupleToolKinematic, TupleToolPrimaries, TupleToolEventInfo,
                MCTupleToolHierarchy, MCTupleToolKinematic, TupleToolPid,
                TupleToolTrackInfo, TupleToolVtxIsoln, LoKi__Hybrid__TupleTool)

            Tuple = DecayTreeTuple(Ds2piPhiName + "Tuple")
            Tuple.Inputs = ["Phys/" + Ds2piPhiName]
            Tuple.Decay = "[D_s+ -> ^pi+ (^phi(1020) => ^K+ ^K-)]cc"
            Tuple.Branches = {
                "pion": "[D_s+ -> ^pi+ (phi(1020) => K+ K-)]cc",
                "kaonplus": "[D_s+ -> pi+ (phi(1020) => ^K+ K-)]cc",
                "kaonminus": "[D_s+ -> pi+ (phi(1020) => K+ ^K-)]cc",
                "phi": "[D_s+ -> pi+ (^phi(1020) => K+ K-)]cc",
                "D_s": "[D_s+]cc :[D_s+ -> pi+ (phi(1020) => K+ K-)]cc"
            }

            Tuple.addTool(TupleToolDecay, name='pion')
            Tuple.addTool(TupleToolDecay, name='phi')
            Tuple.addTool(TupleToolDecay, name='kaonplus')
            Tuple.addTool(TupleToolDecay, name='kaonminus')
            Tuple.addTool(TupleToolDecay, name='D_s')

            # k+ specific
            kaonplusLoKiTool = LoKi__Hybrid__TupleTool('kaonplusLoKiTool')
            kaonplusLoKiTool.Variables = {
                "LOKI_PIDK": "PIDK",
                "LOKI_PIDe": "PIDe",
                "LOKI_PIDpi": "PIDpi",
                "LOKI_PIDp": "PIDp",
                "LOKI_PIDmu": "PIDmu",
                "LOKI_PIDK_PIDpi": "PIDK-PIDpi",
                "LOKI_PIDK_PIDe": "PIDK-PIDe",
                "LOKI_PIDK_PIDmu": "PIDK-PIDmu",
                "LOKI_PIDK_PIDp": "PIDK-PIDp"
            }

            Tuple.kaonplus.addTool(kaonplusLoKiTool, name='kaonplusLoKiTool')
            Tuple.kaonplus.ToolList = [
                'LoKi::Hybrid::TupleTool/kaonplusLoKiTool'
            ]

            # k- specific
            kaonminusLoKiTool = LoKi__Hybrid__TupleTool('kaonminusLoKiTool')
            kaonminusLoKiTool.Variables = {
                "LOKI_PIDK": "PIDK",
                "LOKI_PIDe": "PIDe",
                "LOKI_PIDpi": "PIDpi",
                "LOKI_PIDp": "PIDp",
                "LOKI_PIDmu": "PIDmu",
                "LOKI_PIDK_PIDpi": "PIDK-PIDpi",
                "LOKI_PIDK_PIDe": "PIDK-PIDe",
                "LOKI_PIDK_PIDmu": "PIDK-PIDmu",
                "LOKI_PIDK_PIDp": "PIDK-PIDp"
            }

            Tuple.kaonminus.addTool(kaonminusLoKiTool,
                                    name='kaonminusLoKiTool')
            Tuple.kaonminus.ToolList = [
                'LoKi::Hybrid::TupleTool/kaonminusLoKiTool'
            ]

            # pi+ specific
            pionLoKiTool = LoKi__Hybrid__TupleTool('pionLoKiTool')
            pionLoKiTool.Variables = {
                "LOKI_PIDK": "PIDK",
                "LOKI_PIDe": "PIDe",
                "LOKI_PIDpi": "PIDpi",
                "LOKI_PIDp": "PIDp",
                "LOKI_PIDmu": "PIDmu",
                "LOKI_PIDpi_PIDK": "PIDpi-PIDK",
                "LOKI_PIDpi_PIDe": "PIDpi-PIDe",
                "LOKI_PIDpi_PIDmu": "PIDpi-PIDmu",
                "LOKI_PIDpi_PIDp": "PIDpi-PIDp"
            }

            Tuple.pion.addTool(pionLoKiTool, name='pionLoKiTool')
            Tuple.pion.ToolList = ['LoKi::Hybrid::TupleTool/pionLoKiTool']

            # phi specific
            phiLoKiTool = LoKi__Hybrid__TupleTool('phiLoKiTool')
            phiLoKiTool.Variables = {}

            Tuple.phi.addTool(phiLoKiTool, name='phiLoKiTool')
            Tuple.phi.ToolList = ['LoKi::Hybrid::TupleTool/phiLoKiTool']

            # D_s specific
            DsLoKiTool = LoKi__Hybrid__TupleTool('DsLoKiTool')
            DsLoKiTool.Variables = {}

            Tuple.D_s.addTool(DsLoKiTool, name='DsLoKiTool')
            Tuple.D_s.ToolList = ["LoKi::Hybrid::TupleTool/DsLoKiTool"]

            # Common to all particles
            LoKiTool = LoKi__Hybrid__TupleTool('LoKiTool')
            LoKiTool.Variables = {
                "LOKI_ABSID": "ABSID",
                "LOKI_BPVIPCHI2": "BPVIPCHI2()",
                "LOKI_BPVDIRA": "BPVDIRA",
                "LOKI_BPVLTFITCHI2":
                "BPVLTFITCHI2('PropertimeFitter/properTime:PUBLIC')",
                "LOKI_BPVLTCHI2":
                "BPVLTCHI2('PropertimeFitter/properTime:PUBLIC')",
                "LOKI_BPVLTIME":
                "BPVLTIME('PropertimeFitter/properTime:PUBLIC')",
                "LOKI_BPVVDCHI2": "BPVVDCHI2",
                "LOKI_ID": "ID",
                "LOKI_MIPDV_PRIMARY": "MIPDV(PRIMARY)",
                "LOKI_MIPCHI2DV_PRIMARY": "MIPCHI2DV(PRIMARY)",
                "LOKI_MM": "MM",
                "LOKI_M": "M",
                "LOKI_P": "P",
                "LOKI_PT": "PT",
                "LOKI_TRCHI2": "TRCHI2",
                "LOKI_TRCHI2DOF": "TRCHI2DOF",
                "LOKI_VFASPF_VCHI2": "VFASPF(VCHI2)",
                "LOKI_VFASPF_VDOF": "VFASPF(VDOF)"
            }

            Tuple.addTool(LoKiTool, name='LoKiTool')
            Tuple.ToolList = [
                "LoKi::Hybrid::TupleTool/LoKiTool", "TupleToolEventInfo",
                "TupleToolGeometry", "TupleToolKinematic",
                "TupleToolMCBackgroundInfo", "TupleToolPid",
                "TupleToolPrimaries", "TupleToolTrackInfo",
                "TupleToolVtxIsoln", "TupleToolMCTruth"
            ]

            Tuple.addTool(TupleToolEventInfo)
            Tuple.TupleToolEventInfo.OutputLevel = outputLevel

            Tuple.addTool(TupleToolGeometry)
            Tuple.TupleToolGeometry.OutputLevel = outputLevel

            Tuple.addTool(TupleToolKinematic)
            Tuple.TupleToolKinematic.OutputLevel = outputLevel

            Tuple.addTool(TupleToolMCBackgroundInfo)
            Tuple.TupleToolMCBackgroundInfo.OutputLevel = outputLevel

            Tuple.addTool(MCTupleToolHierarchy)
            Tuple.MCTupleToolHierarchy.OutputLevel = outputLevel

            Tuple.addTool(TupleToolMCTruth)
            Tuple.TupleToolMCTruth.OutputLevel = outputLevel
            Tuple.TupleToolMCTruth.addTool(MCTupleToolKinematic())
            Tuple.TupleToolMCTruth.addTool(MCTupleToolHierarchy())
            Tuple.TupleToolMCTruth.ToolList = [
                "MCTupleToolKinematic", "MCTupleToolHierarchy"
            ]
            Tuple.TupleToolMCTruth.MCTupleToolKinematic.StoreKineticInfo = True
            Tuple.TupleToolMCTruth.MCTupleToolKinematic.StoreVertexInfo = True
            Tuple.TupleToolMCTruth.MCTupleToolKinematic.StorePropertimeInfo = True
            Tuple.TupleToolMCTruth.MCTupleToolKinematic.OutputLevel = outputLevel

            Tuple.addTool(TupleToolPid)
            Tuple.TupleToolPid.OutputLevel = outputLevel

            Tuple.addTool(TupleToolPrimaries)
            Tuple.TupleToolPrimaries.OutputLevel = outputLevel

            Tuple.addTool(TupleToolTrackInfo)
            Tuple.TupleToolTrackInfo.OutputLevel = outputLevel

            Tuple.addTool(TupleToolVtxIsoln)
            Tuple.TupleToolVtxIsoln.OutputLevel = outputLevel

            seq.Members += [Tuple]

            Tuple.NTupleLUN = "DSPHIPI"

            from Configurables import NTupleSvc
            NTupleSvc().Output = [
                "DSPHIPI DATAFILE='DsToPhiPi.root'  TYP='ROOT'  OPT='NEW'"
            ]
Esempio n. 55
0
def configure(
        inputdata,  ## the list of input files  
        catalogs=[],  ## xml-catalogs (filled by GRID)
        castor=False,  ## use the direct access to castor/EOS ? 
        params={}):

    ## import DaVinci
    from Configurables import DaVinci
    ## delegate the actual configuration to DaVinci
    dv = DaVinci(DataType='2012',
                 InputType='DST',
                 Simulation=True,
                 TupleFile='Jascha.root',
                 DDDBtag='dddb-20130929-1',
                 CondDBtag='sim-20130522-1-vc-md100')

    from StandardParticles import StdAllLooseKaons as kaons
    from StandardParticles import StdAllLooseMuons as muons
    from StandardParticles import StdLooseResolvedPi0 as pi0

    decay = '[ B+ -> (J/psi(1S) =>  mu+  mu- )  ( K*(892)+ ->  K+  pi0 ) ]CC'
    decay_K = '[ B+ -> (J/psi(1S) =>  mu+  mu- )  ( K*(892)+ -> ^K+  pi0 ) ]CC'
    decay_Kst = '[ B+ -> (J/psi(1S) =>  mu+  mu- ) ^( K*(892)+ ->  K+  pi0 ) ]CC'
    decay_mu = '[ B+ -> (J/psi(1S) => ^mu+ ^mu- )  ( K*(892)+ -> ^K+  pi0 ) ]CC'
    decay_pi0 = '[ B+ -> (J/psi(1S) => ^mu+ ^mu- )  ( K*(892)+ ->  K+ ^pi0 ) ]CC'
    decay_gamma = '[ B+ -> (J/psi(1S) => ^mu+ ^mu- )  ( K*(892)+ ->  K+ (pi0 -> ^gamma ^gamma ) ) ]CC'

    from PhysSelPython.Wrappers import SimpleSelection
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    #
    true_kaons = SimpleSelection(
        'MCTrueKaon',  ## selection name 
        FilterDesktop,  ## algorithm type
        [kaons],  ## input/required selection
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        Code="mcMatch ('%s', 2 )" % decay_K)
    #
    true_muons = SimpleSelection(
        'MCTrueMuon',  ## selection name 
        FilterDesktop,  ## algorithm type
        [muons],  ## input/required selection
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        Code="mcMatch ('%s', 2 )" % decay_mu)

    true_pi0 = SimpleSelection(
        'MCTruePi0',  ## selection name 
        FilterDesktop,  ## algorithm type
        [pi0],  ## input/required selection
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        Code="""
        mcMatch ('%s')
        & CHILDCUT ( mcMatch ('%s') , 1 )
        & CHILDCUT ( mcMatch ('%s') , 2 )
        """ % (decay_pi0, decay_gamma, decay_gamma))

    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    sel_Kst = SimpleSelection(
        'SelKst',  ## name 
        CombineParticles,  ## algorithm type 
        [true_pi0, true_kaons],  ## input/required selections 
        ## algorithm propperties
        Preambulo=["from LoKiPhysMC.decorators import *"],
        ## the decays to be reconstructed
        DecayDescriptor='[K*(892)+ -> K+ pi0]cc',
        ## combination cut : mass window
        CombinationCut="""
        in_range ( 0.8 *  GeV ,  AM , 1.0 * GeV )
        """,
        ##      mother cut : require good vertex
        MotherCut="mcMatch ('%s' )" % decay_Kst)

    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    sel_Jpsi = SimpleSelection(
        'SelJpsi',  ## name 
        CombineParticles,  ## algorithm type 
        [true_muons],  ## input/required selections 
        ## the decays to be reconstructed
        DecayDescriptor='J/psi(1S) -> mu+ mu-',
        ## combination cut : mass window
        CombinationCut="""
        in_range ( 3.0 *  GeV ,  AM , 3.2 * GeV )
        """,
        ##      mother cut : require good vertex
        MotherCut="  VFASPF( VCHI2 ) <  10 ")

    from PhysSelPython.Wrappers import SelectionSequence
    SEQ_Kst = SelectionSequence('TRUEKSSTAR', sel_Kst)
    SEQ_Jpsi = SelectionSequence('TRUEPSI', sel_Jpsi)
    SEQ_K = SelectionSequence('TRUEK', true_kaons)

    alg_name = 'Jascha'
    ## add the name of Bender algorithm into User sequence sequence
    from Configurables import GaudiSequencer
    seq_lines = GaudiSequencer(
        'SEQ_lines',
        Members=[
            GaudiSequencer('K', Members=[SEQ_K.sequence()]),
            GaudiSequencer('PSI', Members=[SEQ_Jpsi.sequence()]),
            GaudiSequencer('KST', Members=[SEQ_Kst.sequence()]), alg_name
        ])

    dv.UserAlgorithms = [seq_lines]

    ## define the input data
    setData(inputdata, catalogs, castor)

    ## get/create application manager
    gaudi = appMgr()

    alg = Jascha(alg_name,
                 Inputs=[
                     SEQ_K.outputLocation(),
                     SEQ_Kst.outputLocation(),
                     SEQ_Jpsi.outputLocation(),
                     'Phys/StdLooseResolvedPi0/Particles'
                 ],
                 ParticleCombiners={'': 'LoKi::VertexFitter/TESTFIT:PUBLIC'},
                 VertexFitters={'': 'LoKi::VertexFitter/TESTFIT:PUBLIC'})

    return SUCCESS
Esempio n. 56
0
def configure(datafiles, catalogs=[], castor=True, params=None):
    """
    Configure the job
    """

    from Configurables import DaVinci  # needed for job configuration
    # from Configurables import EventSelector  # needed for job configuration
    # from Configurables import NTupleSvc

    from PhysConf.Filters import LoKi_Filters

    fltrs = LoKi_Filters(
        STRIP_Code="""
        HLT_PASS_RE ( 'Stripping.*DiMuonHighMass.*Decision' )
        """,
        VOID_Code="""
        0 < CONTAINS (
            '/Event/AllStreams/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles')
        """
    )

    filters = fltrs.filters('Filters')
    filters.reverse()

    from PhysSelPython.Wrappers import AutomaticData, Selection, SelectionSequence

    #
    # defimuon in stripping DST
    #
    # DiMuLocation  =
    # '/Event/Dimuon/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles'
    DiMuLocation = '/Event/AllStreams/Phys/FullDSTDiMuonDiMuonHighMassLine/Particles'

    from PhysSelPython.Wrappers import AutomaticData
    DiMuData = AutomaticData(Location=DiMuLocation)

    # =========================================================================
    # Upsilon -> mumu, cuts by  Giulia Manca
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    UpsAlg = FilterDesktop(
        Code="""
        ( M > 7 * GeV ) &
        DECTREE   ('Meson -> mu+ mu-'  )                      &
        CHILDCUT( 1 , HASMUON & ISMUON )                      &
        CHILDCUT( 2 , HASMUON & ISMUON )                      &
        ( MINTREE ( 'mu+' == ABSID , PT ) > 1 * GeV         ) &
        ( MAXTREE ( ISBASIC & HASTRACK , TRCHI2DOF ) < 4    ) &
        ( MINTREE ( ISBASIC & HASTRACK , CLONEDIST ) > 5000 ) &
        ( VFASPF  ( VPCHI2 ) > 0.5/100 )
        & ( abs ( BPV ( VZ    ) ) <  0.5 * meter     )
        & (       BPV ( vrho2 )   < ( 10 * mm ) ** 2 )
        """,
        Preambulo=[
            "vrho2 = VX**2 + VY**2"
        ],
        ReFitPVs=True
    )

    UpsSel = Selection(
        'UpsSel',
        Algorithm=UpsAlg,
        RequiredSelections=[DiMuData]
    )

    # =========================================================================
    # chi_b -> Upsilon gamma
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    ChibCombine = CombineParticles(
        DecayDescriptor="chi_b1(1P) ->  J/psi(1S) gamma",
        DaughtersCuts={
            "gamma": " ( 350 * MeV < PT ) & ( CL > 0.01 )  "
        },
        CombinationCut="""
        ( AM - AM1 ) < 3 * GeV
        """,
        MotherCut=" PALL",
        #
        # we are dealing with photons!
        #
        ParticleCombiners={
        '': 'LoKi::VertexFitter'
        }
    )
    from StandardParticles import StdLooseAllPhotons  # needed for chi_b
    ChibSel1 = Selection(
        'PreSelChib',
        Algorithm=ChibCombine,
        RequiredSelections=[UpsSel, StdLooseAllPhotons]
    )
    from GaudiConfUtils.ConfigurableGenerators import Pi0Veto__Tagger
    TagAlg = Pi0Veto__Tagger(
        ExtraInfoIndex=25001,  # should be unique!
        MassWindow=20 * MeV,  # cut on delta-mass
        MassChi2=-1,  # no cut for chi2(mass)
    )
    ChibSel2 = Selection(
        'Chi_b',
        Algorithm=TagAlg,
        RequiredSelections=[ChibSel1]
    )
    Chib = SelectionSequence("ChiB", TopSelection=ChibSel2)

    # print 'OUTPUT!!!' , output_loc

    # =========================================================================
    # Upsilons
    # ========================================================================
    Ups = SelectionSequence("UpsSelSeq", TopSelection=UpsSel)
    # ========================================================================
    from Configurables import GaudiSequencer
    myChibSeq = GaudiSequencer('MyChibSeq')
    myChibSeq.Members = [Chib.sequence()] + ["ChibAlg"]

    myUpsSeq = GaudiSequencer('MyUpsSeq')
    myUpsSeq.Members = [Ups.sequence()] + ["UpsilonAlg"]

    davinci = DaVinci(
        EventPreFilters=filters,
        DataType='2011',
        Simulation=True,
        InputType='DST',
        HistogramFile="chib_histos.root",
        TupleFile="chib_tuples.root",
        PrintFreq=1000,
        Lumi=True,
        EvtMax=-1
    )

    davinci.UserAlgorithms = [myChibSeq, myUpsSeq]

    # =========================================================================
    from Configurables import Gaudi__IODataManager as IODataManager
    IODataManager().AgeLimit = 2
    # =========================================================================
    # come back to Bender
    setData(datafiles, catalogs, castor)
    gaudi = appMgr()

    alg_chib = ChibMC(
        'ChibAlg',  # Algorithm name ,
        # input particles
        Inputs=[
            Chib.outputLocation()
        ],
        # take care about the proper particle combiner
        ParticleCombiners={'': 'LoKi::VertexFitter'}
    )

    alg_ups = UpsilonMC(
        'UpsilonAlg',  # Algorithm name ,
        # input particles
        Inputs=[
            Ups.outputLocation()
        ],
        # take care about the proper particle combiner
        ParticleCombiners={'': 'LoKi::VertexFitter'}
    )

    alg_chib.nb = alg_ups.nb = params['nb']
    alg_chib.np = alg_ups.np = params['np']

    # =========================================================================
    return SUCCESS
Esempio n. 57
0
tupleB.Jpsi.TupleToolTISTOS.Verbose = True
tupleB.Jpsi.TupleToolTISTOS.TriggerList = list





from Configurables import DaVinci
DaVinci().TupleFile = "BuKMuMu.root"
DaVinci().EvtMax = -1
DaVinci().DataType = '2012'
DaVinci().Simulation   = False
DaVinci().Lumi = not DaVinci().Simulation

_myseq = GaudiSequencer("myseq")
_myseq.Members += [SeqB.sequence() ] # make B candidates (muon channel)
_myseq.Members +=[ tupleB] # put stuff in a Tuple
DaVinci().UserAlgorithms = [_myseq] # run the whole thing
DaVinci().MainOptions  = ""



"""
#we should put this back later if we want to smear stuff
from Configurables import TrackSmeared
TrackSmeared("TrackSmearing").smearBest = True
TrackSmeared("TrackSmearing").Scale = 0.5
TrackSmearingSeq = GaudiSequencer("TrackSmearingSeq")
TrackSmearingSeq.Members = [ TrackSmeared("TrackSmearing") ]
"""
#try to do it like in the starterkit
Esempio n. 58
0
    "LV01"                    : "LV01" }

#BJpsiKS.addBranches({  # remove all "^" except where needed.
#        "Jpsi"       : "^(J/psi(1S) -> mu- mu+)",
#        "muplus"     : "J/psi -> mu- ^mu+",
#        "muminus"    : "J/psi -> ^mu- mu+"
#        })

### Bplus tools
### Jpsi tools
#BJpsiKS.Jpsi.addTupleTool("TupleToolDownEff")

################################################################
################################################################
Seq1 = GaudiSequencer("Seq1")
Seq1.Members += [ SeqKsPiPi.sequence(), KsPiPiTuple ]
Seq1.Members += [ SeqLambdaPPi.sequence(), LambdaPPiTuple ]
Seq1.ShortCircuit = False
Seq1.ModeOR = True
# ######################################################################################################
DaVinci().MainOptions = ""
DaVinci().UserAlgorithms = [Seq1]
########################################################################
DaVinci().EvtMax    = -1
DaVinci().DataType  = "2016"
DaVinci().PrintFreq = 100
DaVinci().Lumi      = False

DaVinci().InputType = "DST"

if simulation is True:
d0 = CombineParticles('Combine_D0',
                      DecayDescriptor='[D0 -> pi- K+]cc',
                      DaughtersCuts=d0_daughters,
                      CombinationCut=d0_comb,
                      MotherCut=d0_mother)

d0_sel = Selection('Sel_D0',
                   Algorithm=d0,
                   RequiredSelections=[Pions, Kaons])

dstar_daughters = {'pi+': '(TRCHI2DOF < 3) & (PT > 100*MeV)'}
dstar_comb = "(ADAMASS('D*(2010)+') < 400*MeV)"
dstar_mother = (
    "(abs(M-MAXTREE('D0'==ABSID,M)-145.42) < 10*MeV)"
    '& (VFASPF(VCHI2/VDOF)< 9)'
)
dstar_sel = SimpleSelection(
    'Sel_Dstar',
    ConfigurableGenerators.CombineParticles,
    [d0_sel, Pions],
    DecayDescriptor='[D*(2010)+ -> D0 pi+]cc',
    DaughtersCuts=dstar_daughters,
    CombinationCut=dstar_comb,
    MotherCut=dstar_mother
)

dstar_seq = SelectionSequence('Dstar_Seq', TopSelection=dstar_sel)

DaVinci().UserAlgorithms += [dstar_seq.sequence()]