예제 #1
0
    def __apply_configuration__(self):
        GaudiKernel.ProcessJobOptions.PrintOff()
        from functools import partial

        propagator = None
        if self.getProp("RunOnline"):
            #check and reconfigure own properties
            self._onlineMode()
            #in online mode, force certain Moore properties!
            propagator = partial(self.forceOtherProps, force=True)
        else:
            #in offline mode don't force, but set them if not set
            propagator = partial(self.forceOtherProps, force=False)

        #pass certain properties to Moore
        propagator(Moore(), [
            "RunOnline", "UseTCK", 'EnableTimer', 'Simulation', 'DataType',
            'CheckOdin'
        ])

        # Use the online output algorithm
        from Configurables import HltOutputConf
        HltOutputConf().setProp("OutputAlgProperties",
                                self.rawEventMergerProperties)

        from Configurables import LoKiSvc, LoKi__Reporter
        LoKiSvc().addTool(LoKi__Reporter, 'REPORT')
        LoKiSvc().REPORT.OutputLevel = 5

        if self.getProp("UseDBSnapshot"): self._configureDBSnapshot()

        self._configureOnline()
예제 #2
0
  def __apply_configuration__(self):

    GaudiKernel.ProcessJobOptions.PrintOff()
    #done by LHCbApp
    #EventPersistencySvc().CnvServices.append( 'LHCb::RawDataCnvSvc' )

    # forward some settings...
    self.setOtherProps( LHCbApp(), ['EvtMax','SkipEvents','DataType'] )

    # instantiate the sequencer
    mainSeq = GaudiSequencer("LumiSeq")

    # activate the sequence
    appMgr=ApplicationMgr(TopAlg=[],
                          HistogramPersistency='NONE',
                          )
    ApplicationMgr().TopAlg += [ mainSeq ]
    
    # add user algorithms at the end
    if self.getProp("userAlgorithms"):
      for userAlg in self.getProp("userAlgorithms"):
        ApplicationMgr().TopAlg += [ userAlg ]
    
    # input
    self._configureInput()
    
    # configure the main sequence
    self._createWriter(mainSeq)
    
    # output
    self._configureOutput()

    # Switch off LoKi banner
    from Configurables import LoKiSvc
    LoKiSvc().Welcome = False
예제 #3
0
    def __apply_configuration__(self):
        ''' Apply the configuration to the given sequence '''

        sequence = self.getProp("LumiSequencer")
        if sequence == None:
            raise RuntimeError("ERROR : Lumi Sequencer not set")

        # Set context
        context = self.getProp("Context")

        # Check input data type
        dsttype = ('---' + self.getProp('InputType'))[-3:] == 'DST'
        inputType = self.getProp("InputType")
        if (not dsttype) and (inputType not in ["MDF", "DIGI", "ETC"]):
            raise RuntimeError("ERROR : Unknown input type " + str(inputType))

        forced = self.getProp("ForceFullSequence")
        status = self.getProp("SetFSRStatus")
        merge = self.getProp("MergeFSR")

        if inputType == 'MDF' or forced:
            # create the FSRs

            # Create sub-sequences according to BXTypes
            sequence.Members += self.fillFSR()

            # add other method LumiSummaries - deprecated
            if self.getProp('UseLumiLow'):
                sequence.Members += self.fillLowLumiFSR()

            if status is None or status == '':
                #by definition, all raw files are verified
                status = 'VERIFIED'

            # create the TimeSpan FSR
            sequence.Members += self.fillTimeSpanFSR()

        # create the Event FSR
        EvMembers = self.fillEventFSR(status)
        sequence.Members += EvMembers

        # actions on DSTs only
        if inputType != 'MDF':
            # touching is no longer needed
            # Touch all FSRs so they are always copied
            #TouchMembers=self.touchFSR()
            #sequence.Members += TouchMembers
            if merge:
                # merge FSRs (typically done in MERGING and MDST production)
                # must be done after Event accounting
                sequence.Members += self.mergeFSR()

        #finally configure the sequence
        sequence.ModeOR = True
        sequence.ShortCircuit = False
        sequence.IgnoreFilterPassed = True

        # Switch off LoKi banner
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = False
예제 #4
0
 def loki(self):
     """
     Define loki service
     """
     from Configurables import LoKiSvc
     lokiService = LoKiSvc()
     ApplicationMgr().ExtSvc += [lokiService]
def post_action_for_cpp():
    """
    Post-configh action to enforce initialization of DoD-algorithms
    """

    from Gaudi.Configuration import log
    from Configurables import ApplicationMgr
    app = ApplicationMgr(OutputLevel=3)
    app.EvtMax = 0
    app.EvtSel = 'NONE'

    from Configurables import LHCb__ParticlePropertySvc as PPSvc
    from Configurables import DetDataSvc
    from Configurables import LoKiSvc

    #
    ## some reshuffling of order of services is needed
    #    in particular DOD should come after PPSVC, LoKiSvc and ToolSvc
    #

    services = app.ExtSvc
    app.ExtSvc = [
        DetDataSvc('DetectorDataSvc'),
        PPSvc(),
        LoKiSvc(Welcome=False)
    ] + services

    #
    ## suppress some prints
    #
    from Configurables import TimingAuditor
    timer = TimingAuditor()
    from Configurables import SequencerTimerTool
    timer.addTool(SequencerTimerTool, 'TIMER')
    timer.TIMER.OutputLevel = 5

    # suppress printout of various summaries from algorithms.
    from Gaudi.Configuration import allConfigurables
    for conf in allConfigurables.itervalues():
        for opt in ('StatPrint', 'ErrorsPrint', 'HistoPrint'):
            if opt in conf.__slots__:
                setattr(conf, opt, False)

    # ensure that prints from the main tools/factories are not suppressed
    import Configurables
    from Configurables import LoKi__Hybrid__CoreFactory as CoreFactory
    from Configurables import LoKi__Hybrid__Tool as HybridFactory
    from Configurables import LoKi__Hybrid__HltFactory as HltFactory
    for Factory, names in {
            HltFactory: ("HltFactory", "Hlt1HltFactory", "Hlt2HltFactory"),
            CoreFactory: ("Hlt1CoreFactory", "Hlt2CoreFactory", "Hlt1Factory"),
            HybridFactory: ("Hlt1HybridFactory", "Hlt2HybridFactory")
    }.iteritems():
        for name in names:
            f = Factory(name)
            f.OutputLevel = 2
            f.StatPrint = True
예제 #6
0
    def __apply_configuration__(self):
        """
        DaVinci configuration
        """
        log.info("Applying DaVinci configuration")
        log.info(self)

        self._checkOptions()

        self._setAncestorDepth()

        ApplicationMgr().TopAlg = [self.sequence()]
        self._configureSubPackages()
        importOptions(
            "$STDOPTS/PreloadUnits.opts")  # to get units in .opts files
        inputType = self._configureInput()
        self.sequence().Members = [self._dvInit()]
        self.sequence().Members += [self._filteredEventSeq()]

        # _lumi handles event count, lumi integration and merging independently
        self.sequence().Members += self._lumi()

        # Dec reports
        self._decReports()

        # Printouts ...
        verbosePrint = self.getProp("VerboseMessages")
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = verbosePrint
        from Configurables import DataOnDemandSvc
        DataOnDemandSvc().Dump = verbosePrint
        if not verbosePrint:
            msgSvc = getConfigurable("MessageSvc")
            msgSvc.setWarning += ['RFileCnv']

        self._defineMonitors()
        self._defineEvents()
        self._defineInput()
        self._rootFiles()

        # Add main sequence to TopAlg
        self._mainSequence()
        # monitoring
        self._moniSequence()

        self._root_in_Tes()
예제 #7
0
    def configureInit(self, inputType):
        # Init sequence
        if not self.isPropertySet("InitSequence"):
            if self._isReprocessing(inputType):
                self.setProp( "InitSequence", self.DefaultReproInitSequence )
            else:
                self.setProp( "InitSequence", self.DefaultInitSequence )
        from Configurables import ProcessPhase
        ProcessPhase("Init").DetectorList += self.getProp("InitSequence")

        from Configurables import RecInit, MemoryTool
        recInit = RecInit( "BrunelInit",
                           PrintFreq = self.getProp("PrintFreq"))
        GaudiSequencer("InitBrunelSeq").Members += [ recInit ]
        recInit.addTool( MemoryTool(), name = "BrunelMemory" )
        recInit.BrunelMemory.HistoTopDir = "Brunel/"
        recInit.BrunelMemory.HistoDir    = "MemoryTool"
        if not recInit.isPropertySet( "MemoryPurgeLimit" ): recInit.MemoryPurgeLimit = 2000 * 1000 # 2GB

        # count events
        from Configurables import EventCountHisto
        evtC = EventCountHisto("BrunelEventCount")
        evtC.HistoTopDir = "Brunel/"
        GaudiSequencer("InitBrunelSeq").Members += [ evtC ]

        # kill some RAW banks
        banksToKill = []
        if self.isPropertySet( "RawBanksToKill" ):
            banksToKill  = self.getProp( "RawBanksToKill" )
        if ("2009" == self.getProp("DataType")) and (inputType in ["MDF"]) and not self.getProp("Simulation") :
            banksToKill += ["VeloFull", "L0PUFull"]
        if len(banksToKill) > 0 :
            from Configurables import bankKiller
            bkKill = bankKiller("BrunelBankKiller")
            bkKill.BankTypes = banksToKill
            GaudiSequencer("InitBrunelSeq").Members += [ bkKill ]

        # Do not print event number at every event (done already by BrunelInit)
        EventSelector().PrintFreq = -1

        # OutputLevel
        self.setOtherProp(LHCbApp(),"OutputLevel")
        if self.isPropertySet( "OutputLevel" ) :
            level = self.getProp("OutputLevel")
            if level == ERROR or level == WARNING :
                # Suppress known warnings
                importOptions( "$BRUNELOPTS/SuppressWarnings.opts" )
                if not recInit.isPropertySet( "OutputLevel" ): recInit.OutputLevel = INFO
        self.setOtherProps(RecSysConf(), ["OutputLevel","Detectors"])
        self.setOtherProps(RecMoniConf(),["OutputLevel","Detectors"])

        # New NoSPDPRS switches
        noSPDPRS = False
        if [det for det in ['Spd', 'Prs'] if det not in self.getProp("Detectors")]:
            noSPDPRS = True
        # only set properties if no use RecoSequence is defined or if it contains 'PROTO'
        # not that 'PROTO' alone is not sufficient to run the Calo reconstruction, but a requirement
        if ( not self.isPropertySet("RecoSequence") or "PROTO" in self.getProp("RecoSequence") ):
            CaloProcessor().setProp("NoSpdPrs", noSPDPRS)
            GlobalRecoConf().setProp("NoSpdPrs", noSPDPRS)


        # Always print Magnetic Field used
        from Configurables import MagneticFieldSvc
        magSvc = MagneticFieldSvc()
        if not magSvc.isPropertySet("OutputLevel") :
            magSvc.setProp("OutputLevel", INFO)

        # Switch off LoKi banner
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = False
예제 #8
0
        found = False
        for loc in ['Hlt1', 'Hlt2']:
            reports = evt[loc + "/DecReports"]
            dec = "%sDecision" % decision
            rep = reports.decReport(dec)
            if rep and rep.decision():
                found = True
                break
        if found:
            break
    return n


# Configure all the unpacking, algorithms, tags and input files
appConf = ApplicationMgr()
appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

dv = DaVinci()
dv.DataType = "2012"

# disable for older versions of DV
# generally it seems in older versions of DV
# this whole script 'breaks' at places
# raising exceptions and yet works ...
dre = DecodeRawEvent()
dre.DataOnDemand = True

lhcbApp = LHCbApp()
lhcbApp.Simulation = True
CondDB().Upgrade = False
# don't really need tags for looking around
예제 #9
0
       "TupleToolGeometry"
       , "TupleToolKinematic"
       , "TupleToolTrackInfo"
       , "TupleToolPid"
       ]
decaytuple2.Decay = "[pi+]cc"


#######################################################################
#
# Configure the application
#

#remove the welcome message
from Configurables import LoKiSvc
LoKiSvc().Welcome = False

from Configurables import EventSelector
EventSelector().PrintFreq = 500


from Configurables import DaVinci


DaVinci().TupleFile = "SmrdPions.root"
DaVinci().EvtMax = 10
DaVinci().HistogramFile = "DVHistos.root"
DaVinci().DataType = '2010'
DaVinci().Simulation = True

예제 #10
0
def execute(inputdata=None,
            simulation=True,
            decay_descriptor="J/psi(1S) -> mu- mu+"):
    # Configure all the unpacking, algorithms, tags and input files
    appConf = ApplicationMgr()
    appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

    dv = DaVinci()
    dv.DataType = "2012"

    lhcbApp = LHCbApp()
    lhcbApp.Simulation = simulation
    CondDB().Upgrade = False
    # don't really need tags for looking around
    #LHCbApp().DDDBtag = t['DDDB']
    #LHCbApp().CondDBtag  = t['CondDB']

    muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles")

    jpsi = CombineParticles('MyJPsi')
    jpsi.DecayDescriptors = [decay_descriptor]
    jpsi.CombinationCut = "(AM < 7100.0 *GeV)"
    jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"}
    jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)"

    code = """
('J/psi(1S)' == ID) &
in_range(2.990*GeV, M, 3.210*GeV) &
DECTREE('%s') &
CHILDCUT(1, HASMUON & ISMUON) &
CHILDCUT(2, HASMUON & ISMUON) &
(MINTREE('mu+' == ABSID, PT) > 700*MeV) &
(MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) &
(MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) &
(VFASPF(VPCHI2) > 0.5/100) &
(abs(BPV(VZ)) <  0.5*meter) &
(BPV(vrho2) < (10*mm)**2)
""" % (decay_descriptor)
    filter_jpsi = FilterDesktop("MyFilterJPsi",
                                Code=code,
                                Preambulo=["vrho2 = VX**2 + VY**2"],
                                ReFitPVs=True)

    jpsi_sel = Selection("SelMyJPsi",
                         Algorithm=jpsi,
                         RequiredSelections=[muons])
    filter_jpsi_sel = Selection("SelFilterMyJPsi",
                                Algorithm=filter_jpsi,
                                RequiredSelections=[jpsi_sel])
    jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel)

    dtt = DecayTreeTuple("Early2015")
    dtt.Inputs = [jpsi_seq.outputLocation()]
    # Overwriting default list of TupleTools
    # XXX need to add TisTosTool with sensible lines
    dtt.ToolList = [
        "TupleToolKinematic",
        "TupleToolPid",
        "TupleToolMCBackgroundInfo",
    ]
    dtt.Decay = mark(2, mark(3, decay_descriptor))  #"J/psi(1S) -> ^mu- ^mu+"
    dtt.addBranches({
        "X": "^(%s)" % (decay_descriptor),
        "muplus": mark(3, decay_descriptor),  #"J/psi(1S) -> mu- ^mu+",
        "muminus": mark(2, decay_descriptor),  #"J/psi(1S) -> ^mu- mu+",
    })

    x_preamble = [
        "DZ = VFASPF(VZ) - BPV(VZ)",
    ]
    x_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "VPCHI2": "VFASPF(VPCHI2)",
        "DELTAZ": "DZ",
        # DZ * M / PZ / c with c in units of mm/s
        # XXX should this be the PDG mass or measured mass?
        #"TZ": "DZ*M / PZ / 299792458000.0", #seconds
        "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)",  #ps
        "minpt": "MINTREE('mu+' == ABSID, PT)",
        "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)",
        "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)",
    }
    muon_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "CHARGE": "Q",
        "CLONEDIST": "CLONEDIST",
        "TRCHI2DOF": "TRCHI2DOF",
    }

    loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X")
    loki_X.Variables = x_vars
    loki_X.Preambulo = x_preamble

    loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus")
    loki_mup.Variables = muon_vars
    loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus")
    loki_mum.Variables = muon_vars

    dv.UserAlgorithms = [jpsi_seq.sequence(), dtt]
    dv.TupleFile = "DVNtuples.root"

    if isinstance(inputdata, list):
        IOHelper('ROOT').inputFiles(inputdata)
def post_action_for_cpp():
    """
    Post-configh action to enforce initialization of DoD-algorithms
    """

    from Gaudi.Configuration import log

    log.info(
        '# VB: Post-action to enforce the initialization of DoD-algorithms')

    from Configurables import DataOnDemandSvc
    dod = DataOnDemandSvc()
    dod.PreInitialize = True  ## this is the most important line here

    ## dod.AllowPreInitializeFailure = True
    ## dod.Dump                      = True

    removed = []
    for key in dod.AlgMap:
        if 0 <= key.find('Raw/UT'):
            removed.append(key)
            log.warning('# VB:   REMOVE UT decoding from DataOnDemand!')
    dct = dod.AlgMap
    for k in removed:
        del dct[k]
    dod.AlgMap = dct

    from Configurables import ApplicationMgr
    app = ApplicationMgr(OutputLevel=5)
    app.EvtMax = 0
    app.EvtSel = 'NONE'

    from Configurables import LHCb__ParticlePropertySvc as PPSvc
    from Configurables import DetDataSvc
    from Configurables import LoKiSvc

    #
    ## some reshuffling of order of services is needed
    #    in particular DOD should come after PPSVC, LoKiSvc and ToolSvc
    #

    services = app.ExtSvc
    app.ExtSvc = [
        DetDataSvc('DetectorDataSvc'),
        PPSvc(),
        LoKiSvc(Welcome=False)
    ] + services + [dod]

    #
    ## suppress some prints
    #
    from Configurables import TimingAuditor
    timer = TimingAuditor()
    from Configurables import SequencerTimerTool
    timer.addTool(SequencerTimerTool, 'TIMER')
    timer.TIMER.OutputLevel = 5

    # suppress printout of various summaries from algorithms.
    from Gaudi.Configuration import allConfigurables
    for conf in allConfigurables.itervalues():
        for opt in ('StatPrint', 'ErrorsPrint', 'HistoPrint'):
            if opt in conf.__slots__:
                setattr(conf, opt, False)

    # ensure that prints from the main tools/factories are not suppressed
    import Configurables
    for factory in ('Tool', 'CoreFactory', 'TrackFunctorFactory', 'HltFactory',
                    'Hlt1HltFactory', 'Hlt2HltFactory'):
        factory = 'LoKi__Hybrid__%s' % factory
        try:
            factory = getattr(Configurables, factory)
            factory(OutputLevel=2, StatPrint=True)
        except AttributeError:
            # ignore unknown factories
            pass
예제 #12
0
    def _configureOnline(self):
        from Configurables import LoKiSvc
        LoKiSvc().Welcome = False

        import OnlineEnv
        EventLoopMgr().Warnings = False

        app = ApplicationMgr()

        # setup the histograms and the monitoring service
        from Configurables import MonitorSvc
        MonitorSvc().disableDimPropServer = 1
        MonitorSvc().disableDimCmdServer = 1
        MonitorSvc().disableMonRate = 0
        MonitorSvc().CounterUpdateInterval = 15
        app.ExtSvc.append('MonitorSvc')

        if self.getProp('EnableUpdateAndReset'):
            from Configurables import UpdateAndReset
            if not self.getProp('Simulation'):
                app.TopAlg = [UpdateAndReset()] + app.TopAlg

        HistogramPersistencySvc().OutputFile = ''
        HistogramPersistencySvc().Warnings = False
        from Configurables import RootHistCnv__PersSvc
        RootHistCnv__PersSvc().OutputEnabled = False

        # set up the event selector
        if 'EventSelector' in allConfigurables:
            del allConfigurables['EventSelector']

        # Enable Hlt2 ZeroMQ based monitoring
        if self.getProp("HltLevel") == "Hlt2":
            app.ExtSvc += ['HltMonitorSvc/Hlt2MonSvc', 'HltInfoSvc']

        ## Setup Checkpoint & forking: Do this EXACTLY here. Just befor the MEPManager & event selector.
        ## It will not work if these are created before.
        if OnlineEnv.MooreStartupMode == 1:
            self._configureOnlineForking()
        elif OnlineEnv.MooreStartupMode == 2:
            self._configureOnlineCheckpointing()

        importOptions('$MBM_SETUP_OPTIONS')
        mbm_setup = allConfigurables['OnlineEnv']
        task_type = os.environ['TASK_TYPE']

        input_buffer = mbm_setup.__getattribute__(task_type +
                                                  '_Input')  #'Events'
        output_buffer = mbm_setup.__getattribute__(task_type +
                                                   '_Output')  #'Send'
        self.__buffers = [input_buffer, output_buffer]
        TAE = (OnlineEnv.TAE != 0)
        mepMgr = OnlineEnv.mepManager(OnlineEnv.PartitionID,
                                      OnlineEnv.PartitionName, self.__buffers,
                                      False)
        mepMgr.PartitionBuffers = True
        mepMgr.PartitionName = OnlineEnv.PartitionName
        mepMgr.PartitionID = OnlineEnv.PartitionID
        mepMgr.ConnectWhen = 'start'

        app.Runable = OnlineEnv.evtRunable(mepMgr)
        app.ExtSvc.append(mepMgr)

        if TAE:
            eventSelector = OnlineEnv.mbmSelector(input=input_buffer,
                                                  TAE=TAE,
                                                  decode=False)
        elif self.getProp('HltLevel') == "Hlt2" or self.getProp(
                'ForceMDFInput'):
            eventSelector = OnlineEnv.mbmSelector(
                input=input_buffer, TAE=TAE,
                decode=False)  # decode=False for HLT2 ONLY!!!!!
        else:
            eventSelector = OnlineEnv.mbmSelector(input=input_buffer,
                                                  TAE=TAE,
                                                  decode=True)
        app.ExtSvc.append(eventSelector)

        OnlineEnv.evtDataSvc()
        if self.getProp('REQ1'): eventSelector.REQ1 = self.getProp('REQ1')

        from Configurables import AuditorSvc
        AuditorSvc().Auditors = []
        # Now setup the message service
        self._configureOnlineMessageSvc()
예제 #13
0
    def _outputLevel(self):
        """
        Set the print out of various tools, services, all algorithms, and properties of all things like algorithms
        Sensitive to the OutputLevel of Moore

        a) configure things independently of level
        b) configure things depending on level
           - ThresholdSettings via postConfigActions
           - TCKs via transforms

        defaults are now WARNING printouts only, so I need to handle the case the user wishes to switch back if a TCK has been generated with a warning

        """
        #firstly explicitly configure things not seen by TCK
        #firstly configure things which are level-independent

        # Usual output levels for services
        from Configurables import XmlParserSvc
        XmlParserSvc().OutputLevel = WARNING
        ApplicationMgr(
        ).OutputLevel = INFO  #I still want the Application Manager Finalized Sucessfully printout

        # Print algorithm name with 40 characters
        if not self.getProp("RunOnline"):
            if not MessageSvc().isPropertySet("Format"):
                MessageSvc().Format = '% F%40W%S%7W%R%T %0W%M'

        #this should be OK to do here...
        from Funcs import _minSetFileTypes

        #postconfig away common warnings
        def suppresswarningifneeded():
            #histogram warning isn't needed if I didn't want histograms
            from Configurables import RootHistCnv__PersSvc
            if RootHistCnv__PersSvc().getProp(
                    "OutputFile") == "UndefinedROOTOutputFileName" or not len(
                        RootHistCnv__PersSvc().getProp("OutputFile")):
                RootHistCnv__PersSvc().OutputEnabled = False
            if HistogramPersistencySvc().getProp(
                    "OutputFile") == '' or not HistogramPersistencySvc(
                    ).isPropertySet("OutputFile"):
                HistogramPersistencySvc().Warnings = False
            #error from IODataManager is pointless when I have MDFs
            from Funcs import _minSetFileTypes
            if Moore().getProp("RunOnline") or _minSetFileTypes() in [
                    "MDF", "RAW"
            ]:
                from Configurables import IODataManager
                IODataManager().DisablePFNWarning = True

        appendPostConfigAction(suppresswarningifneeded)

        #then configure things that depend on the level
        level = self.getProp("OutputLevel")
        from Configurables import LHCbSequencerTimerTool, SequencerTimerTool
        if level >= INFO: LHCbSequencerTimerTool().OutputLevel = WARNING
        if level >= INFO: SequencerTimerTool().OutputLevel = WARNING

        if level > DEBUG:
            from Configurables import LoKi__DistanceCalculator
            LoKi__DistanceCalculator().MaxPrints = 0
        if level > VERBOSE:
            from Configurables import LoKiSvc
            LoKiSvc().Welcome = False

        from Configurables import Hlt__Service
        if not Hlt__Service().isPropertySet('Pedantic'):
            Hlt__Service().Pedantic = (level < DEBUG)
        ###############################################################
        #if level is less than INFO, I don't need to edit anything else
        #it's up to the users to do that themselves!
        ###############################################################
        if level < INFO:
            return

        if level > INFO:
            if not self.getProp("RunOnline"):
                MessageSvc().OutputLevel = level
            ToolSvc().OutputLevel = level

        if level > INFO and hasattr(
                self, "EnableTimer") and self.getProp("EnableTimer") and type(
                    self.getProp("EnableTimer")) is not str:
            print "# WARNING: Timing table is too verbose for printing, consider outputting to a file instead please, Moore().EnableTimer='timing.csv', for example."

        #################################################
        # If the OutputLevel is set I need
        # Either a postConfigAction or a transform
        # to suppress the outputs properly
        #################################################

        #################################################
        # Running from thresholds, use post config action
        #################################################
        if not self.getProp("UseTCK") and level > INFO:
            #post config to really reset all the output to null
            from DAQSys.Decoders import DecoderDB
            from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools
            props = {}
            props["OutputLevel"] = level
            props["StatPrint"] = (level < WARNING)
            props["ErrorsPrint"] = (level < WARNING)
            props["PropertiesPrint"] = (level < WARNING)

            from DAQSys.Decoders import DecoderDB
            for k, v in DecoderDB.iteritems():
                for pk, pv in props.iteritems():
                    v.Properties[pk] = pv

            props["HistoCountersPrint"] = (level < WARNING)
            calo_tools = [
                "CaloECorrection/ECorrection",
                "CaloSCorrection/SCorrection",
                "CaloLCorrection/LCorrection",
                "CaloHypoEstimator",
                "CaloExtraDigits/SpdPrsExtraE",
                "CaloExtraDigits/SpdPrsExtraG",
                "CaloExtraDigits/SpdPrsExtraM",
                "CaloExtraDigits/SpdPrsExtraS",
                "CaloSelectCluster/PhotonCluster",
                "CaloSelectCluster/ElectronCluster",
                "CaloSelectChargedClusterWithSpd/ChargedClusterWithSpd",
                "CaloSelectClusterWithPrs/ClusterWithPrs",
                "CaloSelectNeutralClusterWithTracks/NeutralCluster",
                "CaloSelectNeutralClusterWithTracks/NotNeutralCluster",
                "CaloSelectorNOT/ChargedCluster",
                "CaloSelectNeutralClusterWithTracks/ChargedCluster.NeutralCluster",
            ]
            tools_per_type = {
                # turn off the calo tool finalize printout, there are *a lot* of tools here
                "CaloSinglePhotonAlg":
                calo_tools,
                "CaloElectronAlg":
                calo_tools,
                "CaloMergedPi0Alg":
                calo_tools,
                "NeutralProtoPAlg":
                calo_tools,
                # three extras for merged pi0
                "CaloMergedPi0Alg": [
                    "CaloCorrectionBase/ShowerProfile",
                    "CaloCorrectionBase/Pi0SCorrection",
                    "CaloCorrectionBase/Pi0LCorrection"
                ],
                # and one calo clustering
                "CellularAutomatonAlg": ["CaloClusterizationTool"],
            }
            func = partial(setPropertiesAndAddTools,
                           properties=props,
                           tools_per_type=tools_per_type,
                           force=True)

            # Instantiate a few public tools (members of the ToolService),
            # which means their output properties will also be set in the post config action
            from Configurables import LoKi__LifetimeFitter, CaloDigitFilterTool, CaloGetterTool, OTChannelMapTool, CaloClusterizationTool
            LoKi__LifetimeFitter("ToolSvc.lifetime")
            CaloDigitFilterTool("ToolSvc.FilterTool")
            CaloGetterTool("ToolSvc.CaloGetter")
            OTChannelMapTool("ToolSvc.OTChannelMapTool")
            CaloClusterizationTool("ToolSvc.CaloClusterizationTool")

            # visit_properties = ['Members', 'Filter0', 'Filter1', 'TopAlg']
            descend_properties = [
                'Members', 'Prescale', 'ODIN', 'L0DU', 'HLT', 'HLT1', 'HLT2',
                'Filter0', 'Filter1', 'Postscale'
            ]
            appendPostConfigAction(
                partial(recurseConfigurables,
                        func,
                        descend_properties=descend_properties,
                        descend_tools=True))

            #I still want to print "Application Manager Finalized Successfully"
            #and "End of event input reached" no matter what

            def AppMrgOP():
                if ApplicationMgr().getProp("OutputLevel") > INFO:
                    ApplicationMgr().OutputLevel = INFO
                if EventSelector().getProp("OutputLevel") > INFO:
                    EventSelector().OutputLevel = INFO

            appendPostConfigAction(AppMrgOP)

            def RestoreGenConfig():
                Moore().getConfigAccessSvc().OutputLevel = INFO
                from Configurables import HltGenConfig
                HltGenConfig().OutputLevel = INFO

            if self.getProp("generateConfig"):
                appendPostConfigAction(RestoreGenConfig)

            #################################################
            # Running from TCK define a similar transform
            #################################################
        elif self.getProp("UseTCK"):
            trans = {".*": {"OutputLevel": {"^.*$": str(level)}}}
            #turn certain things back on if INFO is set again...
            trans[".*"]["StatPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["ErrorsPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["PropertiesPrint"] = {"^.*$": str(level < WARNING)}
            trans[".*"]["HistoCountersPrint"] = {"^.*$": str(level < WARNING)}

            Funcs._mergeTransform(trans)

            #kill LoKi warnings
            set = 0
            if level < WARNING:
                set = 3
            trans = {
                ".*DistanceCalculator.*": {
                    "MaxPrints": {
                        "^.*$": str(set)
                    }
                }
            }
            Funcs._mergeTransform(trans)
            #kill one extra loki print in tool service
            from GaudiConf.Manipulations import recurseConfigurables, setPropertiesAndAddTools
            props = {}
            props["OutputLevel"] = level
            props["StatPrint"] = (level < WARNING)
            props["ErrorsPrint"] = (level < WARNING)
            props["PropertiesPrint"] = (level < WARNING)
            # postConfForAll(head=["LoKi::LifetimeFitter/ToolSvc.lifetime"],force=True,prop_value_dict=props)
            func = partial(setPropertiesAndAddTools,
                           properties=props,
                           force=True)
            appendPostConfigAction(
                partial(recurseConfigurables,
                        func,
                        head="LoKi::LifetimeFitter/ToolSvc.lifetime"))

            from Configurables import HltConfigSvc
            cfg = HltConfigSvc()
            #self-defeating warnings!
            cfg.OutputLevel = ERROR
예제 #14
0
def configOnline(app, alg, name):
    from Configurables import ApplicationMgr, UpdateAndReset
    appMgr = ApplicationMgr()

    ## Configure saving of histograms
    ur = UpdateAndReset()
    ur.saveHistograms = 1
    appMgr.TopAlg.insert(0, ur)

    from Configurables import LoKiSvc
    LoKiSvc().Welcome = False

    import OnlineEnv
    app.DDDBtag = OnlineEnv.DDDBTag
    app.CondDBtag = OnlineEnv.CondDBTag

    from Configurables import CondDB
    conddb = CondDB()
    conddb.IgnoreHeartBeat = True
    conddb.UseDBSnapshot = True
    conddb.EnableRunChangeHandler = True
    conddb.EnableRunStampCheck = False
    conddb.Tags['ONLINE'] = 'fake'

    import ConditionsMap
    conddb.RunChangeHandlerConditions = ConditionsMap.RunChangeHandlerConditions

    from Gaudi.Configuration import EventLoopMgr
    EventLoopMgr().Warnings = False

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

    MonitorSvc().ExpandCounterServices = 0;
    MonitorSvc().ExpandNameInfix       = "<part>_x_<program>/";
    MonitorSvc().PartitionName         = OnlineEnv.PartitionName;
    MonitorSvc().ProgramName           = name + "_00";

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

    from Gaudi.Configuration import allConfigurables
    # set up the event selector
    if 'EventSelector' in allConfigurables :
        del allConfigurables['EventSelector']

    input = 'Events'
    mepMgr = OnlineEnv.mepManager(OnlineEnv.PartitionID,OnlineEnv.PartitionName,[input],True)
    mepMgr.ConnectWhen = "start";

    appMgr.Runable = OnlineEnv.evtRunable(mepMgr)
    appMgr.SvcOptMapping.append('LHCb::OnlineEvtSelector/EventSelector')
    appMgr.SvcOptMapping.append('LHCb::FmcMessageSvc/MessageSvc')
    appMgr.ExtSvc.append(mepMgr)

    eventSelector = OnlineEnv.mbmSelector(input = input, type = 'ONE', decode = False, event_type = 2)
    appMgr.ExtSvc.append(eventSelector)
    appMgr.ExtSvc.append(mepMgr)
    appMgr.OutputLevel = 3

    OnlineEnv.evtDataSvc()
    eventSelector.REQ1 = 'EvType=2;TriggerMask=0x0,0x4,0x0,0x0;VetoMask=0,0,0,0x300;MaskType=ANY;UserType=USER;Frequency=PERC;Perc=100.0'
    appMgr.EvtSel = eventSelector

    from Configurables import AuditorSvc
    AuditorSvc().Auditors = []
    configMsgSvc( appMgr )
    OnlineEnv.end_config(False)
예제 #15
0
#from Configurables import Hlt2Conf
#Hlt2Conf().Hlt1TrackOption = "Rerun"

import GaudiPython
from Gaudi.Configuration import ApplicationMgr
from Configurables import LoKiSvc

appMgr = ApplicationMgr()
#
from Configurables import EventNodeKiller
enk = EventNodeKiller('KillTrigRawEvent')
enk.Nodes = [ "Hlt","Hlt1","Hlt2" ]
appMgr.TopAlg.insert( 0,  enk.getFullName() ) 
#
appMgr.ExtSvc += ['DataOnDemandSvc'] #breaks for real data
appMgr.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]
#appMgr.TopAlg += [ seq ]
gaudi = GaudiPython.AppMgr(outputlevel=4)
gaudi.initialize()

gaudi.algorithm('Hlt').Enable = False
gaudi.algorithm('KillTrigRawEvent').Enable = False
triggerTisTosTool = gaudi.toolsvc().create('TriggerTisTos', interface='ITriggerTisTos')
triggerTisTosTool1 = gaudi.toolsvc().create('Hlt1TriggerTisTos', interface='ITriggerTisTos')
triggerTisTosTool2 = gaudi.toolsvc().create('Hlt2TriggerTisTos', interface='ITriggerTisTos')
tes = gaudi.evtsvc()

hlt1names = [ 
        "Hlt1TrackAllL0Decision"
        ]
예제 #16
0
def execute(simulation=True,
            turbo=True,
            decay_descriptor="J/psi(1S) -> mu- mu+"):
    # Configure all the unpacking, algorithms, tags and input files
    appConf = ApplicationMgr()
    appConf.ExtSvc += ['ToolSvc', 'DataOnDemandSvc', LoKiSvc()]

    ConfigTarFileAccessSvc().File = 'config.tar'

    dv = DaVinci()
    dv.DataType = "2012"

    lhcbApp = LHCbApp()
    lhcbApp.Simulation = simulation
    CondDB().Upgrade = False

    dtt = DecayTreeTuple("Early2015")
    if turbo:
        tesla_prefix = "Hlt2DiMuonJPsi"
        dtt.Inputs = ["/Event/" + tesla_prefix + "/Particles"]
        dtt.InputPrimaryVertices = "/Event/" + tesla_prefix + "/Primary"
        dtt.WriteP2PVRelations = False

    else:
        LHCbApp().DDDBtag = "dddb-20140729"
        polarity = "u"
        LHCbApp().CondDBtag = "sim-20140730-vc-m%s100" % polarity
        muons = AutomaticData(Location="Phys/StdAllLooseMuons/Particles")

        jpsi = CombineParticles('MyJPsi')
        jpsi.DecayDescriptors = [decay_descriptor]
        jpsi.CombinationCut = "(AM < 7100.0 *GeV)"
        jpsi.DaughtersCuts = {"": "ALL", "mu+": "ALL", "mu-": "ALL"}
        jpsi.MotherCut = "(VFASPF(VCHI2/VDOF) < 999999.0)"

        code = """
('J/psi(1S)' == ID) &
in_range(2.990*GeV, M, 3.210*GeV) &
DECTREE('%s') &
CHILDCUT(1, HASMUON & ISMUON) &
CHILDCUT(2, HASMUON & ISMUON) &
(MINTREE('mu+' == ABSID, PT) > 700*MeV) &
(MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF) < 5) &
(MINTREE(ISBASIC & HASTRACK, CLONEDIST) > 5000) &
(VFASPF(VPCHI2) > 0.5/100) &
(abs(BPV(VZ)) <  0.5*meter) &
(BPV(vrho2) < (10*mm)**2)
""" % (decay_descriptor)
        # similar to the HLT2 line
        code = """
(ADMASS('J/psi(1S)')< 120*MeV) &
DECTREE('%s') &
(PT>0*MeV) &
(MAXTREE('mu-'==ABSID,TRCHI2DOF) < 4) &
(MINTREE('mu-'==ABSID,PT)> 0*MeV) &
(VFASPF(VCHI2PDOF)< 25)
""" % (decay_descriptor)
        filter_jpsi = FilterDesktop(
            "MyFilterJPsi",
            Code=code,
            Preambulo=["vrho2 = VX**2 + VY**2"],
            ReFitPVs=True,
            #IgnoreP2PVFromInputLocations=True,
            #WriteP2PVRelations=True
        )

        jpsi_sel = Selection("SelMyJPsi",
                             Algorithm=jpsi,
                             RequiredSelections=[muons])
        filter_jpsi_sel = Selection("SelFilterMyJPsi",
                                    Algorithm=filter_jpsi,
                                    RequiredSelections=[jpsi_sel])
        jpsi_seq = SelectionSequence("SeqMyJPsi", TopSelection=filter_jpsi_sel)
        dtt.Inputs = [jpsi_seq.outputLocation()]

    # Overwriting default list of TupleTools
    dtt.ToolList = [
        "TupleToolKinematic",
        "TupleToolPid",
        "TupleToolEventInfo",
        "TupleToolMCBackgroundInfo",
        "TupleToolMCTruth",
        #"MCTupleToolHierarchy",
        #"MCTupleToolPID",
        "TupleToolGeometry",
        "TupleToolTISTOS",
        # with turbo this crashes
        #"TupleToolTrackInfo",
        "TupleToolTrigger",
    ]
    tlist = [
        "L0HadronDecision",
        "L0MuonDecision",
        "L0DiMuonDecision",
        "L0ElectronDecision",
        "L0PhotonDecision",
        "Hlt1DiMuonHighMassDecision",
        "Hlt1DiMuonLowMassDecision",
        "Hlt1TrackMuonDecision",
        "Hlt1TrackAllL0Decision",
        "Hlt2DiMuonJPsiDecision",
        "Hlt2SingleMuonDecision",
    ]

    dtt.addTool(TupleToolTrigger, name="TupleToolTrigger")
    dtt.addTool(TupleToolTISTOS, name="TupleToolTISTOS")
    # Get trigger info
    dtt.TupleToolTrigger.Verbose = True
    dtt.TupleToolTrigger.TriggerList = tlist
    dtt.TupleToolTISTOS.Verbose = True
    dtt.TupleToolTISTOS.TriggerList = tlist

    from Configurables import TupleToolMCTruth, MCTupleToolHierarchy
    dtt.addTool(TupleToolMCBackgroundInfo, name="TupleToolMCBackgroundInfo")
    dtt.TupleToolMCBackgroundInfo.Verbose = True
    dtt.addTool(MCTupleToolHierarchy, name="MCTupleToolHierarchy")
    dtt.MCTupleToolHierarchy.Verbose = True
    dtt.addTool(TupleToolMCTruth, name="TupleToolMCTruth")
    dtt.TupleToolMCTruth.Verbose = True

    if turbo:
        assoc_seq = TeslaTruthUtils.associateSequence(tesla_prefix, False)
        ChargedPP2MC(tesla_prefix + "ProtoAssocPP").OutputLevel = 1

        assoc_seq.Members.insert(0, PatLHCbID2MCParticle())

        from Configurables import MuonCoord2MCParticleLink
        muon_coords = MuonCoord2MCParticleLink("TeslaMuonCoordLinker")
        assoc_seq.Members.insert(1, muon_coords)

        TrackAssociator("TeslaAssocTr").DecideUsingMuons = True

        relations = TeslaTruthUtils.getRelLoc(tesla_prefix)

    else:
        relations = "Relations/Rec/ProtoP/Charged"

    TeslaTruthUtils.makeTruth(dtt, relations, [
        "MCTupleToolKinematic",
        "MCTupleToolHierarchy",
        "MCTupleToolPID",
    ])

    dtt.Decay = mark(2, mark(3, decay_descriptor))  #"J/psi(1S) -> ^mu- ^mu+"

    dtt.addBranches({
        "X": "^(%s)" % (decay_descriptor),
        "muplus": mark(3, decay_descriptor),  #"J/psi(1S) -> mu- ^mu+",
        "muminus": mark(2, decay_descriptor),  #"J/psi(1S) -> ^mu- mu+",
    })

    x_preamble = [
        "DZ = VFASPF(VZ) - BPV(VZ)",
    ]
    x_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "VPCHI2": "VFASPF(VPCHI2)",
        "DELTAZ": "DZ",
        # DZ * M / PZ / c with c in units of mm/s
        # XXX should this be the PDG mass or measured mass?
        #"TZ": "DZ*M / PZ / 299792458000.0", #seconds
        "TZ": "DZ*3096.916 / PZ/299792458000.0*(10**12)",  #ps
        "minpt": "MINTREE('mu+' == ABSID, PT)",
        "minclonedist": "MINTREE(ISBASIC & HASTRACK, CLONEDIST)",
        "maxtrchi2dof": "MAXTREE(ISBASIC & HASTRACK, TRCHI2DOF)",
    }
    muon_vars = {
        "ETA": "ETA",
        "Y": "Y",
        "PHI": "PHI",
        "CHARGE": "Q",
        "CLONEDIST": "CLONEDIST",
        "TRCHI2DOF": "TRCHI2DOF",
    }

    loki_X = dtt.X.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_X")
    loki_X.Variables = x_vars
    loki_X.Preambulo = x_preamble

    loki_mup = dtt.muplus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuPlus")
    loki_mup.Variables = muon_vars
    #dtt.muplus.addTupleTool("TupleToolGeometry")

    loki_mum = dtt.muminus.addTupleTool("LoKi::Hybrid::TupleTool/LoKi_MuMinus")
    loki_mum.Variables = muon_vars
    #dtt.muminus.addTupleTool("TupleToolGeometry")

    dv.TupleFile = "DVNtuples.root"
    if turbo:
        dv.UserAlgorithms = [assoc_seq, dtt]

    else:
        assocpp = ChargedPP2MC("TimsChargedPP2MC")
        assocpp.OutputLevel = 1
        dv.UserAlgorithms = [jpsi_seq.sequence(), assocpp, dtt]