Beispiel #1
0
def setThresholds(ThresholdSettings, conf_):
    """
    Look in ThresholdSettings for configurable conf_
    and set the appropriate settings
    
    @author G. Raven, P. Koppenburg
    @date 23/7/2009 (moved)
    """
    from Gaudi.Configuration import log
    from HltLine.HltLinesConfigurableUser import HltLinesConfigurableUser
    assert issubclass(conf_, HltLinesConfigurableUser
                      ), '%s is not an HltLinesConfigurableUser' % i.__name__
    conf = conf_(
    )  # The configurable _must_ be instantiated even if not explicitly configured. Or it will be ignored
    for (k, v) in ThresholdSettings.get(conf_, dict()).iteritems():
        if hasattr(conf, k) and v == getattr(conf, k):
            continue  # nothing to do, move on to next item...

        # configurables have an exception for list and dict:
        #   even if not explicitly set, if you ask for them, you get one...
        #   this is done to make foo().somelist += ... work.
        # hence we _assume_ that, even if we have an attr, but it matches the
        # default, it wasn't set explicitly, and we overrule it...
        if hasattr(conf, k) and conf.getProp(k) != conf.getDefaultProperty(k):
            log.warning(
                '%s.%s has explicitly been set, NOT using requested predefined threshold %s, but keeping explicit value: %s '
                % (conf.name(), k, str(v), getattr(conf, k)))
        else:
            if (type(v) == dict
                ):  # special case for dictionaries (needed in topo)
                val = None
                try:
                    val = conf.getProp(k)
                except KeyError as ke:
                    log.warning("Cannot get property %s of Configurable %s" %
                                (k, conf.getName()))
                    raise ke
                val.update(v)
                setattr(conf, k, val)
            else:
                setattr(conf, k, v)
Beispiel #2
0
def Name2Threshold(name):
    if not hasattr(Name2Threshold, '_dict'): Name2Threshold._dict = {}
    if name not in Name2Threshold._dict:
        from Gaudi.Configuration import log
        log.warning(' ' + '#' * (41 + len(name)))
        log.warning(' ## using trigger threshold settings "%s" ##' % name)
        try:
            mod = getattr(__import__('HltSettings.%s' % name), name)
            cls = getattr(mod, name)
        except (AttributeError, ImportError) as error:
            log.error(
                '   ## Unknown ThresholdSetting "%s" -- please fix Moore().ThresholdSetting ##'
                % name)
            raise error
        Name2Threshold._dict[name] = cls()
        #log.warning(' ## type is %-30s ##' % Name2Threshold._dict[name].HltType() )
        log.warning(' ' + '#' * (41 + len(name)))
    return Name2Threshold._dict[name]
Beispiel #3
0
def _kaons_(self):
    return kaons


def _pions_(self):
    return pions

#
# get the selections
#
PC.pions = _pions_
PC.kaons = _kaons_
PC.protons = _protons_
#
logger.warning("Redefine PromptCharm.pions   ")
logger.warning("Redefine PromptCharm.kaons   ")
logger.warning("Redefine PromptCharm.protons ")
#

# =============================================================================
# Lambda_C* -> Lambda_C pi pi selection
# =============================================================================


def _LamCstar_(self):

    sel = self._selection('LambdaCstarForPromptCharm_Selection')
    if sel:
        return sel
Beispiel #4
0
    def __apply_configuration__(self):
        """
        Converts the high-level information passed as properties into low-level configuration.
        """
        # special case for online
        if self.getProp('UseDBSnapshot'): self._configureDBSnapshot()

        # In the Online/Upgrade/Simulation environment, LoadCALIBDB should be defaulted to HLT1
        if self.getProp("Online") or self.getProp('Upgrade') or self.getProp(
                'Simulation'):
            self._properties["LoadCALIBDB"].setDefault("HLT1")
        # Set up environment variables for loading CALIBOFF layers, must be before loading any tags
        LoadCALIBDB = self.getProp('LoadCALIBDB')
        loadcaliboptions = ["HLT1", "OFFLINE"]
        if LoadCALIBDB not in loadcaliboptions:
            raise ValueError(
                "'%s' is not a valid LoadCALIBDB value. Allowed: %s" %
                (LoadCALIBDB, loadcaliboptions))
        if LoadCALIBDB is "OFFLINE" and not exists(
                join(os.environ["SQLITEDBPATH"], "CALIBOFF.db")):
            LoadCALIBDB = "HLT1"  # When CALIBOFF.db is not there, reset the option
        os.environ['LoadCALIBDB'] = LoadCALIBDB

        # Set the usage of the latest global/local tags
        old_latest_Tags_prop = self.getProp(
            "UseLatestTags")  # it is deprecated
        latest_GTags_prop = self.getProp("LatestGlobalTagByDataTypes")
        if not latest_GTags_prop:  # if property not set
            latest_GTags_prop = self.getProp("LatestGlobalTagByDataType")
        latest_LTags_prop = self.getProp("LatestLocalTagsByDataType")
        all_LTags_prop = self.getProp("AllLocalTagsByDataType")

        if old_latest_Tags_prop:
            if latest_GTags_prop or latest_LTags_prop:
                log.warning(
                    "The property 'UseLatestTags' is deprecated:"
                    "'LatestGlobalTagByDataType(s)' and 'LatestLocalTagsByDataType'"
                    " will be used instead.")
            else:
                latest_GTags_prop = old_latest_Tags_prop[0]
                if type(old_latest_Tags_prop[-1]) != bool or \
                   (type(old_latest_Tags_prop[-1]) == bool and not old_latest_Tags_prop[1]):
                    latest_LTags_prop = old_latest_Tags_prop[0]

        if latest_GTags_prop:
            datatype = latest_GTags_prop
            if self.getProp("Tags"):
                self.Tags = {}
            self._useLatestTags(datatype, OnlyGlobalTags=True)
            log.warning(
                "Default global tags will be overridden with the latest ones"
                " available for '%s' data type: %s" %
                (datatype, self.getProp("Tags")))

        if latest_LTags_prop:
            datatypes = latest_LTags_prop
            #if self.getProp("LocalTags"):
            #    self.LocalTags = {}
            self._useLatestTags(datatypes, OnlyLocalTags=True)
            log.warning(
                "Latest unbound local tags on top of the latest global tags"
                " of %s data type(s) are added: %s" %
                (datatypes, self.getProp("LocalTags")))

        if all_LTags_prop:
            datatypes = all_LTags_prop
            self._useAllLocalTags(datatypes)
            log.warning("ALL local tags of %s data type(s) are added: %s" %
                        (datatypes, self.getProp("LocalTags")))

        # Import SQLDDDB specific info
        if self.getProp("UseOracle"):
            CondDBAccessSvc("ONLINE", ConnectionString="CondDBOnline/ONLINE")
            if self.getProp("DisableLFC"):
                COOLConfSvc(UseLFCReplicaSvc=False)
        elif self.getProp('UseDBSnapshot'):
            CondDBAccessSvc("ONLINE")
        else:
            configureOnlineSnapshots()
#            importOptions("$SQLDDDBROOT/options/SQLDDDB.py")

#########################################################################
# Access to ConditionsDB
##########################################################################
        conns = self.getProp("PartitionConnectionString")
        tags = self.getProp("Tags")
        # DB partitions
        partition = {}
        parttypes = [("DDDB", CondDBAccessSvc), ("LHCBCOND", CondDBAccessSvc),
                     ("ONLINE", CondDBTimeSwitchSvc),
                     ("SIMCOND", CondDBAccessSvc),
                     ("DQFLAGS", CondDBAccessSvc)]
        if LoadCALIBDB is "OFFLINE":
            # CALIBOFF not needed for the upgrade
            parttypes += [("CALIBOFF", CondDBAccessSvc)]

        for (p, t) in parttypes:
            partition[p] = getAnyDBReader(p, t)
            # Override connection strings:
            if p in conns:
                if type(partition[p]) is CondDBAccessSvc:
                    partition[p].ConnectionString = conns[p]
                    del conns[p]

            # Override connection strings for Upgrade case
            if self.getProp('Simulation') and self.getProp('Upgrade') and type(
                    partition[p]) is CondDBAccessSvc:
                partition[p].ConnectionString = os.path.join(
                    'sqlite_file:$SQLITEUPGRADEDBPATH', p + '.db', p)
            # Override tags
            if p in tags and p != "ONLINE":
                partition[p].DefaultTAG = tags[p]
                del tags[p]
            # Set the query granularity
            if p != "CALIBOFF":
                self.propagateProperty("QueryGranularity", partition[p])
            if type(partition[p]) is CondDBTimeSwitchSvc:  # also online
                for r in partition[p].Readers:
                    config = allConfigurables[eval(
                        r.split(':')[0]).split("/")[1]]
                    if isinstance(config, CondDBAccessSvc):
                        self.propagateProperty("QueryGranularity", config)
                    # Pass along the configuration for the layered DBs
                    elif isinstance(config, CondDBLayeringSvc):
                        for ly in config.Layers:
                            if isinstance(ly, CondDBAccessSvc):
                                self.propagateProperty("QueryGranularity", ly)

        if conns:
            log.warning(
                "Cannot override the connection strings of the partitions %r",
                conns.keys())
        if tags and tags.keys() != ['ONLINE']:
            log.warning("Cannot set the tag for partitions %r", tags.keys())

        # In the Online environment, IgnoreHeartBeat should be defaulted to True
        if self.getProp("Online"):
            self._properties["IgnoreHeartBeat"].setDefault(True)
        if not self.getProp("IgnoreHeartBeat"):
            if isinstance(partition["ONLINE"], CondDBAccessSvc):
                self.propagateProperty("HeartBeatCondition",
                                       partition["ONLINE"])
            elif isinstance(partition["ONLINE"], CondDBTimeSwitchSvc):
                # Add the heart beat conditions to the latest snapshot only since the
                # others are limited but valid by construction.
                if partition["ONLINE"].Readers:
                    latest = partition["ONLINE"].Readers[-1]
                    config = allConfigurables[eval(
                        latest.split(':')[0]).split("/")[1]]
                    if isinstance(config, CondDBAccessSvc):
                        self.propagateProperty("HeartBeatCondition", config)
                    # Pass along the configuration for the layered DBs
                    elif isinstance(config, CondDBLayeringSvc):
                        for ly in config.Layers:
                            #Only apply HeartBeatCondition for ONLINE
                            if isinstance(ly, CondDBAccessSvc) and ly.getName(
                            ).startswith("ONLINE_"):
                                self.propagateProperty("HeartBeatCondition",
                                                       ly)

        if not self.getProp("Simulation"):
            # Standard configurations
            #  - Reconstruction / analysis
            disp = CondDBDispatcherSvc("MainCondDBReader",
                                       MainAccessSvc=partition["DDDB"],
                                       Alternatives={
                                           "/Conditions":
                                           partition["LHCBCOND"],
                                           "/Conditions/Online":
                                           partition["ONLINE"],
                                           "/Conditions/DQ":
                                           partition["DQFLAGS"]
                                       })
        else:
            #  - Simulation
            disp = CondDBDispatcherSvc(
                "SimulationCondDBReader",
                MainAccessSvc=partition["DDDB"],
                Alternatives={"/Conditions": partition["SIMCOND"]})
        CondDBCnvSvc(CondDBReader=disp)

        if not (self.getProp("Online") or self.getProp("Simulation")):
            self._properties["EnableRunStampCheck"].setDefault(True)
        if self.getProp("EnableRunStampCheck"):
            from Configurables import RunStampCheck
            rsc = RunStampCheck()
            self.propagateProperty("RunStampCondition", rsc)
            ApplicationMgr().ExtSvc.append(rsc)

        # Load the CALIBOFF layer above everything if it exists
#        if len([x for x in parttypes if x[0] == 'CALIBOFF']):
#            self._addLayer(getAnyDBReader('CALIBOFF'))

        localTags = self.getProp("LocalTags")
        not_applied = []
        for p in localTags:
            if p in partition:
                taglist = list(localTags[p])
                taglist.reverse(
                )  # we need to stack the in reverse order to use the first as on top of the others
                i = 0  # counter
                if p is "CALIBOFF":
                    if LoadCALIBDB is not "OFFLINE":
                        raise ValueError(
                            "invalid argument LoadCALIBDB set at '%s' instead of 'OFFLINE' for accessing local tags for CALIBOFF.db"
                            % LoadCALIBDB)
                    pcolayers = []
                    for t in taglist:
                        pcolayers.append(partition[p].clone("CALIBOFF_%d" % i,
                                                            DefaultTAG=t))
                        i += 1
                        for r in partition["ONLINE"].Readers:
                            config = allConfigurables[eval(
                                r.split(':')[0]).split("/")[1]]
                            if isinstance(config, CondDBLayeringSvc):
                                config.Layers = pcolayers + config.Layers
                elif type(partition[p]) is not CondDBTimeSwitchSvc:
                    for t in taglist:
                        self._addLayer(partition[p].clone("%s_%d" % (p, i),
                                                          DefaultTAG=t))
                        i += 1
                else:
                    not_applied.append(p)
            else:
                not_applied.append(p)
        if not_applied:
            log.warning("Cannot set the local tags for partitions %r",
                        not_applied)

        # Modify partitions to use local copies of the DBs
        # before adding user layers and alternatives, which should be already local.
        # This is a no-operation if the property is not set
        self.__make_sqlite_local_copy__(CondDBCnvSvc())

        # Add layers and alternatives
        call = {
            self.LAYER: self._addLayer,
            self.ALTERNATIVE: self._addAlternative
        }
        for override in self.getProp("Overrides"):
            apply(call[override[0]], override[1:])

        # Add the logger
        filename = self.getProp("LogFile")
        if filename:
            cnvSvc = allConfigurables["CondDBCnvSvc"]
            cnvSvc.CondDBReader = CondDBLogger(
                LoggedReader=cnvSvc.CondDBReader, LogFile=filename)

        # Suppress pointless warning from COOL_2_5_0
        msgSvc = getConfigurable("MessageSvc")
        msgSvc.setError.append("RelationalDatabase")

        # Set up Virtual File System service, can be used by ParticlePropertySvc
        from Gaudi.Configuration import VFSSvc
        from Configurables import CondDBEntityResolver
        VFSSvc().FileAccessTools.append(CondDBEntityResolver())
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
Beispiel #6
0
# ============================================================================= 

# =============================================================================
## redefine psi(') -> mu+ mu- to use "stripping versions" 
# =============================================================================

def _psi_ ( self ) :
    """
    psi(') -> mu+ mu- 
    """
    return psis

PsiX0 . psi = _psi_
PsiX  . psi = _psi_

logger.warning ( "Redefine PsiX .psi" )
logger.warning ( "Redefine PsiX0.psi" )


psix   = PsiX   ( 'PsiX'  , {} )
psix0  = PsiX0  ( 'PsiX0' , {} )

# ============================================================================-
## adjust vertex fitter
# ============================================================================-
for s in ( psix.psi_pi       () ,
           psix.psi_K        () ,
           #
           psix.psi_2pi      () ,
           psix.psi_2K       () ,
           psix.psi_2Kpi     () ,