Exemplo n.º 1
0
def timer(obj, *args):
    """ Define the timers
    >>> fun   = ...
    >>> fun_t = timer ( fun ) 
    """
    ##
    if hasattr(obj, '__timer__'): return obj.__timer__(*args)
    ##
    if isinstance(obj, str):
        if not args: return LoKi.Timer(obj)
        elif 1 == len(args):
            arg0 = args[0]
            if hasattr(arg0, '__timer__'): return timer(arg0, obj)
    ##
    raise TypeErorr, "Invalid arguments "
Exemplo n.º 2
0
from LoKiCore.functions import equal_to

# Namespaces:
from LoKiCore.basic import cpp, std, LoKi, LHCb, Gaudi

_RCP = 'const LHCb::Particle*'
_RCV = 'const LHCb::VertexBase*'

_c1 = std.vector(_RCP)
_c2 = std.vector(_RCV)

## ranges
Range = Gaudi.NamedRange_(_c1)
VRange = Gaudi.NamedRange_(_c2)
## range-lists:
RangeL = LoKi.RangeList_(Range)
VRangeL = LoKi.RangeList_(VRange)

# =============================================================================
## "The main" types
# =============================================================================

## @see LoKi::Types::Func
Func = LoKi.Functor(_RCP, 'double')
## @see LoKi::Types::Cuts
Cuts = LoKi.Functor(_RCP, bool)
## @see LoKi::Types::Fun
Fun = LoKi.FunctorFromFunctor(_RCP, 'double')
## @see LoKi::Types::Cut
Cut = LoKi.FunctorFromFunctor(_RCP, bool)
## @see LoKi::Types::Func
Exemplo n.º 3
0
# =============================================================================

import LoKiCore.decorators as _LoKiCore

# Namespaces:
from LoKiCore.basic import cpp, std, LoKi
LHCb = cpp.LHCb

_T = 'const LHCb::Track*'

# =============================================================================
## "Ordinary" functions for Tracks: "Tr"
# =============================================================================

## @see LoKi::Types::TrFunc
TrFunc = LoKi.Functor(_T, 'double')
## @see LoKi::Types::TrCuts
TrCuts = LoKi.Functor(_T, bool)
## @see LoKi::Types::TrFun
TrFun = LoKi.FunctorFromFunctor(_T, 'double')
## @see LoKi::Types::TrCut
TrCut = LoKi.FunctorFromFunctor(_T, bool)

## @see LoKi::Cuts::TrTYPE
TrTYPE = LoKi.Tracks.Type()

## @see @see LoKi::Cuts::TrALL
TrALL = LoKi.Constant(_T, bool)(True)
## @see LoKi::Cuts::TrBACKWARD
TrBACKWARD = LoKi.Tracks.CheckFlag(LHCb.Track.Backward)
## @see LoKi::Cuts::TrCHI2
Exemplo n.º 4
0
def first_n(N):
    """
    helper object to select the first N-elements from the stream 
    """
    return LoKi.FirstN(N)
Exemplo n.º 5
0
    return doubles(lst, *args)


# =============================================================================
## @see LoKi::FirstN
def first_n(N):
    """
    helper object to select the first N-elements from the stream 
    """
    return LoKi.FirstN(N)


# =============================================================================
## @see LoKi::Dump
Dump = LoKi.Dump
dump = LoKi.Dump()
## @see LoKi::Reverse
reverse = LoKi.Reverse()


## add the sequence to the vector
def _iadd_(v, o):
    """
    add the sequence to the vector
    """
    if hasattr(o, '__len__') and not issubclass(type(o), str):
        for i in o:
            v.push_back(i)
    else:
        v.push_back(o)
    return v
Exemplo n.º 6
0
      This file is a part of LoKi project - 
'C++ ToolKit  for Smart and Friendly Physics Analysis'

The package has been designed with the kind help from
Galina PAKHLOVA and Sergey BARSUK.  Many bright ideas, 
contributions and advices from G.Raven, J.van Tilburg, 
A.Golutvin, P.Koppenburg have been used in the design.
"""
# =============================================================================
__author__ = "Pieter David [email protected]"
__date__ = "2007-05-29"
__version__ = "$Revision$ "
# =============================================================================

from LoKiCore.basic import LoKi, std, cpp
FALL = LoKi.Constant("void", bool)(True)
_c1 = std.vector('const LHCb::MCParticle*')
MCRange = cpp.Gaudi.NamedRange_(_c1)

# =============================================================================
if '__main__' == __name__:

    print 80 * '*'
    print __doc__
    print ' Author  : ', __author__
    print ' Version : ', __version__
    print ' Date    : ', __date__
    print 80 * '*'
    for i in dir():
        print i
Exemplo n.º 7
0
try:
    from GaudiKernel import ROOT6WorkAroundEnabled
except ImportError:
    # dummy implementation
    def ROOT6WorkAroundEnabled(id=None):
        return False


if ROOT6WorkAroundEnabled('template-autoloading'):
    cpp.gSystem.Load('libLoKiNumbersDict')

_d = 'double'
## _v = std.vector( _d )
_v = 'std::vector<double>'
XFunc = LoKi.Functor(_d, _d)
XFun = LoKi.FunctorFromFunctor(_d, _d)
XCuts = LoKi.Functor(_d, bool)
XCut = LoKi.FunctorFromFunctor(_d, bool)

XMaps = LoKi.Functor(_v, _v)
XMap = LoKi.FunctorFromFunctor(_v, _v)
XPipes = XMaps
XPipe = XMap

XFunVals = LoKi.Functor(_v, _d)
XFunVal = LoKi.FunctorFromFunctor(_v, _d)
XSources = LoKi.Functor('void', _v)
XSource = LoKi.FunctorFromFunctor('void', _v)

XVCuts = LoKi.Functor(_v, bool)
Exemplo n.º 8
0
def _decorate(name=_name):
    """
    Make the decoration of all objects from this module
    """

    import LoKiCore.decorators as _LoKiCore

    p = 'const LHCb::Particle*'
    v = 'const LHCb::VertexBase*'
    d = 'double'
    _vp = 'std::vector<const LHCb::Particle*>'  ## std.vector( p )
    _vv = 'std::vector<const LHCb::VertexBase*>'  ## std.vector( v )
    _vd = 'std::vector<double>'  ## std.vector( 'double' )
    #_vp  = std.vector( p )
    #_vv  = std.vector( v )
    #_vd  = std.vector( 'double' )
    #

    # "function" : Particle -> double
    _decorated = _LoKiCore.getAndDecorateFunctions(
        name,  ## module name                                   , ## the base 
        LoKi.Functor(p, 'double'),  ## the base
        LoKi.Dicts.FunCalls(LHCb.Particle),  ## call-traits
        LoKi.Dicts.FuncOps(p, p))  ## operators&operations

    # "function" : Vertex -> double
    _decorated |= _LoKiCore.getAndDecorateFunctions(
        name,  ## module name  
        LoKi.Functor(v, 'double'),  ## the base
        LoKi.Dicts.FunCalls(LHCb.VertexBase),  ## call-traits
        LoKi.Dicts.FuncOps(v, v))  ## operators&operations

    # "predicate/cut" :  Particle -> bool
    _decorated |= _LoKiCore.getAndDecoratePredicates(
        name,  ## module name  
        LoKi.Functor(p, bool),  ## the base
        LoKi.Dicts.CutCalls(LHCb.Particle),  ## call-traits
        LoKi.Dicts.CutsOps(p, p))  ## operators&operations

    # "predicate/cut" :  Vertex -> bool
    _decorated |= _LoKiCore.getAndDecoratePredicates(
        name,  ## moduel name  
        LoKi.Functor(v, bool),  ## the base
        LoKi.Dicts.CutCalls(LHCb.VertexBase),  ## call-traits
        LoKi.Dicts.CutsOps(v, v))  ## operators&operations

    # =========================================================================
    ## functional part:
    # =========================================================================

    # "map" : vector<T> -> vector<double>
    _decorated |= _LoKiCore.getAndDecorateMaps(
        name,  ## module name  
        LoKi.Functor(_vp, _vd),  ## the base
        LoKi.Dicts.MapsOps(p))  ## call-traits
    _decorated |= _LoKiCore.getAndDecorateMaps(
        name,  ## module name  
        LoKi.Functor(_vv, _vd),  ## the base
        LoKi.Dicts.MapsOps(v))  ## call-traits

    # "pipe" : vector<T> -> vector<T>
    _decorated |= _LoKiCore.getAndDecoratePipes(
        name,  ## module name  
        LoKi.Functor(_vp, _vp),  ## the base
        LoKi.Dicts.PipeOps(p, p))  ## call-traits
    _decorated |= _LoKiCore.getAndDecoratePipes(
        name,  ## module name  
        LoKi.Functor(_vv, _vv),  ## the base
        LoKi.Dicts.PipeOps(v, v))  ## call-traits

    # "funval" : vector<T> -> double
    _decorated |= _LoKiCore.getAndDecorateFunVals(
        name,  ## module name  
        LoKi.Functor(_vp, 'double'),  ## the base
        LoKi.Dicts.FunValOps(p))  ## call-traits
    _decorated |= _LoKiCore.getAndDecorateFunVals(
        name,  ## module name  
        LoKi.Functor(_vv, 'double'),  ## the base
        LoKi.Dicts.FunValOps(v))  ## call-traits

    # "cutval" : vector<T> -> bool
    _decorated |= _LoKiCore.getAndDecorateCutVals(
        name,  ## module name  
        LoKi.Functor(_vp, bool),  ## the base
        LoKi.Dicts.CutValOps(p))  ## call-traits
    _decorated |= _LoKiCore.getAndDecorateCutVals(
        name,  ## module name  
        LoKi.Functor(_vv, bool),  ## the base
        LoKi.Dicts.CutValOps(v))  ## call-traits

    # 'source' : void -> vector<T>
    _decorated |= _LoKiCore.getAndDecorateSources(
        name,  ## module name  
        LoKi.Functor('void', _vp),  ## the base
        LoKi.Dicts.SourceOps(p, p))  ## call-traits
    _decorated |= _LoKiCore.getAndDecorateSources(
        name,  ## module name  
        LoKi.Functor('void', _vv),  ## the base
        LoKi.Dicts.SourceOps(v, v))  ## call-traits

    # 'infos'
    _decorated |= _LoKiCore.getAndDecorateInfos(
        name,  ## module name
        LoKi.Functor(p, 'double'),  ## the base 
        LoKi.Dicts.InfoOps(p))  ## methods
    _decorated |= _LoKiCore.getAndDecorateInfos(
        name,  ## module name
        LoKi.Functor(v, 'double'),  ## the base 
        LoKi.Dicts.InfoOps(v))  ## methods

    ## void primitives
    _decorated |= _LoKiCore.getAndDecoratePrimitiveVoids(name)

    # decorate pids (Comparison with strings, integers and ParticleID objects:
    for t in (ID, ABSID):
        t = type(t)
        _LoKiCore.decoratePID(t, LoKi.Dicts.PIDOps(t))
        _decorated.add(t)
    ##
    return _decorated
Exemplo n.º 9
0
from LoKiCore.basic import cpp, std, LoKi
LHCb     = cpp.LHCb
Hlt      = cpp.Hlt

# =============================================================================
## new stuff ##
# =============================================================================

_TC = 'const Hlt::Candidate*'
_TS = 'const Hlt::Stage*'
_vC = std.vector( _TC      ) ## std::vector<const Hlt::Candidate*>
_vD = std.vector( 'double' ) ## std::vector<double>


## @see LoKi::Types::TC_Func
TC_Func      = LoKi.Functor                 ( _TC    , 'double' )
## @see LoKi::Types::TC_Cuts
TC_Cuts      = LoKi.Functor                 ( _TC    ,  bool    )
## @see LoKi::Types::TC_Fun
TC_Fun       = LoKi.FunctorFromFunctor      ( _TC    , 'double' )
## @see LoKi::Types::TC_Cut
TC_Cut       = LoKi.FunctorFromFunctor      ( _TC    ,  bool    )

## @see LoKi::Types::TS_Func
TS_Func      = LoKi.Functor                 ( _TS    , 'double' )
## @see LoKi::Types::TC_Cuts
TS_Cuts      = LoKi.Functor                 ( _TS    ,  bool    )
## @see LoKi::Types::TC_Fun
TS_Fun       = LoKi.FunctorFromFunctor      ( _TS    , 'double' )
## @see LoKi::Types::TC_Cut
TS_Cut       = LoKi.FunctorFromFunctor      ( _TS    ,  bool    )