Skip to content
Snippets Groups Projects
Commit 01745a37 authored by Marco Clemencic's avatar Marco Clemencic
Browse files

Prepare for new Gaudi::Algorithm

See merge request !281

(cherry picked from commit 5284ec31)
parent 4c97eccd
No related branches found
No related tags found
1 merge request!322Prepare for new Gaudi::Algorithm
#!/usr/bin/env python #!/usr/bin/env python
# -*- coding: utf-8 -*- # -*- coding: utf-8 -*-
# ============================================================================= ###############################################################################
## @file gpython_algs # (c) Copyright 2000-2018 CERN for the benefit of the LHCb Collaboration #
# simmple test for two problems # #
# - contrintuitive IAlgorithm::isInitialize [But ok...] # This software is distributed under the terms of the GNU General Public #
# - ALG-fuctors, created from python prompt/loop # Licence version 3 (GPL Version 3), copied verbatim in the file "COPYING". #
# [it is ok when they are created via Hybrid framework] # #
# @author Vanya BELYAEV # In applying this licence, CERN does not waive the privileges and immunities #
# @date 2016-01-29 # granted to it by virtue of its status as an Intergovernmental Organization #
# ============================================================================= # or submit itself to any jurisdiction. #
###############################################################################
## # =============================================================================
## Configurables: ## @file gpython_algs
## # simmple test for two problems
from Configurables import DaVinci, MessageSvc # - contrintuitive IAlgorithm::isInitialize [But ok...]
dv = DaVinci( # - ALG-fuctors, created from python prompt/loop
DataType = '2015' , # [it is ok when they are created via Hybrid framework]
InputType = 'DST' , # @author Vanya BELYAEV
Lumi = True # @date 2016-01-29
) # =============================================================================
## ##
## put some algorithms into "user" list ## Configurables:
## ##
from StandardParticles import StdLooseKaons from Configurables import DaVinci, MessageSvc
from PhysSelPython.Wrappers import SelectionSequence dv = DaVinci(
seq = SelectionSequence( 'KAONS' , StdLooseKaons ) DataType = '2015' ,
dv.UserAlgorithms += [ seq.sequence() ] InputType = 'DST' ,
Lumi = True
## produde a lot of prints )
## msg = MessageSvc ( OutputLevel = 2 )
##
## put some algorithms into "user" list
## get some input data ##
from PRConfig import TestFileDB from StandardParticles import StdLooseKaons
TestFileDB.test_file_db["2015_DaVinciTests.davinci.gaudipython_algs"].run(configurable=DaVinci()) from PhysSelPython.Wrappers import SelectionSequence
seq = SelectionSequence( 'KAONS' , StdLooseKaons )
dv.UserAlgorithms += [ seq.sequence() ]
##
## GaudiPython ## produde a lot of prints
## ## msg = MessageSvc ( OutputLevel = 2 )
from GaudiPython.Bindings import AppMgr
## get some input data
gaudi = AppMgr() from PRConfig import TestFileDB
TestFileDB.test_file_db["2015_DaVinciTests.davinci.gaudipython_algs"].run(configurable=DaVinci())
alg = gaudi.algorithm('KAONS')
##
mainseq = 'DaVinciEventSeq' ## GaudiPython
##
from LoKiHlt.algorithms import ALG_EXECUTED, ALG_PASSED, ALG_ENABLED
## start event loop def isExecuted(alg):
for i in range(10) : if hasattr(alg._ialg, 'isExecuted'):
return alg._ialg.isExecuted()
gaudi.run(1) else:
import GaudiPython # make sure we pulled needed classes in cppyy
alg = gaudi.algorithm('KAONS') from cppyy.gbl import Gaudi, AlgExecState
print ' [%d] KAONS initialized? %s [counterintuitive]' % ( i , alg._ialg.isInitialized () ) return (alg._ialg.execState(Gaudi.Hive.currentContext()).state()
print ' [%d] KAONS executed? %s ' % ( i , alg._ialg.isExecuted () ) == AlgExecState.Done)
from GaudiPython.Bindings import AppMgr
print ' without fix in $LOKICORE/src/AlgFunctors.cpp following lines produce segmentation violation'
fun1 = ALG_EXECUTED ( mainseq ) gaudi = AppMgr()
fun2 = ALG_PASSED ( mainseq )
fun3 = ALG_ENABLED ( mainseq )
alg = gaudi.algorithm('KAONS')
print ' [%d] main sequence executed? %s ' % ( i , fun1() )
print ' [%d] main sequence passed? %s ' % ( i , fun2() ) mainseq = 'DaVinciEventSeq'
print ' [%d] main sequence enabled? %s ' % ( i , fun3() )
from LoKiHlt.algorithms import ALG_EXECUTED, ALG_PASSED, ALG_ENABLED
## start event loop
exit() for i in range(10) :
gaudi.run(1)
# =============================================================================
# The END alg = gaudi.algorithm('KAONS')
# ============================================================================= print ' [%d] KAONS initialized? %s [counterintuitive]' % ( i , alg._ialg.isInitialized () )
print ' [%d] KAONS executed? %s ' % ( i , isExecuted(alg) )
print ' without fix in $LOKICORE/src/AlgFunctors.cpp following lines produce segmentation violation'
fun1 = ALG_EXECUTED ( mainseq )
fun2 = ALG_PASSED ( mainseq )
fun3 = ALG_ENABLED ( mainseq )
print ' [%d] main sequence executed? %s ' % ( i , fun1() )
print ' [%d] main sequence passed? %s ' % ( i , fun2() )
print ' [%d] main sequence enabled? %s ' % ( i , fun3() )
exit()
# =============================================================================
# The END
# =============================================================================
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment