def setupOnline():
    """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
    import OnlineEnv

    buffs = ['Events']
    app = Gaudi.ApplicationMgr()
    app.AppName = ''
    app.HistogramPersistency = 'ROOT'
    app.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
    app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    mep = OnlineEnv.mepManager(OnlineEnv.PartitionID, OnlineEnv.PartitionName,
                               buffs, True)
    mep.ConnectWhen = "start"
    sel = OnlineEnv.mbmSelector(input=buffs[0],
                                type='USER',
                                decode=False,
                                event_type=2)
    app.EvtSel = sel
    app.Runable = OnlineEnv.evtRunable(mep)
    app.Runable.NumErrorToStop = -1
    app.ExtSvc.append(mep)
    app.ExtSvc.append(sel)
    app.AuditAlgorithms = False
    ##app.TopAlg.insert(0,"UpdateAndReset")
    Configs.MonitorSvc().OutputLevel = MSG_ERROR
    Configs.MonitorSvc().UniqueServiceNames = 1
    Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
    app.OutputLevel = MSG_INFO
Exemple #2
0
def setupOnline():
  """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
  import OnlineEnv as Online
  
  buffs = ['Events','Output']
  if processingType == 'Reprocessing':
    buffs = ['Input','Output']

  app=Gaudi.ApplicationMgr()
  app.AppName = ''
  app.HistogramPersistency = 'ROOT'
  app.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
  app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')

  mep = Online.mepManager(Online.PartitionID,Online.PartitionName,buffs,True)
  sel = Online.mbmSelector(input=buffs[0],type='ONE',decode=False)
  if requirement:
    print 'Setting requirements:',requirement
    sel.REQ1 = requirement
  app.EvtSel  = sel
  app.Runable = Online.evtRunable(mep)
  app.Runable.NumErrorToStop = -1;
  app.ExtSvc.append(mep)
  app.ExtSvc.append(sel)
  app.AuditAlgorithms = False
  app.TopAlg.insert(0,"UpdateAndReset")
  Configs.MonitorSvc().OutputLevel = MSG_ERROR
  Configs.MonitorSvc().UniqueServiceNames = 1
  Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
  app.OutputLevel = MSG_WARNING
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
def patchMessages():
    """
        Messages in the online get redirected.
        Setup here the FMC message service

        @author M.Frank
  """
    import OnlineEnv
    app = Gaudi.ApplicationMgr()
    Configs.AuditorSvc().Auditors = []
    app.MessageSvcType = 'LHCb::FmcMessageSvc'
    if Gaudi.allConfigurables.has_key('MessageSvc'):
        del Gaudi.allConfigurables['MessageSvc']
    msg = Configs.LHCb__FmcMessageSvc('MessageSvc')
    msg.fifoPath = os.environ['LOGFIFO']
    msg.LoggerOnly = True
    msg.doPrintAlways = False
    msg.OutputLevel = MSG_INFO  # OnlineEnv.OutputLevel
    def setup(self, buffers=['Events', 'Output']):
        """
          Setup the online environment: Buffer managers, event serialisation, etc.

          @author M.Frank
    """
        import OnlineEnv as Online

        self.appMgr = Gaudi.ApplicationMgr()
        self.appMgr.AppName = ''
        self.appMgr.HistogramPersistency = 'ROOT'

        forker = Configs.LHCb__CheckpointSvc("CheckpointSvc")
        forker.NumberOfInstances = 5
        forker.UseCores = False
        forker.ChildSessions = False
        forker.DumpFiles = False
        #forker.Checkpoint          = "Checkpoint.data"
        forker.PrintLevel = 3  # 1=MTCP_DEBUG 2=MTCP_INFO 3=MTCP_WARNING 4=MTCP_ERROR
        forker.OutputLevel = 2  # 1=VERBOSE 2=DEBUG 3=INFO 4=WARNING 5=ERROR 6=FATAL
        #forker.ExitAfterCheckpoint = False
        self.appMgr.ExtSvc.append(forker)

        self.appMgr.SvcOptMapping.append(
            'LHCb::OnlineEvtSelector/EventSelector')
        ##self.appMgr.SvcOptMapping.append('LHCb::DummyMonitorSvc/MonitorSvc')
        self.appMgr.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
        mep = Online.mepManager(Online.PartitionID, Online.PartitionName,
                                buffers, True)
        mep.ConnectWhen = 'start'
        sel = Online.mbmSelector(input=buffers[0], type='ONE', decode=False)
        self.appMgr.ExtSvc.append(mep)
        self.appMgr.ExtSvc.append(sel)

        self.appMgr.EvtSel = sel
        self.appMgr.Runable = Online.evtRunable(mep)
        self.appMgr.Runable.NumErrorToStop = 1
        self.appMgr.AuditAlgorithms = False
        ##mon = Configs.LHCb__DummyMonitorSvc("MonitorSvc")
        mon = Configs.MonitorSvc("MonitorSvc")
        mon.OutputLevel = 5
        mon.UniqueServiceNames = 1
        self.appMgr.OutputLevel = 4
    def patchMessages(self):
        """
          Messages in the online get redirected.
          Setup here the FMC message service

          @author M.Frank
    """
        if self.true_online_version:
            app = Gaudi.ApplicationMgr()
            Configs.AuditorSvc().Auditors = []
            self.appMgr.MessageSvcType = 'LHCb::FmcMessageSvc'
            if Gaudi.allConfigurables.has_key('MessageSvc'):
                del Gaudi.allConfigurables['MessageSvc']
            msg = Configs.LHCb__FmcMessageSvc('MessageSvc')
            msg.fifoPath = os.environ['LOGFIFO']
            msg.LoggerOnly = True
            msg.OutputLevel = 4
            #Configs.ToolsSvc().OutputLevel = 5
            return msg
def configureOutput(self, dstType, withMC, handleLumi):
    global configureBrunelOutput
    print '[ERROR] Configure Brunel output ....'
    sys.stdout.flush()
    if configureBrunelOutput:
        import OnlineEnv
        print '[ERROR] Configure Brunel output sequence ....'
        sys.stdout.flush()
        Configs.DstConf._doWriteROOT = dstconf_write_root
        configureBrunelOutput(self, dstType, withMC, handleLumi)
        ser = Gaudi__SerializeCnvSvc('Gaudi::SerializeCnvSvc')
        ser.Banks = '/Event/GaudiSerialize'
        ser.OutputLevel = 1
        EventPersistencySvc().CnvServices.append(ser)
        writer = OnlineEnv.evtMerger(buffer='Output',
                                     name='BankWriter',
                                     location='/Event/GaudiSerialize',
                                     routing=0x100)
        writer.OutputLevel = 1
        seq = GaudiSequencer('Output')
        seq.Members += [OutputStream('DstWriter'), writer]
        Gaudi.ApplicationMgr().OutStream = [seq]
def setupOnline():
    """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
    import OnlineEnv

    buffs = ['Events', 'Output']
    app = Gaudi.ApplicationMgr()
    app.AppName = ''
    app.HistogramPersistency = 'ROOT'
    app.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
    app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    mep = OnlineEnv.mepManager(OnlineEnv.PartitionID, OnlineEnv.PartitionName,
                               buffs, True)
    mep.ConnectWhen = "start"
    sel = OnlineEnv.mbmSelector(input=buffs[0],
                                type='ONE',
                                decode=False,
                                event_type=2)
    if requirement:
        print '++++ Warning: Setting requirements:', requirement
        sel.REQ1 = requirement
    app.EvtSel = sel
    app.Runable = OnlineEnv.evtRunable(mep)
    app.Runable.NumErrorToStop = -1
    app.ExtSvc.append(mep)
    app.ExtSvc.append(sel)
    app.AuditAlgorithms = False
    app.TopAlg.insert(0, "UpdateAndReset")
    Configs.MonitorSvc().OutputLevel = MSG_ERROR
    Configs.MonitorSvc().UniqueServiceNames = 1
    Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
    app.OutputLevel = MSG_INFO
    if OnlineEnv.RecoStartupMode > 0:  ### os.environ.has_key('NBOFSLAVES'):
        configureForking(app)
Exemple #9
0
def setupOnline():
    """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
    import OnlineEnv

    buffs = ['Events']
    sys.stdout.flush()
    app = Gaudi.ApplicationMgr()
    app.AppName = ''
    app.HistogramPersistency = 'ROOT'
    app.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
    app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    mep = OnlineEnv.mepManager(OnlineEnv.PartitionID, OnlineEnv.PartitionName,
                               buffs, True)
    mep.ConnectWhen = "start"
    sel = OnlineEnv.mbmSelector(input=buffs[0],
                                type='ONE',
                                decode=False,
                                event_type=2)
    sel.REQ1 = "EvType=2;TriggerMask=0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF,0xFFFFFFFF;VetoMask=0,0,0,0;MaskType=ANY;UserType=ONE;Frequency=PERC;Perc=100.0"
    app.EvtSel = sel
    app.Runable = OnlineEnv.evtRunable(mep)
    app.Runable.NumErrorToStop = -1
    app.ExtSvc.append(mep)
    app.ExtSvc.append(sel)
    app.AuditAlgorithms = False
    app.TopAlg.insert(0, "UpdateAndReset")
    Configs.MonitorSvc().OutputLevel = MSG_ERROR
    Configs.MonitorSvc().UniqueServiceNames = 1
    Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
    app.OutputLevel = OnlineEnv.OutputLevel
    configureForking(app)
    sys.stdout.flush()
def setupOnline():
    """
        Setup the online environment: Buffer managers, event serialisation, etc.

        @author M.Frank
  """
    from Configurables import LHCb__FILEEvtSelector as es
    from Configurables import LHCb__AlignDrv as Adrv
    from Configurables import EventClockSvc
    Online = importOnline()

    app = Gaudi.ApplicationMgr()
    app.AppName = ''
    app.HistogramPersistency = 'ROOT'
    app.SvcOptMapping.append('LHCb::FILEEvtSelector/EventSelector')
    app.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    #app.EvtMax = 10000
    Online.rawPersistencySvc()
    evtloop = Configs.EventLoopMgr('LHCb::OnlineRunable/EmptyEventLoop')
    evtloop.Warnings = False
    evtloop.EvtSel = "NONE"
    app.EventLoop = evtloop
    app.HistogramPersistency = "NONE"
    #   runable = Configs.Runable
    #  runable.MEPManager        = ""
    app.AuditAlgorithms = False

    Configs.MonitorSvc().OutputLevel = MSG_ERROR
    Configs.MonitorSvc().UniqueServiceNames = 1
    Configs.RootHistCnv__PersSvc("RootHistSvc").OutputLevel = MSG_ERROR
    app.OutputLevel = MSG_INFO

    def __propAtt(att, fr, to, d=None):
        if hasattr(fr, att):
            setattr(to, att, getattr(fr, att))
        elif d:
            setattr(to, att, d)

    from Configurables import AlignOnlineIterator as Aiter
    ad = Adrv("AlignDrv")
    ad.PartitionName = Online.PartitionName
    ad.FitterClass = "AlignOnlineIterator"
    ad.FitterName = "AlIterator"
    __propAtt('RefFileName', Online, ad)

    ## The Alignment driver is the runable
    app.Runable = ad.getType() + "/" + ad.getName()

    ad.addTool(Aiter, ad.FitterName)
    ai = ad.AlIterator
    ai.PartitionName = Online.PartitionName
    ai.ASDFilePattern = "_Escher.out"
    ai.OutputLevel = 3
    ai.MaxIteration = MAX_NITER
    ai.ServiceInfix = ""
    ai.ReferenceRunNr = Online.DeferredRuns[0] if hasattr(
        Online, "DeferredRuns") else -1
    runType = os.environ.get('RUN_TYPE', 'Unknown')
    runType = runType.split('|')[-1].strip() if '|' in runType else runType
    if runType == 'Tracker':
        sds = ['TT', 'IT', 'OT']
        ai.RunType = runType
    elif runType in ('Velo', 'Muon'):
        sds = [runType]
        ai.RunType = runType
    else:
        print 'WARNING: RUN_TYPE is not one of Velo, Tracker or Muon. Will assume all subdetectors'
        sds = ['Velo', 'TT', 'IT', 'OT', 'Muon']
    ai.SubDetectors = sds

    #   for attr, default in [('ASDDir', "/group/online/alignment/EscherOut/"),
    #                         ('OnlineXmlDir', "/group/online/alignment"),
    #                         ('AlignXmlDir', "/group/online/AligWork")]:
    for attr, default in [('ASDDir', "/calib/align/EscherOut/"),
                          ('OnlineXmlDir', "/group/online/alignment"),
                          ('AlignXmlDir', "/group/online/AligWork")]:
        __propAtt(attr, Online, ai, default)

    initialTime = long(time.time() * 1e9)
    clkSvc = EventClockSvc()
    clkSvc.InitialTime = initialTime

    from Configurables import FakeEventTime
    clkSvc.EventTimeDecoder = "FakeEventTime"
    clkSvc.addTool(FakeEventTime, "FakeEventTime")
    clkSvc.FakeEventTime.StartTime = initialTime
Exemple #11
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
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
    def run(self):
        from Configurables import Brunel
    
        ## Brunel parameters
        Brunel().Detectors   = ['Spd', 'Prs', 'Ecal', 'Hcal' ]
        Brunel().DataType    = "2015"
        Brunel().InputType   = "MDF"
        Brunel().OutputType  = "DST"
        Brunel().EvtMax      = self.__nevt
        Brunel().WriteFSR    = False
        Brunel().Histograms  = "Online"
        Brunel().OnlineMode  = True
        Brunel().PrintFreq   = 1000
        Brunel().DatasetName = self.__dsname

        ## use the conditions database
        ## configuration for online
        from Configurables import CondDB
        CondDB().Simulation = False
        CondDB().UseDBSnapshot = True
        CondDB().DBSnapshotDirectory = "/group/online/hlt/conditions"
        CondDB().EnableRunChangeHandler = True
        CondDB().Tags["ONLINE"] = 'fake'
        CondDB().setProp("IgnoreHeartBeat", True)
        CondDB().Online = True

        try:
            import AllHlt1
        except ImportError:
            rd = '/group/online/hlt/conditions/RunChangeHandler'
            sys.path.append(rd)
            import AllHlt1

        import AllHlt1
        CondDB().RunChangeHandlerConditions = AllHlt1.ConditionMap

        Online = importOnline()
        Brunel().CondDBtag = Online.CondDBTag
        Brunel().DDDBtag   = Online.DDDBTag

        """
        Messages in the online get redirected.
        Setup here the FMC message service
    
        @author M.Frank
        """
        app=Gaudi.ApplicationMgr()
        #Configs.AuditorSvc().Auditors = []
        app.MessageSvcType = 'LHCb::FmcMessageSvc'
        if Gaudi.allConfigurables.has_key('MessageSvc'):
            del Gaudi.allConfigurables['MessageSvc']
        msg = Configs.LHCb__FmcMessageSvc('MessageSvc')
        msg.fifoPath      = os.environ['LOGFIFO']
        msg.LoggerOnly    = True
        msg.doPrintAlways = False
        msg.OutputLevel   = MSG_INFO # Online.OutputLevel

        from GaudiConf import IOHelper
        IOHelper('MDF').inputFiles(self.__inputs)

        from GaudiPython.Bindings import AppMgr    
        gaudi = AppMgr()
        gaudi.initialize()
        gaudi.run(self.__nevt)
        gaudi.stop()
        gaudi.finalize()
        gaudi.exit()
Exemple #14
0
    try:
        import AllHlt1
    except ImportError:
        rd = '/group/online/hlt/conditions/RunChangeHandler'
        sys.path.append(rd)
        import AllHlt1

    import AllHlt1
    CondDB().RunChangeHandlerConditions = AllHlt1.ConditionMap

    Online = importOnline()
    Brunel().CondDBtag = Online.CondDBTag
    Brunel().DDDBtag = Online.DDDBTag

    app = Gaudi.ApplicationMgr()
    #Configs.AuditorSvc().Auditors = []
    app.MessageSvcType = 'LHCb::FmcMessageSvc'
    if Gaudi.allConfigurables.has_key('MessageSvc'):
        del Gaudi.allConfigurables['MessageSvc']
    msg = Configs.LHCb__FmcMessageSvc('MessageSvc')
    msg.fifoPath = os.environ['LOGFIFO']
    msg.LoggerOnly = True
    msg.doPrintAlways = False
    msg.OutputLevel = MSG_INFO  # Online.OutputLevel

    from GaudiConf import IOHelper
    IOHelper('MDF').inputFiles(input_files)

    from GaudiPython.Bindings import AppMgr
    gaudi = AppMgr()