Exemple #1
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'"]
from Gaudi.Configuration import *
from Configurables import (DaVinci, GaudiSequencer)
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"
Exemple #3
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'"
            ]