Newer
Older
Analysis / ganga / Lb2Lcmunu / Lb2Lcmunu_S24_data2015_NEWJET.py
@elena elena on 1 Feb 2016 11 KB comma was missing
########################################################################
from os import environ
import math
from Gaudi.Configuration import *
#from GaudiPython import AppMgr
from Configurables import DecayTreeTuple, BTaggingTool, SubstitutePID, TrackScaleState
from Configurables import CombineParticles, FilterDesktop, TupleToolDecayTreeFitter, TupleToolDecay
from Configurables import TupleToolTrigger, BackgroundCategory, TupleToolTISTOS, TupleToolRecoStats, TupleToolTagging
from Configurables import DaVinci, HltSelReportsDecoder, HltVertexReportsDecoder, HltDecReportsDecoder, LoKi__Hybrid__TupleTool, TupleToolJets
from DecayTreeTuple.Configuration import *
from StrippingConf.Configuration import StrippingConf, StrippingStream
from StrippingSettings.Utils import strippingConfiguration
from StrippingArchive.Utils import buildStreams, cloneLinesFromStream
from Configurables import CombineParticles
from StrippingArchive import strippingArchive


trigger_list = [
    'L0HadronDecision',
    'L0ElectronDecision',
    'L0ElectronHiDecision',
    'L0MuonDecision',
    'L0DiMuonDecision',


    # 'Hlt1SingleMuonNoIPDecision',
    # 'Hlt1SingleMuonHighPTDecision',
    # 'Hlt1DiMuonHighMassDecision',
    # 'Hlt1DiMuonLowMassDecision',
    'Hlt1GlobalDecision',
    'Hlt1TrackAllL0Decision',
    'Hlt1SingleMuonNoIPDecision',
    'Hlt1SingleMuonHighPTDecision',
    'Hlt1TrackMuonDecision',
    'Hlt1MuTrackDecision',
    # 'Hlt1GlobalDecision',

    'Hlt2TopoOSTF2BodyDecision',
    'Hlt2TopoOSTF3BodyDecision',
    'Hlt2TopoOSTF4BodyDecision',
    'Hlt2Topo2BodySimpleDecision',
    'Hlt2Topo3BodySimpleDecision',
    'Hlt2Topo4BodySimpleDecision',
    'Hlt2Topo2BodyBBDTDecision',
    'Hlt2Topo3BodyBBDTDecision',
    'Hlt2Topo4BodyBBDTDecision',
    'Hlt2TopoMu2BodyBBDTDecision',
    'Hlt2TopoMu3BodyBBDTDecision',
    'Hlt2TopoMu4BodyBBDTDecision',
    'Hlt2TopoE2BodyBBDTDecision',
    'Hlt2TopoE3BodyBBDTDecision',
    'Hlt2TopoE4BodyBBDTDecision',
    # 'Hlt2MuonFromHLT1Decision',
    'Hlt2SingleMuonDecision',
    # 'Hlt2SingleMuonHighPTDecision',
    # 'Hlt2SingleMuonLowPTDecision',
    # 'Hlt2DisplVerticesLowMassSingleDecision',
    # 'Hlt2DisplVerticesHighMassSingleDecision',
    # 'Hlt2DisplVerticesDoubleDecision',
    # 'Hlt2DisplVerticesSinglePostScaledDecision',
    # 'Hlt2DisplVerticesHighFDSingleDecision',
    # 'Hlt2DisplVerticesSingleDownDecision',
    # 'Hlt2DiMuonDecision',
    # 'Hlt2DiMuonLowMassDecision',
    # 'Hlt2DiMuonBDecision',
    'Hlt2DiMuonDetachedDecision',
    'Hlt2MuTrackDecision',
    'Hlt2GlobalDecision'
]


###########################################################################
# First run the stripping

eventNodeKiller = EventNodeKiller('Stripkiller')
eventNodeKiller.Nodes = [ '/Event/AllStreams', '/Event/Strip' ]


stripping = 'stripping24'
#get the configuration dictionary from the database
config  = strippingConfiguration(stripping)
#get the line builders from the archive
archive = strippingArchive(stripping)
streams = buildStreams(stripping = config, archive = archive)
MyStream = StrippingStream("MyStream")
MyLines = [ 'Strippingb2LcMuXB2DMuForTauMuLine' ]

for stream in streams:
    for line in stream.lines:
        if line.name() in MyLines:
            print 'Strippingb2LcMuXB2DMuForTauMuLine'
            MyStream.appendLines( [ line ] )


from Configurables import ProcStatusCheck
filterBadEvents = ProcStatusCheck()

sc = StrippingConf( Streams = [ MyStream ],
                    MaxCandidates = 2000,
                    AcceptBadEvents = False,
                    BadEventSelection = filterBadEvents )

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


#from StandardParticles import StdAllLoosePions


Lc_star = CombineParticles("Lc_star")
Lc_star.Inputs = ["Phys/StdAllLoosePions/Particles", "Phys/Lc2pKPiforB2DMuForTauMu/Particles"]
Lc_star.DecayDescriptors = ["[Lambda_c(2595)+ -> Lambda_c+ pi+ pi-]cc"]
Lc_star.MotherCut = "(M<3000) & (M>2300) & (VFASPF(VCHI2/VDOF) < 7.0) "
Lc_star.DaughtersCuts = { "pi+": "PT>0", "pi-": "PT>0", "Lambda_c+": "ADMASS('Lambda_c+') < 50.0 *MeV" }
#############################################################################

# Tau_3pi = CombineParticles("Tau_3pi")
# Tau_3pi.Inputs = ['Phys/StdLoosePions/Particles']
# Tau_3pi.DecayDescriptors = ['[tau+ -> pi+ pi- pi+]cc']
# Tau_3pi.MotherCut = "(M>400.*MeV) & (M < 3500.*MeV) & (BPVDIRA>0.99) & (VFASPF(VCHI2) < 25 )"
# Tau_3pi.DaughtersCuts = {'pi+': '(PT>150.*MeV) & (MIPCHI2DV(PRIMARY) > 4.0) & (TRCHI2DOF<4) & (TRGHOSTPROB<0.4) & (PIDK < 8)', 'pi-': '(PT>150.*MeV) & (MIPCHI2DV(PRIMARY) > 4.0) & (TRCHI2DOF<4) & (TRGHOSTPROB<0.4) & (PIDK < 8)'}
# Tau_3pi.CombinationCut = "((AM>400.*MeV) & (AM<3500.*MeV)) & (ADOCAMAX('')<0.15*mm) & ((AM12<1670.*MeV) or (AM23<1670.*MeV)) & (ANUM(PT < 300*MeV) <= 1) & (15)))"

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

Lb_SL = CombineParticles("Lb_SL")
Lb_SL.Inputs = [ "Phys/MuforB2DMuForTauMu/Particles", "Phys/Lc_star/Particles"]
Lb_SL.DecayDescriptors = [ "[Lambda_b0 -> Lambda_c(2595)+ mu-]cc" ]
Lb_SL.MotherCut = "(M<6500) & (VFASPF(VCHI2/VDOF) < 7.0) & (BPVDIRA>0.999)"

############## WRONG SIGN COMBINATION #######################################

Lb_SL_WS = CombineParticles("Lb_SL_WS")
Lb_SL_WS.Inputs = [ "Phys/MuforB2DMuForTauMu/Particles", "Phys/Lc_star/Particles"]
Lb_SL_WS.DecayDescriptors = [ "[Lambda_b0 -> Lambda_c(2595)+ mu+]cc" ]
Lb_SL_WS.MotherCut = "(M<6500) & (VFASPF(VCHI2/VDOF) < 7.0) & (BPVDIRA>0.999)"


'''
################################################################################
Lb_SLSel = CombineParticles("Lb_SLSel")
Lb_SLSel.Preambulo=JJACUT
Lb_SLSel.Inputs  = ["Phys/Lb_SL/Particles","Phys/StdJetsJEC/Particles"]

Lb_SLSel.DecayDescriptors  = ["[H_10 -> Lambda_b0 CELLjet]cc"]
Lb_SLSel.Preambulo = JJACUT

Lb_SLSel.MotherCut = "(M<15000)"
Lb_SLSel.CombinationCut = "(AM < 15000)&(DR<1.5)"
'''


########################################################################
decay0 = "[Lambda_b0 -> ^(Lambda_c(2595)+ -> ^(Lambda_c+ -> ^K- ^p+ ^pi+ ) ^pi+ ^pi-) ^mu- ]CC"
decay0_WS = "[Lambda_b0 -> ^(Lambda_c(2595)+ -> ^(Lambda_c+ -> ^K- ^p+ ^pi+ ) ^pi+ ^pi-) ^mu+ ]CC"
########################################################################
Lb_SL_OfflineTree = DecayTreeTuple("Lb_SL_OfflineTree")
Lb_SL_OfflineTree.Inputs = ["Phys/Lb_SL/Particles"]
Lb_SL_OfflineTree.Decay = decay0
Lb_SL_OfflineTree.Branches = {
    "Lambda_b0": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu- ]CC",
    "Lambda_c_STAR": "[Lambda_b0 -> ^(Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu- ]CC",
    "mu": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) ^mu- ]CC",
    "Lambda_c": "[Lambda_b0 -> (Lambda_c(2595)+ -> ^(Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu- ]CC",
    "pi_plus": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) ^pi+ pi-) mu- ]CC",
    "pi_minus": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ ^pi-) mu- ]CC",
    "p": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- ^p+ pi+ ) pi+ pi-) mu- ]CC",
    "pi_Lc": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ ^pi+ ) pi+ pi-) mu- ]CC",
    "K_Lc": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> ^K- p+ pi+ ) pi+ pi-) mu- ]CC"
}

Lb_SL_WS_OfflineTree = DecayTreeTuple("Lb_SL_WS_OfflineTree")
Lb_SL_WS_OfflineTree.Inputs = ["Phys/Lb_SL_WS/Particles"]
Lb_SL_WS_OfflineTree.Decay = decay0_WS
Lb_SL_WS_OfflineTree.Branches = {
    "Lambda_b0": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu+ ]CC",
    "Lambda_c_STAR": "[Lambda_b0 -> ^(Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu+ ]CC",
    "mu": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ pi-) ^mu+ ]CC",
    "Lambda_c": "[Lambda_b0 -> (Lambda_c(2595)+ -> ^(Lambda_c+ -> K- p+ pi+ ) pi+ pi-) mu+ ]CC",
    "pi_plus": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) ^pi+ pi-) mu+ ]CC",
    "pi_minus": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ pi+ ) pi+ ^pi-) mu+ ]CC",
    "p": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- ^p+ pi+ ) pi+ pi-) mu+ ]CC",
    "pi_Lc": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> K- p+ ^pi+ ) pi+ pi-) mu+ ]CC",
    "K_Lc": "[Lambda_b0 -> (Lambda_c(2595)+ -> (Lambda_c+ -> ^K- p+ pi+ ) pi+ pi-) mu+ ]CC"
}

from Configurables import TupleToolNeutrinoReco
from Configurables import TupleToolKinematic
from Configurables import TupleToolGeometry
from Configurables import TupleToolTrackIsolation


for DTT in [Lb_SL_OfflineTree, Lb_SL_WS_OfflineTree]:
    DTT.ToolList = [
        "TupleToolKinematic",
        "TupleToolPid",
        "TupleToolGeometry",
        "TupleToolPrimaries",
        "TupleToolTrackInfo",
        "TupleToolEventInfo",
        "TupleToolRecoStats",
        "TupleToolAngles",
        "TupleToolNeutrinoReco",
        "TupleToolMCBackgroundInfo",
        "TupleToolMCTruth",
        "TupleToolJets",
        'TupleToolTrigger',
        'TupleToolTISTOS',
        'TupleToolRICHPid',
        'TupleToolDira',
        'TupleToolEventInfo',
        'TupleToolPropertime',
        'TupleToolRecoStats',
        'TupleToolTrackPosition'
    ]
    DTT.addTool( TupleToolTrigger, name='TupleToolTrigger' )
    DTT.TupleToolTrigger.Verbose = True
    DTT.TupleToolTrigger.TriggerList = trigger_list
    DTT.addTool( TupleToolTISTOS, name='TupleToolTISTOS' )
    DTT.TupleToolTISTOS.Verbose = True
    DTT.TupleToolTISTOS.TriggerList = trigger_list
    DTT.ToolList += [ "TupleToolTISTOS" ]
    DTT.addTool( TupleToolNeutrinoReco, name = "TupleToolNeutrinoReco" )
    DTT.TupleToolNeutrinoReco.Verbose = True
    DTT.TupleToolNeutrinoReco.MotherMass = 5619.5  # MeV
    DTT.TupleToolNeutrinoReco.ExtraName = 'mLb'
    DTT.addTool( TupleToolKinematic, name = "TupleToolKinematic" )
    DTT.TupleToolKinematic.Verbose = True
    DTT.addTool( TupleToolGeometry, name = "TupleToolGeometry" )
    DTT.TupleToolGeometry.Verbose = True
    DTT.addTool(TupleToolRecoStats, name="TupleToolRecoStats")
    DTT.TupleToolRecoStats.Verbose = True
    DTT.UseLabXSyntax = True
    DTT.RevertToPositiveID = False
    DTT.addTupleTool('TupleToolTrackIsolation/TrackIsolation')
    DTT.TrackIsolation.MinConeAngle = 0.5
    DTT.TrackIsolation.MaxConeAngle = 1.5
    DTT.TrackIsolation.StepSize = 0.1
    DTT.TrackIsolation.Verbose = True


##################################################
#DaVinci().Input = ([
#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/MC/2012/ALLSTREAMS.DST/00025296/0000/00025296_00000002_1.allstreams.dst'
#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/MC/2012/ALLSTREAMS.DST/00025296/0000/00025296_00000003_1.allstreams.dst',
#'root://eoslhcb.cern.ch//eos/lhcb/grid/prod/lhcb/MC/2012/ALLSTREAMS.DST/00025296/0000/00025296_00000004_1.allstreams.dst'
#])
from Configurables import DaVinci
#DaVinci().EventPreFilters = fltrs.filters('Filters')
DaVinci().EvtMax = -1                          # Number of events
DaVinci().SkipEvents = 0                       # Events to skip
DaVinci().PrintFreq = 10000
DaVinci().Simulation = False
DaVinci().Lumi = True
DaVinci().appendToMainSequence( [ eventNodeKiller ] )
DaVinci().appendToMainSequence( [ sc.sequence() ] )
DaVinci().UserAlgorithms = [    HltSelReportsDecoder(),
                                HltVertexReportsDecoder(),
                                HltDecReportsDecoder(),
                                Lc_star, Lb_SL, Lb_SL_WS,
                                Lb_SL_OfflineTree, Lb_SL_WS_OfflineTree]
DaVinci().TupleFile = "Lb_Lcstarmunu.root"

#DaVinci().CondDBtag = "Sim08-20130503-1-vc-md100"
#DaVinci().DDDBtag   = "Sim08-20130503-1"
#appMgr = AppMgr()
#appMgr.initialize()
#appMgr.run( DaVinci().EvtMax )