Exemplo n.º 1
0
def start():
    """
        Finish configuration and configure Gaudi application manager

        @author M.Frank
  """
    import OnlineEnv
    Gaudi.appendPostConfigAction(postConfig)
    OnlineEnv.end_config(False)
Exemplo n.º 2
0
def setupOnline(directory, prefix, filename):
    """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
    class __MonAdd:
        def __init__(self):
            pass

        def addMonitors(self):
            GaudiSequencer("EscherSequencer").Members += ["HistogramResetter"]

    from Configurables import LHCb__FILEEvtSelector as es
    Online = importOnline()

    app = Gaudi.ApplicationMgr()
    app.AppName = ''
    HistogramPersistencySvc().OutputFile = ""
    app.HistogramPersistency = ''
    app.SvcOptMapping.append('LHCb::FILEEvtSelector/EventSelector')
    app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    app.ExtSvc.insert(0, "MonitorSvc")
    sel = es("EventSelector")
    sel.Input = filename
    sel.Directory = directory
    sel.OutputLevel = MSG_INFO
    sel.DeleteFiles = False
    sel.FilePrefix = prefix
    sel.Decode = False
    sel.Pause = True
    sel.PauseSleep = 5000
    sel.AllowedRuns = Online.DeferredRuns if hasattr(Online,
                                                     "DeferredRuns") else []
    app.EvtSel = sel
    app.EvtMax = -1
    Online.rawPersistencySvc()
    evtloop = Configs.EventLoopMgr('EventLoopMgr')
    evtloop.Warnings = False
    evtloop.EvtSel = sel
    app.EventLoop = evtloop
    runable = Configs.LHCb__EventRunable("Runable")
    runable.MEPManager = ""
    app.Runable = runable
    app.AuditAlgorithms = False
    Configs.MonitorSvc().OutputLevel = MSG_ERROR
    Configs.MonitorSvc().UniqueServiceNames = 1
    Configs.MonitorSvc().CounterUpdateInterval = -1
    Configs.MonitorSvc().DimUpdateInterval = -1
    Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
    mon = __MonAdd()
    Gaudi.appendPostConfigAction(mon.addMonitors)
    app.OutputLevel = MSG_INFO

    cdb = CondDB()
    cdb.Online = True
Exemplo n.º 3
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"]

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

    # Set up PID monitoring sequence
    pidSeq = GaudiSequencer("RichPIDSelections")
    seq.Members += [pidSeq]

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

    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.º 4
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.º 5
0
input_files = glob.glob("/tmp/thead/stereo-%i/*.digi" % (stereo))
IOHelper("ROOT").inputFiles(input_files)


def setup_mc_truth_matching():
    GaudiSequencer("CaloBanksHandler").Members = []
    GaudiSequencer("DecodeTriggerSeq").Members = []
    GaudiSequencer("MCLinksTrSeq").Members = [
        "VPClusterLinker", "PrLHCbID2MCParticle", "PrTrackAssociator"
    ]
    GaudiSequencer("CheckPatSeq").Members = ["PrChecker"]

    from Configurables import PrLHCbID2MCParticle
    #PrLHCbID2MCParticle().OutputLevel = 2
    PrTrackAssociator().RootOfContainers = "/Event/Rec/Track"

    PrChecker().TriggerNumbers = True
    PrChecker().Eta25Cut = True
    PrChecker().WriteVeloHistos = 2
    PrChecker().WriteForwardHistos = 2
    PrChecker().WriteMatchHistos = 2
    PrChecker().WriteDownHistos = 2
    PrChecker().WriteUpHistos = 2
    PrChecker().WriteTTrackHistos = 2
    PrChecker().WriteBestHistos = 2
    PrChecker().WriteBestLongHistos = 2
    PrChecker().WriteBestDownstreamHistos = 2


GC.appendPostConfigAction(setup_mc_truth_matching)
Exemplo n.º 6
0
PrSeedingXLayers().XOnly = x_only

input_files = glob.glob("/tmp/thead/stereo-%i/*.digi"%(stereo))
IOHelper("ROOT").inputFiles(input_files)

def setup_mc_truth_matching():
    GaudiSequencer("CaloBanksHandler").Members = []
    GaudiSequencer("DecodeTriggerSeq").Members = []
    GaudiSequencer("MCLinksTrSeq").Members = ["VPClusterLinker",
                                              "PrLHCbID2MCParticle",
                                              "PrTrackAssociator"]
    GaudiSequencer("CheckPatSeq" ).Members = ["PrChecker"]

    from Configurables import PrLHCbID2MCParticle
    #PrLHCbID2MCParticle().OutputLevel = 2
    PrTrackAssociator().RootOfContainers = "/Event/Rec/Track"

    PrChecker().TriggerNumbers = True
    PrChecker().Eta25Cut = True
    PrChecker().WriteVeloHistos = 2
    PrChecker().WriteForwardHistos = 2
    PrChecker().WriteMatchHistos = 2
    PrChecker().WriteDownHistos = 2
    PrChecker().WriteUpHistos = 2
    PrChecker().WriteTTrackHistos = 2
    PrChecker().WriteBestHistos = 2
    PrChecker().WriteBestLongHistos = 2
    PrChecker().WriteBestDownstreamHistos = 2

GC.appendPostConfigAction(setup_mc_truth_matching)