コード例 #1
0
ファイル: PyTMVA.py プロジェクト: marromlam/lhcb-software
    ``C++ ToolKit for Smart and Friendly Physics Analysis''

By usage of this code one clearly states the disagreement 
with the smear campain of Dr.O.Callot et al.: 
    ``No Vanya's lines are allowed in LHCb/Gaudi software.''

"""
# =============================================================================
__author__ = 'Vanya BELYAEV  [email protected]'
__date__ = "2013-10-02"
__version__ = '$Revision$'
__all__ = ("Trainer", "Reader", "tmvaGUI")
# =============================================================================
import ROOT
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.PyTMVA')
else: logger = getLogger(__name__)

# =============================================================================


# =============================================================================
## @class TMVATrainer
#  Helper class to train TMVA
#
#  @code
#
#  from PyTMVA import Trainer
#  t = Trainer( methods =  [
#  ## type, name, configuration
#  ( ROOT.TMVA.Types.kMLP ,
コード例 #2
0
    'Amoroso_pdf',  ## another view of generalized Gamma distribution
    'LogGammaDist_pdf',  ## Gamma-distributuon in shape/scale parameterization
    'Log10GammaDist_pdf',  ## Gamma-distributuon in shape/scale parameterization
    'LogGamma_pdf',  ## 
    'BetaPrime_pdf',  ## Beta-prime distribution 
    'Landau_pdf',  ## Landau distribution 
    'Argus_pdf',  ## ARGUS distribution 
    'TwoExpos_pdf',  ## difference of two exponents 
)
# =============================================================================
import ROOT, math
from Ostap.Core import VE, cpp
from GaudiKernel.SystemOfUnits import GeV
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.FitOtherModels')
else: logger = getLogger(__name__)
# =============================================================================
# Specializations of double-sided Crystal Ball function
# =============================================================================
from Ostap.FitBasic import makeVar, PDF
# =============================================================================
models = []


# =============================================================================
## @class GammaDist_pdf
#  Gamma-distribution with shape/scale parameters
#  http://en.wikipedia.org/wiki/Gamma_distribution
#  It suits nicely for fits of multiplicity and/or chi2 distributions
#  @author Vanya BELYAEV [email protected]
コード例 #3
0
    #
    'TsallisFun',  ## Tsallis   function object 
    'QGSMFun',  ## QGSM      function object 
    'GammaDistFun',  ## GammaDist function object 
    #
    'tsallisTF1',  ## Tsallis   create TF1
    'qgsmTF1',  ## QGSM      create TF1 
    'gammaDistTF1',  ## GammaDist create TF1 
    #
)
# =============================================================================
import ROOT, math
from Ostap.Core import VE, cpp, funID
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.FitSpectra')
else: logger = getLogger(__name__)
# =============================================================================
models = []
# =============================================================================
from Ostap.FitOtherModels import Tsallis_pdf
models.append(Tsallis_pdf)
from Ostap.FitOtherModels import QGSM_pdf
models.append(QGSM_pdf)
from Ostap.FitOtherModels import GammaDist_pdf
models.append(GammaDist_pdf)


# ==============================================================================
## @class PtFitBase
#  helper object
コード例 #4
0
 
"""
# =============================================================================
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2015-07-31"
__version__ = "$Revision$"
# =============================================================================
__all__ = (
    'RootShelf',  ## The DB-itself
    'RootOnlyShelf',  ## "data base" for ROOT-only objects
    'open',  ## helper function to hide the actual DB
    'tmpdb',  ## helper function to create TEMPORARY  RootShelve database 
)
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('RootShelve')
else: logger = getLogger(__name__)
# =============================================================================
logger.debug("Simple generic ROOT-based shelve-like-database")
# =============================================================================
import ROOT, shelve


# =============================================================================
## @class RootOnlyShelf
#  Plain vanilla DBASE for ROOT-object (only)
#  essentially it is nothing more than just shelve-like interface for ROOT-files
#  @author Vanya BELYAEV [email protected]
#  @date   2015-07-31
#  @attention It CRUCIALLY depends on the proper TFile-decorations from Ostap.TFileDeco module
#  @code
コード例 #5
0
    'data_options',  ## option for data
    'data_options_nobars',  ## option for data without bars 
    'signal_options',  ## signal options    
    'background_options',  ## background options 
    'component_options',  ## other components
    'fit_options',  ## the fit curve
    ##
    'base_signal_color',  ## base signal color 
    'base_background_color',  ## base signal color 
    'base_component_color',  ## base signal color 
)
# =============================================================================
import ROOT
from Ostap.Logger import getLogger
# =============================================================================
if '__main__' == __name__: logger = getLogger('Ostap.FitDraw')
else: logger = getLogger(__name__)


# =============================================================================
def lineWidth(w):
    return ROOT.RooFit.LineWidth(w)


def lineStyle(s):
    return ROOT.RooFit.LineStyle(s)


def lineColor(c):
    return ROOT.RooFit.LineColor(c)
コード例 #6
0
    'hToGraph3'       , ## convert historgam to graph
    'lw_graph'        , ## make Lafferty-Wyatt's graph from the histo 
    'h1_axis'         , ## book 1D-histogram from axis 
    'h2_axes'         , ## book 2D-histogram from axes
    'h3_axes'         , ## book 3D-histogram from axes
    'axis_bins'       , ## convert list of bin edges to axis
    've_adjust'       , ## adjust the efficiency to be in physical range
    #
    )
# =============================================================================
import ROOT
# =============================================================================
# logging 
# =============================================================================
from Ostap.Logger import getLogger 
logger = getLogger( __name__ )
# =============================================================================
logger.info ( 'Zillions of decorations for ROOT   objects')
# =============================================================================
from Ostap.Core import ( cpp      ,
                         ROOTCWD  , rootID    , 
                         funcID   , funID     , fID             ,
                         histoID  , hID       , dsID            ,
                         cwd      , pwd       ,
                         VE       , SE        , WSE             ,
                         binomEff , binomEff2 ,
                         zechEff  , wilsonEff , agrestiCoullEff , 
                         iszero   , isequal   ,
                         isint    , islong    , natural_entry   ) 
## silently load RooFit library 
from Ostap.Utils import mute
コード例 #7
0
__date__ = "2010-09-21"
__version__ = "$Revision$"
# ============================================================================
__all__ = (
    "uPlot",  ## make  plot of U-statistics 
    "uDist",  ## calculate  U-statistics 
    "uCalc",  ## calclulate the distance between two data points 
)
# ============================================================================
import ROOT, math
from Ostap.Core import cpp, hID
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.uStat')
else: logger = getLogger(__name__)


# =============================================================================
## calculate the distance between two data points
#  @author Vanya Belyaev [email protected]
#  @date 2011-09-21
def uDist(x, y):
    """Calculate the distance between two data points 
    """

    ix = x.createIterator()
    iy = y.createIterator()

    dist = 0.0
コード例 #8
0
    'Selector',  ## The ``fixed'' TPySelector
    'Selector2',  ## The ``fixed'' TPySelector
    'SelectorWithCuts',  ## The ``fixed'' TPySelector with TTree-formula 
    'SelectorWithVars',  ## Generic selctor to fill RooDataSet form TTree/TChain       
    'SelectorWithVarsCached'  ## Generic selector with cache   
)
# =============================================================================
import ROOT, cppyy, math
# construct the global C++ namespace
cpp = cppyy.makeNamespace('')
Analysis = cpp.Analysis
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.Selectors')
else: logger = getLogger(__name__)
# =============================================================================
## C++ Selector
Selector = Analysis.Selector


# =============================================================================
## @class Selector2
#  Useful intermediate class for implementation of (py)selectors
#  @see Analysis::Selector
#  @see TPySelector
#  @see TSelector
#  @author Vanya BELYAEV [email protected]
#  @date   2013-05-09
class Selector2(Analysis.Selector):
コード例 #9
0
    def __init__(
            self,
            variables,  ## list of variables  
            selection,  ## Tree-selection 
            cuts=lambda s: True,
            name='',
            fullname='',
            silence=False):

        if not name:
            from Ostap.PyRoUts import dsID
            name = dsID()

        if not fullname: fullname = "%s/%s " % (__name__, name)

        #
        ## create the logger
        #
        from Ostap.Logger import getLogger
        self._logger = getLogger(fullname)
        #

        #
        ## instantiate the base class
        #
        SelectorWithCuts.__init__(self, selection)  ## initialize the base

        #
        ## keep the cuts
        #
        self._cuts = cuts

        #
        ## variables
        #
        self.varset = ROOT.RooArgSet()
        self._variables = []

        #
        ## add the variables one by one
        #
        for v in variables:
            self.addVariable(*v)

        #
        ## Book dataset
        #
        self.data = ROOT.RooDataSet(
            ##
            name,
            fullname,
            ##
            self.varset)

        #
        ## it is still very puzzling for me: should this line be here at all??
        ROOT.SetOwnership(self.data, False)

        self._events = 0
        self._progress = None
        self._total = 1
        self._skip = 0
        self._silence = silence
コード例 #10
0
ファイル: shelve_ext.py プロジェクト: marromlam/lhcb-software
"""Small extension for standars shelve module to allow more flexible treatment for the data base 

>>> db1 = shelve.open ('$HOME/newdb'  , 'n')    ## create new DB
>>> db2 = shelve.open ('../dir/newdb' , 'n')    ## create new DB
...
>>> db1.ls()  ## list the content 

"""
# =============================================================================
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2012-05-13"
__version__ = "$Revision$"
__all__ = ()  ## nothing to import
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.shelve_ext')
else: logger = getLogger(__name__)
# =============================================================================
#
import shelve
#
_old_shelve_open_ = shelve.open


#
# ========================================================
## A bit extended version of shelve.open
def _new_shelve_open_(filename, *kargs, **kwargs):
    """
    A bit extended version of shelve.open:
コード例 #11
0
ファイル: Utils.py プロジェクト: marromlam/lhcb-software
    'logColor'       , ## swith on locally the colored logging
    'logVerbose'     , ## redefine (locally) the logging level
    'logDebug'       , ## redefine (locally) the logging level
    'logInfo'        , ## redefine (locally) the logging level
    'logWarning'     , ## redefine (locally) the logging level
    'logError'       , ## redefine (locally) the logging level
    )
# =============================================================================
import ROOT,cppyy, time, os,sys ## attention here!!
cpp = cppyy.makeNamespace('')
ROOT_RooFit_ERROR = 4 
# =============================================================================
# logging 
# =============================================================================
from   Ostap.Logger import getLogger, logColor
if '__main__' ==  __name__ : logger = getLogger( 'Ostap.Utils' )
else                       : logger = getLogger( __name__ )
del getLogger 
from   Ostap.Logger import  logVerbose,  logDebug, logInfo, logWarning, logError 
# =============================================================================
## @class Memory
#  Simple context manager to measure the virtual memory increase
#
#  @see System::virtualMemory
#  @code
#
#  with Memory() :
#     <whatever action is>
#     at the exit it prints the chaneg in virtual memory 
#  @endcode
#
コード例 #12
0
"""
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2012-10-16"
# =============================================================================
__all__ = (
    'getLumi',  ## get the lumi
)
# =============================================================================
import ROOT
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.GetLumi')
else: logger = getLogger(__name__)


# =============================================================================
## get luminosity from Lumi tuple
#
#  @param data  (INPUT) tree, chain, file, filename or sequence
#  @return the luminosity
#  @attention Linear addition of uncertainties is used here
#
#  @code
#
#  >>> l1 = getLumi ( 'myfile.root' )
#  >>> l2 = getLumi ( tree  )
#  >>> l3 = getLumi ( chain )
コード例 #13
0
# ...
# >>> abcd = db['some_key']
"""
# =============================================================================
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2014-06-19"
__version__ = "$Revision$"
# =============================================================================
__all__ = (
    'SQLiteShelf',  ## The DB-itself
    'open',  ## helper function to hide the actual DB
    'tmpdb',  ## helper function to create the temporary database 
)
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('SQLiteShelve')
else: logger = getLogger(__name__)
# =============================================================================
from Ostap.sqlitedict import SqliteDict
import zlib


# =============================================================================
## @class SQLiteShelf
#  SQLite-based ``shelve-like'' database with compressed content.
#
#  Keeping the same interface and functionlity as shelve data base,
#  SQLiteShelve allows much more compact file size through
#  the compression of the content
#
#  The actual code has been taken from <c>sqlitedict</c> code
コード例 #14
0
            bar += 1

    import time
    for i in progress_bar(xrange(15000), description="Doing something "):
        time.sleep(0.001)

    for i in running_bar(xrange(15000), description="Empty looping "):
        time.sleep(0.001)


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

    import Ostap.Line
    from Ostap.Logger import getLogger
    logger = getLogger('Ostap.progress_bar')

    logger.info(__file__ + '\n' + Ostap.Line.line)
    logger.info(80 * '*')
    logger.info(__doc__)
    logger.info(80 * '*')
    logger.info(' Author  : %s' % __author__)
    logger.info(' Version : %s' % __version__)
    logger.info(' Date    : %s' % __date__)
    logger.info(' Symbols : %s' % list(__all__))
    logger.info(80 * '*')

    test_bars()
    logger.info(80 * '*')

# =============================================================================
コード例 #15
0
ファイル: pid_calib.py プロジェクト: marromlam/lhcb-software
    pid_calib.py Pi -s 20 -p MagUp -c 'Pi_hasRich==1'

    Use '-h' option to know more 
"""
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2011-06-07"
__all__ = ()
# =============================================================================
import ROOT, cppyy
ROOT.PyConfig.IgnoreCommandLineOptions = True
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('pid_calib')
else: logger = getLogger(__name__)

# =============================================================================


# =============================================================================
## the actual function to fill PIDcalib histograms
#  - it books two histogram  (3D in this case)
#  - it fill them with 'accepted' and 'rejected' events (3D in this case)
#  - update input historgams
#  @author Vanya BELYAEV [email protected]
#  @date   2014-05-10
def PION(particle, dataset, plots=None, verbose=False):
    """
    The actual function to fill PIDCalib histograms
コード例 #16
0
"""
# =============================================================================
__version__ = "$Revision$"
__author__  = "Vanya BELYAEV [email protected]"
__date__    = "2011-06-07"
__all__     = (
    'makeParser'  , ## make  a parser 
    'runPidCalib' , ## run pid-calib machinery 
    'saveHistos'  , ## save the histogram historgams
    'ex_func'     , ## an example of end-user function 
    'ex_func2'    , ## another example of end-user function 
    )
# =============================================================================
import ROOT
from   Ostap.Logger import getLogger, setLogging 
if '__main__' == __name__ : logger = getLogger ( 'Ostap.PidCalib' )
else                      : logger = getLogger ( __name__         )
# =============================================================================
setLogging(4) 
import Ostap.PyRoUts
# =============================================================================
## prepare the parser
#  oversimplified version of parser from MakePerfHistsRunRange.py script 
#  @author Vanya BELYAEV [email protected]
#  @date   2014-07-19
def makeParser () :
    """
    Prepare the parser
    - oversimplified version of parser from MakePerfHistsRunRange.py script 
    """
    import argparse, os, sys
コード例 #17
0
ファイル: RunDB.py プロジェクト: marromlam/lhcb-software
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2015-01-12"
__all__ = (
    'run_info',  ## get run information from RunDB  
    'fill_info',  ## get fill information from RunDB 
    'fill_number',  ## get fill number from given run-number 
    'run_url',  ## pattern for run-information in LHCb RunDB 
    'fill_url',  ## pattern for fill-information in LHCb RunDB 
)
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.RunDB')
else: logger = getLogger(__name__)
# =============================================================================
logger.debug('Collection of utilities to deal with LHCb RunDB')
# =============================================================================
import json, urllib
# =============================================================================
## local caches to minimize accesses to RunDB
# =============================================================================
_fills_ = {}  ## mapping: #run  -> #fill
_finfos_ = {}  ## mapping: #fill -> fill-info
_rinfos_ = {}  ## mapping: #run  -> run-info
# =============================================================================
## LHCb RunDB url format
run_url = 'http://lbrundb.cern.ch/api/run/{0}/'  ## pattern for runs
fill_url = 'http://lbrundb.cern.ch/api/fill/{0}/'  ## pattern for fills
コード例 #18
0
__date__ = "2011-06-07"
__all__ = (
    'ROOTCWD',  ## context manager to keep Current Directory
    'open_mode',  ## decode open-mode for ROOT-files
    'open',  ## just for completness 
)
# =============================================================================
import ROOT, os, cppyy  ## attention here!!

cpp = cppyy.makeNamespace('')
VE = cpp.Gaudi.Math.ValueWithError
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.TFileDeco')
else: logger = getLogger(__name__)
# =============================================================================
logger.debug('Some useful decorations for TFile objects')
# ==============================================================================
## context manager to preserve current directory (rather confusing stuff in ROOT)
from Ostap.Core import ROOTCWD


# ===============================================================================
## write the (T)object to ROOT-file/directory
#  @code
#  histo1 = ...
#  histo2 = ...
#  rfile['MyHisto'      ] = histo1
#  rfile['MyDir/MyHisto'] = histo2
コード例 #19
0
ファイル: HepDATA.py プロジェクト: marromlam/lhcb-software
- TH1D, TH1D
- TGraphErrors
- TGraphAsymmErrors
"""
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2011-06-07"
__all__ = ()
# =============================================================================
import ROOT
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.HepDATA')
else: logger = getLogger(__name__)
# =============================================================================
logger.debug('HepDATA format and conversion routines')
# =============================================================================
## fields required for each dataset
dataset_fields = (
    'location',  ## e.g. Figure 5a
    'dscomment',
    'reackey',  ## e.g. P P --> Z0 Z0 X 
    'obskey',  ## e.g. SIG or DSIG/DPT
    'qual',  ## see http://hepdata.cedar.ac.uk/resource/sample.input
    'xheader',  ## e.g. PT IN GEV 
    'yheader')  ## e.g. DSIG/DPT IN PB/GEV
## fields required for each hepdata file
hepfile_fields = (
コード例 #20
0
see https://its.cern.ch/jira/browse/GAUDI-1197
see https://sft.its.cern.ch/jira/browse/ROOT-8046

"""
# =============================================================================
__version__ = '$Revision$'
__author__ = 'Vanya BELYAEV [email protected]'
__date__ = '2016-02-23'
__all__ = (
    'Task',  ## the base class for task
    'TaskManager',  ## task manager 
)
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.ParalllelPathos')
else: logger = getLogger(__name__)
# =============================================================================
import sys, os, time, copy
excluded_varnames = ('HOSTNAME', 'SSH_CLIENT', 'SSH_CONNECTION', 'DISPLAY')

# =============================================================================
import pathos.core as PC
import pathos.multiprocessing
import pathos.parallel
import dill


def _prefunction(f, task, item):
    return f((task, item))
コード例 #21
0
    'Bu_pdf',  ## pdf for B+        : double-sided Crystal Ball 
    'Bs_pdf',  ## pdf for Bs        : double-sided Crystal Ball 
    'Bc_pdf',  ## pdf for Bc+       : double-sided Crystal Ball 
    #
    'Manca_pdf',  ## Manca function to fit Y->mu mu spectrum  [Y(1S),Y(2S),Y(3S)]
    'Manca2_pdf',  ## Manca function to fit Y->mu mu spectrum  [Y(1S),Y(2S),Y(3S)]
    'MancaX_pdf',  ## associative production of Y+X 
    #
)
# =============================================================================
import ROOT, math
from Ostap.Core import VE, cpp
from GaudiKernel.SystemOfUnits import GeV
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.FitSpecificModels')
else: logger = getLogger(__name__)
# =============================================================================
# Specializations of double-sided Crystal Ball function
# =============================================================================
from Ostap.FitBasic import PDF, PDF2
from Ostap.FitSignalModels import CB2_pdf

models = []


# =============================================================================
## @class Bd_pdf
#  simple wrapper over CB2-pdf
#  @see Analysis::Models::CrystalBallDS
#  @see Gaudi::Math::CrystalBallDS
コード例 #22
0
ファイル: Corr2D.py プロジェクト: marromlam/lhcb-software
#  by                $Author$
# =============================================================================
""" Simple 2D-decorrelation transformation """
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2014-06-08"
__all__ = ('Corr2D', )
# =============================================================================
import ROOT, math
from Ostap.Core import cpp, WSE
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.Corr2D')
else: logger = getLogger(__name__)
# =============================================================================
## get error-function
if not hasattr(math, 'erf'):
    try:
        import scipy.special
        math.erf = scipy.special.erf
        logger.debug('scipy.special.erf is added to math')
    except:
        math.erf = ROOT.TMath.Erf
        logger.debug('ROOT.TMath.Erf    is added to math')
# =============================================================================
## error function
#  @see http://en.wikipedia.org/wiki/Error_function
erf = math.erf
コード例 #23
0
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2011-06-07"
__all__ = (
    'Weight',
    'makeWeights',
)
# =============================================================================
import ROOT
from Ostap.PyRoUts import cpp, VE, SE, iszero, hID
import Ostap.ZipShelve as DBASE  ## needed to store the weights&histos
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.Reweighting')
else: logger = getLogger(__name__)
# =============================================================================
logger.info('Set of utitilities for re-weigthing')


# =============================================================================
## @class Weight
#  helper class for semiautomatic reweighting of data
#  @author Vanya BELYAEV [email protected]
#  @date   2014-05-10
class Weight(object):
    """Helper class for semi-automatic reweighting of data

    It reads various ``weigth components'' from DBASE and calculates
    the ``global'' event weight via smiple accumulation of weights
コード例 #24
0
ファイル: Startup.py プロジェクト: marromlam/lhcb-software
By usage of this code one clearly states the disagreement 
with the smear campaign of Dr.O.Callot et al.: 
``No Vanya's lines are allowed in LHCb/Gaudi software.''

"""
# =============================================================================
__author__ = 'Vanya BELYAEV [email protected]'
__date__ = "2006-10-08"
__version__ = "$Revision$"
__all__ = ()
# =============================================================================
## logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.Startup')
else: logger = getLogger(__name__)
# =============================================================================


def with_ipython():
    try:
        __IPYTHON__
        return True
    except NameError:
        return False


## check if the file is actually "empty"
def _empty_(fname):
コード例 #25
0
>>> lumi  = data.lumi
>>> print data.getLumi() 

"""
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2014-06-08"
__all__ = ('Data', 'DataAndLumi')
# =============================================================================
import ROOT, glob
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.Data')
else: logger = getLogger(__name__)
# =============================================================================
if not hasattr(ROOT.TTree, '__len__'):
    ROOT.TTree.__len__ = lambda s: s.GetEntries()


# =============================================================================
## @class Files
#  Simple utility to pickup the list of files
#  @author Vanya BELYAEV [email protected]
#  @author Alexander BARANOV [email protected]
#  @date   2014-06-08
class Files(object):
    """Simple utility to pickup the list of files     
    >>> data  = Files( '*.root' )
コード例 #26
0
of Dr.O.Callot et al.:

   ``No Vanya's lines are allowed in LHCb/Gaudi software''
"""
# =============================================================================
__author__ = 'Vanya BELYAEV [email protected]'
__date__ = "2012-09-10"
__version__ = '$Revision$'
# =============================================================================
import ROOT, sys
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger

__logger = getLogger('OstapBender')
# =============================================================================
## 1) load LHCb-style file
# =============================================================================
import Ostap.LHCbStyle
# =============================================================================
# The Heart
# =============================================================================
## load zillions of decorations for ROOT-objects
import Ostap.PyRoUts  ## NB: the most important line!
import Ostap.ZipShelve as DBASE

# =============================================================================
## minor decoration for default shelve module
import Ostap.shelve_ext
コード例 #27
0
"""
# =============================================================================
__version__ = "$Revision$"
__author__ = "Vanya BELYAEV [email protected]"
__date__ = "2011-06-07"
__all__ = ()
# =============================================================================
import ROOT, cppyy  ## attention here!!
cpp = cppyy.makeNamespace('')
VE = cpp.Gaudi.Math.ValueWithError
#
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.HTextDeco')
else: logger = getLogger(__name__)
# =============================================================================
logger.debug('Some useful decorations for Histo&Text objects')
# =============================================================================
## further decoration
try:
    import GaudiPython.HistoUtils
    logger.debug('Histogram utilities from GaudiPython.HistoUtils')
except:
    logger.warning(
        'Histogram utilities from GaudiPython.HistoUtils are not loaded')

# =============================================================================
_HS = cpp.Gaudi.Utils.Histos.HistoStrings
コード例 #28
0
#                by $Author$
# =============================================================================
"""LHCb Style for ROOT-plots"""
# =============================================================================
import ROOT
__all__ = (
    'lhcbStyle',
    'lhcbLabel',
    'LHCbStyle',
    'lhcbLatex',
)
# =============================================================================
# logging
# =============================================================================
from Ostap.Logger import getLogger
if '__main__' == __name__: logger = getLogger('Ostap.LHCbStyle')
else: logger = getLogger(__name__)
# =============================================================================

## font
lhcbFont = 132  ## Times-Roman
## line thickness
lhcbWidth = 1

##define style for text
lhcbLabel = ROOT.TText()
lhcbLabel.SetTextFont(lhcbFont)
lhcbLabel.SetTextColor(1)
lhcbLabel.SetTextSize(0.04)
lhcbLabel.SetTextAlign(12)