def makeDecayTreeTuple( location, decay, alg_name, tuple_name ):
  tuple = DecayTreeTuple( alg_name )
  dectype = alg_name[-2:]
  #triggerList = list(l0hlt1List)
  #if 'KK' == dectype:
  #  for trigger in hlt2List_KK:
  #    triggerList.append( trigger + 'Decision')
  #elif 'Pi' == dectype:
  #  for trigger in hlt2List_Pi:
  #    triggerList.append( trigger + 'Decision')
  #elif 'RS' == dectype or 'WS' == dectype:
  #  for trigger in hlt2List_KPi:
  #    triggerList.append( trigger + 'Decision')
  print alg_name, triggerList    

  #tuple = DecayTreeTuple('TupleKK')
  tuple.ToolList = [ "TupleToolPropertime", "TupleToolKinematic", #"TupleToolPropertime/MyPropertimeTool", 
                     "TupleToolGeometry", "TupleToolEventInfo", "TupleToolPrimaries", "TupleToolTISTOS", #"TupleToolTrigger",
                     "TupleToolPid", "TupleToolTrackInfo", "TupleToolRecoStats", #"TupleToolGeneration"
                      ]
  #tuple.addTool( TupleToolPropertime( name="MyPropertimeTool" ) )
  #tuple.MyPropertimeTool.ToolName = "PropertimeFitter/MyPropertimeFitter"
  #tuple.MyPropertimeTool.ExtraName = "MassConstraint"
  #tuple.MyPropertimeTool.addTool( PropertimeFitter( name = "MyPropertimeFitter" ) )
  #tuple.MyPropertimeTool.MyPropertimeFitter.applyBMassConstraint = True
  
  tuple.Inputs = [ location ]#_strippingOutput]
  #tuple.InputLocations = [ location ]#_strippingOutput]
  tuple.Decay = decay
  #tuple.Decay = "[D0 -> ^K- ^pi+]CC"
  tuple.TupleName = tuple_name
  #tuple.TupleName = "D0KKTuple"
  
  tuple.addTool( TupleToolPropertime() )
  tuple.TupleToolPropertime.FitToPV = True

  #tuple.addTool( TupleToolTrigger() )
  #tuple.TupleToolTrigger.TriggerList = triggerList
  #tuple.TupleToolTrigger.VerboseL0 = True
  #tuple.TupleToolTrigger.VerboseHlt1 = True
  #tuple.TupleToolTrigger.VerboseHlt2 = True
  #tuple.TupleToolTrigger.Verbose = True
  
  tuple.addTool( TupleToolTISTOS() )
  tuple.TupleToolTISTOS.VerboseL0 = True
  tuple.TupleToolTISTOS.VerboseHlt1 = True
  tuple.TupleToolTISTOS.VerboseHlt2 = True
  tuple.TupleToolTISTOS.Verbose = True
  tuple.TupleToolTISTOS.TriggerList = triggerList
  return tuple
# 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 = {
                "nTracks"  : "CONTAINS('/Event/Charm/Rec/Track/Best')",
                "nPVs"    : "CONTAINS('/Event/Charm/Rec/Vertex/Primary')"
                }
Exemple #3
0
    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]
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",
        "TupleToolRecoStats",
        "TupleToolTrackInfo",
        "TupleToolTISTOS",
        "TupleToolBremInfo",
        "TupleToolPhotonInfo"#,
       ,"TupleToolTrackIsolation"
        , "TupleToolANNPID"
   # , "TupleBuKmmFit"
] # Probably need to add many more Tools.


tupleB.addBranches ({
      "Kplus" :  "[B+ -> ^K+ (J/psi(1S) -> mu+ mu-)]CC",
      "Jpsi" :  "[B+ -> K+ ^(J/psi(1S) -> mu+ mu-)]CC",
############################################################
## 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
tuple.TrackIsolation.MaxConeAngle = 1.
tuple.TrackIsolation.StepSize = 0.1

# Other event infos
tuple.addTupleTool('LoKi::Hybrid::EvtTupleTool/LoKi_Evt')
tuple.LoKi_Evt.VOID_Variables = {
    "nSPDHits" :  " CONTAINS('Raw/Spd/Digits')  " ,
tuple2 = MCDecayTreeTuple("MCTeslaTuple")
tuple2.Inputs = ['/Event/Tesla/Particles']
tuple2.Decay = tuple.Decay

from Configurables import DataOnDemandSvc, L0SelReportsMaker, L0DecReportsMaker
DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker()
DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker()
from Configurables import L0Conf
L0Conf().FullL0MuonDecoding = True
L0Conf().EnableL0DecodingOnDemand = True
L0Conf().EnsureKnownTCK=False

tuple3 = DecayTreeTuple("StrippingTuple")
tuple3.Inputs = ['/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles']
tuple3.Decay = tuple.Decay
tuple3.ToolList = tuple.ToolList
tuple3.addTool(TupleToolTrigger, name="TupleToolTrigger")
tuple3.addTool(TupleToolTISTOS, name="TupleToolTISTOS")
tuple3.TupleToolTrigger.Verbose = True
tuple3.TupleToolTrigger.TriggerList = tlist
tuple3.TupleToolTISTOS.Verbose = True
tuple3.TupleToolTISTOS.TriggerList = tlist

tuple4 = MCDecayTreeTuple("MCStrippingTuple")
tuple4.Inputs = ['/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles']
tuple4.Decay = tuple.Decay

#DaVinci().UserAlgorithms += [ tuple2 ]
#DaVinci().TupleFile = "DVNtuples.root"

Exemple #7
0
def addTuple(name="", decay="", addendum="", head="/Event/Phys/", dtf=True, resonant=True, shortname="", verbose=[] ):
    from Configurables import DecayTreeTuple, PrintDecayTree, FilterDesktop, GaudiSequencer, PrintHeader, TESCheck
    
    if shortname == "": shortname = name
    shortname = shortname+"_Tuple"+addendum
    shortname = shortname.replace("MCMC","MC")
    seq = GaudiSequencer("Seq"+shortname)
    if ( not "/"==head[-1] ): head = head+'/'

    location = head+name+"/Particles" 
    from Configurables import LoKi__HDRFilter
    if ( "/Event/Phys/" == head ):
        filter = TESCheck("Check"+shortname,Inputs = [ location ], Stop = False)
    else :              # I am not running the selection, hence the stripping decision must be here     
        filter = LoKi__HDRFilter( "Check"+shortname,
                                  Code = "HLT_PASS('Stripping"+name+"Decision')",
                                  Location="/Event/Strip/Phys/DecReports" )

    #filter.OutputLevel = 1
    seq.Members += [  filter ] # PrintHeader(),
    tuple = DecayTreeTuple(shortname)
    isMDST = (addendum.upper()=="MDST")        
    if (isMDST):
        RIT = head.replace("/Phys","")
        print "RootInTES set to", RIT
        tuple.RootInTES = RIT
        tuple.Inputs = [ "Phys/"+name+"/Particles" ]
    else :
        tuple.Inputs = [ location ]

#    tuple.OutputLevel = 1
    tuple.ToolList =  []
        
    tuple.Decay = decay

    tg = tuple.addTupleTool("TupleToolGeometry")
    if not isMDST: tg.FillMultiPV = True


    tlist = []
    if ("e+" in decay):
        tlist = electronLines()            
    elif ("mu+" in decay):
        tlist = muonLines()

    if ( False ):
        tlist = allLines()
    print tlist
    
    if ( Jpsi2MuMu != decay ): bpsi = (decay.replace("^","")).replace("(J/psi(1S)","^(J/psi(1S)")
    else : bpsi = "^("+decay.replace("^","")+")"

    print "J/psi branch is `` ", bpsi, "''" 
    tuple.Branches["Psi"] = bpsi

    # sort out kstars
    if "892" in decay:
        bkstar = (decay.replace("^","")).replace("(K*(892)","^(K*(892)")
        tuple.Branches["Kstar"] = bkstar
        Kstar = tuple.addTupleTool("TupleToolDecay/Kstar")

    from Configurables import TupleToolTISTOS
    tistos = TupleToolTISTOS(TriggerList = tlist
            , VerboseHlt1 = True, VerboseHlt2 = True, VerboseL0 = True)
    
    Psi = tuple.addTupleTool("TupleToolDecay/Psi")
    Psi.addTool(tistos)
    Psi.ToolList += [ "TupleToolTISTOS" ]
#    if (not isMDST):
#        vi = tuple.Psi.addTupleTool("TupleToolVtxIsoln")
#        vi.InputParticles = [ "/Event/Phys/MyGoodPions" ]

    if ( Jpsi2MuMu == decay ):
        if (dtf):
            pvfit = tuple.Psi.addTupleTool("TupleToolDecayTreeFitter/PVFit")        # fit with all constraints I can think of
            pvfit.Verbose = True
            pvfit.constrainToOriginVertex = True
        
    else:       
        B = tuple.addTupleTool("TupleToolDecay/B")
        if ( Bs2JpsiPhi==decay ):
            p2vv = B.addTupleTool("TupleToolP2VV") 
            p2vv.Calculator = "Bs2JpsiPhiAngleCalculator"
        elif ( "K*(892)0" in decay and not Bd2MuMuKstSS==decay ):
            p2vv = B.addTupleTool("TupleToolP2VV") 
            p2vv.Calculator = "Bd2KstarMuMuAngleCalculator"
        if (Lambdab2Jpsippi==decay ): B.addTupleTool("TupleToolDalitz") 
 
        if ('Xi_b-' in decay ): bh = 'Xi_b-'
        elif ('Xi_b~+' in decay ): bh = 'Xi_b~+'
        elif ('Lambda_b0' in decay ): bh = 'Lambda_b0'
        elif ('B0' in decay): bh = 'B0'
        elif ('B+' in decay ): bh = 'B+'
        elif ('B_s0' in decay ): bh = 'B_s0'
        if ('CC' in decay): bh = '['+bh+']cc'
        print "Branch will be ``", bh+" : "+decay.replace("^",""), "''"

        tuple.Branches["B"] = "^("+decay.replace("^","")+")"
        
        # This is needed for ConstB
        bhh = bh.replace('[','').replace(']cc','')

        if (('pi0' not in decay) and ('KS0' not in decay) and ('Lambda0' not in decay)):
#            B.ToolList +=  [ "TupleToolAngles"] 
            tta = tuple.addTupleTool("TupleToolAngles") 
            if (not resonant): tta.WRTMother = False 
#            if (( 'K*(892)0' in decay)  or ('phi' in decay)): tuple.B.ToolList +=  [ "TupleToolP2VV" ]  # really wants a VV
        if (dtf):
            FullFit = B.addTupleTool("TupleToolDecayTreeFitter/FullFit")
            FullFit.Verbose = True                          # fills daughters
            FullFit.constrainToOriginVertex = True
            FullFit.daughtersToConstrain += [ "J/psi(1S)" ] # even non resonant
            if ("ConstBFit" in verbose):
                ConstBFit = B.addTupleTool("TupleToolDecayTreeFitter/ConstBFit")
                ConstBFit.Verbose = True
                ConstBFit.constrainToOriginVertex = True
                ConstBFit.daughtersToConstrain += [ "J/psi(1S)", bhh ] # constrain B as well
                ConstBFit.UpdateDaughters = True                       # Maurizio's daughters

            for d in [ 'KS0', 'pi0', 'Lambda0' ]:
                if d in decay:
                    FullFit.daughtersToConstrain += [ d ]
                    if ( "ConstBFit" in verbose ): ConstBFit.daughtersToConstrain += [ d ]
            if (not resonant):
                NoPsiFit = B.addTupleTool("TupleToolDecayTreeFitter/NoPsiFit")
                NoPsiFit.Verbose = True
                NoPsiFit.constrainToOriginVertex = True
            if (not resonant): #b constraint for calculating qsq
                ConstBNoPsiFit = B.addTupleTool("TupleToolDecayTreeFitter/ConstBNoPsiFit")
                ConstBNoPsiFit.Verbose = True
                ConstBNoPsiFit.constrainToOriginVertex = True
                ConstBNoPsiFit.daughtersToConstrain += [ bhh ] # constrain B as well
                ConstBNoPsiFit.UpdateDaughters = True                       # Maurizio's daughters

            #if (resonant and ('KS0' in decay or "pi0" in decay or 'Lambda0' in decay)):
            #    OnlyPsiFit = B.addTupleTool("TupleToolDecayTreeFitter/OnlyPsiFit")
            #    OnlyPsiFit.Verbose = True
            #    OnlyPsiFit.constrainToOriginVertex = True
            #    OnlyPsiFit.daughtersToConstrain += [ "J/psi(1S)" ]
            if ('phi' in decay):
                substitute1 = { 'Beauty -> Meson (Strange -> ^K+ K-)': 'pi+'  }
                from Configurables import TupleToolDecayTreeFitter
                subDTF = TupleToolDecayTreeFitter("SubPipKm", Verbose=False,
                                                  daughtersToConstrain = [ "J/psi(1S)" ],
                                                  constrainToOriginVertex=True,
                                                  Substitutions=substitute1)
                B.addTool(subDTF)
                B.ToolList += [ "TupleToolDecayTreeFitter/SubPipKm" ]
                
                B.addTool(subDTF)
                substitute2 = { 'Beauty -> Meson (Strange -> K+ ^K-)': 'pi-' }
                B.addTool(subDTF.clone("SubKpPim",Substitutions=substitute2))
                B.ToolList += [ "TupleToolDecayTreeFitter/SubKpPim" ]

            if ( Lambdab2Jpsippi==decay ):
                substitute1 = { 'Beauty -> Meson p+ ^pi-': 'K-', 'Beauty -> Meson p~- ^pi+': 'K+'  }
                from Configurables import TupleToolDecayTreeFitter
                B.addTupleTool(TupleToolDecayTreeFitter("SubpK", Verbose=False,
                                                        daughtersToConstrain = [ "J/psi(1S)" ],
                                                        constrainToOriginVertex=True,
                                                        Substitutions=substitute1))
                        
                substitute2 = { 'Beauty -> Meson ^p+ pi-': 'K+', 'Beauty -> Meson ^p~- pi+': 'K-'  }
                B.addTupleTool(TupleToolDecayTreeFitter("SubKpi", Verbose=False,
                                                        daughtersToConstrain = [ "J/psi(1S)" ],
                                                        constrainToOriginVertex=True,
                                                        Substitutions=substitute2))
                if ("ConstBFit" in verbose):
                    ConstBSubFit = B.addTupleTool("TupleToolDecayTreeFitter/ConstBSubFit")
                    ConstBSubFit.Substitutions=substitute1   # substitute and then constrain
                    ConstBSubFit.Verbose = True
                    ConstBSubFit.constrainToOriginVertex = True
                    ConstBSubFit.daughtersToConstrain += [ "J/psi(1S)", bhh ] # constrain B as well
                    ConstBSubFit.UpdateDaughters = True                       # Maurizio's daughters

            if ( Bd2JpsiKS0==decay ):
                substitute1 = { 'Beauty -> Meson (Strange -> ^pi+ pi-)' : 'K+' }
                substitute2 = { 'Beauty -> Meson (Strange -> pi+ ^pi-)' : 'K-' }
                from Configurables import TupleToolDecayTreeFitter
                B.addTupleTool(TupleToolDecayTreeFitter("PsiKppim", Verbose=False,
                                                        daughtersToConstrain = [ "J/psi(1S)" ],
                                                        constrainToOriginVertex=True,
                                                        Substitutions=substitute1))
                        
                B.addTupleTool(TupleToolDecayTreeFitter("PsiKmpip", Verbose=False,
                                                        daughtersToConstrain = [ "J/psi(1S)" ],
                                                        constrainToOriginVertex=True,
                                                        Substitutions=substitute2))

            if ( Bu2JpsiK == decay):
            
                substitute2 = { 'Beauty -> Meson ^K+': 'pi+', 'Beauty -> Meson ^K-': 'pi-' }
                subDTF2 = B.addTupleTool(TupleToolDecayTreeFitter("Subpi", Verbose=False,
                                                                  daughtersToConstrain = [ "J/psi(1S)" ],
                                                                  constrainToOriginVertex=True,
                                                                  Substitutions=substitute2))
            
            if ( Bu2eeK == decay or Bu2MuMuK == decay or Bu2MueK == decay or Bu2eMuK == decay):
                if Bu2eeK == decay : substitute1 = {  "Beauty -> ( J/psi(1S) -> ^e+ X- ) Strange " : "pi+" ,
                                                      "Beauty -> ( J/psi(1S) -> ^e- X+ ) Strange " : "pi-" }
                elif Bu2MuMuK == decay : substitute1 = {  "Beauty -> ( J/psi(1S) -> ^mu+ X- ) Strange " : "pi+" ,
                                                          "Beauty -> ( J/psi(1S) -> ^mu- X+ ) Strange " : "pi-" }
                elif Bu2MueK == decay : substitute1 = {  "Beauty -> ( J/psi(1S) -> ^e+ X- ) Strange " : "pi+" ,
                                                         "Beauty -> ( J/psi(1S) -> ^mu- X+ ) Strange " : "pi-" }
                elif Bu2eMuK == decay : substitute1 = {  "Beauty -> ( J/psi(1S) -> ^mu+ X- ) Strange " : "pi+" ,
                                                         "Beauty -> ( J/psi(1S) -> ^e- X+ ) Strange " : "pi-" }

                from Configurables import TupleToolDecayTreeFitter
                subDTF = B.addTupleTool(TupleToolDecayTreeFitter("Subpipi", Verbose=False,
                                                                 constrainToOriginVertex=True,
                                                                 Substitutions=substitute1,
                                                                 UpdateDaughters = True)) # Maurizio's daughters
                    
        """
        if (('KS0' in decay) or ("K*(892)" in decay) or ("Lambda0" in decay)):
            mh = tuple.addTupleTool("TupleToolMassHypo")
            if ("KS0" in decay):
                mh.PIDReplacements = { "pi+" : "p+" }    
            #if ("K*(892)" in decay):
            #    mh.PIDReplacements = { "pi-" : "K+" }     
            if ("Lambda0" in decay):
                mh.PIDReplacements = { "p+" : "pi+" }
        """
                
        B.addTool(tistos)
        B.ToolList += [ "TupleToolTISTOS"  ]

    rs = tuple.addTupleTool("TupleToolRecoStats")
    rs.Verbose = ("RecoStats" in verbose)
    ei = tuple.addTupleTool("TupleToolEventInfo")
    ei.Verbose = ("EventInfo" in verbose)          # gives GpsYear, month, day, etc
    ki = tuple.addTupleTool("TupleToolKinematic")  # gives _AtVtx_P
    ki.Verbose=  ("Kinematic" in verbose)
    tuple.addTupleTool("TupleToolPrimaries")
    ti = tuple.addTupleTool("TupleToolTrackInfo")
    ti.Verbose = ("TrackInfo" in verbose)          # gives many more chi2
    if ( "TrackPosition" in  verbose):             # extrapolates to TT, IT
        tp1 = tuple.addTupleTool("TupleToolTrackPosition/TupleToolTrackPositionTT")
        tp2 = tuple.addTupleTool("TupleToolTrackPosition/TupleToolTrackPositionIT")
        tp1.ExtraName = "TT"
        tp2.ExtraName = "IT"
        tp2.Z = 7800    
    pid = tuple.addTupleTool("TupleToolPid")
    pid.Verbose = ("Pid" in verbose)               # many more vars in RICH
    if ("Pid" in verbose) :
        tuple.addTupleTool("TupleToolANNPID")
    tuple.addTupleTool("TupleToolL0Calo")
    if ('e+' in decay):
        brem = tuple.addTupleTool("TupleToolBremInfo")
    #isolation
    if "iso" in verbose :
        # lines from Greg Ciezarek
        from configIso import configIso
        configIso()
        # this is work in progress 
        #will be comitted to SVN properly at a future date as of 3/4/14
        from Configurables import TupleToolApplyIsolation
        tuple.B.addTool(TupleToolApplyIsolation,    name="TupleToolApplyIsolationHard")
        tuple.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
        tuple.B.TupleToolApplyIsolationHard.WeightsFile="weightsHard.xml"
        tuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationHard"]
        tuple.B.addTool(TupleToolApplyIsolation,    name="TupleToolApplyIsolationSoft")
        tuple.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
        tuple.B.TupleToolApplyIsolationSoft.WeightsFile="weightsSoft.xml"
        tuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationSoft"]  
        vtxiso = tuple.B.addTupleTool("TupleToolVtxIsoln")
        tuple.B.TupleToolApplyIsolationHard.OutputLevel = 3 
        tuple.B.TupleToolApplyIsolationSoft.OutputLevel = 3 
    tuple.addTupleTool("TupleToolPropertime")
    if ( "/Event/Phys/" == head): # not reading stripping output
        tts = tuple.addTupleTool("TupleToolStripping")

    tuple.addTupleTool("TupleToolPhotonInfo")
    tuple.addTupleTool("TupleToolPi0Info")
#    tuple.OutputLevel = 1
    if ( addendum == "MC" ):   # it's MC!
        tmc = tuple.addTupleTool("TupleToolMCTruth")
        #tmc.addTupleTool("MCTupleToolKinematic")
        tmc.addTupleTool("MCTupleToolHierarchy")
        tuple.addTupleTool("TupleToolMCBackgroundInfo")

    if (isMDST):
        seq.Members += [ #PrintDecayTree( Inputs = [ location]),
            EventNodeKiller(Nodes=["DAQ"] ) ]

    if ( addendum == "MC" ):   # it's not MC!
        from Configurables import TrackSmearState as SMEAR
        smear = SMEAR()
#        seq.Members += [ smear ]
    elif (not isMDST):   # it's not mdst
        from Configurables import TrackScaleState as SCALER
        scaler = SCALER('StateScale')   
#        seq.Members += [ scaler ]

    seq.Members += [ # PrintDecayTree( Inputs = [ location]),
                     tuple ]
    return [ seq ]
Exemple #8
0
from Gaudi.Configuration import *
#
# DecayTreeTuple
#
from Configurables import DecayTreeTuple, LoKi__Hybrid__TupleTool, TupleToolDecay, TupleToolTrigger, TupleToolTISTOS, TupleToolTagging
from Configurables import FitDecayTrees, TupleToolGeometry
tuple = DecayTreeTuple('Lb2JpsiLTree') 
tuple.Inputs = [ 'Phys/Bs2Jpsif0' ]

tuple.TupleName = "mytree"

tuple.ToolList =  [
       "TupleToolGeometry",
       "TupleToolKinematic",
       "TupleToolEventInfo",
#       "TupleToolTISTOS",
       "TupleToolPid",
       "TupleToolTrackInfo",
#       "TupleToolTagging"
        ]
tistos = TupleToolTISTOS("tistos")
tistos.VerboseL0 = 1
tistos.VerboseHlt1 = 1
tistos.VerboseHlt2 = 1
tistos.TriggerList = [
                          'L0DiMuonDecision',
                             'L0HCALDecision',
                             'L0MuonDecision',
                         'L0MuonHighDecision',
               'Hlt1SingleMuonNoIPL0Decision',
                 'Hlt1DiMuonHighMassDecision',
Exemple #9
0
sc = StrippingConf( Streams = [ AllStreams ],
                    MaxCandidates = 2000
                    )




tuple = DecayTreeTuple("Jpsi_Tuple")

tuple.Inputs = ["Phys/B2XMuMu_InclDiMuHighQ2Line/Particles/"]


tuple.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
    , "TupleToolMCTruth"
    , "TupleToolMCBackgroundInfo"
   # , "TupleBuKmmFit"
]


tuple.addBranches ({         
      "muplus" :  "B0 -> ^mu+ mu-",
      "muminus" :  "B0 -> mu+ ^mu-",
      "Dimuon" : "B0 : B0 -> mu+ mu-",
})
LoKi_All=tuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_All")
LoKi_All.Variables = {
        'MINIPCHI2' : "MIPCHI2DV(PRIMARY)", 
        'MINIP' : "MIPDV(PRIMARY)",
        'IPCHI2_OWNPV' : "BPVIPCHI2()", 
Exemple #10
0
_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("Bplus_Tuple")
tupleB.Inputs = [SeqB.outputLocation()]
tupleB.Decay = "[B+ -> ^K+ ^(J/psi(1S) -> ^mu+ ^mu-)]CC"


tupleB.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
   # , "TupleBuKmmFit"
] # Probably need to add many more Tools. 


tupleB.addBranches ({         
      "Kplus" :  "[B+ -> ^K+ (J/psi(1S) -> mu+ mu-)]CC",
      "Jpsi" :  "[B+ -> K+ ^(J/psi(1S) -> mu+ mu-)]CC",
      "muplus" :  "[B+ -> K+ (J/psi(1S) -> ^mu+ mu-)]CC",
      "muminus" :  "[B+ -> K+ (J/psi(1S) -> mu+ ^mu-)]CC",
      "Bplus" : "[B+ -> K+ J/psi(1S)]CC",
})



LoKi_All=tupleB.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_All")
Exemple #11
0
def execute(stripRun, stripConf, stripLine, dataType, hltReport, tupleDecay, evtMax, mag, outputType="ntuple", strippingStream = "Charm"):

  #0 "pi" "pi"
  #1 "mu" "mu"
  #2 "K"  "pi"
  #3 "e"  "mu"
  #4 "K"  "mu"
  stripLines = {
    "kkpi":0,
    "kpipi":1,
    "pipipi":2,
    "kpipios":3,
    "kkk":4,
    "kkpios":5,
    "hhh":6,
    }

  lineNumber = stripLines[stripLine]

  # Now build the stream
  from StrippingConf.StrippingStream import StrippingStream
  ss = StrippingStream("ByTom")

  from StrippingSelections import StrippingD2hhh_conf
  line = False
  if stripConf == "default" or stripConf == "def":

    from StrippingArchive import Utils
    D2HHHConf, default_config = Utils.lineBuilderAndConf("stripping20","D2hhh")

    def_str_no_pre = default_config
    for key, val in def_str_no_pre.iteritems():
      if "Prescale" in key:
        def_str_no_pre[key] = 1.0

    D2HHHConf = StrippingD2hhh_conf.D2hhhConf('D2hhh',def_str_no_pre)
    D2hhhLines = D2HHHConf.lines()
    for line in D2hhhLines :
      print line.name(), line.outputLocation()

    ss.appendLines( [D2hhhLines[lineNumber]] )
    stripOutputLoc = D2hhhLines[lineNumber].outputLocation()
  else:
    raise ValueError("Unknown value of stripConf: %s"%stripConf)

  from StrippingConf.Configuration import StrippingConf
  conf = StrippingConf( Streams = [ ss ] )

  from Configurables import StrippingReport
  sr = StrippingReport(Selections = conf.selections())


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

  from Configurables import DaVinci
  from Configurables import LoKi__HDRFilter as StripFilter

  strfilter = StripFilter( 'StripPassFilter', Code="HLT_PASS('"+D2hhhLines[lineNumber].name()+"Decision')", Location="/Event/Strip/Phys/DecReports" )
  #strfilter = StripFilter( 'StripPassFilter', Code="HLT_PASS('StrippingD2hhh_PPPLineDecision')", Location="/Event/Strip/Phys/DecReports" )
  DaVinci().EventPreFilters += [strfilter]

  DaVinci().PrintFreq = 500
  DaVinci().HistogramFile = 'DV_histos.root'
  DaVinci().TupleFile = "DPiPiPi_NTuple.root"
  DaVinci().EvtMax = evtMax

  storeExp = StoreExplorerAlg()
  storeExp.Load = 1
  storeExp.PrintFreq = 10.0

  #DaVinci().appendToMainSequence( [ storeExp ] )
  if stripRun:
    #from Configurables import bankKiller
    #bk = bankKiller( "KillHltBanks", BankTypes = [ "Evt/Strip/Phys/DecReports", "Evt/AllStreams" ] )
    #DaVinci().appendToMainSequence( [ bk ] )
    from Configurables import EventNodeKiller
    enk = EventNodeKiller()
    enk.Nodes=[
      "Event/Strip/Phys/DecReports",
      "Event/AllStreams"]
    DaVinci().appendToMainSequence( [ enk ] )
    #DaVinci().appendToMainSequence( [ storeExp ] )

    DaVinci().appendToMainSequence( [ conf.sequence() ] )
    DaVinci().appendToMainSequence( [ sr ] )
  if hltReport:
    from Configurables import ReadHltReport
    DaVinci().appendToMainSequence( [ ReadHltReport() ] )

  DaVinci().InputType = 'MDST'
  DaVinci().RootInTES = "/Event/Charm"

  a = "->"

  if dataType == "MC10":
    DaVinci().DataType = "2010"
    DaVinci().Simulation = True
    DaVinci().DDDBtag = "head-20101206"
    if mag == "up":
      DaVinci().CondDBtag = "sim-20101210-vc-mu100"
    elif mag == "down":
      DaVinci().CondDBtag = "sim-20101210-vc-md100"
    DaVinci().Lumi = False
  elif dataType == "MC11":
    DaVinci().DataType = "2011"
    DaVinci().Simulation = True
    DaVinci().DDDBtag = "MC11-20111102"
    if mag == "up":
      DaVinci().CondDBtag = "sim-20111111-vc-mu100"
    elif mag == "down":
      DaVinci().CondDBtag = "sim-20111111-vc-md100"
    DaVinci().Lumi = False
  elif dataType == "MC11a":
    DaVinci().DataType = "2011"
    DaVinci().Simulation = True
    DaVinci().DDDBtag = "MC11-20111102"
    if mag == "up":
      DaVinci().CondDBtag = "sim-20111111-vc-mu100"
    elif mag == "down":
      DaVinci().CondDBtag = "sim-20111111-vc-md100"
    DaVinci().Lumi = False
  elif dataType == "MC2012":
    DaVinci().DataType = "2012"
    DaVinci().Simulation = True
    DaVinci().DDDBtag = "Sim08-20130503-1"
    if mag == "up":
      DaVinci().CondDBtag = "Sim08-20130503-1-vc-mu100"
    elif mag == "down":
      DaVinci().CondDBtag = "Sim08-20130503-1-vc-md100"
    DaVinci().Lumi = False
  elif dataType == "MC2011":
    DaVinci().DataType = "2011"
    DaVinci().Simulation = True
    DaVinci().DDDBtag = "Sim08-20130503"
    if mag == "up":
      DaVinci().CondDBtag = "Sim08-20130503-vc-mu100"
    elif mag == "down":
      DaVinci().CondDBtag = "Sim08-20130503-vc-md100"
    DaVinci().Lumi = False
  elif dataType == "data2012":
    a = "->"
    DaVinci().DataType = "2012"
    DaVinci().Simulation = False
    #DaVinci().DDDBtag = "dddb-20130111"
    #if mag == "up":
      #DaVinci().CondDBtag = "cond-20130114"
    #elif mag == "down":
      #DaVinci().CondDBtag = "cond-20130114"
    DaVinci().Lumi = True
  elif dataType == "data2011":
    a = "->"
    DaVinci().DataType = "2011"
    DaVinci().Simulation = False
    #DaVinci().DDDBtag = "dddb-20130111"
    #if mag == "up":
      #DaVinci().CondDBtag = "cond-20130114"
    #elif mag == "down":
      #DaVinci().CondDBtag = "cond-20130114"
    DaVinci().Lumi = True
  elif dataType == "data":
    sys.exit("correct the dataType to include the year")


  from Configurables import DecayTreeTuple
  from Configurables import TupleToolTISTOS
  from Configurables import TupleToolMassHypo, TupleToolSubMass

  if outputType in ["ntuple", "nt", "tuple", "root"]:

    print "stripOutputLoc:",stripOutputLoc

    dttuple = DecayTreeTuple( "DPiPiPi_NTuple" )

    dttuple.ToolList = ["TupleToolGeometry",
                        "TupleToolEventInfo",
                        "TupleToolKinematic",
                        #"TupleToolPrimaries",
                        "TupleToolPropertime",
                        "TupleToolAngles",
                        "TupleToolPid",
                        #"TupleToolRICHPid",
                        "TupleToolDecay",
                        #"TupleToolTrigger",
                        #"TupleToolTrackPosition",
                        #"TupleToolTrackInfo",
                        #"TupleToolRecoStats",
                        "TupleToolDira",
                        "TupleToolDalitz",
                        "TupleToolSubMass",
                        ]

    dttuple.Inputs = [ stripOutputLoc ]

    print "tuple input :",dttuple.Inputs
    print "number of events:", DaVinci().EvtMax


    #[D+ -> pi- pi+ pi+]CC

    if tupleDecay == "pipipi":
      dttuple.Decay = "[D+ "+a+" ^pi- ^pi+ ^pi+]CC"
      dttuple.addBranches ({
        "D":   "[D+ "+a+" pi- pi+ pi+]CC",
        "x1": "[D+ "+a+" ^pi- pi+ pi+]CC",
        "x2": "[D+ "+a+" pi- ^pi+ pi+]CC",
        "x3": "[D+ "+a+" pi- pi+ ^pi+]CC",
        })
    elif tupleDecay == "kpipios":
      dttuple.Decay = "[D+ "+a+" ^pi- ^pi+ ^K+]CC"
      dttuple.addBranches ({
        "D":   "[D+ "+a+" pi- pi+ K+]CC",
        "x1": "[D+ "+a+" ^pi- pi+ K+]CC",
        "x2": "[D+ "+a+" pi- ^pi+ K+]CC",
        "x3": "[D+ "+a+" pi- pi+ ^K+]CC",
        })
    elif tupleDecay == "ds2phipi":
      dttuple.Decay = "[D+ "+a+" ^mu+ ^mu- ^pi+]CC"
      dttuple.addBranches ({
        "D":   "[D+ "+a+" mu+ mu- pi+]CC",
        "x1": "[D+ "+a+" ^mu+ mu- pi+]CC",
        "x2": "[D+ "+a+" mu+ ^mu- pi+]CC",
        "x3": "[D+ "+a+" mu+ mu- ^pi+]CC",
        })

    #if tupleDecay == "eta":
      #dttuple.Decay = "[(D+ "+a+" ^(eta "+a+" ^pi+ ^pi-) ^pi+),(D- "+a+" ^(eta "+a+" ^pi+ ^pi-) ^pi-)]"
      #dttuple.addBranches ({
        #"D":   "[(D+ "+a+" (eta "+a+" pi+ pi-) pi+),(D- "+a+" (eta "+a+" pi+ pi-) pi-)]",
        #"eta": "[(D+ "+a+" ^(eta "+a+" ^pi+ ^pi-) ^pi+),(D- "+a+" ^(eta "+a+" ^pi+ ^pi-) ^pi-)]",
        #"pip": "[(D+ "+a+" (eta "+a+" ^pi+ pi-) pi+),(D- "+a+" (eta "+a+" ^pi+ pi-) pi-)]",
        #"pim": "[(D+ "+a+" (eta "+a+" pi+ ^pi-) pi+),(D- "+a+" (eta "+a+" pi+ ^pi-) pi-)]",
        #"pi":  "[(D+ "+a+" (eta "+a+" pi+ pi-) ^pi+),(D- "+a+" (eta "+a+" pi+ pi-) ^pi-)]",
        #})

    dttuple.TupleName = "DPiPiPi_NTuple"

    ttmhk = TupleToolMassHypo("KaonHypo")
    ttmhk.PIDReplacements = { "pi+" : "K+"}
    #ttmhk.CC = True
    dttuple.D.addTool(ttmhk)
    dttuple.D.ToolList += ["TupleToolMassHypo/KaonHypo"]

    ttmhm = TupleToolMassHypo("MuonHypo")
    ttmhm.PIDReplacements = { "pi+" : "mu+"}
    #ttmhm.CC = True
    dttuple.D.addTool(ttmhm)
    dttuple.D.ToolList += ["TupleToolMassHypo/MuonHypo"]

    dttuple.addTool(TupleToolTISTOS())
    dttuple.TupleToolTISTOS.VerboseL0 = True
    dttuple.TupleToolTISTOS.VerboseHlt1 = True
    dttuple.TupleToolTISTOS.VerboseHlt2 = True
    dttuple.TupleToolTISTOS.Verbose = True
    dttuple.ToolList += ["TupleToolTISTOS"]

    dttuple.TupleToolTISTOS.TriggerList = [

        "L0CALODecision",
        "L0ElectronDecision",
        "L0PhotonDecision",
        "L0HadronDecision",
        "L0MuonDecision",

        "Hlt1TrackMuonDecision",
        "Hlt1TrackAllL0Decision",

        "Hlt2Topo2BodyBBDTDecision",
        "Hlt2Topo3BodyBBDTDecision",
        "Hlt2Topo4BodyBBDTDecision",

        'Hlt2CharmHadD2HHHDecision',

        ] #+ [ trigger_name+"Decision" for trigger_name in
          #      ["L0CALO","L0ElectronNoSPD","L0PhotonNoSPD","L0HadronNoSPD","L0MuonNoSPD","L0DiMuonNoSPD","L0Electron","L0ElectronHi","L0Photon","L0PhotonHi","L0Hadron","L0Muon","L0DiMuon","L0HighSumETJet","L0B1gas","L0B2gas",]\
          #    + ["Hlt1MBMicroBiasVelo","Hlt1Global","Hlt1DiMuonHighMass","Hlt1DiMuonLowMass","Hlt1SingleMuonNoIP","Hlt1SingleMuonHighPT","Hlt1TrackAllL0","Hlt1TrackMuon","Hlt1TrackPhoton","Hlt1Lumi","Hlt1LumiMidBeamCrossing","Hlt1MBNoBias","Hlt1MBMicroBiasVeloRateLimited","Hlt1MBMicroBiasTStation","Hlt1MBMicroBiasTStationRateLimited","Hlt1L0Any","Hlt1L0AnyRateLimited","Hlt1L0AnyNoSPD","Hlt1L0AnyNoSPDRateLimited","Hlt1NoPVPassThrough","Hlt1DiProton","Hlt1DiProtonLowMult","Hlt1BeamGasNoBeamBeam1","Hlt1BeamGasNoBeamBeam2","Hlt1BeamGasBeam1","Hlt1BeamGasBeam2","Hlt1BeamGasCrossingEnhancedBeam1","Hlt1BeamGasCrossingEnhancedBeam2","Hlt1BeamGasCrossingForcedReco","Hlt1ODINTechnical","Hlt1Tell1Error","Hlt1VeloClosingMicroBias","Hlt1BeamGasCrossingParasitic","Hlt1ErrorEvent","Hlt1SingleElectronNoIP","Hlt1TrackForwardPassThrough","Hlt1TrackForwardPassThroughLoose","Hlt1CharmCalibrationNoBias","Hlt1L0HighSumETJet","Hlt1BeamGasCrossingForcedRecoFullZ","Hlt1BeamGasHighRhoVertices","Hlt1VertexDisplVertex","Hlt1TrackAllL0Tight","Hlt1HighPtJetsSinglePV","Hlt1L0PU","Hlt1L0CALO",]\
          #    + ["Hlt2SingleElectronTFLowPt","Hlt2SingleElectronTFHighPt","Hlt2DiElectronHighMass","Hlt2DiElectronB","Hlt2B2HHLTUnbiased","Hlt2Topo2BodySimple","Hlt2Topo3BodySimple","Hlt2Topo4BodySimple","Hlt2Topo2BodyBBDT","Hlt2Topo3BodyBBDT","Hlt2Topo4BodyBBDT","Hlt2TopoMu2BodyBBDT","Hlt2TopoMu3BodyBBDT","Hlt2TopoMu4BodyBBDT","Hlt2TopoE2BodyBBDT","Hlt2TopoE3BodyBBDT","Hlt2TopoE4BodyBBDT","Hlt2IncPhi","Hlt2IncPhiSidebands","Hlt2CharmHadD02HHKsLL","Hlt2Dst2PiD02PiPi","Hlt2Dst2PiD02MuMu","Hlt2Dst2PiD02KMu","Hlt2Dst2PiD02KPi","Hlt2PassThrough","Hlt2Transparent","Hlt2Forward","Hlt2DebugEvent","Hlt2CharmHadD02HH_D02PiPi","Hlt2CharmHadD02HH_D02PiPiWideMass","Hlt2CharmHadD02HH_D02KK","Hlt2CharmHadD02HH_D02KKWideMass","Hlt2CharmHadD02HH_D02KPi","Hlt2CharmHadD02HH_D02KPiWideMass","Hlt2ExpressJPsi","Hlt2ExpressJPsiTagProbe","Hlt2ExpressLambda","Hlt2ExpressKS","Hlt2ExpressDs2PhiPi","Hlt2ExpressBeamHalo","Hlt2ExpressDStar2D0Pi","Hlt2ExpressHLT1Physics","Hlt2Bs2PhiGamma","Hlt2Bs2PhiGammaWideBMass","Hlt2Bd2KstGamma","Hlt2Bd2KstGammaWideKMass","Hlt2Bd2KstGammaWideBMass","Hlt2CharmHadD2KS0H_D2KS0Pi","Hlt2CharmHadD2KS0H_D2KS0K","Hlt2CharmRareDecayD02MuMu","Hlt2B2HH","Hlt2MuonFromHLT1","Hlt2SingleMuon","Hlt2SingleMuonHighPT","Hlt2SingleMuonLowPT","Hlt2DiProton","Hlt2DiProtonTF","Hlt2DiProtonLowMult","Hlt2DiProtonLowMultTF","Hlt2CharmSemilepD02HMuNu_D02KMuNuWS","Hlt2CharmSemilepD02HMuNu_D02PiMuNuWS","Hlt2CharmSemilepD02HMuNu_D02KMuNu","Hlt2CharmSemilepD02HMuNu_D02PiMuNu","Hlt2TFBc2JpsiMuX","Hlt2TFBc2JpsiMuXSignal","Hlt2DisplVerticesLowMassSingle","Hlt2DisplVerticesHighMassSingle","Hlt2DisplVerticesDouble","Hlt2DisplVerticesSinglePostScaled","Hlt2DisplVerticesHighFDSingle","Hlt2DisplVerticesSingleDown","Hlt2CharmSemilepD2HMuMu","Hlt2CharmSemilepD2HMuMuWideMass","Hlt2B2HHPi0_Merged","Hlt2CharmHadD2HHH","Hlt2CharmHadD2HHHWideMass","Hlt2DiMuon","Hlt2DiMuonLowMass","Hlt2DiMuonJPsi","Hlt2DiMuonJPsiHighPT","Hlt2DiMuonPsi2S","Hlt2DiMuonB","Hlt2DiMuonZ","Hlt2DiMuonDY1","Hlt2DiMuonDY2","Hlt2DiMuonDY3","Hlt2DiMuonDY4","Hlt2DiMuonDetached","Hlt2DiMuonDetachedHeavy","Hlt2DiMuonDetachedJPsi","Hlt2DiMuonNoPV","Hlt2TriMuonDetached","Hlt2TriMuonTau","Hlt2CharmSemilepD02HHMuMu","Hlt2CharmSemilepD02HHMuMuWideMass","Hlt2CharmHadD02HHHH","Hlt2CharmHadD02HHHHWideMass","Hlt2ErrorEvent","Hlt2Global","Hlt2diPhotonDiMuon","Hlt2LowMultMuon","Hlt2LowMultHadron","Hlt2LowMultPhoton","Hlt2LowMultElectron","Hlt2SingleTFElectron","Hlt2SingleTFVHighPtElectron","Hlt2B2HHLTUnbiasedDetached","Hlt2CharmHadLambdaC2KPPi","Hlt2SingleMuonVHighPT","Hlt2CharmSemilepD02HMuNu_D02KMuNuTight","Hlt2CharmHadMinBiasLambdaC2KPPi","Hlt2CharmHadMinBiasD02KPi","Hlt2CharmHadMinBiasD02KK","Hlt2CharmHadMinBiasDplus2hhh","Hlt2CharmHadMinBiasLambdaC2LambdaPi","Hlt2DisplVerticesSingle","Hlt2DisplVerticesDoublePostScaled","Hlt2DisplVerticesSingleHighMassPostScaled","Hlt2DisplVerticesSingleHighFDPostScaled","Hlt2DisplVerticesSingleMVPostScaled","Hlt2RadiativeTopoTrackTOS","Hlt2RadiativeTopoPhotonL0","Hlt2DiMuonPsi2SHighPT","Hlt2DoubleDiMuon","Hlt2DiMuonAndMuon","Hlt2DiMuonAndGamma","Hlt2DiMuonAndD0","Hlt2DiMuonAndDp","Hlt2DiMuonAndDs","Hlt2DiMuonAndLc","Hlt2CharmSemilepD02HHMuMuHardHadronsSoftMuons","Hlt2CharmSemilepD02HHMuMuHardHadronsSoftMuonsWideMass","Hlt2CharmSemilepD02HHMuMuHardHadronsAndMuons","Hlt2CharmSemilepD02HHMuMuHardHadronsAndMuonsWideMass","Hlt2TopoRad2BodyBBDT","Hlt2TopoRad2plus1BodyBBDT","Hlt2Lumi","Hlt2LowMultHadron_nofilter","Hlt2LowMultElectron_nofilter","Hlt2CharmHadD02HHKsDD","Hlt2CharmHadD2KS0KS0","Hlt2CharmHadD2KS0KS0WideMass","Hlt2ExpressD02KPi","Hlt2CharmHadLambdaC2KPPiWideMass","Hlt2CharmHadLambdaC2KPK","Hlt2CharmHadLambdaC2KPKWideMass","Hlt2CharmHadLambdaC2PiPPi","Hlt2CharmHadLambdaC2PiPPiWideMass","Hlt2CharmHadLambdaC2PiPK","Hlt2CharmHadLambdaC2PiPKWideMass","Hlt2CharmHadD2KS0H_D2KS0DDPi","Hlt2CharmHadD2KS0H_D2KS0DDK","Hlt2DiPhi","Hlt2CharmHadD02HHHHDstNoHltOne_4pi","Hlt2CharmHadD02HHHHDstNoHltOne_4piWideMass","Hlt2CharmHadD02HHHHDstNoHltOne_K3pi","Hlt2CharmHadD02HHHHDstNoHltOne_K3piWideMass","Hlt2CharmHadD02HHHHDstNoHltOne_KKpipi","Hlt2CharmHadD02HHHHDstNoHltOne_KKpipiWideMass","Hlt2CharmHadD02HHHHDstNoHltOne_2K2pi","Hlt2CharmHadD02HHHHDstNoHltOne_2K2piWideMass","Hlt2CharmHadD02HHHHDstNoHltOne_3Kpi","Hlt2CharmHadD02HHHHDstNoHltOne_3KpiWideMass","Hlt2CharmHadD02HHHHDstNoHltOne_Ch2","Hlt2CharmHadD02HHHHDstNoHltOne_Ch2WideMass","Hlt2CharmSemilep3bodyD2PiMuMu","Hlt2CharmSemilep3bodyD2PiMuMuSS","Hlt2CharmSemilep3bodyD2KMuMu","Hlt2CharmSemilep3bodyD2KMuMuSS","Hlt2CharmSemilep3bodyLambdac2PMuMu","Hlt2CharmSemilep3bodyLambdac2PMuMuSS","Hlt2LambdaC_LambdaC2Lambda0LLPi","Hlt2LambdaC_LambdaC2Lambda0LLK","Hlt2LambdaC_LambdaC2Lambda0DDPi","Hlt2LambdaC_LambdaC2Lambda0DDK","Hlt2RadiativeTopoTrack","Hlt2RadiativeTopoPhoton","Hlt2CharmHadD02HHHHDst_4pi","Hlt2CharmHadD02HHHHDst_4piWideMass","Hlt2CharmHadD02HHHHDst_K3pi","Hlt2CharmHadD02HHHHDst_K3piWideMass","Hlt2CharmHadD02HHHHDst_KKpipi","Hlt2CharmHadD02HHHHDst_KKpipiWideMass","Hlt2CharmHadD02HHHHDst_2K2pi","Hlt2CharmHadD02HHHHDst_2K2piWideMass","Hlt2CharmHadD02HHHHDst_3Kpi","Hlt2CharmHadD02HHHHDst_3KpiWideMass","Hlt2CharmHadD02HHHHDst_Ch2","Hlt2CharmHadD02HHHHDst_Ch2WideMass","Hlt2CharmSemilepD02PiPiMuMu","Hlt2CharmSemilepD02KKMuMu","Hlt2CharmSemilepD02KPiMuMu","Hlt2CharmHadD02HHHH_4pi","Hlt2CharmHadD02HHHH_4piWideMass","Hlt2CharmHadD02HHHH_K3pi","Hlt2CharmHadD02HHHH_K3piWideMass","Hlt2CharmHadD02HHHH_KKpipi","Hlt2CharmHadD02HHHH_KKpipiWideMass","Hlt2CharmHadD02HHHH_2K2pi","Hlt2CharmHadD02HHHH_2K2piWideMass","Hlt2CharmHadD02HHHH_3Kpi","Hlt2CharmHadD02HHHH_3KpiWideMass","Hlt2CharmHadD02HHHH_Ch2","Hlt2CharmHadD02HHHH_Ch2WideMass","Hlt2DiMuonDetachedPsi2S","Hlt2CharmHadD02HHXDst_hhX","Hlt2CharmHadD02HHXDst_hhXWideMass","Hlt2LowMultD2KPi","Hlt2LowMultD2KPiPi","Hlt2LowMultD2K3Pi","Hlt2LowMultChiC2HH","Hlt2LowMultChiC2HHHH","Hlt2LowMultD2KPiWS","Hlt2LowMultD2KPiPiWS","Hlt2LowMultD2K3PiWS","Hlt2LowMultChiC2HHWS","Hlt2LowMultChiC2HHHHWS","Hlt2LowMultDDInc","Hlt2DisplVerticesSingleLoosePS","Hlt2DisplVerticesSingleHighFD","Hlt2DisplVerticesSingleVeryHighFD","Hlt2DisplVerticesSingleHighMass","Hlt2DisplVerticesSinglePS","Hlt2DisplVerticesDoublePS","Hlt2CharmHadD2HHHKsLL","Hlt2CharmHadD2HHHKsDD","Hlt2KshortToMuMuPiPi","Hlt2LowMultChiC2PP","Hlt2LowMultDDIncCP","Hlt2LowMultDDIncVF","Hlt2LowMultLMR2HH","Hlt2HighPtJets","Hlt2ChargedHyperon_Xi2Lambda0LLPi","Hlt2ChargedHyperon_Xi2Lambda0LLMu","Hlt2ChargedHyperon_Omega2Lambda0LLK","Hlt2ChargedHyperon_Xi2Lambda0DDPi","Hlt2ChargedHyperon_Xi2Lambda0DDMu","Hlt2ChargedHyperon_Omega2Lambda0DDK","Hlt2CharmHadD02HHXDst_BaryonhhX","Hlt2CharmHadD02HHXDst_BaryonhhXWideMass","Hlt2CharmHadD02HHXDst_BaryonhhXWithKSLL","Hlt2CharmHadD02HHXDst_BaryonhhXWithKSLLWideMass","Hlt2CharmHadD02HHXDst_BaryonhhXWithLambda0LL","Hlt2CharmHadD02HHXDst_BaryonhhXWithLambda0LLWideMass","Hlt2CharmHadD02HHXDst_BaryonhhXWithKSDD","Hlt2CharmHadD02HHXDst_BaryonhhXWithKSDDWideMass","Hlt2CharmHadD02HHXDst_BaryonhhXWithLambda0DD","Hlt2CharmHadD02HHXDst_BaryonhhXWithLambda0DDWideMass","Hlt2CharmHadD02HHXDst_LeptonhhX","Hlt2CharmHadD02HHXDst_LeptonhhXWideMass","Hlt2CharmHadD02HHXDst_LeptonhhXWithKSLL","Hlt2CharmHadD02HHXDst_LeptonhhXWithKSLLWideMass","Hlt2CharmHadD02HHXDst_LeptonhhXWithLambda0LL","Hlt2CharmHadD02HHXDst_LeptonhhXWithLambda0LLWideMass","Hlt2CharmHadD02HHXDst_LeptonhhXWithKSDD","Hlt2CharmHadD02HHXDst_LeptonhhXWithKSDDWideMass","Hlt2CharmHadD02HHXDst_LeptonhhXWithLambda0DD","Hlt2CharmHadD02HHXDst_LeptonhhXWithLambda0DDWideMass"]
          #  ]

    from Configurables import LoKi__Hybrid__TupleTool
    LoKi_DTFMASS = LoKi__Hybrid__TupleTool("LoKi_DTFMASS")
    LoKi_DTFMASS.Variables = {
        "DTF_CHI2"   : "DTF_CHI2( True )",
        "DTF_NDOF"   : "DTF_NDOF( True )",

        "DTF_D_M"     : "DTF_FUN ( M ,                      True )",
        "DTF_D_MM"    : "DTF_FUN ( MM ,                     True )",
        "DTF_D_P"     : "DTF_FUN ( P ,                      True )",
        "DTF_D_PT"    : "DTF_FUN ( PT ,                     True )",
        "DTF_D_PE"    : "DTF_FUN ( E ,                      True )",
        "DTF_D_PX"    : "DTF_FUN ( PX ,                     True )",
        "DTF_D_PY"    : "DTF_FUN ( PY ,                     True )",
        "DTF_D_PZ"    : "DTF_FUN ( PZ ,                     True )",

        "DTF_x1_M"   : "DTF_FUN ( CHILD(M,1) ,             True )",
        "DTF_x1_MM"  : "DTF_FUN ( CHILD(MM,1) ,            True )",
        "DTF_x1_P"   : "DTF_FUN ( CHILD(P,1) ,             True )",
        "DTF_x1_PT"  : "DTF_FUN ( CHILD(PT,1) ,            True )",
        "DTF_x1_PE"  : "DTF_FUN ( CHILD(E,1) ,             True )",
        "DTF_x1_PX"  : "DTF_FUN ( CHILD(PX,1) ,            True )",
        "DTF_x1_PY"  : "DTF_FUN ( CHILD(PY,1) ,            True )",
        "DTF_x1_PZ"  : "DTF_FUN ( CHILD(PZ,1) ,            True )",

        "DTF_x2_M"   : "DTF_FUN ( CHILD(M,2) ,             True )",
        "DTF_x2_MM"  : "DTF_FUN ( CHILD(MM,2) ,            True )",
        "DTF_x2_P"   : "DTF_FUN ( CHILD(P,2) ,             True )",
        "DTF_x2_PT"  : "DTF_FUN ( CHILD(PT,2) ,            True )",
        "DTF_x2_PE"  : "DTF_FUN ( CHILD(E,2) ,             True )",
        "DTF_x2_PX"  : "DTF_FUN ( CHILD(PX,2) ,            True )",
        "DTF_x2_PY"  : "DTF_FUN ( CHILD(PY,2) ,            True )",
        "DTF_x2_PZ"  : "DTF_FUN ( CHILD(PZ,2) ,            True )",

        "DTF_x3_M"   : "DTF_FUN ( CHILD(M,3) ,             True )",
        "DTF_x3_MM"  : "DTF_FUN ( CHILD(MM,3) ,            True )",
        "DTF_x3_P"   : "DTF_FUN ( CHILD(P,3) ,             True )",
        "DTF_x3_PT"  : "DTF_FUN ( CHILD(PT,3) ,            True )",
        "DTF_x3_PE"  : "DTF_FUN ( CHILD(E,3) ,             True )",
        "DTF_x3_PX"  : "DTF_FUN ( CHILD(PX,3) ,            True )",
        "DTF_x3_PY"  : "DTF_FUN ( CHILD(PY,3) ,            True )",
        "DTF_x3_PZ"  : "DTF_FUN ( CHILD(PZ,3) ,            True )",

        }
    dttuple.D.ToolList+=["LoKi::Hybrid::TupleTool/LoKi_DTFMASS"]
    dttuple.D.addTool(LoKi_DTFMASS)

    if "MC" in dataType:
      from Configurables import TupleToolMCBackgroundInfo
      dttuple.addTool(TupleToolMCBackgroundInfo, name="TupleToolMCBackgroundInfo")
      dttuple.TupleToolMCBackgroundInfo.Verbose=True
      dttuple.addTool(TupleToolMCTruth, name="truth")
      dttuple.truth.ToolList += ["MCTupleToolHierarchy",
                                "MCTupleToolKinematic"]
      dttuple.ToolList+=["TupleToolMCBackgroundInfo/TupleToolMCBackgroundInfo"]
      dttuple.ToolList+=["TupleToolMCTruth/truth"]

    DaVinci().appendToMainSequence( [ dttuple ] )

  elif outputType == "dst":

    from Configurables import SelDSTWriter
    if stripRun:
      dst_Sel = AutomaticData(Location = stripOutputLoc)
    else:
      dst_Sel = AutomaticData(Location = "/Event/"+strippingStream+"/" + stripOutputLoc)

    dst_Filter = FilterDesktop('dst_Filter', Code = "ALL")

    dst_FilterSel = Selection(name = line.name().replace("Stripping",""),
                              Algorithm = dst_Filter,
                              RequiredSelections = [ dst_Sel ])

    dst_Seq = SelectionSequence('lsdata',
                                TopSelection = dst_FilterSel,
                                )

    dstw = SelDSTWriter("DSTWriter")
    dstw.OutputFileSuffix = "PiPiPi"
    #dstw.CopyProtoParticles = False
    dstw.SelectionSequences = [dst_Seq]
    #dstw.CopyL0DUReport = False
    #dstw.CopyHltDecReports = False
    #dstw.CopyMCTruth = True
    #dstw.CopyBTags = True
    DaVinci().appendToMainSequence( [ dstw.sequence() ] )
Exemple #12
0
Bu_Kmumu = Selection ("Sel"+name,
                     Algorithm = _stripfilter,
                     RequiredSelections = [stripsel])
seq = SelectionSequence("seq",
                      TopSelection = Bu_Kmumu)

tuple = DecayTreeTuple("Jpsi_Tuple")

tuple.Inputs = [stripsel.outputLocation()]


tuple.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
    , "TupleToolMCTruth"
    , "TupleToolMCBackgroundInfo"
    , "TupleBuKmmFit"
]


tuple.addBranches ({         
      "Kplus" :  "[B+ -> ^K+ (J/psi(1S) -> mu+ mu-)]CC",
      "Jpsi" :  "[B+ -> K+ ^(J/psi(1S) -> mu+ mu-)]CC",
      "muplus" :  "[B+ -> K+ (J/psi(1S) -> ^mu+ mu-)]CC",
      "muminus" :  "[B+ -> K+ (J/psi(1S) -> mu+ ^mu-)]CC",
      "Bplus" : "[B+ -> K+ J/psi(1S)]CC",
})
LoKi_All=tuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_All")
LoKi_All.Variables = {
        'MINIPCHI2' : "MIPCHI2DV(PRIMARY)", 
def execute_option_file(path):
    # ================= BEGIN EDIT AREA =======================
    tuplename = "Bu2LLK_meLine"
    simulation_inputstring = "/Event/AllStreams/Phys/Bu2LLK_meLine/Particles"
    data_inputstring = "/Event/Leptonic/Phys/Bu2LLK_meLine/Particles"

    decaydescriptor = "[B+ -> ^[J/psi(1S) -> ^mu+ ^e-]CC ^K+]CC"
    branches = {    # Dictionary for the branches to write in the tuple
        "B"         : "[B+ -> [J/psi(1S) -> mu+ e-]CC K+]CC",
        "Psi"       : "[B+ -> ^[J/psi(1S) -> mu+ e-]CC K+]CC",
        "muplus"    : "[B+ -> [J/psi(1S) -> ^mu+ e-]CC K+]CC",
        "eminus"    : "[B+ -> [J/psi(1S) -> mu+ ^e-]CC K+]CC",
        "Kplus"     : "[B+ -> [J/psi(1S) -> mu+ mu-]CC ^K+]CC"
    }

    toollist = [
                "TupleToolBremInfo"       #Bremsstrahlung information
                , "TupleToolGeometry"       #geometry of vertex locations (ENDVERTEX, OWNPV, IP_OWNPV, FD_OWNPV, DIRA_OWNPV)
                , "TupleToolKinematic"      #kinematic variables (inv. mass MM, kin. mass M/sqrt(E^2-p^2), P, PX/Y/Z/E, PT)
                , "TupleToolEventInfo"      #Event information such as run number, polarity, GPS time etc.
                , "TupleToolPropertime"     #proper lifetime of reconstructed particles
                , "TupleToolAngles"        #decay angles of charged tracks
                , "TupleToolTrigger"
                , "TupleToolTrackInfo"      #GhostProb of track and track type (TYPE) - 0 = unknown, 1 = velo track...
                , "TupleToolPrimaries"      #Number and coordinates of all primary vertices
                , "TupleToolDira"
                , "TupleToolTrackPosition"  #Plot the X/Y position at a given Z (default: 2500 = TTstation)
                , "TupleToolRecoStats"
                , "TupleToolBremInfo"       #Bremsstrahlung information
                , "TupleToolIsolationTwoBody"  #degree of isolation of two particles with common mother from Bsmumu
                , "TupleToolANNPID"         #V2,V3,... ProbNN variables
                #, "TupleToolCaloHypo"
                #, "TupleToolL0Calo"
                ]
    # ================= END EDIT AREA =======================




    # ================= BEGIN DO NOT EDIT HERE =======================
    from Configurables import GaudiSequencer
    MySequencer = GaudiSequencer('Sequence')



    #Check whether it is a DST or MDST file
    import os.path
    extension = os.path.splitext(path)[1]
    print extension
    if extension.lower() == ".dst":
        DaVinci().InputType = 'DST'
    elif extension.lower() == ".mdst":
        DaVinci().InputType = 'MDST'
    else:
        raise Exception("Extension {extension} of {path} does not match .mdst or .dst".format(extension, path))

    #Kill some nodes if micro dst-file
    if DaVinci().InputType == 'MDST':
        from Configurables import EventNodeKiller
        eventNodeKiller = EventNodeKiller('DAQkiller')
        eventNodeKiller.Nodes = ['/Event/DAQ','/Event/pRec']
        MySequencer.Members+=[eventNodeKiller]



    #DecayTreeTuple -> Fills information about particles, vertices and daughters
    ntuple = DecayTreeTuple(tuplename)



    if DaVinci().Simulation is True: # for MC
        ntuple.Inputs = [simulation_inputstring]
    elif DaVinci().Simulation is False: # for Tuple
        ntuple.Inputs = [data_inputstring]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    ntuple.Decay = decaydescriptor
    ntuple.addBranches(branches)

    ntuple.TupleName = "DecayTree"


    #Tools added to the ToolList can not be modified i.e. no other options than the defaults can be used
    ntuple.ToolList = toollist

    MySequencer.Members.append(ntuple)





    # ================= BEGIN EDIT TUPLETOOLS WITH OPTIONS ==================

    # LOKI TupleTool
    LoKi = ntuple.addTupleTool("LoKi::Hybrid::TupleTool")
    LoKi.Variables =  {
        "ETA" : "ETA",
        "PHI" : "PHI"       #Azimuthal angle
    }


    #Isolation tool from Alex
    weightsfolder = ""
    if(True):
        from Configurables import TupleToolApplyIsolation
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationHard")
        ntuple.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
        ntuple.B.TupleToolApplyIsolationHard.WeightsFile= weightsfolder+"weightsHard.xml"
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationSoft")
        ntuple.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
        ntuple.B.TupleToolApplyIsolationSoft.WeightsFile= weightsfolder+"weightsSoft.xml"
        ntuple.B.addTupleTool("TupleToolVtxIsoln")
        #ntuple.B.TupleToolApplyIsolationHard.OutputLevel = 3
        #ntuple.B.TupleToolApplyIsolationSoft.OutputLevel = 3




    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().UserAlgorithms = [MySequencer]
    DaVinci().MoniSequence += [ntuple]
    DaVinci().EvtMax     = 200
    DaVinci().SkipEvents = 0
    DaVinci().Lumi       = True
def execute_option_file():

    B2JpsiK = DecayTreeTuple('B2JpsiK')

    B2JpsiK.ToolList = [
          "TupleToolGeometry"
        , "TupleToolKinematic"
        , "TupleToolEventInfo"
        , "TupleToolPropertime"
        , "TupleToolTrigger"
        , "TupleToolTISTOS"
        , "TupleToolPid"
        , "TupleToolTrackInfo"
        , "TupleToolPrimaries"
        , "TupleToolDira"
        , "TupleToolTrackIsolation"
        , "TupleToolTrackPosition"
        , "TupleToolRecoStats"
        ]
    if DaVinci().Simulation is True:
        B2JpsiK.ToolList +=[
        "TupleToolMCBackgroundInfo"
        , "TupleToolMCTruth"
        ]


    L0Triggers = ["L0MuonDecision", "L0DiMuonDecision", "L0HadronDecision", "L0ElectronDecision", "L0PhotonDecision" ]
    ##            ['Muon',               'DiMuon',               '  Hadron',     'Electron',  'Photon','PhotonHi','ElectronHi']


    Hlt1Triggers = [  "Hlt1TrackAllL0Decision", "Hlt1TrackMuonDecision" ,"Hlt1TrackPhotonDecision" ,"Hlt1DiMuonLowMassDecision" ,"Hlt1DiMuonHighMassDecision"]

    Hlt2Triggers = [
        ## muon lines
        "Hlt2SingleMuonDecision", "Hlt2SingleMuonLowPTDecision", "Hlt2SingleMuonHighPTDecision",
        "Hlt2DiMuonDecision",  "Hlt2DiMuonLowMassDecision",
        "Hlt2DiMuonJPsiDecision",  "Hlt2DiMuonJPsiHighPTDecision",  "Hlt2DiMuonPsi2SDecision",
        "Hlt2DiMuonDetachedDecision",  "Hlt2DiMuonDetachedJPsiDecision", "Hlt2DiMuonDetachedHeavyDecision", "Hlt2TriMuonTauDecision",
        ## hadron/Topo lines
        "Hlt2B2HHDecision",
        "Hlt2DiMuonBDecision",  "Hlt2DiMuonZDecision",
        "Hlt2TopoMu2BodyBBDTDecision", "Hlt2TopoMu3BodyBBDTDecision", "Hlt2TopoMu4BodyBBDTDecision",
        "Hlt2Topo2BodyBBDTDecision",   "Hlt2Topo3BodyBBDTDecision",   "Hlt2Topo4BodyBBDTDecision",
        ##others
        "Hlt2PassThroughDecision",
        "Hlt2TransparentDecision",
        ## inclusive decisions
        "Hlt2DiMuonDY.*Decision","Hlt2TopoE.*Decision", "Hlt2Topo.*Decision",  "Hlt2Charm.*Decision", "Hlt2DiElectron.*Decision"
        ]

    triggerList = L0Triggers + Hlt1Triggers + Hlt2Triggers


    B2JpsiK.addTool(TupleToolTISTOS)
    B2JpsiK.TupleToolTISTOS.VerboseL0 = True
    B2JpsiK.TupleToolTISTOS.VerboseHlt1 = True
    B2JpsiK.TupleToolTISTOS.VerboseHlt2 = True
    B2JpsiK.TupleToolTISTOS.FillL0 = True
    B2JpsiK.TupleToolTISTOS.FillHlt1 = True
    B2JpsiK.TupleToolTISTOS.FillHlt2 = True
    B2JpsiK.TupleToolTISTOS.OutputLevel = INFO
    B2JpsiK.TupleToolTISTOS.TriggerList = triggerList


    if DaVinci().Simulation is True: # for MC
        B2JpsiK.Inputs = ["/Event/AllStreams/Phys/Bs2MuMuLinesBu2JPsiKLine/Particles"]
    elif DaVinci().Simulation is False: # for Data
        B2JpsiK.Inputs = ["/Event/Dimuon/Phys/Bs2MuMuLinesBu2JPsiKLine/Particles"]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    B2JpsiK.Decay = "[B+ -> ^(J/psi(1S) -> ^mu+ ^mu-) ^K+]CC"
    B2JpsiK.addBranches({
        "Bplus"   : "[B+ -> (J/psi(1S) -> mu+ mu-) K+]CC",
        "Jpsi"    : "[B+ -> ^(J/psi(1S) -> mu+ mu-) K+]CC",
        "muplus"  : "[B+ -> (J/psi(1S) -> ^mu+ mu-) K+]CC",
        "muminus" : "[B+ -> (J/psi(1S) -> mu+ ^mu-) K+]CC",
        "Kplus"   : "[B+ -> (J/psi(1S) -> mu+ mu-) ^K+]CC"
        })

    B2JpsiK.TupleName = "default"

    fitter = B2JpsiK.Bplus.addTupleTool("TupleToolDecayTreeFitter/FIX_JPSI")
    fitter.constrainToOriginVertex = False
    fitter.daughtersToConstrain = [ "J/psi(1S)" ]
    fitter.Verbose = True


    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().InputType = 'DST'
    DaVinci().UserAlgorithms = [B2JpsiK]
    DaVinci().MoniSequence += [B2JpsiK]
    DaVinci().EvtMax     = -1
    DaVinci().Lumi       = True
_otherd2kkpi.Preambulo = [
    "from LoKiPhysMC.decorators import *",
    "from PartProp.Nodes import CC" ]

selD2KKPiOther = Selection("DsMinusCandidates",
                           Algorithm = _otherd2kkpi,
                           RequiredSelections=[_otherKaons, _otherPions],
                           OutputBranch="NewEvent/Phys")

#selD2KKPiOther.OutputLevel = 1

seqD2KKPiOther = SelectionSequence('MCFilterOther', TopSelection = selD2KKPiOther)

othertuple = DecayTreeTuple("Ds2KKPiTuple", RootInTES='/Event/NewEvent')
othertuple.Decay = "[D_s+ -> K- K+ pi+]CC"
#othertuple.Inputs = [seqD2KKPi.outputLocation()]
othertuple.Inputs = ['Phys/SelD2KKPiOther/Particles']
othertuple.ToolList = []
from Configurables import MCMatchObjP2MCRelator

othertuple.addTupleTool('TupleToolKinematic')
othertuple.addTupleTool('TupleToolPropertime')

mcTruth = othertuple.addTupleTool("TupleToolMCTruth")
mcTruth.IP2MCPAssociatorTypes = ['MCMatchObjP2MCRelator/MyMCMatcher']
mcTruth.addTool(MCMatchObjP2MCRelator, name='MCMatchObjP2MCRelator')
mcTruth.MCMatchObjP2MCRelator.RelTableLocations = ['/Event/NewEvent/Relations/NewEvent/Rec/ProtoP/Charged']

#tuple.addTupleTool("TupleToolPropertime")

def execute_option_file(path):

    from Configurables import GaudiSequencer
    MySequencer = GaudiSequencer('Sequence')



    #Check whether it is a DST or MDST file
    import os.path
    extension = os.path.splitext(path)[1]
    print extension
    if extension.lower() == ".dst":
        DaVinci().InputType = 'DST'
    elif extension.lower() == ".mdst":
        DaVinci().InputType = 'MDST'
    else:
        raise Exception("Extension {extension} of {path} does not match .mdst or .dst".format(extension, path))

    #Kill some nodes if micro dst-file
    if DaVinci().InputType == 'MDST':
        from Configurables import EventNodeKiller
        eventNodeKiller = EventNodeKiller('DAQkiller')
        eventNodeKiller.Nodes = ['DAQ','pRec']
        MySequencer.Members+=[eventNodeKiller]




    #DecayTreeTuple
    data = DecayTreeTuple('Bu2LLK_mmLine')

    data.ToolList = [
          "TupleToolGeometry"
        , "TupleToolKinematic"
        , "TupleToolEventInfo"
        , "TupleToolPropertime"
        , "TupleToolTrigger"
        , "TupleToolTISTOS"
        , "TupleToolPid"
        , "TupleToolTrackInfo"
        , "TupleToolPrimaries"
        , "TupleToolDira"
        , "TupleToolTrackPosition"
        , "TupleToolRecoStats"
        ]
    if DaVinci().InputType != 'MDST':
        data.ToolList += ["TupleToolTrackIsolation"]
    if DaVinci().Simulation is True:
        data.ToolList +=[
          "TupleToolMCBackgroundInfo"
        , "TupleToolMCTruth"
        ]


    L0Triggers = ["L0MuonDecision", "L0DiMuonDecision", "L0HadronDecision", "L0ElectronDecision", "L0PhotonDecision" ]
    ##            ['Muon',               'DiMuon',               '  Hadron',     'Electron',  'Photon','PhotonHi','ElectronHi']


    Hlt1Triggers = [  "Hlt1TrackAllL0Decision", "Hlt1TrackMuonDecision" ,"Hlt1TrackPhotonDecision" ,"Hlt1DiMuonLowMassDecision" ,"Hlt1DiMuonHighMassDecision"]

    Hlt2Triggers = [
        ## muon lines
        "Hlt2SingleMuonDecision", "Hlt2SingleMuonLowPTDecision", "Hlt2SingleMuonHighPTDecision",
        "Hlt2DiMuonDecision",  "Hlt2DiMuonLowMassDecision",
        "Hlt2DiMuonJPsiDecision",  "Hlt2DiMuonJPsiHighPTDecision",  "Hlt2DiMuonPsi2SDecision",
        "Hlt2DiMuonDetachedDecision",  "Hlt2DiMuonDetachedJPsiDecision", "Hlt2DiMuonDetachedHeavyDecision", "Hlt2TriMuonTauDecision",
        ## hadron/Topo lines
        "Hlt2B2HHDecision",
        "Hlt2DiMuonBDecision",  "Hlt2DiMuonZDecision",
        "Hlt2TopoMu2BodyBBDTDecision", "Hlt2TopoMu3BodyBBDTDecision", "Hlt2TopoMu4BodyBBDTDecision",
        "Hlt2Topo2BodyBBDTDecision",   "Hlt2Topo3BodyBBDTDecision",   "Hlt2Topo4BodyBBDTDecision",
        ##others
        "Hlt2PassThroughDecision",
        "Hlt2TransparentDecision",
        ## inclusive decisions
        "Hlt2DiMuonDY.*Decision","Hlt2TopoE.*Decision", "Hlt2Topo.*Decision",  "Hlt2Charm.*Decision", "Hlt2DiElectron.*Decision"
        ]

    triggerList = L0Triggers + Hlt1Triggers + Hlt2Triggers


    data.addTool(TupleToolTISTOS)
    data.TupleToolTISTOS.VerboseL0 = True
    data.TupleToolTISTOS.VerboseHlt1 = True
    data.TupleToolTISTOS.VerboseHlt2 = True
    data.TupleToolTISTOS.FillL0 = True
    data.TupleToolTISTOS.FillHlt1 = True
    data.TupleToolTISTOS.FillHlt2 = True
    data.TupleToolTISTOS.OutputLevel = INFO
    data.TupleToolTISTOS.TriggerList = triggerList


    if DaVinci().Simulation is True: # for MC
        data.Inputs = ["/Event/AllStreams/Phys/Bu2LLK_mmLine/Particles"]
    elif DaVinci().Simulation is False: # for Tuple
        data.Inputs = ["/Event/Leptonic/Phys/Bu2LLK_mmLine/Particles"]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    data.Decay = "[B+ -> ^(J/psi(1S) -> ^mu+ ^mu-) ^K+]CC"
    data.addBranches({
        "B"         : "[B+ -> (J/psi(1S) -> mu+ mu-) K+]CC",
        "Psi"       : "[B+ -> ^(J/psi(1S) -> mu+ mu-) K+]CC",
        "muplus"    : "[B+ -> (J/psi(1S) -> ^mu+ mu-) K+]CC",
        "muminus"   : "[B+ -> (J/psi(1S) -> mu+ ^mu-) K+]CC",
        "Kplus"     : "[B+ -> (J/psi(1S) -> mu+ mu-) ^K+]CC"
        })

    data.TupleName = "DecayTree"


    #DecayTreeFitter
    fitter = data.B.addTupleTool("TupleToolDecayTreeFitter/FIX_JPSI")
    fitter.constrainToOriginVertex = False
    fitter.daughtersToConstrain = [ "J/psi(1S)" ]
    fitter.Verbose = True



    #Isolation
    data.B.addTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationHard")
    data.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
    data.B.TupleToolApplyIsolationHard.WeightsFile="weightsHard.xml"
    data.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationHard"]
    data.B.addTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationSoft")
    data.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
    data.B.TupleToolApplyIsolationSoft.WeightsFile="weightsSoft.xml"
    data.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationSoft"]
    vtxiso = data.B.addTupleTool("TupleToolVtxIsoln")
    #data.B.TupleToolApplyIsolationHard.OutputLevel = 3
    #data.B.TupleToolApplyIsolationSoft.OutputLevel = 3


    MySequencer.Members.append(data)





    #EventTuple for simulation
    """
    if DaVinci().Simulation is True:
        etuple = EventTuple()
        etuple.ToolList=["TupleToolEventInfo"]

        MySequencer.Members.append(etuple)
    """



    #DDDB and CondDB-Tags for DATA (needs to be set for Simulation in runfile.py according to generation->see bookkeeping!)
    #Always use the latest tags for the given datatype from (the newest are currently not in the database yet, therefore take the default ones!)
    """
    if DaVinci().Simulation is False:
        if DaVinci().DataType == '2012':
            DaVinci().CondDBtag = "dddb-20150522-2"
            DaVinci().DDDBtag = "cond-20150409-1"
        elif DaVinci().DataType == '2011':
            DaVinci().CondDBtag = "dddb-20150522-1"
            DaVinci().DDDBtag = "cond-20150409"
    """



    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().UserAlgorithms = [MySequencer]
    DaVinci().MoniSequence += [data]
    DaVinci().EvtMax     = -1
    DaVinci().Lumi       = True
from DecayTreeTuple.Configuration import *

#from Configurables import ( ANNGlobalPID__ChargedProtoANNPIDTrainingTuple )
#pidtuple = ANNGlobalPID__ChargedProtoANNPIDTrainingTuple("ANNPID")
#pidtuple.NTupleLUN = "ANNPIDTUPLE"
#DaVinci().UserAlgorithms += [ pidtuple ]

from Configurables import (DecayTreeTuple, LoKi__Hybrid__TupleTool)
tuple = DecayTreeTuple("ANNPID")
tuple.Decay = "[pi+]cc"
tuple.NTupleLUN = "ANNPIDTUPLE"
tuple.Inputs = [
    'Phys/StdAllNoPIDsPions/Particles', 'Phys/StdNoPIDsUpPions/Particles',
    'Phys/StdNoPIDsDownPions/Particles'
]
tuple.ToolList = ["TupleToolANNPIDTraining", "TupleToolGeometry"]
#lokiT = tuple.addTupleTool( LoKi__Hybrid__TupleTool, name = "LokiTool" )
#lokiT.Variables = { "MIPCHI2_PRIMARY" : "MIPCHI2DV(PRIMARY)" }
DaVinci().UserAlgorithms += [tuple]

DaVinci().EvtMax = -1
DaVinci().PrintFreq = 1000
#DaVinci().SkipEvents = 100000

DaVinci().InputType = 'DST'
DaVinci().Simulation = True

DaVinci().DataType = "2011"

NTupleSvc().Output += [
    "ANNPIDTUPLE DATAFILE='ProtoPIDANN.MC.tuples.root' TYP='ROOT' OPT='NEW'"
def execute_option_file():

    Tuple = DecayTreeTuple('Bu2LLK_eeLine2')

    Tuple.ToolList = [
          "TupleToolGeometry"
        , "TupleToolKinematic"
        , "TupleToolEventInfo"
        , "TupleToolPropertime"
        , "TupleToolTrigger"
        , "TupleToolTISTOS"
        , "TupleToolPid"
        , "TupleToolTrackInfo"
        , "TupleToolPrimaries"
        , "TupleToolDira"
        , "TupleToolTrackIsolation"
        , "TupleToolTrackPosition"
        , "TupleToolRecoStats"
        ]
    if DaVinci().Simulation is True:
        Tuple.ToolList +=[
          "TupleToolMCBackgroundInfo"
        , "TupleToolMCTruth"
        ]


    L0Triggers = ["L0MuonDecision", "L0DiMuonDecision", "L0HadronDecision", "L0ElectronDecision", "L0PhotonDecision" ]
    ##            ['Muon',               'DiMuon',               '  Hadron',     'Electron',  'Photon','PhotonHi','ElectronHi']


    Hlt1Triggers = [  "Hlt1TrackAllL0Decision", "Hlt1TrackMuonDecision" ,"Hlt1TrackPhotonDecision" ,"Hlt1DiMuonLowMassDecision" ,"Hlt1DiMuonHighMassDecision"]

    Hlt2Triggers = [
        ## muon lines
        "Hlt2SingleMuonDecision", "Hlt2SingleMuonLowPTDecision", "Hlt2SingleMuonHighPTDecision",
        "Hlt2DiMuonDecision",  "Hlt2DiMuonLowMassDecision",
        "Hlt2DiMuonJPsiDecision",  "Hlt2DiMuonJPsiHighPTDecision",  "Hlt2DiMuonPsi2SDecision",
        "Hlt2DiMuonDetachedDecision",  "Hlt2DiMuonDetachedJPsiDecision", "Hlt2DiMuonDetachedHeavyDecision", "Hlt2TriMuonTauDecision",
        ## hadron/Topo lines
        "Hlt2B2HHDecision",
        "Hlt2DiMuonBDecision",  "Hlt2DiMuonZDecision",
        "Hlt2TopoMu2BodyBBDTDecision", "Hlt2TopoMu3BodyBBDTDecision", "Hlt2TopoMu4BodyBBDTDecision",
        "Hlt2Topo2BodyBBDTDecision",   "Hlt2Topo3BodyBBDTDecision",   "Hlt2Topo4BodyBBDTDecision",
        ##others
        "Hlt2PassThroughDecision",
        "Hlt2TransparentDecision",
        ## inclusive decisions
        "Hlt2DiMuonDY.*Decision","Hlt2TopoE.*Decision", "Hlt2Topo.*Decision",  "Hlt2Charm.*Decision", "Hlt2DiElectron.*Decision"
        ]

    triggerList = L0Triggers + Hlt1Triggers + Hlt2Triggers


    Tuple.addTool(TupleToolTISTOS)
    Tuple.TupleToolTISTOS.VerboseL0 = True
    Tuple.TupleToolTISTOS.VerboseHlt1 = True
    Tuple.TupleToolTISTOS.VerboseHlt2 = True
    Tuple.TupleToolTISTOS.FillL0 = True
    Tuple.TupleToolTISTOS.FillHlt1 = True
    Tuple.TupleToolTISTOS.FillHlt2 = True
    Tuple.TupleToolTISTOS.OutputLevel = INFO
    Tuple.TupleToolTISTOS.TriggerList = triggerList


    if DaVinci().Simulation is True: # for MC
        Tuple.Inputs = ["/Event/Leptonic/Phys/Bu2LLK_eeLine2/Particles"]
    elif DaVinci().Simulation is False: # for Tuple
        Tuple.Inputs = ["/Event/Leptonic/Phys/Bu2LLK_eeLine2/Particles"]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    Tuple.Decay = "[B+ -> ^(J/psi(1S) -> ^e+ ^e-) ^K+]CC"
    Tuple.addBranches({
        "B"         : "[B+ -> (J/psi(1S) -> e+ e-) K+]CC",
        "Psi"       : "[B+ -> ^(J/psi(1S) -> e+ e-) K+]CC",
        "eplus"    : "[B+ -> (J/psi(1S) -> ^e+ e-) K+]CC",
        "eminus"   : "[B+ -> (J/psi(1S) -> e+ ^e-) K+]CC",
        "Kplus"     : "[B+ -> (J/psi(1S) -> e+ e-) ^K+]CC"
        })

    Tuple.TupleName = "DecayTree"

    #DecayTreeFitter
    fitter = Tuple.B.addTupleTool("TupleToolDecayTreeFitter/FIX_JPSI")
    fitter.constrainToOriginVertex = False
    fitter.daughtersToConstrain = [ "J/psi(1S)" ]
    fitter.Verbose = True


    #Isolation
    Tuple.B.addTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationHard")
    Tuple.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
    Tuple.B.TupleToolApplyIsolationHard.WeightsFile="weightsHard.xml"
    Tuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationHard"]
    Tuple.B.addTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationSoft")
    Tuple.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
    Tuple.B.TupleToolApplyIsolationSoft.WeightsFile="weightsSoft.xml"
    Tuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationSoft"]
    vtxiso = Tuple.B.addTupleTool("TupleToolVtxIsoln")
    #Tuple.B.TupleToolApplyIsolationHard.OutputLevel = 3
    #Tuple.B.TupleToolApplyIsolationSoft.OutputLevel = 3


    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().InputType = 'DST'
    DaVinci().UserAlgorithms = [Tuple]
    DaVinci().MoniSequence += [Tuple]
    DaVinci().EvtMax     = -1
    DaVinci().Lumi       = True
Exemple #19
0
from Gaudi.Configuration import *
from PhysSelPython.Wrappers import Selection, SelectionSequence, DataOnDemand

from Configurables import DecayTreeTuple, FitDecayTrees, TupleToolRecoStats, TupleToolTrigger, TupleToolTISTOS, CondDB
from DecayTreeTuple.Configuration import *

tuple = DecayTreeTuple("Jpsi_Tuple")

tuple.Inputs = ["/Event/Dimuon/Phys/B2XMuMu_Line/Particles"]

tuple.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
    , "TupleBuKmmFit"
]

tuple.addBranches ({
      "Bplus"        :  "[B+ ->  K+  ( J/psi(1S) ->  mu+  mu-)]CC",
      "Kplus"        :  "[B+ -> ^K+  ( J/psi(1S) ->  mu+  mu-)]CC",
      "Jpsi"         :  "[B+ ->  K+ ^( J/psi(1S) ->  mu+  mu-)]CC",
      "muplus"       :  "[B+ ->  K+  ( J/psi(1S) -> ^mu+  mu-)]CC",
      "muminus"      :  "[B+ ->  K+  ( J/psi(1S) ->  mu+ ^mu-)]CC",
})

LoKi_All = tuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_All")
LoKi_All.Variables = {
        'MINIPCHI2' : "MIPCHI2DV(PRIMARY)",
        'MINIP' : "MIPDV(PRIMARY)",
        'IPCHI2_OWNPV' : "BPVIPCHI2()",
        'IP_OWNPV' : "BPVIP()"
Exemple #20
0
def decay_tree_tuple(name, decay, mothers, intermediate, daughters, inputs,
                     mc):
    """Return a configured DecayTreeTuple instance.

    A DecayTreeTuple is configured with the given decay descriptor.
    The mothers dictionary is used to give exclusive tools to vertices, and it
    should be, as daughters, a dictionary of tuple branch names to branch
    descriptors.
    A typical method call might look like
        decay_tree_tuple(
            'TupleDstToD0pi_D0ToKpi',
            '[D*(2010)+ -> K- pi+]CC',
            {
                'Dst': '[D*(2010) -> (D0 -> K- pi+) pi+]CC',
                'D0': '[D*(2010) -> ^(D0 -> K- pi+) pi+]CC'
            },
            {
                'D0_K': '[D*(2010) -> (D0 -> ^K- pi+) pi+]CC',
                'D0_pi': '[D*(2010) -> (D0 -> K- ^pi+) pi+]CC',
                'Dst_pi': '[D*(2010) -> (D0 -> K- pi+) ^pi+]CC'
            },
            'Phys/StrippingLineName/Particles'
        )
    Keyword arguments:
    name -- TDirectory the DecayTreeTuple TTree will be saved in
    decay -- Decay descriptor
    mothers -- Branch descriptors to be added to the tuple as mothers;
               decaying particles
    daughters -- Branch descriptors to be added to the tuple as daughters;
                 final state particles
    inputs -- str of list of str, as the value of DecayTreeTuple.Inputs
    mc -- Extra MC information is included if True
    """

    # Define tuple tools to add
    tools = [
        "TupleToolPropertime",
        'TupleToolEventInfo',
    ]

    # Extra variables, added using LoKi hybrid tuple tools
    basic_loki_vars = {
        'ETA': 'ETA',
        'PHI': 'PHI',
        'PT': 'PT',
        'ID': 'ID',
        'P': 'P',
        'Loki_BPVIPCHI2': 'BPVIPCHI2()',
        'Loki_MIPCHI2DV': 'MIPCHI2DV(PRIMARY)',
    }
    intermediate_loki_vars = {
        'Loki_AM34': 'LoKi.Particles.PFunA(AM34)',
        'Loki_AM4': 'LoKi.Particles.PFunA(AM4)',
        'Loki_BPVDIRA': "BPVDIRA",
        'Loki_acosBPVDIRA': "acos(BPVDIRA)",
    }
    daughter_loki_vars = {
        'PIDK': 'PIDK',
        'PIDe': 'PIDe',
        'PIDmu': 'PIDmu',
        'PIDp': 'PIDp',
        'Loki_TRACKCHI2NDOF': 'TRCHI2DOF',
        'Loki_TRACKGHOSTPROB': 'TRGHOSTPROB',
    }
    mother_loki_vars = {
        'M': 'M',
        'Loki_BPVVDCHI2': 'BPVVDCHI2',
        'Loki_BPVIPCHI2': 'BPVIPCHI2()',
        'Loki_DOCAMAX': 'DOCAMAX',
        'Loki_AMAXDOCA': "LoKi.Particles.PFunA(AMAXDOCA(''))",
        'Loki_AMINDOCA': "LoKi.Particles.PFunA(AMINDOCA(''))",
        'Loki_DOCACHI2MAX': 'DOCACHI2MAX',
        'Loki_VCHI2NDOF': 'VFASPF(VCHI2/VDOF)',
        'Loki_VX': 'VFASPF(VX)',
        'Loki_VY': 'VFASPF(VY)',
        'Loki_VZ': 'VFASPF(VZ)',
        'Loki_SUMPT': 'SUMTREE(PT,  ISBASIC)',
        'Loki_BPVLTIME': "BPVLTIME()",
    }

    # Template DecayTreeTuple
    t = DecayTreeTuple(name)

    # Providing str will throw an exception, so wrap it in a list
    try:
        t.Inputs = inputs
    except ValueError:
        t.Inputs = [inputs]
    t.Decay = decay
    # Merge the mother and daughter dictionaries
    t.addBranches(
        dict(mothers.items() + intermediate.items() + daughters.items()))
    # Tools for all branches
    t.ToolList = tools
    # Verbose reconstruction information
    t.addTupleTool('TupleToolANNPID').ANNPIDTunes = ["MC15TuneV1"]
    # t.addTupleTool('TupleToolRecoStats')
    # MC truth information
    if mc:
        if has_turbo_inputs(t):
            print 'Adding MC truth information for Turbo'
            from TeslaTools import TeslaTruthUtils
            relations = TeslaTruthUtils.getRelLoc("")
            print 'relations = {}'.format(relations)
            toollist = ['MCTupleToolPrompt']
            rels = [relations]

            MCTruth = TupleToolMCTruth()
            #MCTruth.OutputLevel = 1
            MCTruth = t.addTupleTool('TupleToolMCTruth')
            MCTruth.ToolList = toollist
            MCTruth.addTool(DaVinciSmartAssociator)
            MCTruth.DaVinciSmartAssociator.RedoNeutral = False
            MCTruth.DaVinciSmartAssociator.addTool(P2MCPFromProtoP)
            MCTruth.DaVinciSmartAssociator.P2MCPFromProtoP.Locations = rels
            MCTruth.addTool(MCMatchObjP2MCRelator)
            MCTruth.MCMatchObjP2MCRelator.RelTableLocations = rels

            MCTruth.DaVinciSmartAssociator.addTool(BackgroundCategory)
            MCTruth.DaVinciSmartAssociator.BackgroundCategory.addTool(
                P2MCPFromProtoP)
            MCTruth.DaVinciSmartAssociator.BackgroundCategory.vetoNeutralRedo = True
            MCTruth.DaVinciSmartAssociator.BackgroundCategory.P2MCPFromProtoP.Locations = rels

            bkgcat = t.addTupleTool('TupleToolMCBackgroundInfo')
            bkgcat.addTool(BackgroundCategory)
            bkgcat.OutputLevel = 10
            bkgcat.BackgroundCategory.vetoNeutralRedo = True
            bkgcat.BackgroundCategory.addTool(P2MCPFromProtoP)
            bkgcat.BackgroundCategory.P2MCPFromProtoP.Locations = rels

            t.OutputLevel = 10
        else:
            print 'Adding MC truth information'
            t.addTupleTool('TupleToolMCTruth')
            t.addTupleTool('TupleToolMCBackgroundInfo')
    # Extra information from LoKi
    hybrid_tt = t.addTupleTool('LoKi::Hybrid::TupleTool/basicLoKiTT')
    hybrid_tt.Variables = basic_loki_vars
    hybrid_tt.Preambulo = ['from LoKiTracks.decorators import TrIDC']

    # Add mother-specific varaibles to each mother branch
    for mother in mothers:
        branch = getattr(t, mother)
        branch.addTupleTool('LoKi::Hybrid::TupleTool/{0}LoKiTT'.format(
            mother)).Variables = mother_loki_vars
        # For some unknown reason this doesn't work with Turbo candidates, so
        # the information for them has to be added to every branch
        DictTuple = branch.addTupleTool(LoKi__Hybrid__Dict2Tuple,
                                        name="DTFTuple")
        DictTuple.addTool(DTFDict, name="DTF")
        DictTuple.Source = "LoKi::Hybrid::DTFDict/DTF"
        DictTuple.NumVar = 6 * (len(mothers) + len(intermediate) +
                                len(daughters))

        # configure the DecayTreeFitter in the usual way
        DictTuple.DTF.constrainToOriginVertex = True
        DictTuple.DTF.daughtersToConstrain = ['D0']
        DictTuple.DTF.addTool(LoKi__Hybrid__DictOfFunctors, name="dict")
        DictTuple.DTF.Source = "LoKi::Hybrid::DictOfFunctors/dict"
        DictTuple.DTF.dict.Variables = {
            "DTFDict_{}_PT".format(mother): "PT",
            "DTFDict_{}_ETA".format(mother): "ETA",
            "DTFDict_{}_PHI".format(mother): "PHI",
            "DTFDict_{}_P".format(mother): "P",
            "DTFDict_{}_M".format(mother): "M",
        }
        for part, decay in intermediate.items() + daughters.items():
            DictTuple.DTF.dict.Variables["DTFDict_{}_PT".format(
                part)] = "CHILD(PT,'{}')".format(decay)
            DictTuple.DTF.dict.Variables["DTFDict_{}_ETA".format(
                part)] = "CHILD(ETA,'{}')".format(decay)
            DictTuple.DTF.dict.Variables["DTFDict_{}_PHI".format(
                part)] = "CHILD(PHI,'{}')".format(decay)
            DictTuple.DTF.dict.Variables["DTFDict_{}_P".format(
                part)] = "CHILD(P,'{}')".format(decay)
            DictTuple.DTF.dict.Variables["DTFDict_{}_M".format(
                part)] = "CHILD(M,'{}')".format(decay)

    # Add intermediate-specific varaibles to each mother branch
    mom_int = mother_loki_vars.copy()
    mom_int.update(intermediate_loki_vars)
    for mother in intermediate:
        branch = getattr(t, mother)
        branch.addTupleTool('LoKi::Hybrid::TupleTool/{0}LoKiTT'.format(
            mother)).Variables = mom_int
        # For some unknown reason this doesn't work with Turbo candidates, so
        # the information for them has to be added to every branch

    for daughter in daughters:
        branch = getattr(t, daughter)
        branch.addTupleTool('LoKi::Hybrid::TupleTool/{0}LoKiTT'.format(
            daughter)).Variables = daughter_loki_vars

    return t
Exemple #21
0
from PhysSelPython.Wrappers import SelectionSequence
SeqKsPiPi = SelectionSequence('SeqKsPiPi', TopSelection = LooseKsPiPi)

KsPiPiTuple = DecayTreeTuple("KsPiPiTuple")

# input locations
KsPiPiTuple.Inputs = [ LooseKsPiPi.outputLocation() ]
# decay descriptors
KsPiPiTuple.Decay = "KS0 -> ^pi+ ^pi-"
# define the tools and configure them
KsPiPiTuple.ToolList = [
    "TupleToolKinematic"
    ,"TupleToolGeometry"
    ,"TupleToolPid"
    ,"TupleToolANNPID"
    #,"TupleToolTrackInfo"
    ,"TupleToolRecoStats"
    ,"TupleToolTrigger"
    ,"TupleToolPrimaries"
    ]

KsPiPiTuple.addTupleTool("TupleToolTrackInfo/TupleToolTrackInfo")
KsPiPiTuple.TupleToolTrackInfo.Verbose = True

# define the list of triggers that could have fired...

KsPiPiTuple.addTupleTool("LoKi::Hybrid::TupleTool/LoKiTool")
KsPiPiTuple.LoKiTool.Variables = {
    "eta"                     : "ETA",
    "phi"                     : "PHI",
    "LV01"                    : "LV01" }
tuple2.Decay = tuple.Decay

from Configurables import DataOnDemandSvc, L0SelReportsMaker, L0DecReportsMaker
DataOnDemandSvc().AlgMap["HltLikeL0/DecReports"] = L0DecReportsMaker()
DataOnDemandSvc().AlgMap["HltLikeL0/SelReports"] = L0SelReportsMaker()
from Configurables import L0Conf
L0Conf().FullL0MuonDecoding = True
L0Conf().EnableL0DecodingOnDemand = True
L0Conf().EnsureKnownTCK = False

tuple3 = DecayTreeTuple("StrippingTuple")
tuple3.Inputs = [
    '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles'
]
tuple3.Decay = tuple.Decay
tuple3.ToolList = tuple.ToolList
tuple3.addTool(TupleToolTrigger, name="TupleToolTrigger")
tuple3.addTool(TupleToolTISTOS, name="TupleToolTISTOS")
tuple3.TupleToolTrigger.Verbose = True
tuple3.TupleToolTrigger.TriggerList = tlist
tuple3.TupleToolTISTOS.Verbose = True
tuple3.TupleToolTISTOS.TriggerList = tlist

tuple4 = MCDecayTreeTuple("MCStrippingTuple")
tuple4.Inputs = [
    '/Event/AllStreams/Phys/FullDSTDiMuonJpsi2MuMuDetachedLine/Particles'
]
tuple4.Decay = tuple.Decay

#DaVinci().UserAlgorithms += [ tuple2 ]
#DaVinci().TupleFile = "DVNtuples.root"
from DecayTreeTuple.Configuration import *

from FlavourTagging.Tunings import applyTuning

ntuple = DecayTreeTuple("TaggingTest")

descriptor_B = "[B0 -> ^(J/psi(1S) -> ^mu+ ^mu-) ^(K*(892)0 -> ^K+ ^pi-)]CC"

ntuple.Inputs = ['Dimuon/Phys/BetaSBd2JpsiKstarDetachedLine/Particles']
ntuple.Decay = descriptor_B
ntuple.addBranches({'B0': descriptor_B})
ntuple.ReFitPVs = True

ntuple.ToolList = [
    "TupleToolKinematic", "TupleToolPropertime", "TupleToolPrimaries",
    "TupleToolPid"
]

# Configure TupleToolTagging
tt_tagging = ntuple.addTupleTool("TupleToolTagging")
tt_tagging.UseFTfromDST = False
tt_tagging.OutputLevel = INFO
tt_tagging.Verbose = True
btag = tt_tagging.addTool(BTaggingTool, 'MyBTaggingTool')
applyTuning(btag, tuning_version="Summer2019Optimisation_v1_Run2"
            )  # apply most recent tuning
#applyTuning(btag)   # apply default tuning
tt_tagging.TaggingToolName = btag.getFullName()
tt_tagging.AddTagPartsInfo = True

# DaVinci configuration
Exemple #24
0
from StandardParticles import StdNoPIDsPions, StdNoPIDsKaons, StdNoPIDsProtons, StdNoPIDsMuons
from GaudiKernel.SystemOfUnits import MeV, GeV, cm, mm

from Configurables import DecayTreeTuple, FitDecayTrees, TupleToolRecoStats, TupleToolTrigger, TupleToolSubMass
from Configurables import TupleToolTISTOS, CondDB, SelDSTWriter
from Configurables import TupleToolTrackInfo, TupleToolRICHPid, TupleToolGeometry, TupleToolPid
from Configurables import TupleToolANNPID
from Configurables import TupleToolSLTruth
from Configurables import TupleToolTauMuDiscrVarsLcMassConstraint
from DecayTreeTuple.Configuration import *

tupleB = DecayTreeTuple("tupleout")
tupleB.Inputs = ["/Event/Semileptonic/Phys/b2LcMuXB2DMuForTauMuLine/Particles"]
tupleB.Decay = "[B- -> ^(Lambda_c+ -> ^p+ ^K- ^pi+) ^mu-]CC"
tupleB.ToolList = [
    "TupleToolKinematic", "TupleToolEventInfo", "TupleToolRecoStats"
]  # Probably need to add many more Tools.

tupleB.addBranches({
    "Lb": "[B- -> (Lambda_c+ -> p+ K- pi+) mu-]CC",
    "Lc": "[B- -> ^Lambda_c+ mu-]CC",
    "p": "[B- -> (Lambda_c+ -> ^p+ K- pi+) mu-]CC",
    "pi": "[B- -> (Lambda_c+ -> p+ K- ^pi+) mu-]CC",
    "K": "[B- -> (Lambda_c+ -> p+ ^K- pi+) mu-]CC",
    "mu": "[B- -> (Lambda_c+ -> p+ K- pi+) ^mu-]CC"
})

l0_lines = ['L0HadronDecision', 'L0MuonDecision', 'L0ElectronDecision']

hlt1_lines = ['Hlt1TrackMVADecision', 'Hlt1TwoTrackMVADecision']
Exemple #25
0
    def __apply_configuration__(self):

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

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

        if self.getProp("RunSelection"):

            # STD particles
            from StandardParticles import StdNoPIDsPions, StdNoPIDsKaons

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

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

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

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

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

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

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

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

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

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

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

            outputLevel = INFO

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

            seq.Members += [Tuple]

            Tuple.NTupleLUN = "DSPHIPI"

            from Configurables import NTupleSvc
            NTupleSvc().Output = [
                "DSPHIPI DATAFILE='DsToPhiPi.root'  TYP='ROOT'  OPT='NEW'"
            ]
def execute_option_file(path):
    # ================= BEGIN EDIT AREA =======================
    tuplename = "Bu2LLK_meLine"
    simulation_inputstring = "/Event/AllStreams/Phys/Bu2LLK_meLine/Particles"
    data_inputstring = "/Event/Leptonic/Phys/Bu2LLK_meLine/Particles"

    decaydescriptor = "[B+ -> ^[J/psi(1S) -> ^mu+ ^e-]CC ^K+]CC"
    branches = {    # Dictionary for the branches to write in the tuple
        "B"         : "[B+ -> [J/psi(1S) -> mu+ e-]CC K+]CC",
        "Psi"       : "[B+ -> ^[J/psi(1S) -> mu+ e-]CC K+]CC",
        "muplus"    : "[B+ -> [J/psi(1S) -> ^mu+ e-]CC K+]CC",
        "eminus"    : "[B+ -> [J/psi(1S) -> mu+ ^e-]CC K+]CC",
        "Kplus"     : "[B+ -> [J/psi(1S) -> mu+ mu-]CC ^K+]CC"
    }

    #Tools added to the ToolList can not be modified i.e. no other options than the defaults can be used
    #use data.addTupleTool('<tool>') in the corresponding section below if you also want to modify the specific tool
    toollist = [
          "TupleToolGeometry"       #geometry of vertex locations (ENDVERTEX, OWNPV, IP_OWNPV, FD_OWNPV, DIRA_OWNPV)
        , "TupleToolKinematic"      #kinematic variables (inv. mass MM, kin. mass M/sqrt(E^2-p^2), P, PX/Y/Z/E, PT)
        , "TupleToolEventInfo"      #Event information such as run number, polarity, GPS time etc.
        #, "TupleToolPropertime"    #proper lifetime of reconstructed particles
        , "TupleToolAngles"         #decay angles of charged tracks (i.e. angle in mothers frame, name: CosTheta)
        #, "TupleToolTrigger"       #Saves trigger decision (I prefer to use TupleToolTISTOS)
        , "TupleToolTISTOS"         #Trigger on/independent of signal
        , "TupleToolTrackInfo"      #GhostProb of track and track type (TYPE) - 0 = unknown, 1 = velo track...
        , "TupleToolPrimaries"      #Number and coordinates of all primary vertices
        , "TupleToolDira"           #Angle between secondary minus primary vertex and the mother momentum
        #, "TupleToolTrackPosition" #Extrapolate track to given z-position (option .Z, default=2500. which is TT)
        , "TupleToolRecoStats"      #Fills reconstruction information like nTracks, nSPDHits, nMuonTracks from RecSummary
        , "TupleToolBremInfo"       #Bremsstrahlung information
        ]
    # ================= END EDIT AREA =======================









    # ================= BEGIN DO NOT EDIT HERE =======================
    from Configurables import GaudiSequencer
    MySequencer = GaudiSequencer('Sequence')



    #Check whether it is a DST or MDST file
    import os.path
    extension = os.path.splitext(path)[1]
    print extension
    if extension.lower() == ".dst":
        DaVinci().InputType = 'DST'
    elif extension.lower() == ".mdst":
        DaVinci().InputType = 'MDST'
    else:
        raise Exception("Extension {extension} of {path} does not match .mdst or .dst".format(extension, path))

    #Kill some nodes if micro dst-file
    if DaVinci().InputType == 'MDST':
        from Configurables import EventNodeKiller
        eventNodeKiller = EventNodeKiller('DAQkiller')
        eventNodeKiller.Nodes = ['/Event/DAQ','/Event/pRec']
        MySequencer.Members+=[eventNodeKiller]




    #DecayTreeTuple -> Fills information about particles, vertices and daughters
    ntuple = DecayTreeTuple(tuplename)


    ntuple.ToolList = toollist


    if DaVinci().InputType != 'MDST':
        ntuple.ToolList += ["TupleToolTrackIsolation"]
    if DaVinci().Simulation is True:
        ntuple.ToolList +=["TupleToolMCBackgroundInfo"]            #Sets the background category
        MCTruth=ntuple.addTupleTool("TupleToolMCTruth")            #Saves information of MC particle associated to the current particle (you can add tools to it itself!)
        MCTruth.addTupleTool("MCTupleToolHierarchy")               #True IDs of mother and grandmother particles



    if DaVinci().Simulation is True: # for MC
        ntuple.Inputs = [simulation_inputstring]
    elif DaVinci().Simulation is False: # for Tuple
        ntuple.Inputs = [data_inputstring]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    ntuple.Decay = decaydescriptor
    ntuple.addBranches(branches)

    ntuple.TupleName = "DecayTree"

    MySequencer.Members.append(ntuple)
    # ================= END DO NOT EDIT HERE =======================













    # ================= BEGIN EDIT TUPLETOOLS WITH OPTIONS ==================

    # LOKI TupleTool
    LoKi = ntuple.addTupleTool("LoKi::Hybrid::TupleTool")
    LoKi.Variables =  {
        "ETA" : "ETA",       #Pseudorapidity
        "PHI" : "PHI"       #Azimuthal angle
    }




    # PID TupleTool
    if(True):
        pid = ntuple.addTupleTool("TupleToolPid")            #PID information for charged particles
        pid.Verbose = True                                 #More information like isMuonLoose etc.



    #TISTOS TupleTool
    if(True):
        from Configurables import TupleToolTISTOS

        L0Triggers = ["L0MuonDecision", "L0DiMuonDecision", "L0HadronDecision", "L0ElectronDecision", "L0PhotonDecision" ]
        ##            ['Muon',               'DiMuon',               '  Hadron',     'Electron',  'Photon','PhotonHi','ElectronHi']

        Hlt1Triggers = [  "Hlt1TrackAllL0Decision", "Hlt1TrackMuonDecision" ,"Hlt1TrackPhotonDecision" ,"Hlt1DiMuonLowMassDecision" ,"Hlt1DiMuonHighMassDecision"]

        Hlt2Triggers = [
            ## muon lines
            "Hlt2SingleMuonDecision", "Hlt2SingleMuonLowPTDecision", "Hlt2SingleMuonHighPTDecision",
            "Hlt2DiMuonDecision",  "Hlt2DiMuonLowMassDecision",
            "Hlt2DiMuonJPsiDecision",  "Hlt2DiMuonJPsiHighPTDecision",  "Hlt2DiMuonPsi2SDecision",
            "Hlt2DiMuonDetachedDecision",  "Hlt2DiMuonDetachedJPsiDecision", "Hlt2DiMuonDetachedHeavyDecision", "Hlt2TriMuonTauDecision",
            ## hadron/Topo lines
            "Hlt2B2HHDecision",
            "Hlt2DiMuonBDecision",  "Hlt2DiMuonZDecision",
            "Hlt2TopoMu2BodyBBDTDecision", "Hlt2TopoMu3BodyBBDTDecision", "Hlt2TopoMu4BodyBBDTDecision",
            "Hlt2TopoE2BodyBBDTDecision", "Hlt2TopoE3BodyBBDTDecision", "Hlt2TopoE4BodyBBDTDecision",
            "Hlt2Topo2BodyBBDTDecision",   "Hlt2Topo3BodyBBDTDecision",   "Hlt2Topo4BodyBBDTDecision",
            ##others
            "Hlt2PassThroughDecision",
            "Hlt2TransparentDecision",
            ## inclusive decisions
            "Hlt2DiMuonDY.*Decision","Hlt2TopoE.*Decision", "Hlt2Topo.*Decision",  "Hlt2Charm.*Decision", "Hlt2DiElectron.*Decision"
            ]

        triggerList = L0Triggers + Hlt1Triggers + Hlt2Triggers

        ntuple.addTool(TupleToolTISTOS)
        ntuple.TupleToolTISTOS.VerboseL0 = True
        ntuple.TupleToolTISTOS.VerboseHlt1 = True
        ntuple.TupleToolTISTOS.VerboseHlt2 = True
        ntuple.TupleToolTISTOS.FillL0 = True
        ntuple.TupleToolTISTOS.FillHlt1 = True
        ntuple.TupleToolTISTOS.FillHlt2 = True
        ntuple.TupleToolTISTOS.OutputLevel = INFO
        ntuple.TupleToolTISTOS.TriggerList = triggerList



    #DecayTreeFitter
    if(False):
        fitter = ntuple.B.addTupleTool("TupleToolDecayTreeFitter/FIX_JPSI")
        fitter.constrainToOriginVertex = False
        fitter.daughtersToConstrain = [ "J/psi(1S)" ]
        fitter.Verbose = True

    #Isolation
    if(True):
        from Configurables import TupleToolApplyIsolation
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationHard")
        ntuple.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
        ntuple.B.TupleToolApplyIsolationHard.WeightsFile="weightsHard.xml"
        #ntuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationHard"]
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationSoft")
        ntuple.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
        ntuple.B.TupleToolApplyIsolationSoft.WeightsFile="weightsSoft.xml"
        #ntuple.B.ToolList+=["TupleToolApplyIsolation/TupleToolApplyIsolationSoft"]
        ntuple.B.addTupleTool("TupleToolVtxIsoln")
        #ntuple.B.TupleToolApplyIsolationHard.OutputLevel = 3
        #ntuple.B.TupleToolApplyIsolationSoft.OutputLevel = 3


    #Settings for TupleToolTrackHits (some only are necessary for MDST-files because of other locations of the clusters)
    if(True):   #Change this value if you don't want to use this tool
        from Configurables import TupleToolTrackHits, STOfflinePosition
        trackhits = ntuple.addTupleTool("TupleToolTrackHits")
        trackhits.Verbose = True

        if DaVinci().InputType == 'MDST':
            from Configurables import MeasurementProvider
            ntuple.addTool(MeasurementProvider('MeasProvider'))
            ntuple.MeasProvider.RootInTES = "/Event/Leptonic/"        #Change Leptonic for your stream-name in case of MDST
            trackhits.MeasurementProvider = ntuple.MeasProvider

        itClusterPosition = STOfflinePosition('ToolSvc.ITClusterPosition')      #avoid crashes from missing IT channels
        itClusterPosition.DetType = 'IT'


    # ================= END EDIT TUPLETOOLS WITH OPTIONS ==================
















    #DDDB and CondDB-Tags for DATA (needs to be set for Simulation in runfile.py according to generation->see bookkeeping!)
    #Always use the latest tags for the given datatype from (the newest are currently not in the database yet, therefore take the default ones!)
    """
    if DaVinci().Simulation is False:
        if DaVinci().DataType == '2012':
            DaVinci().CondDBtag = "dddb-20150522-2"
            DaVinci().DDDBtag = "cond-20150409-1"
        elif DaVinci().DataType == '2011':
            DaVinci().CondDBtag = "dddb-20150522-1"
            DaVinci().DDDBtag = "cond-20150409"
    """



    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().UserAlgorithms = [MySequencer]
    DaVinci().MoniSequence += [ntuple]
    DaVinci().EvtMax     = -1
    DaVinci().Lumi       = True
Exemple #27
0
    def __apply_configuration__(self) :

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

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

        if self.getProp("RunSelection") :

            # STD particles
            from StandardParticles import StdLooseMuons

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

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

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

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

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

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

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

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

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

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

            from Configurables import ( DecayTreeTuple,
                                        TupleToolDecay,
                                        LoKi__Hybrid__FilterCriterion,
                                        LoKi__Hybrid__TupleTool,
                                        TupleToolMCBackgroundInfo,
                                        BackgroundCategory,
                                        TupleToolTrigger,
                                        TupleToolMCTruth,
                                        MCTupleToolKinematic,
                                        MCTupleToolHierarchy,
                                        TupleToolVtxIsoln,
                                        TupleToolP2VV
                                        )
            
            JPsiMuMuTree = DecayTreeTuple( JPsiMuMuName + 'Tuple')
            JPsiMuMuTree.Inputs = [ 'Phys/'+JPsiMuMuName]
            JPsiMuMuTree.Decay = 'J/psi(1S) ->  ^mu+ ^mu- '
            
            # set some names for ntuple branchs
            MyBranch_jpsi  = "jpsi"
            MyBranch_mup   = "mup"
            MyBranch_mum   = "mum"
            
            # label the branches for the particle tools
            JPsiMuMuTree.Branches = {
                MyBranch_jpsi  : "J/psi(1S) : J/psi(1S) ->  mu+ mu- ",
                MyBranch_mup   : "J/psi(1S) ->  ^mu+ mu- ",
                MyBranch_mum   : "J/psi(1S) ->  mu+ ^mu- ",
                }
            
            JPsiMuMuTree.ToolList = [
                "TupleToolEventInfo"
                , "TupleToolGeneration"
                , "TupleToolMCTruth"
                , "TupleToolMCBackgroundInfo"
                , "MCTupleToolKinematic"
                , "TupleToolPrimaries"
                , "TupleToolVtxIsoln"
                , "TupleToolTrackInfo"
                , "TupleToolPid"
                , "TupleToolGeometry"
                , "TupleToolKinematic"
                , "TupleToolPropertime"
                , "TupleToolPid"
                , "TupleToolPrimaries"
                , "TupleToolTrigger"
                ]
            
            JPsiMuMuTree.addTool(BackgroundCategory())
            JPsiMuMuTree.BackgroundCategory.SoftPhotonCut = 2000
            JPsiMuMuTree.OutputLevel = INFO
            JPsiMuMuTree.addTool(TupleToolTrigger())
            JPsiMuMuTree.TupleToolTrigger.VerboseL0 = True
            JPsiMuMuTree.addTool(TupleToolMCTruth())
            JPsiMuMuTree.TupleToolMCTruth.addTool(MCTupleToolKinematic())
            JPsiMuMuTree.TupleToolMCTruth.addTool(MCTupleToolHierarchy())
            JPsiMuMuTree.TupleToolMCTruth.ToolList = [
                "MCTupleToolKinematic" ,
                "MCTupleToolHierarchy"
                ]
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StoreKineticInfo = True
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StoreVertexInfo = True
            JPsiMuMuTree.TupleToolMCTruth.MCTupleToolKinematic.StorePropertimeInfo = False
            JPsiMuMuTree.addTool(TupleToolVtxIsoln( OutputLevel = 6 ))
            JPsiMuMuTree.TupleToolVtxIsoln.IP = 2.0
            JPsiMuMuTree.TupleToolVtxIsoln.InputParticles = [ "Phys/StdLooseMuons"]
            
            seq.Members += [JPsiMuMuTree]
            
            JPsiMuMuTree.NTupleLUN = "JPSIMUMU"
            
            from Configurables import NTupleSvc
            NTupleSvc().Output = ["JPSIMUMU DATAFILE='JpsiMuMu_Presel.root'  TYP='ROOT'  OPT='NEW'"]
Exemple #28
0
def ConfigureTuples():
    from JetAccessoriesMC.ConfigurationHelpers import ConfigureDoD
    tables = ConfigureDoD()
    from Configurables import TupleToolJetRelations, DecayTreeTuple
    HepMCAllJetTuple = DecayTreeTuple("HepMCAllJetTuple")

    HepMCAllJetTuple.InputLocations = ['Phys/StdHepMCAllJets/Particles']
    HepMCAllJetTuple.Decay = "CELLjet"
    HepMCAllJetTuple.ToolList = [
        'TupleToolKinematic', 'TupleToolEventInfo',
        'LoKi__Hybrid__TupleTool/LoKiTool'
    ]
    from JetAccessoriesMC.ConfigurationHelpers import addRelationTuple

    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJetsPartonic'],
                     InvertTable=True,
                     ReverseMatching=True)
    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJetsPartonic'],
                     InvertTable=True,
                     ReverseMatching=False)

    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCJets2StdJetsDeltaR'],
                     InvertTable=False,
                     ReverseMatching=True,
                     extraName='DeltaR')
    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCJets2StdJetsDeltaR'],
                     InvertTable=False,
                     ReverseMatching=False,
                     extraName='DeltaR')

    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJets2StdJetsmeasured'],
                     InvertTable=False,
                     ReverseMatching=True)
    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJets2StdJetsmeasured'],
                     InvertTable=False,
                     ReverseMatching=False)
    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJets2StdJetsMCtrue'],
                     InvertTable=False,
                     ReverseMatching=True)
    addRelationTuple(HepMCAllJetTuple,
                     tables['StdHepMCAllJets2StdJetsMCtrue'],
                     InvertTable=False,
                     ReverseMatching=False)

    from Configurables import LoKi__Hybrid__TupleTool
    LoKiTool = LoKi__Hybrid__TupleTool('LoKiTool')
    LoKiTool.Variables = {"ETA": "ETA", "PHI": "PHI", "Y": "Y"}
    HepMCAllJetTuple.addTool(LoKiTool)
    DaVinci().UserAlgorithms += [HepMCAllJetTuple]

    HepMCJetTuple = DecayTreeTuple("HepMCJetTuple")  #,OutputLevel = VERBOSE)
    HepMCJetTuple.InputLocations = ['Phys/StdHepMCJets/Particles']
    HepMCJetTuple.Decay = "CELLjet"
    HepMCJetTuple.ToolList = [
        'TupleToolKinematic', 'TupleToolEventInfo',
        'LoKi__Hybrid__TupleTool/LoKiTool'
    ]

    addRelationTuple(HepMCJetTuple,
                     tables['StdHepMCJets2StdJetsmeasured'],
                     InvertTable=False,
                     ReverseMatching=True,
                     extraName='Measured')
    HepMCJetTuple.StdHepMCJets2StdJetsRevMeasured.ExtraWeights = {
        'OverlapMeasured': tables['StdHepMCJets2StdJetsmeasured'].OutputTable,
        'OverlapMCtrue': tables['StdHepMCJets2StdJetsMCtrue'].OutputTable
    }

    addRelationTuple(HepMCJetTuple,
                     tables['StdHepMCJets2StdJetsMCtrue'],
                     InvertTable=False,
                     ReverseMatching=True,
                     extraName='MCtrue')
    HepMCJetTuple.StdHepMCJets2StdJetsRevMCtrue.ExtraWeights = {
        'OverlapMeasured': tables['StdHepMCJets2StdJetsmeasured'].OutputTable,
        'OverlapMCtrue': tables['StdHepMCJets2StdJetsMCtrue'].OutputTable
    }

    addRelationTuple(HepMCJetTuple,
                     tables['StdHepMCJets2StdJetsDeltaR'],
                     InvertTable=False,
                     ReverseMatching=False,
                     extraName='DeltaR')

    HepMCJetTuple.StdHepMCJets2StdJetsDeltaR.ExtraWeights = {
        'OverlapMeasured': tables['StdHepMCJets2StdJetsmeasured'].OutputTable,
        'OverlapMCtrue': tables['StdHepMCJets2StdJetsMCtrue'].OutputTable
    }

    HepMCJetTuple.addTool(LoKiTool)
    DaVinci().UserAlgorithms += [HepMCJetTuple]
DaVinci().DDDBtag = "dddb-20170721-3"
DaVinci().CondDBtag = "sim-20170721-2-vc-md100"

##### BASE DTT ##########
from Configurables import DecayTreeTuple
from DecayTreeTuple.Configuration import *
dtt = DecayTreeTuple("BaseTuple")
dtt.ToolList = ["TupleToolEventInfo",
                 "TupleToolPrimaries",
                 "TupleToolRecoStats",
                 "TupleToolCPU",
                 "TupleToolKinematic",
                 "TupleToolPid",
                 "TupleToolAngles",
                 "TupleToolDira",
                 "TupleToolL0Data",
                 "TupleToolDalitz",
                 "TupleToolPhotonInfo",
                 "TupleToolParticleStats",
                 "TupleToolCaloHypo",
                 # MC tuple tools
                 'TupleToolMCTruth',
                 'MCTupleToolEventType',
                 'MCTupleToolPrimaries',
                 'TupleToolMCBackgroundInfo']

# verbose TupleTools
dtt_geo = dtt.addTupleTool("TupleToolGeometry")
dtt_geo.Verbose = True

dtt_trk = dtt.addTupleTool("TupleToolTrackInfo")
dtt_trk.Verbose = True
        "DTF_CTAUS"         : "DTF_CTAUSIGNIFICANCE( 0, True )",
        "DTF_CHI2NDOF"      : "DTF_CHI2NDOF( True )",
        "DTF_CTAUERR"       : "DTF_CTAUERR( 0, True )",
        "DTF_MASS_constr1"  : "DTF_FUN ( M , True , strings(['J/psi(1S)']) )" ,
        "DTF_MASS_constr2"  : "DTF_FUN ( M , True , strings(['psi(2S)']) )" ,
        "DTF_VCHI2NDOF"     : "DTF_FUN ( VFASPF(VCHI2/VDOF) , True )",
    }

LoKi_Mu = LoKi__Hybrid__TupleTool("LoKi_Mu")
LoKi_Mu.Variables =  {
        "NSHAREDMU" : "NSHAREDMU"  # this apparently no longer exists or runs
    }

tuple_B2psiomega = DecayTreeTuple("Tuple")
tuple_B2psiomega.Inputs = [ location ]
tuple_B2psiomega.ToolList = tupletools[:]
# tuple_B2psiomega.Decay = '[B0 -> ^(J/psi(1S) -> ^mu+ ^mu-) ^(omega(782) -> ^pi+ ^pi- ^(pi0 -> ^gamma ^gamma ) )]CC'
tuple_B2psiomega.Decay = '[B0 -> ^(J/psi(1S) -> ^mu+ ^mu-) ^(omega(782) -> ^pi+ ^pi- ^pi0 )]CC'
tuple_B2psiomega.Branches = {
        # 'B'       : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'Jpsi'    : "[ B0 --> ^(J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'muplus'  : "[ B0 -->  (J/psi(1S) -> ^mu+  mu- ...)  (omega(782) ->  pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'muminus' : "[ B0 -->  (J/psi(1S) ->  mu+ ^mu- ...)  (omega(782) ->  pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'omega'   : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...) ^(omega(782) ->  pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'piplus'  : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) -> ^pi+  pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'piminus' : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+ ^pi-  (pi0 ->  gamma  gamma ) ) ]CC",
        # 'pizero'  : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi- ^(pi0 ->  gamma  gamma ) ) ]CC",
        # 'gamma1'  : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi-  (pi0 -> ^gamma  gamma ) ) ]CC",
        # 'gamma2'  : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi-  (pi0 ->  gamma ^gamma ) ) ]CC",
        #
        'B'       : "[ B0 -->  (J/psi(1S) ->  mu+  mu- ...)  (omega(782) ->  pi+  pi-  pi0 ) ]CC",
Exemple #31
0
inclmumu = Selection ("Sel"+name,
                     Algorithm = stripfilter,
                     RequiredSelections = [stripsel])
seq = SelectionSequence("seq",
                      TopSelection = inclmumu)


tuple = DecayTreeTuple("Incl_Tuple")

tuple.Inputs = [stripsel.outputLocation()]
tuple.ToolList =  [
      "TupleToolKinematic"
    , "TupleToolEventInfo"
    , "TupleToolRecoStats"
    , "TupleToolMCBackgroundInfo"
    , "TupleToolGeometry"
    , "TupleToolPid"
    , "TupleToolPropertime"
    , "TupleToolPrimaries"
    , "TupleToolTrackInfo"
]
MCtruth = tuple.addTupleTool("TupleToolMCTruth")
MCtruth.addTupleTool("LoKi::Hybrid::MCTupleTool/LoKi_Photos").Variables = {
    "nPhotons"  : "MCNINTREE(('gamma' == MCABSID))",
    "photons_TRUEP_X" : "MCSUMTREE(MCPX,('gamma' == MCABSID))", 
    "photons_TRUEP_Y" : "MCSUMTREE(MCPY,('gamma' == MCABSID))",
    "photons_TRUEP_Z" : "MCSUMTREE(MCPZ,('gamma' == MCABSID))", 
    "photons_TRUEP_E"  : "MCSUMTREE(MCE,('gamma'==MCABSID))" 
    }
      
tuple.addBranches ({         
Exemple #32
0
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",
    "TupleToolKinematic",
    "TupleToolPropertime",
    "TupleToolRecoStats",
    "TupleToolTrackInfo",
    "TupleToolTISTOS",
    "TupleToolBremInfo",
    "TupleToolPhotonInfo"  #, 
    ,
    "TupleToolTrackIsolation",
    "TupleToolANNPID"
]  # Probably need to add many more Tools.

tupleB.addBranches({
    "Kplus": "[B+ -> ^K+ (J/psi(1S) -> mu+ mu-)]CC",
    "Jpsi": "[B+ -> K+ ^(J/psi(1S) -> mu+ mu-)]CC",
Exemple #33
0
    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")
tuple.LoKi_Evt.VOID_Variables = {
    "nTracks": "CONTAINS('/Event/Charm/Rec/Track/Best')",
    "nPVs": "CONTAINS('/Event/Charm/Rec/Vertex/Primary')",
}
Exemple #34
0
from GaudiKernel.SystemOfUnits import MeV, GeV, cm, mm

from Configurables import DecayTreeTuple, FitDecayTrees, TupleToolRecoStats, TupleToolTrigger, TupleToolSubMass
from Configurables import TupleToolTISTOS, CondDB, SelDSTWriter
from Configurables import TupleToolTrackInfo, TupleToolRICHPid, TupleToolGeometry, TupleToolPid
from Configurables import TupleToolANNPID
from Configurables import TupleToolSLTruth
from Configurables import TupleToolTauMuDiscrVarsLcMassConstraint
from DecayTreeTuple.Configuration import *

tupleB = DecayTreeTuple("tupleout")
tupleB.Inputs = ["/Event/Semileptonic/Phys/b2LcMuXB2DMuForTauMuLine/Particles"]
tupleB.Decay = "[B+ -> ^(Lambda_c+ -> ^p+ ^K- ^pi+) ^mu+]CC"
tupleB.ToolList = [
    "TupleToolKinematic", "TupleToolEventInfo", "TupleToolRecoStats"
    #, "TupleToolGeometry"
    #,"TupleToolSLTruth"
]  # Probably need to add many more Tools.

tupleB.addBranches({
    "Lb": "[B+ -> (Lambda_c+ -> p+ K- pi+) mu+]CC",
    "Lc": "[B+ -> ^Lambda_c+ mu+]CC",
    "p": "[B+ -> (Lambda_c+ -> ^p+ K- pi+) mu+]CC",
    "pi": "[B+ -> (Lambda_c+ -> p+ K- ^pi+) mu+]CC",
    "K": "[B+ -> (Lambda_c+ -> p+ ^K- pi+) mu+]CC",
    "mu": "[B+ -> (Lambda_c+ -> p+ K- pi+) ^mu+]CC"
})

l0_lines = ['L0HadronDecision', 'L0MuonDecision', 'L0ElectronDecision']

hlt1_lines = ['Hlt1TrackMVADecision', 'Hlt1TwoTrackMVADecision']
Exemple #35
0
LoKi_psi = LoKi__Hybrid__TupleTool("LoKi_psi")
LoKi_psi.Variables = {
    "q_PV_constr_B_constr" : "DTF_FUN ( M , True , 'B+' )" ,
    "q_PV_constr" : "DTF_FUN ( M , True )" ,
    "q_B_constr"  : "DTF_FUN ( M , False , 'B+' )" ,
    "q_no_constr" : "DTF_FUN ( M , False )" ,
    }

LoKi_Mu = LoKi__Hybrid__TupleTool("LoKi_Mu")
LoKi_Mu.Variables =  {
    "NSHAREDMU" : "NSHAREDMU"
    }

tuple_B2Kmumu = DecayTreeTuple("Tuple_B2Kmumu")
tuple_B2Kmumu.Inputs = [ location ]
tuple_B2Kmumu.ToolList = tupletools[:]
tuple_B2Kmumu.Decay = '[B+ -> ^(J/psi(1S) -> ^mu+ ^mu-) ^K+]CC'
tuple_B2Kmumu.Branches = {
        "B"      : "[B+ ->  (J/psi(1S) ->  mu+  mu-)  K+]CC",
        "Kplus"  : "[B+ ->  (J/psi(1S) ->  mu+  mu-) ^K+]CC",
        "psi"    : "[B+ -> ^(J/psi(1S) ->  mu+  mu-)  K+]CC",
        "muplus" : "[B+ ->  (J/psi(1S) -> ^mu+  mu-)  K+]CC",
        "muminus": "[B+ ->  (J/psi(1S) ->  mu+ ^mu-)  K+]CC",
    }
for particle in ["B", "Kplus", "psi", "muplus", "muminus"]:
        tuple_B2Kmumu.addTool(TupleToolDecay, name = particle)

# List of the reconstructed tuples
tuples = [ tuple_B2Kmumu
    ]
Exemple #36
0
print "stripOutputLoc:",stripOutputLoc

from DecayTreeTuple.Configuration import *

dttuple = DecayTreeTuple( "DPiPiPi_NTuple" )

dttuple.ToolList = ["TupleToolGeometry",
                    "TupleToolEventInfo",
                    "TupleToolKinematic",
                    "TupleToolPrimaries",
                    "TupleToolPropertime",
                    "TupleToolAngles",
                    "TupleToolPid",
                    "TupleToolRICHPid",
                    "TupleToolDecay",
                    "TupleToolTrigger",
                    "TupleToolTISTOS",
                    "TupleToolTrackInfo",
                    "TupleToolRecoStats",
                    "TupleToolDira",
                    "TupleToolDalitz",
                    "TupleToolSubMass",
                    ]

dttuple.Inputs = [ stripOutputLoc ]

print "tuple input :",dttuple.Inputs
print "number of events:", DaVinci().EvtMax

a = "->"
def execute_option_file(path):
    # ================= BEGIN EDIT AREA =======================
    tuplename = "Bu2LLK_meLine"
    simulation_inputstring = "/Event/AllStreams/Phys/Bu2LLK_meLine/Particles"
    data_inputstring = "/Event/Leptonic/Phys/Bu2LLK_meLine/Particles"

    decaydescriptor = "[B+ -> ^[J/psi(1S) -> ^mu+ ^e-]CC ^K+]CC"
    branches = {    # Dictionary for the branches to write in the tuple
        "B"         : "[B+ -> [J/psi(1S) -> mu+ e-]CC K+]CC",
        "Psi"       : "[B+ -> ^[J/psi(1S) -> mu+ e-]CC K+]CC",
        "muplus"    : "[B+ -> [J/psi(1S) -> ^mu+ e-]CC K+]CC",
        "eminus"    : "[B+ -> [J/psi(1S) -> mu+ ^e-]CC K+]CC",
        "Kplus"     : "[B+ -> [J/psi(1S) -> mu+ mu-]CC ^K+]CC"
    }

    toollist = [  "TupleToolBremInfo"       #Bremsstrahlung information
                #, "TupleToolGeometry"       #geometry of vertex locations (ENDVERTEX, OWNPV, IP_OWNPV, FD_OWNPV, DIRA_OWNPV)
                , "TupleToolKinematic"      #kinematic variables (inv. mass MM, kin. mass M/sqrt(E^2-p^2), P, PX/Y/Z/E, PT)
                #, "TupleToolEventInfo"      #Event information such as run number, polarity, GPS time etc.
                #, "TupleToolPropertime"     #proper lifetime of reconstructed particles
                #, "TupleToolAngles"        #decay angles of charged tracks
                #, "TupleToolTrigger"
                #, "TupleToolTrackInfo"      #GhostProb of track and track type (TYPE) - 0 = unknown, 1 = velo track...
                #, "TupleToolPrimaries"      #Number and coordinates of all primary vertices
                #, "TupleToolDira"
                #, "TupleToolTrackPosition"  #Plot the X/Y position at a given Z (default: 2500 = TTstation)
                #, "TupleToolRecoStats"
                #, "TupleToolIsolationTwoBody"  #degree of isolation of two particles with common mother from Bsmumu
                #, "TupleToolANNPID"         #V2,V3,... ProbNN variables
                #, "TupleToolCaloHypo"
                #, "TupleToolL0Calo"
                ]
    # ================= END EDIT AREA =======================




    # ================= BEGIN DO NOT EDIT HERE =======================
    from Configurables import GaudiSequencer
    MySequencer = GaudiSequencer('Sequence')



    #Check whether it is a DST or MDST file
    import os.path
    extension = os.path.splitext(path)[1]
    print extension
    if extension.lower() == ".dst":
        DaVinci().InputType = 'DST'
    elif extension.lower() == ".mdst":
        DaVinci().InputType = 'MDST'
    else:
        raise Exception("Extension {extension} of {path} does not match .mdst or .dst".format(extension, path))

    #Kill some nodes if micro dst-file
    if DaVinci().InputType == 'MDST':
        from Configurables import EventNodeKiller
        eventNodeKiller = EventNodeKiller('DAQkiller')
        eventNodeKiller.Nodes = ['/Event/DAQ','/Event/pRec']
        MySequencer.Members+=[eventNodeKiller]



    #DecayTreeTuple -> Fills information about particles, vertices and daughters
    ntuple = DecayTreeTuple(tuplename)



    if DaVinci().Simulation is True: # for MC
        ntuple.Inputs = [simulation_inputstring]
    elif DaVinci().Simulation is False: # for Tuple
        ntuple.Inputs = [data_inputstring]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    ntuple.Decay = decaydescriptor
    ntuple.addBranches(branches)

    ntuple.TupleName = "DecayTree"


    #Tools added to the ToolList can not be modified i.e. no other options than the defaults can be used
    ntuple.ToolList = toollist

    MySequencer.Members.append(ntuple)






    # ================= END DO NOT EDIT HERE =======================




    if DaVinci().Simulation is True:
        from Configurables import BackgroundCategory
        backgroundinfo = ntuple.addTupleTool("TupleToolMCBackgroundInfo")           #Fills the background category
        backgroundinfo.addTool(BackgroundCategory('BackgroundCategory'))
        backgroundinfo.BackgroundCategory.SoftPhotonCut = 100000000000.                    #Ignores all photons
        MCTruth=ntuple.addTupleTool("TupleToolMCTruth")            #Saves information of MC particle associated to the current particle (you can add tools to it itself!)
        MCTruth.addTupleTool("MCTupleToolHierarchy")               #True IDs of mother and grandmother particles




    # ================= BEGIN EDIT TUPLETOOLS WITH OPTIONS ==================

    # LOKI TupleTool
    LoKi = ntuple.addTupleTool("LoKi::Hybrid::TupleTool")
    LoKi.Variables =  {
        "ETA" : "ETA",
        "PHI" : "PHI"       #Azimuthal angle
    }


    #Track isolation
    if(False):
        if DaVinci().InputType != 'MDST':
            ntuple.ToolList += ["TupleToolTrackIsolation"]


    # PID TupleTool
    if(True):
        pid = ntuple.addTupleTool("TupleToolPid")            #PID information for charged particles
        pid.Verbose = True                                   #More information like isMuonLoose etc.



    #TISTOS TupleTool
    if(False):
        from Configurables import TupleToolTISTOS

        L0Triggers = ["L0MuonDecision", "L0DiMuonDecision", "L0HadronDecision", "L0ElectronDecision", "L0PhotonDecision" ]
        ##            ['Muon',               'DiMuon',               '  Hadron',     'Electron',  'Photon','PhotonHi','ElectronHi']

        Hlt1Triggers = [  "Hlt1TrackAllL0Decision", "Hlt1TrackMuonDecision" ,"Hlt1TrackPhotonDecision" ,"Hlt1DiMuonLowMassDecision" ,"Hlt1DiMuonHighMassDecision"]

        Hlt2Triggers = [
            ## muon lines
            "Hlt2SingleMuonDecision", "Hlt2SingleMuonLowPTDecision", "Hlt2SingleMuonHighPTDecision",
            "Hlt2DiMuonDecision",  "Hlt2DiMuonLowMassDecision",
            "Hlt2DiMuonJPsiDecision",  "Hlt2DiMuonJPsiHighPTDecision",  "Hlt2DiMuonPsi2SDecision",
            "Hlt2DiMuonDetachedDecision",  "Hlt2DiMuonDetachedJPsiDecision", "Hlt2DiMuonDetachedHeavyDecision", "Hlt2TriMuonTauDecision",
            ## hadron/Topo lines
            "Hlt2B2HHDecision",
            "Hlt2DiMuonBDecision",  "Hlt2DiMuonZDecision",
            "Hlt2TopoMu2BodyBBDTDecision", "Hlt2TopoMu3BodyBBDTDecision", "Hlt2TopoMu4BodyBBDTDecision",
            "Hlt2TopoE2BodyBBDTDecision", "Hlt2TopoE3BodyBBDTDecision", "Hlt2TopoE4BodyBBDTDecision",
            "Hlt2Topo2BodyBBDTDecision",   "Hlt2Topo3BodyBBDTDecision",   "Hlt2Topo4BodyBBDTDecision",
            ##others
            "Hlt2PassThroughDecision",
            "Hlt2TransparentDecision",
            ## inclusive decisions
            "Hlt2DiMuonDY.*Decision","Hlt2TopoE.*Decision", "Hlt2Topo.*Decision",  "Hlt2Charm.*Decision", "Hlt2DiElectron.*Decision"
            ]

        triggerList = L0Triggers + Hlt1Triggers + Hlt2Triggers

        ntuple.addTupleTool("TupleToolTISTOS")
        ntuple.TupleToolTISTOS.VerboseL0 = True
        ntuple.TupleToolTISTOS.VerboseHlt1 = True
        ntuple.TupleToolTISTOS.VerboseHlt2 = True
        ntuple.TupleToolTISTOS.FillL0 = True
        ntuple.TupleToolTISTOS.FillHlt1 = True
        ntuple.TupleToolTISTOS.FillHlt2 = True
        ntuple.TupleToolTISTOS.OutputLevel = INFO
        ntuple.TupleToolTISTOS.TriggerList = triggerList



    #DecayTreeFitter
    if(False):
        fitter = ntuple.B.addTupleTool("TupleToolDecayTreeFitter/FIX_JPSI")
        fitter.constrainToOriginVertex = False
        fitter.daughtersToConstrain = [ "J/psi(1S)" ]
        fitter.Verbose = True





    #Isolation tool from Alex
    weightsfolder = "./"
    if(False):
        from Configurables import TupleToolApplyIsolation
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationHard")
        ntuple.B.TupleToolApplyIsolationHard.OutputSuffix="_Hard"
        ntuple.B.TupleToolApplyIsolationHard.WeightsFile= weightsfolder+"weightsHard.xml"
        ntuple.B.addTupleTool(TupleToolApplyIsolation, name="TupleToolApplyIsolationSoft")
        ntuple.B.TupleToolApplyIsolationSoft.OutputSuffix="_Soft"
        ntuple.B.TupleToolApplyIsolationSoft.WeightsFile= weightsfolder+"weightsSoft.xml"
        ntuple.B.addTupleTool("TupleToolVtxIsoln")
        #ntuple.B.TupleToolApplyIsolationHard.OutputLevel = 3
        #ntuple.B.TupleToolApplyIsolationSoft.OutputLevel = 3

    #Tool from B2ee
    if(False):
        from Configurables import TupleToolMuonVariables
        ntuple.addTupleTool("TupleToolMuonVariables")
        if DaVinci().InputType == 'MDST':
            ntuple.TupleToolMuonVariables.TrackContainer = "/Event/Leptonic/Rec/Track/Best"         #Change in case of MDST!
        ntuple.TupleToolMuonVariables.BDTSRootFile = weightsfolder+"HflatBDTS_7Dec.root"
        ntuple.TupleToolMuonVariables.BDTSXMLFile  = weightsfolder+"TMVA_7Dec.weights.xml"





    #Settings for TupleToolTrackHits (some only are necessary for MDST-files because of other locations of the clusters)
    if(True):   #Change this value if you don't want to use this tool
        from Configurables import TupleToolTrackHits, STOfflinePosition
        trackhits = ntuple.addTupleTool("TupleToolTrackHits")
        trackhits.Verbose = True

        if DaVinci().InputType == 'MDST':
            from Configurables import MeasurementProvider
            ntuple.addTool(MeasurementProvider('MeasProvider'))
            ntuple.MeasProvider.RootInTES = "/Event/Leptonic/"        #Change Leptonic for your stream-name in case of MDST
            trackhits.MeasurementProvider = ntuple.MeasProvider

        itClusterPosition = STOfflinePosition('ToolSvc.ITClusterPosition')      #avoid crashes from missing IT channels
        itClusterPosition.DetType = 'IT'


    #Settings for TupleToolAllPhotons (only works for fullDST files)
    #Should be always added to only one branch
    if(DaVinci().InputType == 'DST'):
        if(True):
            from Configurables import TupleToolAllPhotons, STOfflinePosition
            allphotons = ntuple.eminus.addTupleTool("TupleToolAllPhotons")
            allphotons.MCTruth = True
            allphotons.PhotonsLocation = "/Event/Phys/StdVeryLooseAllPhotons/Particles"

            itClusterPosition = STOfflinePosition('ToolSvc.ITClusterPosition')      #avoid crashes from missing IT channels
            itClusterPosition.DetType = 'IT'
            #allphotons.PhotonsLocation = "/Event/Phys/StdLooseAllPhotons/Particles"



    #Settings for TupleToolBremRemover
    #Should be always added to specific branches
    if(True):
        from Configurables import TupleToolBremRemover
        bremremover = ntuple.eminus.addTupleTool("TupleToolBremRemover")
        if DaVinci().Simulation is True:
            bremremover.TRUEP = True


    #TupleToolTrackKink: Refits the track and outputs kink as point with highest Chi2 variation (should be run last because of the refit)
    if(False):
        ntuple.eminus.addTupleTool("TupleToolTrackKink")

    # ================= END EDIT TUPLETOOLS WITH OPTIONS ==================




    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().UserAlgorithms = [MySequencer]
    DaVinci().MoniSequence += [ntuple]
    DaVinci().EvtMax     = -1
    DaVinci().SkipEvents = 0
    DaVinci().Lumi       = True
Exemple #38
0
    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
        ]

        # Other event infos
        tuple.addTupleTool("LoKi::Hybrid::EvtTupleTool/LoKi_Evt")
        if dataSample.isMC:
            tuple.LoKi_Evt.VOID_Variables = {
                # "nSPDHits" :  " CONTAINS('Raw/Spd/Digits')  " ,
                "nTracks": "TrSOURCE('Rec/Track/Best') >> TrSIZE",
                "nPVs": "CONTAINS('Rec/Vertex/Primary')",
            }
        else:
            tuple.LoKi_Evt.VOID_Variables = {
                # "nSPDHits" :  " CONTAINS('Raw/Spd/Digits')  " ,
                "nTracks": "CONTAINS('/Event/Charm/Rec/Track/Best')",
                "nPVs": "CONTAINS('/Event/Charm/Rec/Vertex/Primary')",
            }

        # # 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_CTAU_Ks1": "DTF_CTAU(1, True, strings('KS0') )",
            "DTF_CTAU_Ks2": "DTF_CTAU(2, True, strings('KS0') )",
            "DTF_DT": "DTF_CTAU(1, True, strings('KS0') )- DTF_CTAU(2, True, strings('KS0') )",
            "DTF_ADT": "abs(DTF_CTAU(1, True, strings('KS0') )- DTF_CTAU(2, True, strings('KS0') ))",
        }

        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]
tupleB.Decay = decay



tupleB.ToolList =  [
      "TupleToolKinematic"
      , "TupleToolEventInfo"
      , "TupleToolRecoStats"
      ,"TupleToolMCBackgroundInfo",#comment out for data
      "TupleToolMCTruth", #comment out for data
      "TupleToolTrigger",
      "TupleToolPid",
      "TupleToolPrimaries",
      "TupleToolAngles",
      "TupleToolEventInfo",
      "TupleToolGeometry",
      "TupleToolKinematic",
      "TupleToolPropertime",
      "TupleToolRecoStats",
      "TupleToolTrackInfo",
      "TupleToolTISTOS",
      "TupleToolBremInfo",
      "TupleToolPhotonInfo"#,
      ,"TupleToolTrackIsolation"
      , "TupleToolANNPID"
      
] # Probably need to add many more Tools.



def execute_option_file(path):

    from Configurables import GaudiSequencer
    MySequencer = GaudiSequencer('Sequence')


    #Check whether it is a DST or MDST file
    import os.path
    extension = os.path.splitext(path)[1]
    print extension
    if extension.lower() == ".dst":
        DaVinci().InputType = 'DST'
    elif extension.lower() == ".mdst":
        DaVinci().InputType = 'MDST'
    else:
        raise Exception("Extension {extension} of {path} does not match .mdst or .dst".format(extension, path))

    #Kill some nodes if micro dst-file
    if DaVinci().InputType == 'MDST':
        from Configurables import EventNodeKiller
        eventNodeKiller = EventNodeKiller('DAQkiller')
        eventNodeKiller.Nodes = ['/Event/DAQ','/Event/pRec']
        MySequencer.Members+=[eventNodeKiller]




    #Create DecayTreeTuple -> Fills information about particles, vertices and daughters
    data = DecayTreeTuple('Bu2LLK_meLine')

    #Set root "folder" for MDST - better don't do this as it most likely causes a crash
    #Instead set RootInTES for the particular Tool (e.g. TupleToolTrackHits that needs it)
    #if DaVinci().InputType == 'MDST':
    #    data.RootInTES = "/Event/Leptonic"


    if DaVinci().Simulation is True: # for MC
        data.Inputs = ["/Event/AllStreams/Phys/Bu2LLK_meLine/Particles"]
    elif DaVinci().Simulation is False: # for Tuple
        data.Inputs = ["/Event/Leptonic/Phys/Bu2LLK_meLine/Particles"]
    else:
        raise Exception(" `DaVinci().Simulation` not set.")

    data.Decay = "[B+ -> ^[J/psi(1S) -> ^mu+ ^e-]CC ^K+]CC"
    data.addBranches({
        "B"         : "[B+ -> [J/psi(1S) -> mu+ e-]CC K+]CC",
        "Psi"       : "[B+ -> ^[J/psi(1S) -> mu+ e-]CC K+]CC",
        "muplus"    : "[B+ -> [J/psi(1S) -> ^mu+ e-]CC K+]CC",
        "eminus"   : "[B+ -> [J/psi(1S) -> mu+ ^e-]CC K+]CC",
        "Kplus"     : "[B+ -> [J/psi(1S) -> mu+ mu-]CC ^K+]CC"
        })

    data.TupleName = "DecayTree"


    #TupleTools

    #Tools added to the ToolList can not be modified i.e. no other options than the defaults can be used
    data.ToolList = [

        ]


    #Settings for TupleToolTrackHits (some only are necessary for MDST-files because of other locations of the clusters)
    if(True):   #Change this value if you don't want to use this tool
        from Configurables import TupleToolTrackHits, STOfflinePosition
        trackhits = data.addTupleTool("TupleToolTrackHits")

        if DaVinci().InputType == 'MDST':
            from Configurables import MeasurementProvider
            data.addTool(MeasurementProvider('MeasProvider'))
            data.MeasProvider.RootInTES = "/Event/Leptonic/"        #Change Leptonic for your stream-name in case of MDST
            trackhits.MeasurementProvider = data.MeasProvider

        itClusterPosition = STOfflinePosition('ToolSvc.ITClusterPosition')      #avoid crashes from missing IT channels
        itClusterPosition.DetType = 'IT'






    MySequencer.Members.append(data)






    ################################
    ###   DaVinci configuration ####
    ################################

    DaVinci().UserAlgorithms = [MySequencer]
    DaVinci().MoniSequence += [data]
    DaVinci().EvtMax     = 5000
    DaVinci().Lumi       = True
    DaVinci().SkipEvents = 0
    "B": "[B+ -> ( J/psi(1S)  -> mu-  mu+ ) pi+ ]CC",
    "Jpsi": "[B+ -> ^(J/psi(1S)  -> mu-  mu+) pi+]CC",
    "mu_prim": "[B+ -> (J/psi(1S) -> mu- ^mu+) pi+]CC",
    "mu_sec": "[B+ -> (J/psi(1S) -> ^mu- mu+) pi+]CC",
    "pi": "[B+ -> (J/psi(1S) -> mu- mu+) ^pi+]CC",
}

tuple.ToolList = [
    "TupleToolKinematic",
    "TupleToolPid",
    "TupleToolGeometry",
    "TupleToolPrimaries",
    "TupleToolTrackInfo",
    "TupleToolEventInfo",
    "TupleToolAngles",
    "TupleToolANNPID",
    "TupleToolMCBackgroundInfo",
    "TupleToolMCTruth",
    "TupleToolTrigger",
    "TupleToolDira",
    "TupleToolEventInfo",
    "TupleToolPropertime",
    "TupleToolRecoStats",
]

trigger_list = [
    'L0MuonDecision', 'L0DiMuonDecision', 'L0HadronDecision',
    'Hlt1TrackAllL0Decision', 'Hlt1TrackMuonDecision', 'Hlt1TrackMVADecision',
    'Hlt1TwoTrackMVADecision', 'Hlt1TrackMVALooseDecision',
    'Hlt1TwoTrackMVALooseDecision', 'Hlt2TopoMu2BodyBBDTDecision',
    'Hlt2TopoMu3BodyBBDTDecision', 'Hlt2Topo2BodyDecision',
Exemple #42
0
# Use same tags as Gauss (from Gauss/options/Gauss-2012.py)
LHCbApp().DDDBtag = "dddb-20180726-2"
LHCbApp().CondDBtag = "sim-20160321-2-vc-md100"
LHCbApp().Simulation = True

# we did not run Moore, so force the TCK check to false.
L0Conf().EnsureKnownTCK = False

tup = DecayTreeTuple('electrons')
tup.Decay = '[e-]CC'
#tup.setDescriptorTemplate('${eminus}[e-]CC')
tup.Inputs = ["Phys/StdAllLooseElectrons/Particles"]
#tup.ReFitPVs = True

tup.ToolList = []
tup.addTupleTool("TupleToolKinematic")  # Momenta
tup.addTupleTool("TupleToolBremInfo")  # Info on photon that was BremAdded
tup.addTupleTool("TupleToolCaloInfo")  # (custom) dump of ECAL clusters
tup.addTupleTool(
    "TupleToolInfoAtCalo")  # (custom) info on extrapolated position at ECAL

mctruthtool = tup.addTupleTool("TupleToolMCTruth")
mctruthtool.ToolList += ["MCTupleToolPhotonDaughters"
                         ]  # (custom) info of MC bremphoton daughters

nobremtool = tup.addTupleTool('LoKi::Hybrid::TupleTool/nobremtool')
nobremtool.Variables = {
    'nobrem_P': 'PPINFO(504,-100,-200)',
    'nobrem_PT': 'PPINFO(505,-100,-200)',
}
Exemple #43
0
LoKi_B = LoKi__Hybrid__TupleTool("LoKi_B")
LoKi_B.Variables = {
    "ETA": "ETA",
    "PHI": "PHI",
    "FDCHI2": "BPVVDCHI2",
    "FDS": "BPVDLS",
    "DIRA": "BPVDIRA",
    "pi0veto": "CHILDFUN ( PINFO( 25030 , -1 ) , 'gamma' == ABSID ) ",
}

LoKi_Mu = LoKi__Hybrid__TupleTool("LoKi_Mu")
LoKi_Mu.Variables = {"NSHAREDMU": "NSHAREDMU"}

tuple_B2Kmumu = DecayTreeTuple("Tuple")
tuple_B2Kmumu.Inputs = [location]
tuple_B2Kmumu.ToolList = tupletools[:]
tuple_B2Kmumu.Decay = '[Lambda_b0 -> ^(chi_c1(1P) -> ^(J/psi(1S) -> ^mu+ ^mu-) ^gamma) ^p+ ^K-]CC'
tuple_B2Kmumu.Branches = {
    "Lambda_b0":
    "[Lambda_b0 ->  (chi_c1(1P) ->  (J/psi(1S) ->  mu+  mu-)  gamma)  p+  K-]CC",
    "chi_c":
    "[Lambda_b0 -> ^(chi_c1(1P) ->  (J/psi(1S) ->  mu+  mu-)  gamma)  p+  K-]CC",
    "Jpsi":
    "[Lambda_b0 ->  (chi_c1(1P) -> ^(J/psi(1S) ->  mu+  mu-)  gamma)  p+  K-]CC",
    "gamma":
    "[Lambda_b0 ->  (chi_c1(1P) ->  (J/psi(1S) ->  mu+  mu-) ^gamma)  p+  K-]CC",
    "muplus":
    "[Lambda_b0 ->  (chi_c1(1P) ->  (J/psi(1S) -> ^mu+  mu-)  gamma)  p+  K-]CC",
    "muminus":
    "[Lambda_b0 ->  (chi_c1(1P) ->  (J/psi(1S) ->  mu+ ^mu-)  gamma)  p+  K-]CC",
    "proton":
Exemple #44
0
#PROBNNmu not available in 2015 Turbo(++)

from Configurables import CondDB
CondDB(LatestGlobalTagByDataType=the_year)

## (5) fill tuple
from Configurables import DecayTreeTuple, TupleToolPrimaries
tuple = DecayTreeTuple("DecayTree")
tuple.Inputs = [StripSel1.outputLocation()]
tuple.Decay = decay
tuple.ToolList = [
    "TupleToolKinematic",
    "TupleToolPid",
    "TupleToolANNPID",
    "TupleToolPropertime",
    "TupleToolGeometry",
    "TupleToolPrimaries",
    "TupleToolTrackInfo",
    "TupleToolEventInfo",
    "TupleToolRecoStats"  #,
]
tuple.Branches = {
    "B": "[B+ -> ( J/psi(1S)  -> mu-  mu+ ) pi+ ]CC",
    "Jpsi": "[B+ -> ^(J/psi(1S)  -> mu-  mu+) pi+]CC",
    "mu_prim": "[B+ -> (J/psi(1S) -> mu- ^mu+) pi+]CC",
    "mu_sec": "[B+ -> (J/psi(1S) -> ^mu- mu+) pi+]CC",
    "pi": "[B+ -> (J/psi(1S) -> mu- mu+) ^pi+]CC",
}
########################################################################
from Configurables import TupleToolGeometry
tuple.addTool(TupleToolGeometry, name="TupleToolGeometry")