示例#1
0
    _muons2 = DataOnDemand(Location='Phys/SmrdLooseMuons')
    _filtermuons2 = FilterDesktop("filterMuons2", Code = "TRCHI2DOF<4")
    _selMuons2 = Selection("SelFilterMuons2",
                            Algorithm = _filtermuons,
                            RequiredSelections = [_muons])
    _seqMuons2 = SelectionSequence("SeqFilterMuons2", TopSelection = _selMuons2)


#######################################################################
#
# Decay Tree tuple
#

from Configurables import DecayTreeTuple
decaytuple = DecayTreeTuple("OriginalPionsTuple")
decaytuple.InputLocations = [_seqPions.outputLocation() ]
decaytuple.ToolList +=  [
    "TupleToolGeometry"
    , "TupleToolKinematic"
    , "TupleToolTrackInfo"
    , "TupleToolPid"
   ]
decaytuple.Decay = "[pi+]cc"
from Configurables import TupleToolTrigger
decaytuple.addTool( TupleToolTrigger, name='TupleToolTrigger' )
decaytuple.TupleToolTrigger.Verbose = True
decaytuple.TupleToolTrigger.UseAutomaticTriggerList = False
decaytuple.TupleToolTrigger.TriggerList =[
"Hlt1MBNoBiasDecision",
"Hlt1MBMicroBiasRZVeloDecision",
"Hlt1MBMicroBiasTStationDecision",
示例#2
0
subsel = Selection("subsel",Algorithm = subalg, RequiredSelections = [_selDimuons])

# Try and make B->J/psi K
_B = CombineParticles()
_B.DaughtersCuts = { "K+" : "(PT>500*MeV)&(MIPCHI2DV(PRIMARY) > 9)" }
_B.MotherCut = "(DMASS('B+')<5000*MeV) & (VFASPF(VCHI2)/VFASPF(VDOF)<5.0) & (BPVDIRA > 0.999)" #need to check these cuts
_B.DecayDescriptors = [ "[B+ -> J/psi(1S) K+]cc" ]


_BdecaySelection = Selection( "TurboB", Algorithm = _B, RequiredSelections = [subsel,kaons] )
SeqB = SelectionSequence('SeqB', TopSelection = _BdecaySelection)

# Here we just put the output candidates in an Tuple

tupleB = DecayTreeTuple("bae-muon-data")
tupleB.Inputs = [SeqB.outputLocation()]
tupleB.Decay = "[B+ -> ^K+ ^(J/psi(1S) -> ^mu+ ^mu-)]CC"


tupleB.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
    ,    "TupleToolTrigger",
        "TupleToolPid",
        "TupleToolPrimaries",
        "TupleToolAngles",
        "TupleToolEventInfo",
        "TupleToolGeometry",
        "TupleToolKinematic",
        "TupleToolPropertime",
示例#3
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]
示例#4
0
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"
    , "TupleToolEventInfo"
    , "TupleToolPropertime"
    ,"LoKi::Hybrid::TupleTool/LoKiTupleBhh" 
     ]
from Configurables import LoKi__Hybrid__TupleTool
LoKiTupleBhh = LoKi__Hybrid__TupleTool("LoKiTupleBhh")
LoKiTupleBhh.Variables = {
    "Charge"  : "Q" ,
                         Preambulo=preambulo,
                         DecayDescriptors = ['[B+ -> eta_prime pi+]cc'],
                         CombinationCut="(AM>3000.0) & (AM<10000.0) & (ACUTDOCA(0.04*mm,''))",
                         MotherCut ="(VFASPF(VCHI2/VDOF)<20.0)" 
                         )

Bu_sel = Selection("Bu_sel",
                   Algorithm= makeBu,
                   RequiredSelections=[etap_selection,pion_Sel]
                   )

Bu_selSeq = SelectionSequence("Bu_selSeq",TopSelection=Bu_sel)

from Configurables import PrintDecayTree

pt= PrintDecayTree(Inputs=[Bu_selSeq.outputLocation()])

from Configurables import SubstitutePID
SubKToPi = SubstitutePID (name = "SubKToPi",
                          Code = "DECTREE('[(B+ -> eta_prime pi+),(B- -> eta_prime pi-)]')",
                          Substitutions = {
                                  'B+ -> eta_prime ^pi+' : 'K+',
                                  'B- -> eta_prime ^pi-' : 'K-',
                          }
                          )
BuK_Sel=Selection("BuK_Sel",Algorithm=SubKToPi,RequiredSelections=[Bu_sel])

BuKFilter= FilterDesktop("BuKFilter",Code="(M>4900.0) & (M<5600.0) & (VFASPF(VCHI2/VDOF)<6.0)")

BuKFilteredSel = Selection("BuKFilteredSel",Algorithm=BuKFilter,RequiredSelections=[BuK_Sel])
示例#6
0
    }
)

# create a selection using the substitution algorithm
selSub = Selection(
    'Dst2D0pi_D02pipi_Sel',
    Algorithm=subs,
    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
示例#7
0
#--------------------------------------------------------------------------
# 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" )
tuple.Inputs = [ SeqFilterL.outputLocation() ]



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

from Configurables import DaVinci #!
DaVinci().Simulation   = True
DaVinci().EvtMax = -1                        # Number of events
#DaVinci().EventPreFilters = fltrs.filters('Filter') #!
DaVinci().UserAlgorithms = [ seq, tuple  ]
from Configurables import CondDB #!
DaVinci().DataType = "2012"
DaVinci().DDDBtag   = "Sim08-20130503-1" #!
DaVinci().CondDBtag = "Sim08-20130503-1-vc-md100" #!
JpsiSeq = SelectionSequence(
    'SeqJpsi',
    TopSelection=JpsiFilterSel,
)

############# DecayTreeTuple
from Configurables import DecayTreeTuple, TupleToolTrigger, TupleToolDecay, TupleToolTISTOS
tuple = DecayTreeTuple("Jpsi_Tuple")
# tuple.addTupleTool( "TupleToolGeometry") // already default
# tuple.addTupleTool( "TupleToolKinematic")// already default
tuple.addTupleTool("TupleToolPropertime")
tuple.addTupleTool("TupleToolPrimaries")
# tuple.addTupleTool( "TupleToolEventInfo")// already default
tuple.addTupleTool("TupleToolTrackInfo")
tuple.Decay = "J/psi(1S) -> ^mu+ ^mu-"
tuple.Inputs = [JpsiSeq.outputLocation()]
tuple.addTupleTool(TupleToolTISTOS)
tuple.TupleToolTISTOS.TriggerList = [
    "Hlt2DiMuonJPsiDecision", "Hlt2DiMuonJPsiHighPTDecision",
    "Hlt2DiMuonDetachedJPsiDecision"
]
tuple.TupleToolTISTOS.VerboseHlt2 = True
DaVinci().appendToMainSequence([JpsiSeq.sequence(), tuple])
##################

######### Debugging
# decision filter test
from Configurables import LoKi__HDRFilter as StripFilter
DaVinci().appendToMainSequence([
    StripFilter('StripPassFilter',
                Code="HLT_PASS('Stripping" + line + "Decision')",
#from GaudiConf import IOHelper
#IOHelper().inputFiles([
#        '~/DSTs/pPbPhotons/MinBiasMC.dst'
#],clear=True)

#===================
# Setup GaudiPython

if False:
    from Configurables import HltParticleFlow, HltJetBuilder
    pf = HltParticleFlow('pf')
    pf.Inputs += [['ProtoParticle', 'best', 'Rec/ProtoP/Charged'],
                  ['ProtoParticle', 'gamma', 'Rec/ProtoP/Neutrals']]

    pf.Inputs += [['Particle', 'daughters',
                   convLLSeq.outputLocation()],
                  ['Particle', 'daughters',
                   convDDSeq.outputLocation()],
                  ['Particle', 'daughters',
                   caloSeq.outputLocation()],
                  ['Particle', 'daughters',
                   mergedpi0Seq.outputLocation()],
                  ['Particle', 'daughters',
                   dimuSeq.outputLocation()]]

    pf.Output = 'Phys/PF/Particles'
    pf.ProBestNames = ['mu+', 'e+', 'p+', 'K+', 'pi+']
    pf.ProBestKeys = [701, 700, 704, 703, 702]
    pf.ProBestMins = [0.5, 0.5, 0.5, 0.5, 0.5]
    pf.EcalBest = True
    pf.SprRecover = False
                     RequiredSelections=[StdAllLoosePions])
seqDipos = SelectionSequence('SeqDipos', TopSelection=selDipos)
if Mode == 'pi': DaVinci().appendToMainSequence([seqDipss, seqDipos])

# Create the jets.
from Configurables import HltParticleFlow, HltJetBuilder
pf = HltParticleFlow('pf')
pf.Inputs += [['ProtoParticle', 'best', 'Rec/ProtoP/Charged'],
              ['ProtoParticle', 'gamma', 'Rec/ProtoP/Neutrals']]
if 'Turbo' in Type:
    pf.Inputs += [[
        'Particle', 'daughters', '/Event/Turbo/' + loc + '/Particles'
    ] for loc in TrgLocs]
elif Mode == 'mu':
    pf.Inputs += [['Particle', 'daughters',
                   seqDimus.outputLocation()],
                  ['Particle', 'daughters',
                   seqQdmus.outputLocation()]]
    if 'MC' in Type:
        pf.Inputs += [['Particle', 'daughters', seqSsmus.outputLocation()]]
elif Mode == 'Ks':
    pf.Inputs += [['Particle', 'daughters', seqKss.outputLocation()]]
elif Mode == 'pi':
    pf.Inputs += [['Particle', 'daughters',
                   seqDipss.outputLocation()],
                  ['Particle', 'daughters',
                   seqDipos.outputLocation()]]
pf.Output = 'Phys/PF/Particles'
pf.ProBestNames = ['mu+', 'e+', 'p+', 'K+', 'pi+']
pf.ProBestKeys = [701, 700, 704, 703, 702]
pf.ProBestMins = [0.5, 0.5, 0.5, 0.5, 0.5]
示例#11
0
def configure(datafiles,
              catalogs=[],
              castor=False):
    """
    Job configuration 
    """

    # =======================================================================
    # J/psi
    # =======================================================================

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

    from StrippingSelections.StrippingPromptCharm import StrippingPromptCharmConf as PC

    # ======================================
    # REMOVED !!!                         +
    # ( TRGHOSTPROB < 0.5 ) &             +
    # ======================================
    pc = PC('PromptCharm', {
        'TrackCuts'       : """
        ( TRCHI2DOF < 5     ) &
        ( PT > 250 * MeV    ) &
        in_range  ( 2 , ETA , 5 )
        """ ,
        'KaonCuts': ' & ( 0 < PIDK  - PIDpi ) ',
        'PionCuts': ' & ( 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)<25
        "ctau   = BPVLTIME ( 25 ) * c_light "
    ]

    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    # ========================================================================
    # prepare Ds+
    # ========================================================================

    Ds_alg = CombineParticles(
        # the decays to be reconstructed
        DecayDescriptor="[D_s+ -> K-  K+ pi+]cc ",
        #
        Preambulo=Preambulo,
        # combination cut : wide mass-cut & PT-cut
        CombinationCut="""
        (   AM12           < 1050 * MeV ) & 
        ( ( ADAMASS('D+')  <   60 * MeV ) | ( ADAMASS('D_s+') <   60 * MeV ) ) & 
        (   APT            >  900 * MeV )
        """ ,
        # mother cut
        MotherCut="""
        (   chi2vx        < 25       ) &
        (   PT            >  1 * GeV ) &
        ( ( ADMASS('D+')  < 50 * MeV ) | ( ADMASS('D_s+') < 50 * MeV ) ) 
        """ ,
        #
        ParticleCombiners={'': 'LoKi::VertexFitter'}
    )

    from PhysSelPython.Wrappers import Selection
    # make selection
    Ds_sel = Selection(
        'DsForPsiC',
        Algorithm=Ds_alg,
        RequiredSelections=[kaons, pions]
    )

    # ========================================================================
    BDs_alg = CombineParticles(
        # the decays to be reconstructed
        DecayDescriptor="[ B_c+ -> J/psi(1S) D_s+ ]cc ",
        #
        Preambulo=Preambulo,
        # combination cut :
        CombinationCut="""
        in_range ( 5 * GeV , AM ,  7 * GeV ) 
        """ ,
        # mother cut
        MotherCut="""
        ( chi2vx  <  16              ) &
        ( ctau    > -10 * micrometer ) 
        """ ,
        #
        ParticleCombiners={'': 'LoKi::VertexFitter'},
        ReFitPVs=True
    )

    # make the selection
    BDs_sel = Selection(
        'PsiDs',
        Algorithm=BDs_alg,
        RequiredSelections=[jpsi, Ds_sel]
    )

    # ========================================================================
    # Bc -> J/psi + 3pi
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    bc_3pi = CombineParticles(
        DecayDescriptor='[B_c+ -> J/psi(1S) pi+ pi+ pi-]cc',
        #
        Preambulo=Preambulo,
        DaughtersCuts={
            "J/psi(1S)": " M < 4.0 * GeV "
        },
        #
        CombinationCut="""
        in_range ( 5.9 * GeV , AM ,  6.6 * GeV ) 
        """ ,
        #
        MotherCut="""
        ( chi2vx  < 49              ) &
        ( ctau    > 50 * micrometer ) 
        """ ,
        #
        ParticleCombiners={'': 'LoKi::VertexFitter'},
        ReFitPVs=True
    )
    #
    Bc_3p = Selection(
        'Psi3pi',
        Algorithm=bc_3pi,
        RequiredSelections=[jpsi, pions]
    )

    # ========================================================================
    # Bc -> J/psi + pi
    # ========================================================================
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    bc_pi = CombineParticles(
        DecayDescriptor='[B_c+ -> J/psi(1S) pi+ ]cc',
        #
        Preambulo=Preambulo,
        DaughtersCuts={
            "J/psi(1S)": " M < 4.0 * GeV "
        },
        #
        CombinationCut="""
        in_range ( 5.9 * GeV , AM ,  6.6 * GeV ) 
        """ ,
        #
        MotherCut="""
        ( chi2vx  < 16              ) &
        ( ctau    > 50 * micrometer ) 
        """ ,
        ParticleCombiners={'': 'LoKi::VertexFitter'},
        ReFitPVs=True
    )
    #
    Bc_1p = Selection(
        'Psi1Pi',
        Algorithm=bc_pi,
        RequiredSelections=[jpsi, pions]
    )

    from PhysSelPython.Wrappers import SelectionSequence

    Bc_1PI = SelectionSequence("PSIPi", TopSelection=Bc_1p)
    Bc_3PI = SelectionSequence("PSI3Pi", TopSelection=Bc_3p)
    Bc_Ds = SelectionSequence("PSIDs", TopSelection=BDs_sel)

    # 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
    )

    # =====================================================================
    from Configurables import DaVinci  # needed for job configuration

    the_year = '2011'

    davinci = DaVinci(
        EventPreFilters=fltrs.filters('FilterMC'),
        DataType=the_year,
        InputType='DST',
        Simulation=True,
        PrintFreq=1000,
        EvtMax=-1,
        #
        HistogramFile='BcMC_Histos.root',
        TupleFile='BcMC.root',
        ## HistogramFile = 'BcMC1pi_Histos.root' ,
        ## TupleFile     = 'BcMC1pi.root'        ,
        #
        # for Ds
        #DDDBtag   = 'MC2011-20120727'          ,
        #CondDBtag = 'MC2011-20120727-vc-mu100' ,
        #
        # for  pi
        # DDDBtag   =  'MC11-20111102' ,
        # CondDBtag =  'sim-20111111-vc-md100' ,
        #
        ## Lumi          = True ,
        #
    )

    from Configurables import GaudiSequencer
    seqDs = GaudiSequencer(
        'DS',
        Members=[Bc_Ds   . sequence(),
                 "MCBc2Ds"]
    )
    from Configurables import GaudiSequencer
    seq1pi = GaudiSequencer(
        'Pi1',
        Members=[Bc_1PI . sequence(),
                 "MCBc1Pi"]
    )

    from Configurables import TrackSmearState
    state_smear = TrackSmearState(
        'StateSmear',
        ## RootInTES  = rootInTES  ,
    )

    davinci.UserAlgorithms = [state_smear, seqDs]

    ## davinci.UserAlgorithms = [ seq1pi ]

    # from Configurables import CondDB
    # CondDB ( LatestGlobalTagByDataType = the_year )

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

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

    #
    # start Gaudi
    #
    gaudi = appMgr()

    alg1 = MCBc(
        'MCBc2Ds',  # Algorithm name ,
        Inputs=[Bc_Ds.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged']
    )

    alg2 = MCBc1Pi(
        'MCBc1Pi',  # Algorithm name ,
        Inputs=[Bc_1PI.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged']
    )

    return SUCCESS
示例#12
0
_mainpions = DataOnDemand(Location='Phys/StdMCPions/Particles')

#
# MC matching
#

matchD2KKPi = "(mcMatch('D_s+  ==> K- K+ pi+'))"
#matchKaons = "(mcMatch('[K+]cc'))"
#matchPions = "(mcMatch('[pi+]cc'))"

_maind2kkpi = CombineParticles("d2kkpiMain")
_maind2kkpi.DecayDescriptor = "D_s+ -> K+ K- pi+"
#_d2kkpi.DaughtersCuts = { "pi+" : matchPions, "K+" : matchKaons}
_maind2kkpi.MotherCut = matchD2KKPi
_maind2kkpi.Preambulo = [
    "from LoKiPhysMC.decorators import *",
    "from PartProp.Nodes import CC" ]

selD2KKPiMain = Selection( "DsPlusCandidates",
                            Algorithm = _maind2kkpi,
                            RequiredSelections=[_mainkaons, _mainpions])  

seqD2KKPiMain = SelectionSequence('MCFilterMain',TopSelection = selD2KKPiMain)

maintuple = DecayTreeTuple("out")
maintuple.Decay = "[D_s+ -> K- K+ pi+]CC"
maintuple.Inputs = [seqD2KKPiMain.outputLocation()]
mcTruth = maintuple.addTupleTool("TupleToolMCTruth")
maintuple.addTupleTool("TupleToolPropertime")

示例#13
0
#_d2kkpi.DaughtersCuts = { "pi+" : matchPions, "K+" : matchKaons}
_d2kkpi.MotherCut = matchD2KKPi
_d2kkpi.Preambulo = [
    "from LoKiPhysMC.decorators import *",
    "from PartProp.Nodes import CC" ]

SelD2KKPi = Selection( "SelD2KKPi",
                        Algorithm = _d2kkpi,
                        RequiredSelections=[_kaons,_pions])  

dumpAlg = DumpAddr(OutputFile='eventaddr.txt', ObjectPath='/Event')
SeqD2KKPi = SelectionSequence('MCFilter',TopSelection = SelD2KKPi, PostSelectionAlgs=[dumpAlg])

tuple = DecayTreeTuple("out")
tuple.Decay = "[D_s+ -> K- K+ pi+]CC"
tuple.Inputs = [SeqD2KKPi.outputLocation()]
mcTruth = tuple.addTupleTool("TupleToolMCTruth")
tuple.addTupleTool("TupleToolPropertime")

checkPV = CheckPV()

dstWriter = SelDSTWriter("MyDSTWriter",
                         SelectionSequences = [SeqD2KKPi],
                         OutputFileSuffix = 'EXTRA'
                         )

from Gaudi.Configuration import *

from Configurables import DaVinci
DaVinci().EvtMax = 10000
DaVinci().PrintFreq = 10
示例#14
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]
示例#15
0
    "from PartProp.Nodes import CC"    
    ]
_selPions2 = Selection("SelFilterPions2",
                        Algorithm = _filter2,
                        RequiredSelections = [_pions2])
_seqPions2 = SelectionSequence("SeqFilterPions2", TopSelection = _selPions2)


#######################################################################
#
# Decay Tree tuple
#

from Configurables import DecayTreeTuple
decaytuple = DecayTreeTuple("OriginalPionsTuple")
decaytuple.InputLocations = [_seqPions.outputLocation() ]
decaytuple.ToolList +=  [
    "TupleToolGeometry"
    , "TupleToolKinematic"
    , "TupleToolTrackInfo"
    , "TupleToolPid"
    ]
decaytuple.Decay = "[pi+]cc"

decaytuple2 = DecayTreeTuple("SmearedPionsTuple")
decaytuple2.InputLocations = [_seqPions2.outputLocation() ]
decaytuple2.ToolList +=  [
       "TupleToolGeometry"
       , "TupleToolKinematic"
       , "TupleToolTrackInfo"
       , "TupleToolPid"
示例#16
0
seqK = SeqKst2K.sequence()
SeqKst2pi = SelectionSequence("SeqKst2pi", TopSelection = Kst2pi)
seqpi= SeqKst2pi.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

tuple =   DecayTreeTuple( "B02JpsiKpiTree" )
tuple.Inputs =   [ SeqB02JpsiKpi.outputLocation() ]

#----------begin former Xb2JpsiXTree.py-----------------#

########################################################################
#
# J/psi n-tuple
#
# @author Bilas Pal
# @date 2010-11-01
######
########################################################################
from Gaudi.Configuration import *
#
# DecayTreeTuple
#
示例#17
0
    TupleToolEventInfo,
    TupleToolPrimaries,
    TupleToolPid,
    TupleToolTrackInfo,
    TupleToolRecoStats,
    TupleToolMCTruth,
    LoKi__Hybrid__TupleTool,
    LoKi__Hybrid__EvtTupleTool,
)


tuple = DecayTreeTuple("TupleJPsi2KsKs")

# Give DecayTreeTuple the location of your stripped candidates
# If you apply a selection, this will be the output of a selection sequence object.
tuple.Inputs = [seq.outputLocation()]
tuple.ToolList = [
    "TupleToolKinematic",
    "TupleToolEventInfo",
    "TupleToolTrackInfo",
    "TupleToolPid",
    "TupleToolGeometry",
    "TupleToolAngles",
]

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


# # Other event infos

tuple.addTupleTool("LoKi::Hybrid::EvtTupleTool/LoKi_Evt")
示例#18
0
#IOHelper().inputFiles([
#        '~/DSTs/pPbPhotons/MinBiasMC.dst'
#],clear=True)

#===================
# Setup GaudiPython

if False:
    from Configurables import HltParticleFlow, HltJetBuilder
    pf = HltParticleFlow('pf')
    pf.Inputs += [['ProtoParticle', 'best', 'Rec/ProtoP/Charged'],
                  ['ProtoParticle', 'gamma', 'Rec/ProtoP/Neutrals']]

    pf.Inputs += [
        ['Particle', 'daughters',
         convLLSeq.outputLocation()],
        ['Particle', 'daughters',
         convDDSeq.outputLocation()],
        ['Particle', 'daughters',
         caloSeq.outputLocation()],
        #['Particle', 'daughters', mergedpi0Seq.outputLocation()],
        ['Particle', 'daughters',
         dimuSeq.outputLocation()]
    ]

    pf.Output = 'Phys/PF/Particles'
    pf.ProBestNames = ['mu+', 'e+', 'p+', 'K+', 'pi+']
    pf.ProBestKeys = [701, 700, 704, 703, 702]
    pf.ProBestMins = [0.5, 0.5, 0.5, 0.5, 0.5]
    pf.EcalBest = True
    pf.SprRecover = False
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        )
        ,
        'KaonCut'   : """
        ( PT          > 200 * MeV ) &
        ( 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 StdAllNoPIDsKaons   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 StdAllNoPIDsPions   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 () )


    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' ,
    )

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


    my_name = "Bplus"


    davinci.UserAlgorithms = [ seq , my_name ]

    setData ( datafiles , catalogs , castor )

    gaudi = appMgr()

    # create local algorithm:
    alg = MCAnalysisAlgorithm(
        my_name,
        Inputs = [
            psi3kpi.outputLocation()
        ] ,
        PP2MCs = [ 'Relations/Rec/ProtoP/Charged' ],
        ReFitPVs = True
    )

    return SUCCESS
示例#20
0
文件: runmc.py 项目: goi42/LbJpsipPi
###########################################################################
# 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("Bs2JpsiXTreeMC.py")


tupleLb = DecayTreeTuple( "Lb2JpsipKTree" )
tupleLb.Inputs = [ SeqLb2JpsipK.outputLocation() ]
#fmc = MCDecayTreeTuple("MyMCDecayTreeTuple")

DaVinci().Simulation   = True
DaVinci().EvtMax = -1                        # Number of events
DaVinci().DataType = "2012"
DaVinci().CondDBtag = "Sim08-20130503-1-vc-md100"
DaVinci().DDDBtag = "Sim08-20130503-1"
DaVinci().TupleFile = "mc.root"
DaVinci().PrintFreq = 50000
DaVinci().Lumi = False
#DaVinci().UserAlgorithms = [ seq, tuple, fmc]
DaVinci().UserAlgorithms = [ seqLb, tupleLb]
#DaVinci().UserAlgorithms = [ seq, tuple, tuple1]

示例#21
0
### Gaudi sequence
SeqBs2JpsiKpi = SelectionSequence("SeqBs2JpsiKpi", TopSelection = Bs2JpsiKpi)
seq = SeqBs2JpsiKpi.sequence()

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

# from Configurables import  OfflineVertexFitter

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

tuple = DecayTreeTuple( "Bs2JpsiKpiTree" )
tuple.Inputs = [ SeqBs2JpsiKpi.outputLocation() ]


#----------begin former Xb2JpsiXTree.py-----------------#

########################################################################
#
# J/psi n-tuple
#
# @author Bilas Pal
# @date 2010-11-01
######
########################################################################
from Gaudi.Configuration import *
#
# DecayTreeTuple
示例#22
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
def test_instantiate_dataondemand_sequencer():
    sel00 = AutomaticData(Location='Phys/Sel00/Particles')
    seq = SelectionSequence('Seq00DOD', TopSelection=sel00)
    assert seq.outputLocation() == 'Phys/Sel00/Particles'
示例#24
0
# get the selection(s) created by the stripping
strippingSels = [DataOnDemand(Location=tesLoc)]

# create a selection using the substitution algorithm
selSub = Selection(
    'Dst2D0pi_D02pipi_Sel',
    Algorithm=subs,
    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
示例#25
0
#                                  TopSelection = tau_selection)
                                   #EventPreSelector = prescaler)


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

############################################################
## Make tuple
############################################################

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


tuple = DecayTreeTuple() # I can put as an argument a name if I use more than a DecayTreeTuple
tuple.Inputs = [ tau_sequence.outputLocation() ]
tuple.Decay = dec
tuple.ToolList = ['TupleToolKinematic',
                  'TupleToolEventInfo',
                  'TupleToolTrackInfo',
                  'TupleToolPid',
                  'TupleToolGeometry', 
                  'TupleToolAngles', # Helicity angle
                  #'TupleToolP2VV', # various angles, not useful in my analysis because only default values
                  'TupleToolPropertime', #proper time TAU of reco particles
                  #'TupleToolPrimaries', #num primary vertices and coords
                  ]

# Track isolation
tuple.addTupleTool('TupleToolTrackIsolation/TrackIsolation')
tuple.TrackIsolation.MinConeAngle = 0.5
示例#26
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
示例#27
0
    "from PartProp.Nodes import CC" ]

selectionA = Selection("FakeDsPlusSel",
                        Algorithm = combineA,
                        RequiredSelections=[_kaons, _pions])

selectionB = Selection("FakeDsMinusSel",
                        Algorithm = combineB,
                        RequiredSelections=[_kaons, _pions])

selASelectionSequence = SelectionSequence('FakeDsPlus', TopSelection = selectionA)
selBSelectionSequence = SelectionSequence('FakeDsMinus', TopSelection = selectionB)

selectionAB = Selection("FakeBsSel",
                        Algorithm = combineAB,
                        RequiredSelections=[DataOnDemand(Location=selASelectionSequence.outputLocation()),
                                            DataOnDemand(Location=selBSelectionSequence.outputLocation())])
                                            
selABSelectionSequence = SelectionSequence('FakeBs', TopSelection = selectionAB)


from Configurables import FitDecayTrees
fitD2KKP = FitDecayTrees ( 
    "fitD2KKP" , 
    Code = "DECTREE('B_s0 -> (D_s+ -> K+ K- pi+) (D_s- -> K- K+ pi-)')",
    MassConstraints = [ 'D_s+', 'D_s-' ], 
    )
fitD2KKP.Inputs = [selABSelectionSequence.outputLocation()]

from Configurables import P2MCPFromProtoP, BackgroundCategory
fakebstuple = DecayTreeTuple("out")
示例#28
0
#--------------------------------------------------------------------------
# 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" )
tuple.Inputs = [ SeqL.outputLocation() ]



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

from Configurables import DaVinci
DaVinci().TupleFile = "DVNtuples.root"
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")
示例#29
0
#This filter is used just to speed up the process, nothing happens if there
# # is no stripped candidates at that location.
# from PhysConf.Filters import LoKi_Filters
# fltrs = LoKi_Filters(
#   STRIP_Code = "HLT_PASS('StrippingPhiToKSKS_PhiToKsKsLineDecision')")


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
from Configurables import LoKi__LifetimeFitter

tuple = DecayTreeTuple("TuplePhi2KsKs")

#Give DecayTreeTuple the location of your stripped candidates
#If you apply a selection, this will be the output of a selection sequence object.
tuple.Inputs = [Ds_sequence.outputLocation()]
tuple.ToolList =  ['TupleToolKinematic',
                    'TupleToolEventInfo', 
                    'TupleToolTrackInfo',
                    'TupleToolPid',
                    'TupleToolGeometry', 
                    'TupleToolAngles',
]

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


# # Other event infos

tuple.addTupleTool('LoKi::Hybrid::EvtTupleTool/LoKi_Evt')
tuple.LoKi_Evt.VOID_Variables = {
示例#30
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
示例#31
0
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",
    "TupleToolPropertime", "LoKi::Hybrid::TupleTool/LoKiTupleMuMu"
]
from Configurables import LoKi__Hybrid__TupleTool

LoKiTupleMuMu = LoKi__Hybrid__TupleTool("LoKiTupleMuMu")
LoKiTupleMuMu.Variables = {
    "Charge": "Q",
    "DOCA": "DOCA(1,2)",
    "DOCAMAX": "DOCAMAX",
    "NetOut": "INFO(LHCb.Particle.LastGlobal+1, -999)",
    "NetProb": "INFO(LHCb.Particle.LastGlobal+2, -999)"
示例#32
0
                   RequiredSelections=[_selDimuons])

# Try and make B->J/psi K
_B = CombineParticles()
_B.DaughtersCuts = {"K+": "PT>500*MeV"}
_B.MotherCut = "(DMASS('B+')<5000*MeV) & (VFASPF(VCHI2)<25.0)"  #need to check these cuts
_B.DecayDescriptors = ["[B+ -> J/psi(1S) K+]cc"]

_BdecaySelection = Selection("TurboB",
                             Algorithm=_B,
                             RequiredSelections=[subsel, kaons])
SeqB = SelectionSequence('SeqB', TopSelection=_BdecaySelection)

tupleB = DecayTreeTuple("bae-muon-MC")

tupleB.Inputs = [SeqB.outputLocation()]
tupleB.Decay = "[B+ -> ^(J/psi(1S) -> ^mu+ ^mu-) ^K+]CC"

tupleB.ToolList = [
    "TupleToolKinematic",
    "TupleToolEventInfo",
    "TupleToolRecoStats",
    "TupleToolMCBackgroundInfo",
    "TupleToolMCBackgroundInfo",  #comment out for data
    "TupleToolMCTruth",  #comment out for data
    "TupleToolTrigger",
    "TupleToolPid",
    "TupleToolPrimaries",
    "TupleToolAngles",
    "TupleToolEventInfo",
    "TupleToolGeometry",
示例#33
0
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() ]



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

from Configurables import DaVinci
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
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]
示例#35
0
def parseConfiguration(
        tupleConfig,  # TupleConfig object describing sample
        tesFormat,  # Input TES with "<line>" placeholder
        mdstOutputFile,  # MicroDST output extension
        mdstOutputPrefix,  # MicroDST prefix for production
        varsByType,  # requested variables by type
        varsByName,  # requested variables by name
        eventVariables,  # event variables
        writeNullWeightCandidates=True,
        writeMuonPIDPlus=True,
        mdstInput=False,
        tupleOutput=True):
    cfg = tupleConfig
    reviveSequences = []  # mark sequences to unpack std particles
    swSequences = []  # mark sequences to apply sWeights
    filterSequences = []  # mark sequences to be written in tuples
    matchSequences = []  # mark sequences to be written in tuples
    tupleSequences = []  # mark tuple sequences
    dstSequences = []  # sequences writing (Micro)DST files

    triggerList = [
        "L0MuonDecision",
        "L0HadronDecision",
        "L0ElectronDecision",
        "Hlt1TrackMVADecision",
        "Hlt1TrackMuonDecision",
    ]

    for basicPart in ["Muons", "Pions", "Kaons", "Protons", "Electrons"]:
        location = "Phys/StdAllNoPIDs{s}/Particles".format(s=basicPart)
        reviveSequences += [
            SelectionSequence("fs_std" + basicPart,
                              TopSelection=DataOnDemand(location))
        ]

    for basicPart in [
            "DownPions", "DownKaons", "DownProtons", "DownElectrons"
    ]:
        location = "Phys/StdNoPIDs{s}/Particles".format(s=basicPart)
        reviveSequences += [
            SelectionSequence("fs_std" + basicPart,
                              TopSelection=DataOnDemand(location))
        ]

    location = "Phys/StdLooseDownMuons/Particles"
    reviveSequences += [
        SelectionSequence("fs_std" + "DownMuons",
                          TopSelection=DataOnDemand(location))
    ]

    for sample in cfg:
        ################################################################################
        ## Configure sWeighting                                                       ##
        ################################################################################
        for line in cfg[sample].InputLines:
            location = tesFormat.replace('<line>', line)
            protoLocation = location.replace('/Particles', '/Protos')

            #     swSequences+=[ProbNNcalib ("TurboProbNN" + line, protoLocation).sequence()]
            if cfg[sample].Calibration:
                swSequences += [
                    ApplySWeights(
                        "ApplySW" + sample,
                        InputTes=location,
                        sTableDir=cfg[sample].Calibration,
                        sTableName="sTableSignal",
                    )
                ]

################################################################################
## Creates filter sequences to fill nTuples                                   ##
################################################################################

        selectionName = sample
        _cut = "DECTREE ('{}')".format(cfg[sample].Decay.replace("^", ""))

        if writeNullWeightCandidates == False:
            _cut += " & ( WEIGHT != 0 ) "

        if cfg[sample].Filter:
            _cut += " & ({}) ".format(cfg[sample].Filter.cut)

        inputSelection = MergedSelection(
            "input" + selectionName,
            RequiredSelections=[
                DataOnDemand(tesFormat.replace('<line>', line))
                for line in cfg[sample].InputLines
            ],
        )

        selection = Selection(
            selectionName,
            RequiredSelections=[inputSelection],
            Algorithm=FilterDesktop("alg_" + selectionName, Code=_cut),
        )

        filterSequence = SelectionSequence("Seq" + selectionName,
                                           TopSelection=selection)

        filterSequences += [filterSequence]

        ################################################################################
        ## Creates matching selections (used to create the proper locations in mdst)  ##
        ################################################################################
        matchingSel = Selection("Match" + selectionName,
                                Algorithm=CopyAndMatchCombination(
                                    "MatchAlg" + selectionName,
                                    Downstream=cfg[sample].Downstream,
                                ),
                                RequiredSelections=[selection])

        matchingSeq = SelectionSequence("SeqMatch" + selectionName,
                                        TopSelection=matchingSel)

        matchSequences += [matchingSeq]

        partsInBranches = []

        for branchName in cfg[sample].Branches:

            partName = branchName
            if len(cfg[sample].Branches[branchName].isAlso) > 0:
                partName = cfg[sample].Branches[branchName].isAlso[0]

            partsInBranches += [partName]

        #print("partsInBranches = ", partsInBranches)

################################################################################
## Parses the configuration dictionaries and configure the tuples             ##
################################################################################
        tuple = DecayTreeTuple(sample + "Tuple")
        tuple.Inputs = [filterSequence.outputLocation()]
        tuple.Decay = cfg[sample].Decay
        tuple.ToolList = ["TupleToolANNPID"]
        if mdstInput:
            tuple.RootInTES = "/Event/Turbo"

        if "e" in partsInBranches:
            ttBrem = tuple.addTupleTool("TupleToolBremInfo")
            ttBrem.Particle = ["pi+", "p", "K+", "mu+", "e+"]
            ttBrem.Verbose = True
            ttBrem.RootInTES = ""  #### !!!!

        ttPPD = tuple.addTupleTool("TupleToolProtoPData")
        ttPPD.DataList = [
            "VeloCharge", "CaloEoverP", "CaloEcalChi2", "CaloPrsE",
            "CaloHcalE", "EcalPIDe", "PrsPIDe", "HcalPIDe", "CaloEcalE"
        ]

        if writeMuonPIDPlus and ("mu" in partsInBranches):
            muidPlus = tuple.addTupleTool("TupleToolMuonPidPlus")
            muidPlus.MuonIDPlusToolName = "MuonIDPlusTool"
            muidPlus.OutputLevel = 5
            muidPlus.RootInTES = ""  ####  !!!!!
            muidPlus.addTool(MuonIDPlusTool)
            muidPlus.MuonIDPlusTool.OutputLevel = 5
            muidPlus.MuonIDPlusTool.RootInTES = ""  ####  !!!!!
            muidPlus.MuonIDPlusTool.ReleaseObjectOwnership = False
            muidPlus.MuonIDPlusTool.MatchToolName = "MuonChi2MatchTool"
            muidPlus.Verbose = True

        eventTool = tuple.addTupleTool("LoKi::Hybrid::EvtTupleTool/LoKiEvent")
        if 'VOID' in eventVariables.keys():
            eventTool.VOID_Variables = eventVariables['VOID']

        if not mdstInput:
            if 'ODIN' in eventVariables.keys():
                eventTool.ODIN_Variables = eventVariables['ODIN']

        if 'HLT' in eventVariables.keys():
            eventTool.HLT_Variables = eventVariables['HLT']

        if 'L0DU' in eventVariables.keys():
            eventTool.L0DU_Variables = eventVariables['L0DU']

        eventTool.Preambulo = [
            "from LoKiTracks.decorators import *",
            "from LoKiCore.functions import *"
        ]
        tuple.addTool(eventTool)

        if mdstInput:
            matchingLocation = {
                "mu+": "/Event/PIDCALIB/Phys/Match" + sample + "/Particles",
                "pi+": "/Event/PIDCALIB/Phys/Match" + sample + "/Particles",
                "K+": "/Event/PIDCALIB/Phys/Match" + sample + "/Particles",
                "p+": "/Event/PIDCALIB/Phys/Match" + sample + "/Particles",
                "e+": "/Event/PIDCALIB/Phys/Match" + sample + "/Particles",
            }
        else:
            if cfg[sample].Downstream:
                matchingLocation = {
                    "mu+": "Phys/StdLooseDownMuons/Particles",
                    "pi+": "Phys/StdNoPIDsDownPions/Particles",
                    "K+": "Phys/StdNoPIDsDownKaons/Particles",
                    "p+": "Phys/StdNoPIDsDownProtons/Particles",
                    "e+": "Phys/StdNoPIDsDownElectrons/Particles",
                }
            else:
                matchingLocation = {
                    "mu+": "Phys/StdAllNoPIDsMuons/Particles",
                    "pi+": "Phys/StdAllNoPIDsPions/Particles",
                    "K+": "Phys/StdAllNoPIDsKaons/Particles",
                    "p+": "Phys/StdAllNoPIDsProtons/Particles",
                    "e+": "Phys/StdAllNoPIDsElectrons/Particles",
                }

        tupleSequences += [tuple]

        for branchName in cfg[sample].Branches:

            partName = branchName
            if len(cfg[sample].Branches[branchName].isAlso) > 0:
                partName = cfg[sample].Branches[branchName].isAlso[0]

            #print ("PartName = ", partName)

            b = tuple.addBranches(
                {branchName: cfg[sample].Branches[branchName].Particle})
            b = b[branchName]
            matcher = b.addTupleTool("TupleToolTwoParticleMatching/Matcher_" +
                                     branchName)
            matcher.ToolList = []
            matcher.Prefix = ""
            matcher.Suffix = "_Brunel"
            matcher.MatchLocations = matchingLocation

            lokitool = b.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_" +
                                      branchName)
            vardict = copy(varsByType[cfg[sample].Branches[branchName].Type])
            pidcalibtool = b.addTupleTool("TupleToolPIDCalib/PIDCalibTool_" +
                                          branchName)
            pidcalibtool_matched = TTpid("PIDCalibTool_match_" + branchName)
            for partName in [branchName
                             ] + cfg[sample].Branches[branchName].isAlso:
                if partName in varsByName:
                    vardict.update(varsByName[partName])


#        if partName == 'e':
#          pidcalibtool.FillBremInfo = True
#          pidcalibtool_matched.FillBremInfo = True

            lokimatchedtool = LokiTool("LoKi_match_" + branchName)

            matcher.addTool(pidcalibtool_matched)
            matcher.ToolList += [
                "LoKi::Hybrid::TupleTool/LoKi_match_" + branchName,
                "TupleToolPIDCalib/PIDCalibTool_match_" + branchName
            ]

            from Configurables import TupleToolTISTOS
            tistostool = TupleToolTISTOS("TISTOSForTheOffline" + branchName)
            tistostool.FillL0 = True
            tistostool.FillHlt1 = True
            tistostool.FillHlt2 = False
            tistostool.Verbose = True  # 16/01/2020 for L0Calo
            tistostool.VerboseL0 = True
            tistostool.VerboseHlt1 = True
            tistostool.VerboseHlt2 = False
            tistostool.TriggerList = triggerList
            matcher.addTool(tistostool)
            matcher.ToolList += [
                "TupleToolTISTOS/TISTOSForTheOffline" + branchName
            ]

            # 16/01/2020 for L0Calo variables
            from Configurables import TupleToolL0Calo
            l0calotool = TupleToolL0Calo("L0CaloForTheOffline" + branchName)
            l0calotool.WhichCalo = "HCAL"
            l0calotool.TriggerClusterLocation = "Trig/L0/FullCalo"  # Added 29/01/2020 for "trigger" variables
            matcher.addTool(l0calotool)
            matcher.ToolList += [
                "TupleToolL0Calo/L0CaloForTheOffline" + branchName
            ]

            from Configurables import TupleToolBremInfo, TupleToolProtoPData, TupleToolANNPID, TupleToolMuonPidPlus

            if partName == "e":
                ttbi = TupleToolBremInfo("BremInfoForTheOffline" + branchName)
                ttbi.Particle = ["pi+", "p", "K+", "mu+", "e+"]
                ttbi.RootInTES = ""
                matcher.addTool(ttbi)
                matcher.ToolList += [
                    "TupleToolBremInfo/BremInfoForTheOffline" + branchName
                ]

            ttppd = TupleToolProtoPData("ProtoPDataForTheOffline" + branchName)
            ttppd.DataList = [
                "VeloCharge", "CaloEoverP", "CaloEcalChi2", "CaloPrsE",
                "CaloHcalE", "EcalPIDe", "PrsPIDe", "HcalPIDe", "CaloEcalE"
            ]
            matcher.addTool(ttppd)
            matcher.ToolList += [
                "TupleToolProtoPData/ProtoPDataForTheOffline" + branchName
            ]

            ttann = TupleToolANNPID("ANNPIDForTheOffline" + branchName)
            ttann.PIDTypes = [
                "Electron", "Muon", "Pion", "Kaon", "Proton", "Ghost",
                "Deuteron"
            ]
            #      ttann.PIDTypes = [ "Electron","Muon","Pion","Kaon","Proton","Ghost" ]
            ttann.ANNPIDTunes = [
                "MC12TuneV2", "MC12TuneV3", "MC12TuneV4", "MC15TuneV1",
                "MC15TuneDNNV1", "MC15TuneCatBoostV1", "MC15TuneFLAT4dV1"
            ]
            matcher.addTool(ttann)
            matcher.ToolList += [
                "TupleToolANNPID/ANNPIDForTheOffline" + branchName
            ]

            if writeMuonPIDPlus and partName == "mu":
                ttmuidPlus = TupleToolMuonPidPlus(
                    "TupleToolMuonPidPlusForTheOffline" + branchName)
                ttmuidPlus.MuonIDPlusToolName = "MuonIDPlusTool"
                ttmuidPlus.OutputLevel = 5
                ttmuidPlus.RootInTES = ""  ####  !!!!!
                ttmuidPlus.addTool(MuonIDPlusTool)
                ttmuidPlus.MuonIDPlusTool.OutputLevel = 5
                ttmuidPlus.MuonIDPlusTool.RootInTES = ""  ####  !!!!!
                ttmuidPlus.MuonIDPlusTool.ReleaseObjectOwnership = False
                ttmuidPlus.MuonIDPlusTool.MatchToolName = "MuonChi2MatchTool"
                ttmuidPlus.Verbose = True
                matcher.addTool(ttmuidPlus)
                matcher.ToolList += [
                    "TupleToolMuonPidPlus/TupleToolMuonPidPlusForTheOffline" +
                    branchName
                ]

            vardict.update(cfg[sample].Branches[branchName].LokiVariables)
            lokimatchedtool.Variables = vardict
            lokitool.Variables = vardict

            matcher.addTool(lokimatchedtool)

            # Additional variables for Greg/Phoebe's uBDT
            from Configurables import TupleToolANNPIDTrainingLight
            if hasattr(tuple, 'probe'):
                tuple.probe.addTool(TupleToolANNPIDTrainingLight,
                                    name='TupleToolANNPIDTrainingLight')
                tuple.probe.ToolList += [
                    'TupleToolANNPIDTrainingLight/TupleToolANNPIDTrainingLight'
                ]

    print "Input TES: "
    print "\n".join([f.outputLocation() for f in filterSequences])
    if mdstOutputFile:
        dstSequences += configureMicroDSTwriter(
            mdstOutputFile, mdstOutputPrefix, filterSequences + matchSequences)

    if mdstInput:
        return (reviveSequences + swSequences + filterSequences +
                matchSequences + tupleSequences)
    else:
        if tupleOutput:
            return (reviveSequences + swSequences + filterSequences +
                    matchSequences + dstSequences + tupleSequences)
        else:
            return (reviveSequences + filterSequences + matchSequences +
                    dstSequences)
示例#36
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
tuple.B.TupleToolTISTOS.VerboseHlt2 = True
tuple.B.TupleToolTISTOS.VerboseL0 = True
tuple.B.TupleToolTISTOS.TriggerList = myTriggerList

from Configurables import TupleToolDecayTreeFitter
tuple.B.ToolList +=  ["TupleToolDecayTreeFitter/MassFit",
                     ]         # fit with eta_prime mass onstraint
tuple.B.addTool(TupleToolDecayTreeFitter,name="MassFit")
tuple.B.MassFit.constrainToOriginVertex = False
tuple.B.MassFit.daughtersToConstrain = [ "eta_prime" ]
tuple.B.MassFit.Verbose = True
tuple.B.MassFit.UpdateDaughters = True



tuple.Inputs= [B2EtapKFil_Seq.outputLocation()]

DaVinci().InputType = 'DST'
# MC 2012
DaVinci().DDDBtag =  "dddb-20130929-1"
DaVinci().CondDBtag= "sim-20130522-1-vc-md100"
DaVinci().DataType = "2012"
DaVinci().EvtMax = 10000
DaVinci().PrintFreq = 10000
DaVinci().HistogramFile = "DVHistos.root"
DaVinci().Simulation = True
DaVinci().TupleFile = "B2ETAPK_MC.root"
DaVinci().appendToMainSequence([B2EtapKFil_Seq,tuple])


from GaudiConf import IOHelper
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 
示例#39
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
示例#40
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)
示例#41
0
文件: mctuples.py 项目: mazurov/chib
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
示例#42
0
def configure(datafiles,
              catalogs=[],
              castor=False,
              params={}):
    """
    Job configuration 
    """

    from BenderTools.Parser import hasInFile

    the_year = "2011"

    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, 'Stripping17'):
            the_year = '2011'
        elif hasInFile(datafiles, 'Stripping19'):
            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)

    #
    # pseudo stripping & WG-production
    #
    # from PhysSelPython.Wrappers import AutomaticData
    # jpsi_location = '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles'
    # jpsi = AutomaticData ( Location = jpsi_location )

# 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
    import CommonParticles.StdLooseJpsi2MuMu

    # from StandardParticles import StdLooseJpsi2MuMu
    # jpsi  = StdLooseJpsi2MuMu

    from PhysSelPython.Wrappers import AutomaticData
    jpsi = AutomaticData('/Event/Phys/StdLooseJpsi2MuMu/Particles')

    from GaudiConfUtils.ConfigurableGenerators import FilterDesktop
    # pions :
    alg_pions = FilterDesktop(
        #
        Code="""
        ( PT > 500  * MeV      ) & 
        ( CLONEDIST   > 5000   ) & 
        ( TRGHOSTPROB < 0.5    ) &
        ( TRCHI2DOF   < 4      ) & 
        in_range ( 2 , ETA , 5 ) &
        HASRICH                  &
        ( PIDpi - PIDK > -2    ) 
        """ ,
    )

    from PhysSelPython.Wrappers import Selection
    from StandardParticles import StdAllLoosePions
    pions = Selection(
        "ThePions",
        Algorithm=alg_pions,
        RequiredSelections=[StdAllLoosePions]
    )

    alg_kaons = FilterDesktop(
        #
        Code="""
        ( PT > 500  * MeV      ) & 
        ( CLONEDIST   > 5000   ) & 
        ( TRCHI2DOF   < 4      ) & 
        ( TRGHOSTPROB < 0.5    ) & 
        in_range ( 2 , ETA , 5 ) &
        HASRICH                  &
        ( PIDK - PIDpi > -2    ) 
        """
    )

    from StandardParticles import StdAllLooseKaons
    kaons = Selection(
        "TheKaons",
        Algorithm=alg_kaons,
        RequiredSelections=[StdAllLooseKaons]
    )

    #
    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)<16
        "ctau_25   = BPVLTIME ( 25 ) * c_light ",
        "mbc_acut  = in_range ( 6.050 * GeV , AM , 6.550 * GeV ) ",
        "mbp_acut  = in_range ( 5.100 * GeV , AM , 5.550 * GeV ) ",
        # mass-cut for beauty particles
        "mbc_cut   = in_range ( 6.100 * GeV ,  M , 6.500 * GeV ) ",
        "mbp_cut   = in_range ( 5.150 * GeV ,  M , 5.500 * GeV ) ",
    ]

    # Bc :
    from GaudiConfUtils.ConfigurableGenerators import CombineParticles
    alg_bc = CombineParticles(
        DecayDescriptor="[B_c+ -> J/psi(1S) pi+ ]cc",
        Preambulo=Preambulo,
        CombinationCut=" mbc_acut ",
        MotherCut="""
        ( chi2vx < 20  ) & mbc_cut &  ( ctau_25 > %s )
        """ %  ( 40 * micrometer )
    )

    sel_bc = Selection(
        "TheBc",
        Algorithm=alg_bc,
        RequiredSelections=[jpsi, pions]
    )

    # B+ :
    alg_bu = CombineParticles(
        DecayDescriptor="[B+ -> J/psi(1S) K+ ]cc",
        Preambulo=Preambulo,
        CombinationCut=" mbp_acut ",
        MotherCut="""
        ( chi2vx < 20  ) & mbp_cut &  ( ctau_25 > %s )
        """ %  ( 40 * micrometer )
    )

    sel_bu = Selection(
        "TheB",
        Algorithm=alg_bu,
        RequiredSelections=[jpsi, kaons]
    )

    # B0 :
    alg_bd = CombineParticles(
        DecayDescriptor="[B0 -> J/psi(1S) K+ pi-]cc",
        Preambulo=Preambulo,
        CombinationCut="""
        mbp_acut & in_range ( 600 * MeV , AM23  , 1.2 * GeV ) 
        """ ,
        MotherCut="""
        ( chi2vx < 50  ) & mbp_cut &  ( ctau_25 > %s )
        """ %  ( 40 * micrometer )
    )

    sel_bd = Selection(
        "TheB0",
        Algorithm=alg_bd,
        RequiredSelections=[jpsi, kaons, pions]
    )

    from PhysSelPython.Wrappers import SelectionSequence
    selseq_pi = SelectionSequence("Bc", TopSelection=sel_bc)
    selseq_k = SelectionSequence("Bu", TopSelection=sel_bu)
    selseq_kst = SelectionSequence("Bd", TopSelection=sel_bd)

    # Read only fired events to speed up
    from PhysConf.Filters import LoKi_Filters
    fltrs = LoKi_Filters(
        #
        # Require at least one primary vertex
        #
        VOID_Code="""
        ( RECSUMMARY (  0 , -1 ) >  0.5 ) 
        """
    )

    #
    # make the final sequencers:
    #

    from Configurables import GaudiSequencer
    seq_pi = GaudiSequencer(
        'PION',
        Members=[selseq_pi  . sequence(), "MCB2PI"]
    )
    seq_k = GaudiSequencer(
        'KAON',
        Members=[selseq_k   . sequence(), "MCB2K"]
    )
    seq_kst = GaudiSequencer(
        'KSTAR',
        Members=[selseq_kst . sequence(), "MCB2KST"]
    )

    #
    # make the final choice
    #

    mode = params['Mode']
    mode = mode.upper()
    if 0 <= mode.find('BC') or 0 <= mode.find('PI'):
        seq = seq_pi
    elif  0 <= mode.find( 'B+' ) or 0 <= mode.find('BP') or \
            0 <= mode.find('BU') or 0 <= mode.find('K+'):
        seq = seq_k
    elif 0 <= mode.find('B0') or 0 <= mode.find('BZ') or 0 <= mode.find('K*'):
        seq = seq_kst

    #
    # finally: DaVinci
    #
    ## needed for job configuration
    from Configurables import DaVinci
    davinci = DaVinci(
        EventPreFilters=fltrs.filters('Filters'),
        DataType=the_year,
        InputType='MDST',
        Simulation=True,
        PrintFreq=1000,
        EvtMax=-1,
        #
        HistogramFile='MCBc_Histos.root',
        TupleFile='MCBc.root',
        #
        DDDBtag=params['DDDB'],
        CondDBtag=params['SIMCOND'],
        #
        Lumi=False  # True ,
        #
    )

    from BenderTools.Utils import silence
    silence()

    #
    # finally inform Davinci about algorithsm
    #
    davinci.UserAlgorithms = [
        seq
    ]

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

    #
    # start Gaudi
    #
    gaudi = appMgr()
    #

    #
    alg1 = MCB2PsiH(
        'MCB2PI',  # Algorithm name ,
        Inputs=[selseq_pi.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged'],
        ReFitPVs=True
    )

    alg2 = MCB2PsiH(
        'MCB2K',  # Algorithm name ,
        Inputs=[selseq_k.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged'],
        ReFitPVs=True
    )

    alg3 = MCB2PsiH(
        'MCB2KST',  # Algorithm name ,
        Inputs=[selseq_kst.outputLocation()],
        PP2MCs=['Relations/Rec/ProtoP/Charged'],
        ReFitPVs=True
    )

    alg3._decay = '[ Beauty -> ( J/psi(1S) -> mu+ mu- ) K+ pi- ]CC'

    return SUCCESS