Exemplo n.º 1
0
    def _unpackProtoParticles(self):

        from Configurables import (GaudiSequencer, UnpackProtoParticle)

        # Neutrals
        # --------

        neutralLoc = "/Event/Rec/ProtoP/Neutrals"
        unpackNeutrals = UnpackProtoParticle(
            name="UnpackNeutralProtos",
            OutputName=neutralLoc,
            InputName="/Event/pRec/ProtoP/Neutrals")
        DataOnDemandSvc().AlgMap[neutralLoc] = unpackNeutrals

        # Charged
        # -------

        chargedLoc = "/Event/Rec/ProtoP/Charged"
        chargedSeq = GaudiSequencer("UnpackChargedProtosSeq")
        DataOnDemandSvc().AlgMap[chargedLoc] = chargedSeq

        # Unpacker
        unpackCharged = UnpackProtoParticle(
            name="UnpackChargedProtos",
            OutputName=chargedLoc,
            InputName="/Event/pRec/ProtoP/Charged")
        chargedSeq.Members += [unpackCharged]

        # Additional processing, not for MDST
        inputtype = self.getProp('DstType').upper()
        if inputtype != 'MDST':

            # PID calibration
            from Configurables import (ChargedProtoParticleAddRichInfo,
                                       ChargedProtoParticleAddMuonInfo,
                                       ChargedProtoCombineDLLsAlg, TESCheck)
            recalib = GaudiSequencer("ProtoParticleCombDLLs")
            recalib.IgnoreFilterPassed = False
            chargedSeq.Members += [recalib]
            # Filter to check in Protos exist
            recalib.Members += [
                TESCheck(name="CheckChargedProtosExist",
                         Inputs=[chargedLoc],
                         OutputLevel=5,
                         Stop=False)
            ]
            # Add Rich and Muon PID results to protoparticles
            recalib.Members += [
                ChargedProtoParticleAddMuonInfo("ChargedProtoPAddMuon")
            ]
            recalib.Members += [
                ChargedProtoParticleAddRichInfo("ChargedProtoPAddRich")
            ]
            # Combined DLLs
            recalib.Members += [
                ChargedProtoCombineDLLsAlg("ChargedProtoPCombDLL")
            ]
Exemplo n.º 2
0
 def _configureHistos(self):
     monitorSeq = GaudiSequencer('TelaMonitors')
     monitorSeq.IgnoreFilterPassed = True 
     monitorSeq.Members += self.getProp('Monitors')
     self.teslaSeq.Members += [ monitorSeq ]
     #
     ApplicationMgr().HistogramPersistency = "ROOT"
     
     if ( self.getProp("Histogram") != "" ):
         HistogramPersistencySvc().OutputFile = self.getProp("Histogram")
Exemplo n.º 3
0
 def redoMCLinks(self,init):
     """
     Redo MC links.
     """
     
     if ( self.getProp("Simulation") ):
         redo = self.getProp("RedoMCLinks")
         if ( redo ):
             from Configurables import (GaudiSequencer,TESCheck,EventNodeKiller,TrackAssociator)
             mcKillSeq = GaudiSequencer("KillMCLinks") # The sequence killing the node of it exists
             tescheck = TESCheck("DaVinciEvtCheck")    # Check for presence of node ...
             tescheck.Inputs = ["Link/Rec/Track/Best"] # 
             tescheck.Stop = False                     # But don't stop
             tescheck.OutputLevel = 5                  # don't print warnings
             evtnodekiller = EventNodeKiller("DaVinciEvtNodeKiller") # kill nodes
             evtnodekiller.Nodes = ["Link/Rec/Track"]        # Kill that
             mcKillSeq.Members = [ tescheck, evtnodekiller, TrackAssociator() ]                  
             mcLinkSeq = GaudiSequencer("RedoMCLinks") # The sequence redoing the links
             mcLinkSeq.IgnoreFilterPassed = True       # Run it always
             mcLinkSeq.Members = [ mcKillSeq, TrackAssociator() ]  
             init.Members += [ mcLinkSeq ]
Exemplo n.º 4
0
    lb_combine.DaughtersCuts = lb_daughters
    lb_combine.MotherCut = lb_mother
    # Output of combining Lc daughters is input to combining Lb daughters
    lb_combine.Inputs = [
        "Phys/StdAllNoPIDsMuons",
        "Phys/{0}".format(lc_combine_name)
    ]
    # Clone the DecayTreeTuple created above
    cheat_tuple = tuple.clone("Tuple{0}".format(lb_combine_name))
    cheat_tuple.Inputs = ["Phys/{0}".format(lb_combine_name)]

    # Sequences for ntuple creation
    dec_sequence = GaudiSequencer("SeqBook{0}".format(line))
    dec_sequence.Members = [filter, tuple]
    mc_sequence = GaudiSequencer("SeqMCGenBook{0}".format(line))
    mc_sequence.Members = [mc_tuple]
    cheat_sequence = GaudiSequencer("SeqMCCheatBook{0}".format(line))
    cheat_sequence.Members = [lc_combine, lb_combine, cheat_tuple]

    # Sequence for ntuple sequences
    tuples_sequence = GaudiSequencer("SeqTuples{0}".format(line))
    tuples_sequence.IgnoreFilterPassed = True
    tuples_sequence.Members = [dec_sequence, mc_sequence, cheat_sequence]

    # Sequence for MC filter then ntuple sequences
    master_sequence = GaudiSequencer("SeqMaster{0}".format(line))
    master_sequence.Members = [mc_filter, tuples_sequence]

    DaVinci().UserAlgorithms.append(master_sequence)

from Configurables import FilterDesktop

myInputParticlesList = []
myParticlesFilterList = []
myParticlesList = []
myParticlesSeqList = []
myParticlesLocationList = []

from Configurables import GaudiSequencer

filterSeq = GaudiSequencer( 'FilterSeq' )
filterSeq.ModeOR = True

mainSeq = GaudiSequencer( 'MainSeq' )
mainSeq.MeasureTime = True
mainSeq.IgnoreFilterPassed = False

codeIN = ""

for particles, cuts in particlesAndCuts.iteritems():
    codeIN = codeIN.replace("||","|")
    codeIN += "(CONTAINS( '"+str(particles)+"' )>0) || "
    
    myParticlesName = particles.split("/")[-2]

    myInputParticlesList += [ AutomaticData( Location = particles ) ]
    
    myParticlesFilterList += [ FilterDesktop( myParticlesName+"Filter",
                                              Code = cuts ) ]
    myParticlesList += [ Selection( myParticlesName,
                                    Algorithm = myParticlesFilterList[-1],
# Configure Stripping
from Configurables import ProcStatusCheck
filterBadEvents = ProcStatusCheck()

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


from Configurables import StrippingReport
sr = StrippingReport(Selections = sc.selections());

MySequencer = GaudiSequencer('Sequence')
MySequencer.Members = [sc.sequence(),sr]
MySequencer.IgnoreFilterPassed = True 

DaVinci().appendToMainSequence([killer, MySequencer])


 
from Configurables import FilterInTrees

rho_list = FilterInTrees( 'rho_list', Code = "'rho(770)0'==ABSID")
rho_Sel = Selection ( "rho_Sel" , Algorithm =rho_list  , RequiredSelections = [ AutomaticData(Location = location) ] )
rho_Seq = SelectionSequence("rho_Seq", TopSelection = rho_Sel)



 
pion_list= FilterInTrees( 'pion_list', Code = "'pi+'==ABSID")   
Exemplo n.º 7
0
def patchBrunel():
    """
        Instantiate the options to run Brunel with raw data

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

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

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

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

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

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

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

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

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

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

    pidSeq = GaudiSequencer("RichPIDSelections")

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

    seq.Members += [pidSeq]

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

    muEffMoni = MuEffMonitor("MuEffMonitor")

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

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

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

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

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

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

    muEffMoni.HistoLevel = "OfflineFull"

    seq.Members += [muEffMoni]

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

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

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

    #
    # Make pions and protons
    #

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

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

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

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

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

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

    #
    # Make muons and J/psi
    #

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

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

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

    child1cuts = tag1cuts + " & " + probe2cuts

    child2cuts = tag2cuts + " & " + probe1cuts

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

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

    JpsiMonitor.OutputLevel = 6

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

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

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

    #
    # Monitoring muon mis-id with Lambda_0
    #

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

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

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

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

    # MuonID FOI parameters

    MuIDLambdaPlot.FOIfactor = 1.

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

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

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

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

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

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

    #
    # Parameters of the Landau functions
    #

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

    MuPidMoniSeq_Lambda.Members += [MuIDLambdaPlot]

    #
    # Monitoring muon id with J/psi
    #

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

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

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

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

    # MuonID FOI parameters

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

    #
    # Parameters of the Landau functions
    #

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

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

    seq.Members += [MuPidMoniSeq_Lambda, MuPidMoniSeq_Jpsi]

    # set the options

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

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

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

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

    brunel.UseDBSnapshot = True  # try it
    Brunel.Configuration.Brunel.configureOutput = dummy
    HistogramPersistencySvc().OutputFile = ""
    HistogramPersistencySvc().OutputLevel = MSG_ERROR
    print brunel
    return brunel
Exemplo n.º 8
0
dtf_BMFit.daughtersToConstrain = ['B_s0']

dtf_MFit = dtt_pi0R.addTupleTool("TupleToolDecayTreeFitter/MassFit")
dtf_MFit.Verbose = True
dtf_MFit.UpdateDaughters = True
dtf_MFit.constrainToOriginVertex = False
dtf_MFit.daughtersToConstrain = ['pi0']

# Vtx Isoln
dtt_vtxIso = dtt_pi0R.addTupleTool('TupleToolVtxIsoln')
dtt_vtxIso.Verbose=True    

# offlineVertexFitter
from Configurables import OfflineVertexFitter
dtt_pi0R.VertexFitters.update( { "" : "OfflineVertexFitter"} )
dtt_pi0R.addTool(OfflineVertexFitter)
dtt_pi0R.OfflineVertexFitter.useResonanceVertex = False

# configure decay maker
dtt_pi0R.Inputs = sel_seq.outputLocations()
seq.Members += [ dtt_pi0R ]

# configure the categories
catSeq = GaudiSequencer('hhpi0RG')
catSeq.IgnoreFilterPassed = True
catSeq.Members += [seq]

DaVinci().UserAlgorithms += [catSeq]

# EOF
Exemplo n.º 9
0
from math import *
from Gaudi.Configuration import *
from Configurables import GaudiSequencer
from GaudiKernel.SystemOfUnits import *
from CommonParticles.Utils import *
from Configurables import TrackClusterFinder
TrkClusterFinder = TrackClusterFinder("TrkClusterFinder")
TrkClusterFinder.MinWeightSeed = 6
TrkClusterFinder.ConeExtFactor = 4.0
TrkClusterFinder.MaxDeltaPhi = 4.0
TrkClusterFinder.MaxDeltaEta = 0.15
TrkClusterFinder.Min1stJetPt = 10.0
TrkClusterFinder.Min2ndJetPt = 7.0
TrkClusterFinder.JetMult = 2
TrkClusterFinder.MaxRPV = 1.0
## #####################################################################
DVSeq = GaudiSequencer("DVSeq")
DVSeq.IgnoreFilterPassed = False
DVSeq.Members += [TrkClusterFinder]
## #####################################################################
from Configurables import DaVinci
DaVinci().EvtMax = -1
DaVinci().PrintFreq = 100
DaVinci().SkipEvents = 0
DaVinci().DataType = "2010"
DaVinci().Simulation = False
DaVinci().HistogramFile = "test_histo.root"
DaVinci().TupleFile = "test.root"
DaVinci().UserAlgorithms = [DVSeq]
########################################################################
Exemplo n.º 10
0
def setup():
    initialTime = long(time.time() * 1e9)

    OTGaudiSeq = GaudiSequencer("OTt0OnlineClbrSeq")
    OTt0OnlineClbrAlg = OTt0OnlineClbr("OTt0OnlineClbrAlg")
    #OTt0OnlineClbrAlg.InputFiles  = [ "/hist/Savesets/2013/LHCb/Brunel/01/20/Brunel-135576-20130120T161302-EOR.root"]

    # OT T0 calibration algorithm
    OTt0OnlineClbrAlg.InputTasks = ["Brunel"]
    OTt0OnlineClbrAlg.Partition = partition
    OTt0OnlineClbrAlg.ReadInitialT0FromDB = False
    OTt0OnlineClbrAlg.SaveFits = False
    OTt0OnlineClbrAlg.RunOnline = True
    OTt0OnlineClbrAlg.CheckDataT0 = True
    OTt0OnlineClbrAlg.PublishedName = "OT/Calib"
    OTt0OnlineClbrAlg.XMLFilePath = "/group/online/alignment/OT/Calib"
    OTt0OnlineClbrAlg.OutputLevel = MSG_INFO
    OTt0OnlineClbrAlg.UseClockPhase = (partition != "FEST")
    OTt0OnlineClbrAlg.InitialTime = initialTime
    OTt0OnlineClbrAlg.Threshold = 0.1
    OTt0OnlineClbrAlg.MaxDifference = 2
    # Keep analysis task going.
    OTt0OnlineClbrAlg.StopAlgSequence = False

    OTGaudiSeq.Members += [OTt0OnlineClbrAlg]
    OTGaudiSeq.IgnoreFilterPassed = True

    ## Configure saving of histograms
    from Configurables import UpdateAndReset
    ur = UpdateAndReset()
    ur.saveHistograms = 1
    ApplicationMgr().TopAlg.insert(0, ur)

    from Configurables import MonitorSvc
    MonitorSvc().disableDimPropServer = 1
    MonitorSvc().disableDimCmdServer = 1

    #import OnlineEnv
    MonitorSvc().ExpandCounterServices = 0
    MonitorSvc().ExpandNameInfix = "<part>_x_<program>/"
    #MonitorSvc().PartitionName         = OnlineEnv.PartitionName;
    MonitorSvc().PartitionName = partition
    MonitorSvc().ProgramName = "OTOnlineCalib_0"

    #setup the histograms and the monitoring service
    #ApplicationMgr().ExtSvc.append( 'MonitorSvc' )
    from Configurables import RootHistCnv__PersSvc
    RootHistCnv__PersSvc().OutputEnabled = False

    ApplicationMgr().TopAlg += [OTGaudiSeq]
    ApplicationMgr().EvtSel = "NONE"
    ApplicationMgr().ExtSvc += [
        "LHCb::PublishSvc", "MonitorSvc", "IncidentSvc"
    ]
    ApplicationMgr().Runable = "LHCb::OnlineRunable/Runable"

    from Configurables import CondDB
    conddb = CondDB()
    conddb.Tags["ONLINE"] = 'fake'
    conddb.IgnoreHeartBeat = True
    conddb.UseDBSnapshot = True
    conddb.DBSnapshotDirectory = "/group/online/hlt/conditions"

    from Configurables import EventClockSvc, FakeEventTime, EventDataSvc
    ecs = EventClockSvc()
    ecs.InitialTime = initialTime
    ecs.addTool(FakeEventTime, "EventTimeDecoder")
    ecs.EventTimeDecoder.StartTime = initialTime
    ecs.EventTimeDecoder.TimeStep = 10
    EventDataSvc().ForceLeaves = True

    # Configure DB tags and per-run conditions to be used to be the same as what
    # the HLT1 reconstruction farm uses. This is done by directly importing the
    # python file to ensure the script can also start when LHCb is running
    # passthrough.
    conddb.EnableRunChangeHandler = True
    conddb.RunChangeHandlerConditions = {
        'LHCb/2015/%d/ot.xml': ["Conditions/Calibration/OT/CalibrationGlobal"]
    }

    from Configurables import LHCbApp
    import ConditionsMap
    LHCbApp().CondDBtag = ConditionsMap.CondDBTag
    LHCbApp().DDDBtag = ConditionsMap.DDDBTag

    # LHCbApp().CondDBtag = 'cond-20150409-2'
    # LHCbApp().DDDBtag   = 'dddb-20150119-3'
    LHCbApp().DataType = '2015'
Exemplo n.º 11
0
    def applyConf(self):

        from Configurables import (GaudiSequencer, HltL0CaloCandidates)

        if self.getName() == 'CaloLines' and (self.getProp('Context') == ''
                                              or self.getProp('Context')
                                              == 'CaloLines'):
            self.setProp(
                'Context', 'Offline'
            )  # default is Offline is neither context nor name is specified

        # overwrite Reco & PID onDemand
        dod = self.getProp('EnableOnDemand')
        pdod = self.getProp('ProtoOnDemand')
        if dod:
            pdod = dod

        tracks = self.getProp('TrackLocations')

        ###
        caloLines = GaudiSequencer('CaloLinesSeq' + self.getName())
        caloLines.Members[:] = []

        if self.getProp('L0Calo2Calo'):
            l0calo2calo = HltL0CaloCandidates('L0Calo2Calo')
            if self.getProp('ClusterizationLevel') > 0:
                level = self.getProp('ClusterizationLevel')
                l0calo2calo.ClusterizationLevel = level
            addAlgs(caloLines, l0calo2calo)
            tagHighP = ''
            tagLowP = ''
            tagLowE = ''
        else:
            tagHighP = 'HighPhoton'
            tagLowP = 'LowPhoton'
            tagLowE = 'LowElectron'

        name = self.getName()
        fac = self.getProp('ClusterEtFactor')

        if self.getProp('HighPhoton'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'HighPhoton'
            hp = CaloProcessor(
                name + 'HighPhoton',
                TrackLocations=tracks,
                Context=context,
                RecList=['Digits', 'Clusters', 'Photons'],
                CaloPIDs=False,
                ExternalClusters="/Event/Rec/Calo/HighEtPhotons",
                ClusterPt=self.getProp('HighEt') * fac,
                PhotonPt=self.getProp('HighEt'),
                MakeExternalClustersWithTag=tagHighP,
                NoSpdPrs=self.getProp('NoSpdPrs'))

            addAlgs(caloLines, hp.caloSequence(tracks=tracks))

            if self.getProp('HighEtProtoPPrefix') == '':
                hploc = name + 'HighPhoton/ProtoP'
            else:
                hploc = self.getProp('HighEtProtoPPrefix')
            addAlgs(caloLines,
                    hp.neutralProtoSequence(protoPrefix=hploc, tracks=tracks))

        if self.getProp('LowPhoton'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'LowPhoton'
            lp = CaloProcessor(name + 'LowPhoton',
                               TrackLocations=tracks,
                               Context=context,
                               RecList=[
                                   'Digits', 'Clusters', 'Photons',
                                   'MergedPi0s', 'SplitPhotons'
                               ],
                               ExternalClusters="/Event/Rec/Calo/LowEtPhotons",
                               CaloPIDs=False,
                               ClusterPt=self.getProp('LowEt') * fac,
                               PhotonPt=self.getProp('LowEt'),
                               MakeExternalClustersWithTag=tagLowP,
                               NoSpdPrs=self.getProp('NoSpdPrs'))
            addAlgs(caloLines, lp.caloSequence(tracks=tracks))
            if self.getProp('LowEtProtoPPrefix') == '':
                lploc = name + 'LowPhoton/ProtoP'
            else:
                lploc = self.getProp('LowEtProtoPPrefix')
            addAlgs(caloLines,
                    lp.neutralProtoSequence(protoPrefix=lploc, tracks=tracks))

        if self.getProp('LowElectron'):
            context = self.getProp('Context')
            if context != '':
                context = context + 'LowElectron'
            le = CaloProcessor(
                name + 'LowElectron',
                TrackLocations=tracks,
                Context=context,
                RecList=['Digits', 'Clusters', 'Electrons'],
                ExternalClusters="/Event/Rec/Calo/LowEtElectrons",
                ClusterPt=self.getProp('LowEt') * fac,
                ElectronPt=self.getProp('LowEt'),
                SkipNeutrals=True,
                ProtoOnDemand=pdod,
                MakeExternalClustersWithTag=tagLowE,
                NoSpdPrs=self.getProp('NoSpdPrs'))
            addAlgs(caloLines, le.caloSequence(tracks=tracks))
            if self.getProp('LowEtProtoPPrefix') == '':
                leloc = name + 'LowElectron/ProtoP'
            else:
                leloc = self.getProp('LowEtProtoPPrefix')
            addAlgs(caloLines,
                    le.chargedProtoSequence(protoPrefix=leloc, tracks=tracks))

        caloLines.IgnoreFilterPassed = True
        ## propagate the global properties
        if self.isPropertySet("OutputLevel"):
            setTheProperty(caloLines, 'OutputLevel',
                           self.getProp('OutputLevel'))

        ## define the sequencers
        if self.isPropertySet('Sequencer'):
            main = self.getProp('Sequencer')
            addAlgs(main, caloLines)
#line below should be the default in the db. its default in the analysistask
#OTt0OnlineClbrAlg.CondStructure = "Conditions/OT/Calibration/"

#OTt0OnlineClbrAlg.globalt0_threshold = 0.1

OTt0OnlineClbrAlg.OutputLevel = 2
#OTt0OnlineClbrAlg.Simulation = False
#OTt0OnlineClbrAlg.Fit_module_contributions = False
OTt0OnlineClbrAlg.UseMean = False
OTt0OnlineClbrAlg.SaveFits = False

#simulation = OTt0OnlineClbrAlg.Simulation

OTGaudiSeq.Members += [OTt0OnlineClbrAlg]

OTGaudiSeq.IgnoreFilterPassed = True

from Configurables import ApplicationMgr
ApplicationMgr().TopAlg += [OTGaudiSeq]

ApplicationMgr().EvtSel = "NONE"
# ApplicationMgr().ExtSvc += [ "MonitorSvc" ]
# ApplicationMgr().Runable = "LHCb::OnlineRunable/Runable"

from Configurables import LHCbApp
#LHCbApp().DDDBtag   = "head-20120413"
#LHCbApp().CondDBtag = "cond-20120730"

#LHCbApp().Simulation = simulation

#if simulation :
Exemplo n.º 13
0
tutorialseq.Members += [jpsi2mumu]
#######################################################################
#
# 2) Add the Phi
#
phi2kk = TutorialAlgorithm("Phi2KK")
phi2kk.Inputs = ["Phys/StdAllLooseKaons/Particles"]
phi2kk.MassWindow = 50 * MeV
phi2kk.Particle = "phi(1020)"
phi2kk.MaxChi2 = 20
tutorialseq.Members += [phi2kk]
#######################################################################
#
# Say True to have all phis. False to be fast.
#
tutorialseq.IgnoreFilterPassed = True  # get all phis
#######################################################################
#
# 3) Configure the application
#
from Configurables import DaVinci
DaVinci().HistogramFile = "DVHistos_3.root"  # Histogram file
DaVinci().EvtMax = 10000  # Number of events
DaVinci().DataType = "2012"  #
DaVinci().Simulation = True  # When running on MC
#
# Add our own stuff
#
DaVinci().UserAlgorithms = [tutorialseq]
DaVinci().MainOptions = ""  # None
########################################################################
def configure_dv() :
    global toolList
    streams = get_streams(strippingVersion)
    configs = []
    userSeq = GaudiSequencer('UserSeq')
    userSeq.IgnoreFilterPassed = True
    if isMC :
        toolList += ['TupleToolMCTruth',
                     #'TupleToolGeneration'
                     'TupleToolMCBackgroundInfo'
                     ]
    for baryon in charmBaryons :
        for bachelor in bachelors :
            lineName = stripping_line_name(bachelor, baryon)
            dtt, line, stream, conf = \
                make_stripping_tuple(lineName, streams, toolList,
                                     lineName[:-len('Beauty2Charm')] + 'Tuple')
            dttSeq = GaudiSequencer(line.name() + 'Seq', Members = [dtt])
            if 'Xic' == baryon :
                decayDesc = dtt.Decay
                dtt.Decay = decayDesc.replace('Lambda_b0', 'Xi_b0')
                decayDescPlus = reduce(lambda x,y : x.replace(y, ''), ('^', '[', ']', 'CC'), decayDesc)
                decayDescMinus = decayDescPlus.replace('+', '!').replace('->', '#').replace('-', '+')\
                    .replace('!', '-').replace('0', '~0').replace('#', '->').replace('Xi_c-', 'Xi_c~-').replace('p-', 'p~-')
                subPID = SubstitutePID(baryon+bachelor+'SubstitutePID', Code = 'ALL', 
                                       Substitutions = {decayDescPlus : 'Xi_b0',
                                                        decayDescMinus : 'Xi_b~0'},
                                       Inputs = dtt.Inputs,
                                       Output = dtt.Inputs[0].replace('Beauty2CharmLine', 'Beauty2CharmLine-Subd'))
                dtt.Inputs = [subPID.Output]
                dttSeq.Members.insert(0, subPID)
            configs.append({'dtt' : dtt, 'dttSeq' : dttSeq, 'line' : line, 'stream' : stream,
                           'conf' : conf, 'charmBaryon' : baryon, 'bachelor' : bachelor})
            dtt.ReFitPVs = True # Do I need this? - probably yes if you want to use vertex constraints without biasing the lifetime.
            # Configure DTF
            decayNoCaret = dtt.Decay.replace('^', '')

            baryonSymbol = baryonSymbols[baryon]
            baryonDec = baryonDescriptors[baryon]
            decayCharmCaret = decayNoCaret.replace('('+baryonDec, '^(' + baryonDec)

            dtt.addBranches( {'X_b0' : decayNoCaret, 
                              'X_cplus' : decayCharmCaret } )

            bachelorDec = bachelorDescriptors[bachelor]
            otherBachelorDec = oppositeBachelors[bachelor]

            decayBachelorCaret = decayNoCaret[::-1].replace(bachelorDec[::-1], bachelorDec[::-1]+'^', 1)[::-1]
            bachelorSub = {decayBachelorCaret : otherBachelorDec}

            for mass, massName in ([baryonDec], '_Mass'), ([], '') :
                for vtx, vtxName in (True, '_Vtx'), (False, '') :
                    tt_dtf_name = 'TupleToolDecayTreeFitter/DTF' + massName + vtxName
                    tt_dtf = dtt.X_b0.addTupleTool(tt_dtf_name)
                    tt_dtf_sub = dtt.X_b0.addTupleTool(tt_dtf_name + '_Sub')
                    tt_dtf_sub.Substitutions = bachelorSub
                    for dtf in tt_dtf, tt_dtf_sub :
                        dtf.constrainToOriginVertex = vtx
                        dtf.daughtersToConstrain = mass
                        dtf.Verbose = True

    dv.DataType = get_data_type(firstInputFile)

    if isMC :
        for config in configs :
            line = config['line']
            #algs = line.filterMembers()
            algs = line._members
            # Remove TISTOS tagger and BDT filter. 
            algs = algs[:-3]
            # Remove VoidFilter for nTracks < 250.
            #algs.pop(0)
            #remove_selection_criteria(algs[3], algs[5], algs[7], 
            #                          algs[9]) # std particles.
            selalgs = filter(lambda x : isinstance(x, (FilterDesktop, 
                                                       CombineParticles)), algs)
            remove_selection_criteria(*selalgs)
            decayDesc = config['dtt'].Decay.replace('^', '')
            preamble = [ "from LoKiPhysMC.decorators import *" , "from LoKiPhysMC.functions import mcMatch" ]
            # for alg in selalgs :
            #     alg.Preambulo = preamble
            #     if hasattr(alg, 'Code') :
            #         alg.Code += ' & mcMatch({0!r})'.format(decayDesc)
            #     else :
            #         alg.MotherCut += ' & mcMatch({0!r})'.format(decayDesc)
            # filter(lambda x : isinstance(x, CombineParticles), algs)[-1].CombinationCut = '(AM<7000*MeV) & (AM>5200*MeV)'
            #remove_selection_criteria(algs[8], # Lc/Xic
            #                          algs[10]) # Lb
            combineParticles = filter(lambda x : isinstance(x, CombineParticles), algs)
            for comb in combineParticles :
                comb.Preambulo = preamble
            motherSymbol = baryonDescriptors[config['charmBaryon']]
            decayDesc = decayDesc.replace('->', '==>') # to allow for intermediate resonances.
            combineParticles[0].MotherCut += ' & mcMatch({0!r})'.format(decayDesc.replace('(' + motherSymbol, '^(' + motherSymbol))
            combineParticles[0].DaughtersCuts = {'p+' : 'mcMatch({0!r})'.format(decayDesc.replace('p+', '^p+')),
                                                'K-' : 'mcMatch({0!r})'.format(decayDesc.replace('K-', '^K-')),
                                                'pi+' : 'mcMatch({0!r})'.format(decayDesc.replace('pi+', '^pi+'))}
            bachelorSymbol = bachelorDescriptors[config['bachelor']]
            combineParticles[1].DaughtersCuts = {bachelorSymbol : 'mcMatch({0!r})'.format(decayDesc.replace(bachelorSymbol, '^' + bachelorSymbol)),
                                                motherSymbol : 'ALL'}

            #algs = remove_selection_criteria(*algs)
            algs[-1].Output = config['dttSeq'].Members[0].Inputs[0]
            config['dttSeq'].Members = algs + config['dttSeq'].Members
            
        dv.Simulation = True
        dv.DDDBtag = dddbTag 
        dv.CondDBtag = conddbTag

    else :
        scaler = TrackScaleState()
        #scaler.CONDDBpath = '/dd/Conditions/Calibration/LHCb/MomentumScale'
        #scaler.CONDDBpath = '/dd/Conditions/Calibration/LHCb'
        userSeq.Members = [scaler]
        from Configurables import CondDB
        CondDB(LatestGlobalTagByDataType = dv.DataType)

    for config in configs :
        userSeq.Members.append(config['dttSeq'])
    dv.UserAlgorithms = [userSeq]
    dv.InputType = firstInputFile.split('.')[-1].upper()
    if 'MDST' == dv.InputType :
        dv.RootInTES = '/Event/' + configs[0]['stream'].name()