Commit 59d2f03c authored by Joerg Stelzer's avatar Joerg Stelzer Committed by Graeme Stewart
Browse files

python/TrigConf2COOLLib.py: fix a small issue with the output level (TrigConfigSvc-01-01-67)

	* python/TrigConf2COOLLib.py: fix a small issue with the output level
	detection of the Trig conf to cool archiver
	* TrigConfigSvc-01-01-67

2016-04-23 Joerg Stelzer <stelzer@cern.ch>
	* DSConfigSvc.cxx: connect to the correct database for MC and trigger reprocessing jobs
	* python/TrigConf2COOLLib.py: add writing of BGK to tmp cool (for MC production)
	* TrigConfigSvc-01-01-66

2016-04-22  Frank Winklmeier  <fwinkl@cern>
	* Remove obsolete files referencing TriggerMenuPython
	* TrigConfigSvc-01-01-64

2016-04-09 Joerg Stelzer <stelzer@cern>
	* Update checkTriggerConfig.py
	* TrigConfigSvc-01-01-63

2016-04-08 Joerg Stelzer <stelzer@cern>
	* python/TrigConfigSvcConfig.py: ensure that the TrigConfigSvc is initialized
	before the run starts
...
(Long ChangeLog diff - truncated)
parent 5d7d696c
################################################################################
# Package: TrigConfigSvc
################################################################################
# Declare the package name:
atlas_subdir( TrigConfigSvc )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Control/AthenaBaseComps
Control/StoreGate
GaudiKernel
Trigger/TrigConfiguration/TrigConfHLTData
Trigger/TrigConfiguration/TrigConfInterfaces
Trigger/TrigConfiguration/TrigConfL1Data
Trigger/TrigEvent/TrigSteeringEvent
PRIVATE
Control/AthenaKernel
Database/AthenaPOOL/AthenaPoolUtilities
Database/IOVDbDataModel
Event/EventInfo
Tools/PathResolver
Trigger/TrigConfiguration/TrigConfBase
Trigger/TrigConfiguration/TrigConfJobOptData
Trigger/TrigConfiguration/TrigConfStorage
Trigger/TrigMonitoring/TrigMonitorBase
Trigger/TrigT1/L1Topo/L1TopoConfig )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( COOL COMPONENTS CoolKernel )
find_package( ROOT COMPONENTS Core Tree MathCore Hist RIO pthread PyROOT )
# Component(s) in the package:
atlas_add_library( TrigConfigSvcLib
src/*.cxx
PUBLIC_HEADERS TrigConfigSvc
PRIVATE_INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS}
LINK_LIBRARIES AthenaBaseComps GaudiKernel TrigConfHLTData TrigConfL1Data TrigSteeringEvent StoreGateLib SGtests TrigMonitorBaseLib
PRIVATE_LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${COOL_LIBRARIES} AthenaKernel AthenaPoolUtilities IOVDbDataModel EventInfo PathResolver TrigConfBase TrigConfJobOptData TrigConfStorage L1TopoConfig )
atlas_add_component( TrigConfigSvc
src/components/*.cxx
INCLUDE_DIRS ${ROOT_INCLUDE_DIRS} ${Boost_INCLUDE_DIRS} ${COOL_INCLUDE_DIRS}
LINK_LIBRARIES ${ROOT_LIBRARIES} ${Boost_LIBRARIES} ${COOL_LIBRARIES} AthenaBaseComps StoreGateLib SGtests GaudiKernel TrigConfHLTData TrigConfL1Data TrigSteeringEvent AthenaKernel AthenaPoolUtilities IOVDbDataModel EventInfo PathResolver TrigConfBase TrigConfJobOptData TrigConfStorage TrigMonitorBaseLib L1TopoConfig TrigConfigSvcLib )
# Install files from the package:
atlas_install_python_modules( python/*.py )
atlas_install_joboptions( share/*.py )
atlas_install_scripts( share/checkTrigger.py share/checkTriggerConfig.py )
atlas_install_xmls( data/*.dtd data/*.xml )
# Aliases:
atlas_add_alias( checkTrigger "checkTrigger.py" )
......@@ -11,12 +11,14 @@
#include "TrigConfHLTData/HLTFrame.h"
#include "GaudiKernel/ServiceHandle.h"
#include "AthenaBaseComps/AthService.h"
#include "TrigConfigSvc/ConfigSvcBase.h"
#include "AthenaKernel/IIOVSvc.h"
#include "StoreGate/StoreGateSvc.h"
#include "TrigConfInterfaces/ITrigConfigSvc.h"
#include <memory>
namespace TXC {
class L1TopoMenu;
}
......@@ -38,74 +40,93 @@ namespace TrigConf {
* on what is provided by HLTConfigSvc and LVL1ConfigSvc
*
*/
class DSConfigSvc : public AthService,
virtual public ITrigConfigSvc
class DSConfigSvc : public extends1<ConfigSvcBase, ITrigConfigSvc>
{
public:
/// Standard Gaudi Service constructor
// Standard Gaudi Service constructor
DSConfigSvc( const std::string& name, ISvcLocator* pSvcLocator );
/// Destructor
// Destructor
virtual ~DSConfigSvc();
/**@brief initialize the service*/
// @brief initialize the service
StatusCode initialize();
/**@brief finalize the service*/
StatusCode finalize();
// @brief finalize the service
StatusCode finalize() {
return StatusCode::SUCCESS;
}
/**@brief set the master key of the configuration to be requested*/
// @brief set the master key of the configuration to be requested
StatusCode queryInterface( const InterfaceID& riid, void** ppvIF );
/**@brief L1 topo configuration menu*/
const TXC::L1TopoMenu* menu() const;
/// LVL1 menu and prescales only (no bunchgroups, prescale clocks, etc.)
const CTPConfig* ctpConfig() const;
// not available when reading from detector store
// (source of config meta data is COOL or AOD-header)
const Muctpi* muctpiConfig() const;
const ThresholdConfig* thresholdConfig() const;
/**@brief BunchGroupSet
*
* @returns bunch group set
*/
const BunchGroupSet* bunchGroupSet() const { return m_bunchGroupSet; }
// HLT accessors
const HLTChainList* chainList() const;
const HLTChainList& chains() const { return m_hltFrame.chains(); }
const HLTSequenceList* sequenceList() const;
const HLTSequenceList& sequences() const { return m_hltFrame.sequences(); }
/**@brief configuration master key
*
* @returns configuration master key
*/
// @brief L1 topo configuration menu
virtual const TXC::L1TopoMenu* menu() const {
return m_topoMenu.get();
}
// LVL1 menu and prescales only (no bunchgroups, prescale clocks, etc.)
const CTPConfig* ctpConfig() const {
return & m_ctpConfig;
}
// access muctpi configuration
const Muctpi* muctpiConfig() const {
return & m_ctpConfig.muCTPi();
}
// access to trigger thresholds
const ThresholdConfig* thresholdConfig() const {
return & m_ctpConfig.menu().thresholdConfig();
}
// returns bunch group set
const BunchGroupSet* bunchGroupSet() const {
return & m_ctpConfig.bunchGroupSet();
}
// access to HLT chains
const HLTChainList* chainList() const {
return & m_hltFrame.getHLTChainList();
}
// access to HLT chains
const HLTChainList& chains() const {
return m_hltFrame.chains();
}
// access to HLT sequences
const HLTSequenceList* sequenceList() const {
return & m_hltFrame.getHLTSequenceList();
}
// access to HLT sequences
const HLTSequenceList& sequences() const {
return m_hltFrame.sequences();
}
// access to SMK
uint32_t masterKey() const { return m_masterKey; }
/**@brief LVL1 prescale key
*
* @returns LVL1 prescale configuration key
*/
uint32_t lvl1PrescaleKey() const { return m_lvl1PsKey; }
// access to LVL1 prescale key
uint32_t lvl1PrescaleKey() const {
return m_lvl1PsKey;
}
/**@brief HLT prescale key
*
* @returns HLT prescale configuration key
*/
// access to HLT prescale configuration key
uint32_t hltPrescaleKey() const { return m_hltPsKey; }
/**@brief Configuration source
*
* @returns description of the source of the configuration (TriggerDB/XMLfilename)
*/
const std::string& configurationSource() const { return m_configSrc; }
// access to a description of the source of the configuration (TriggerDB/XMLfilename)
const std::string& configurationSource() const {
return m_configSrc;
}
StatusCode updatePrescaleSets(uint requestcount);
// This method is called by TrigSteer on *every* event (keep it fast)
// This is never used in connection with COOL configuration data
StatusCode assignPrescalesToChains(uint lumiblock );
private:
......@@ -117,11 +138,13 @@ namespace TrigConf {
void set_ChainlistFromHltPrescaleSet();
void set_HltPrescaleSetFromChainlist();
StatusCode loadMenuFromDB( uint32_t smk, uint32_t l1psk, uint32_t hltpsk, uint32_t bgsk );
std::unique_ptr<TXC::L1TopoMenu> m_topoMenu;
CTPConfig m_ctpConfig; ///< LVL1 configuration
HLTFrame m_hltFrame; ///< HLT configuration
ThresholdConfig * m_thrcfg; ///< list of thresholds
HLTPrescaleSet * m_prescaleSet; ///< hlt prescales set
uint32_t m_masterKey; ///< configuration master key
uint32_t m_lvl1PsKey; ///< lvl1 prescale key
uint32_t m_hltPsKey; ///< hlt prescale key
......@@ -132,17 +155,12 @@ namespace TrigConf {
/// Handle to the Detector Store
ServiceHandle< StoreGateSvc > m_detstore;
std::vector< unsigned char > m_itembgs; ///< item assignments to bunchgroups
TrigConf::BunchGroupSet* m_bunchGroupSet; ///< bunchgroup definitions
bool m_readyState; ///< ready to deliver trigger configuration ?
bool m_readLvl1Thr; ///< if set to true, read also the lvl1 thresholds
bool m_readLvl1BG; ///< if set to true, read also the lvl1 bunchgroups
///to avoid crashes when a folder is not present and allow for lvl1/htl separation :
/// /* std::string folders will take the info on folders from IOVDbSvc*/
std::string m_folders;
/// /* hasFolder(folder_name) will return true if folder_name is found in the string returned by IOVDbSvc, false otherwise */
// hasFolder(folder_name) will return true if folder_name is found in the string returned by IOVDbSvc, false otherwise
bool hasFolder( const std::string& folder_name );
}; // class DSConfigSvc
......
......@@ -82,6 +82,7 @@ namespace TrigConf {
// Properties:
bool m_setMergedHLT;
bool m_doMon;
std::string m_partition;
Histo1DProperty m_histProp_timePrescaleUpdate;
......
......@@ -42,7 +42,6 @@ apply_pattern declare_joboptions files="*.py"
apply_pattern declare_python_modules files="*.py"
apply_pattern declare_xmls
apply_pattern install_xmls
......
......@@ -28,11 +28,11 @@ class TmpThr(threading.Thread):
output = os.popen(self.syscmd).readlines()
maxlevel = 0
for line in output:
if 'warning' in line.lower():
if ' warning ' in line.lower():
maxlevel = max(1,maxlevel)
if 'error' in line.lower():
if ' error ' in line.lower():
maxlevel = max(2,maxlevel)
elif 'fatal' in line.lower() or 'exception' in line.lower():
elif ' fatal ' in line.lower() or 'exception ' in line.lower():
maxlevel = max(3,maxlevel)
output = ''.join(output)
if maxlevel==1:
......@@ -99,6 +99,7 @@ class ConfToCoolSQlite:
self.smk = 0
self.l1psk = 0
self.hltpsk = 0
self.bgsk = 1
self.useFrontier = tf.triggerUseFrontier()
def setTriggerDBConnection(self,trigDbConnectionParameters):
......@@ -130,10 +131,10 @@ class ConfToCoolSQlite:
else: # db
if self.smk==0 or self.l1psk==0 or self.hltpsk==0:
raise RuntimeError, "Source of trigger menu configuration is the TriggerDB, but no keys are specified: %i/%i/%i" % (self.smk, self.l1psk, self.hltpsk)
msg.info("Writing menu (keys: %i/%i/%i) from triggerDB (%s) to COOL (%s)" % (self.smk, self.l1psk, self.hltpsk, self.trigdb, self.dbfilename) )
msg.info("Writing menu (keys: %i/%i/%i/%i) from triggerDB (%s) to COOL (%s)" % (self.smk, self.l1psk, self.hltpsk, self.bgsk, self.trigdb, self.dbfilename) )
syscmd = "rm -f %s; TrigConf2COOLApp -e createwrite" % self.dbfilename
syscmd += " --cooldb 'sqlite://;schema=%s;dbname=%s'" % (self.dbfilename,self.dbname)
syscmd += " --trigdb '%s' --configkey %i --prescalekeylvl1 %i --prescalekeyhlt %i" % (self.trigdb, self.smk, self.l1psk, self.hltpsk)
syscmd += " --trigdb '%s' --configkey %i --prescalekeylvl1 %i --prescalekeyhlt %i --bgkey %i" % (self.trigdb, self.smk, self.l1psk, self.hltpsk, self.bgsk)
if self.useFrontier:
syscmd += " --usefrontier"
syscmd += " --infiov"
......
......@@ -380,7 +380,8 @@ class SetupTrigConfigSvc:
trigSvc = TrigConfigSvc("TrigConfigSvc")
trigSvc.PriorityList = self.states
ServiceMgr += trigSvc
from AthenaCommon.AppMgr import theApp
theApp.CreateSvc += [ ServiceMgr.TrigConfigSvc.getFullName() ]
def GetPlugin(self):
if not self.initialised:
......
......@@ -472,8 +472,6 @@ def getMenuNameFromDB(connection, hltprescalekey):
# temporarily here, but should use the function from TMP
m = re.match( "(.*)_default_prescale", hltpsName)
menuName = m.group(1) if m else hltpsName
# from TriggerMenuPython.TriggerPythonConfig import TriggerPythonConfig
# menuName = TriggerPythonConfig.getMenuNameFromHltpsName(hltpsName)
log.info("Interpreting menu name from HLT prescale key %i: %s" % (hltprescalekey,menuName))
......
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
# moved to TriggerMenuPython
# here only a forward is kept
from AthenaCommon.Logging import logging
msg = logging.getLogger( 'TrigConfigSvc/TriggerPythonConfig.py' )
msg.info('ATTENTION: TriggerPythonConfig.py has been moved from package TrigConfigSvc to package TriggerMenuPython')
msg.info(' Pleace change your code according to the description in:')
msg.info(' https://svnweb.cern.ch/trac/atlasoff/browser/Trigger/TrigConfiguration/TrigConfigSvc/trunk/python/TriggerPythonConfig.py')
from TriggerMenuPython.TriggerPythonConfig import *
## Moving to the new source is quite easy:
# instead of
#
# from TrigConfigSvc.TriggerPythonConfig import *
#
# use
#
# from TriggerMenuPython.TriggerPythonConfig import *
#
# and instead of
#
# import TrigConfigSvc.TriggerPythonConfig
# c = TrigConfigSvc.TriggerPythonConfig.CTPInfo
#
# use
#
# import TriggerMenuPython.TriggerPythonConfig
# c = TriggerMenuPython.TriggerPythonConfig.CTPInfo
#
#!/usr/bin/env python
# @file: checkTriggerConfig.py
# @purpose: print all trigger configuration summary info of a pool file
# @purpose: print trigger configuration summary info of a pool file
# @author: Joerg Stelzer
# @date: January 2009
# @date: January 2016
#
# @example:
# @code
# checkTriggerConfig.py aod.pool.root
# checkTrigger /castor/cern.ch/user/j/johndoe/aod.pool.root
# checkTrigger somedir/*/*.pool
# @endcode
#
from optparse import OptionParser
statistics = {}
def _elemFilter(elem):
if elem.key().startswith('/TRIGGER/'):
return elem
return None
def dumpMeta(tt, name):
print "----------------------------------------------------------------------"
# Get meta data branch
br = tt.GetBranch( name )
if br == None:
print "Could not find branch for ",name
return
try:
if br.GetEntry( 0 ) <= 0:
print ":: Could not get meta data for first event for branch", anem
pass
#print "Dumping class", br.GetObjClassName(), " for key ", name
# access meta data
metaData = getattr(tt, br.GetName())
payloadContainer = metaData.payloadContainer()
print "Folder %s [size %i]" % (metaData.folderName(),payloadContainer.size())
statistics[metaData.folderName()] = payloadContainer.size()
for c, attrListColl in enumerate(payloadContainer):
#attrListColl.dump()
for i in range(attrListColl.size()):
chanNum = attrListColl.chanNum(i)
iov = attrListColl.iovRange( chanNum )
print "%i) %s" % (i,iov)
attrList = attrListColl.attributeList( chanNum )
for k in attrList.keys():
print " %s : %s" % (k,attrList[k])
except Exception, ex:
print "## Caught exception [%s] !!" % str(ex.__class__)
print "## What:",ex
import sys
print sys.exc_info()[0]
print sys.exc_info()[1]
sc = 1
def dumpAll(tt, doDetailedDump):
folders = ['_TRIGGER_HLT_HltConfigKeys', '_TRIGGER_LVL1_Lvl1ConfigKey', '_TRIGGER_LVL1_BunchGroupKey', '_TRIGGER_HLT_PrescaleKey']
if doDetailedDump:
folders += [ '_TRIGGER_LVL1_Thresholds', '_TRIGGER_LVL1_Prescales', '_TRIGGER_LVL1_Menu', '_TRIGGER_LVL1_ItemDef', '_TRIGGER_HLT_Prescales', '_TRIGGER_HLT_Menu' ]
for f in folders:
dumpMeta(tt, f)
if __name__ == '__main__':
import sys
from optparse import OptionParser
parser = OptionParser(usage="usage: %prog options file [file2 [...]]")
parser.add_option( "-d",
"--chainsdetail",
action = "store_true",
default = False,
dest = "chainsdetail",
help = "prints detailed chain definition" )
parser.add_option( "-d", "--detail", action = "store_true", default = False,
dest = "printdetail", help = "prints detailed chain definition" )
(options, args) = parser.parse_args()
fileNames = [arg for arg in args if arg[0] != "-" ]
if len(fileNames)==0:
print "No file specified"
parser.print_help()
from sys import exit
exit(1)
from TrigConfigSvc.TriggerConfigARA import TriggerConfigARA
trigconf = TriggerConfigARA(fileNames)
trigconf.printFileSummary(options.chainsdetail)
import cppyy
import PyCool
sys.modules['PyCintex'] = PyCintex = cppyy
import ROOT
ROOT.IOVTime.__str__ = lambda x: "%i/%i" % (x.run(),x.event())
ROOT.IOVTime.__lt__ = lambda s,o: s.run()<o.run() or s.run()==o.run() and s.event()<o.event()
ROOT.IOVTime.__eq__ = lambda s,o: s.run()==o.run() and s.event()==o.event()
ROOT.IOVTime.__le__ = lambda s,o: s<o or s==o
ROOT.IOVRange.__str__ = lambda x: "[%s - %s]" % (x.start(),x.stop())
ROOT.IOVRange.isInRange = lambda x,e: x.start()<=e and e<x.stop()
from PyUtils.Helpers import ROOT6Setup
ROOT6Setup()
import AthenaROOTAccess.transientTree
fileName = fileNames[0] # only one file for now
print "... opening file %s" % fileName
f = ROOT.TFile.Open(fileName)
assert f.IsOpen()
tt = AthenaROOTAccess.transientTree.makeTree( f, persTreeName = 'MetaData', dhTreeName = 'MetaDataHdr',
dhBranchName = 'DataHeader', dhfilt = _elemFilter )
print "\n\n\n"
dumpAll( tt, doDetailedDump = options.printdetail )
#########################################################################
# #
# Standalone jobO for testing the HLT Config service #
# and the TriggerPythonConfig menu generator #
MessageSvc = Service( "MessageSvc" )
MessageSvc.OutputLevel = VERBOSE
MessageSvc.defaultLimit = 10000000
from TriggerJobOpts.TriggerFlags import TriggerFlags
TriggerFlags.inputHLTconfigFile = 'generated_hlt_menu.xml' # here we use it
from AthenaCommon.Logging import logging
logging.getLogger( 'Unit test: ' )
from TrigConfigSvc.TrigConfigSvcConfig import SetupTrigConfigSvc
log.info('Creating the trigger configuration service wrapper')
svc = SetupTrigConfigSvc()
svc.SetStates(["xml"]);
svc.hltXmlFile = TriggerFlags.inputHLTconfigFile()
svc.InitialiseSvc();
theApp.Dlls += [ "TrigConfigSvc" ]
#######################################################
##### Generate menu similar to the hlt_menu
from TriggerMenuPython.TriggerPythonConfig import *
menu = TriggerPythonConfig('generated_hlt_menu.xml', 'generated_lvl1_menu.xml')
#menu = TriggerPythonConfig('generated_hlt_menu.xml')
# fake L1
mu6 = menu.addLvl1Threshold('MU6', 'MUON', 0,'SLOT9','CON0')\
.addMuonThresholdValue(6, -49, 49, 0, 64)
em1 = menu.addLvl1Threshold('EM1', 'EM', 0, 'SLOT7', 'CON1')\
.addEMThresholdValue(7, -49, 49, 0, 64,\
IsolationOff,IsolationOff,IsolationOff)
em18 = menu.addLvl1Threshold('EM18', 'EM', 3, 'SLOT7', 'CON1')\
.addEMThresholdValue(18, -49, 49, 0, 64, \
IsolationOff,IsolationOff,IsolationOff)
cond_1mu6 = mu6.condition(1)
cond_1em1 = em1.condition(1)
cond_1em18 = em18.condition(1)
item_1em1 = LVL1MenuItem('L1_1EM1', 0x0, '1', 100, 'LOW').setLogic(cond_1em1)
item_1em20 = LVL1MenuItem('L1_EM20', 0x3, '1', 1, 'LOW').setLogic(cond_1em18)
item_2em20 = LVL1MenuItem('L1_2EM20', 0x3, '1', 1, 'LOW').setLogic(cond_1em18&cond_1em18)
menu.addLVL1Item(item_1em1)
menu.addLVL1Item(item_1em20)
menu.addLVL1Item(item_2em20)
# sequence
menu.addSequence('EM1', ['T2CaloRec', 'T2CaloHypo'], 'em10t2calo')
menu.addSequence('em10t2calo',['T2CaloIsol', 'T2CaloIsolHypo'], 'em10t2caloi')
menu.addSequence('em10t2caloi', ['IDScan', 'IDHypo'], 'em10t2track')
menu.addSequence('em10t2track', ['IDScan', 'IDHypo'], 'em10match')
menu.addSequence('EM18', ['T2CaloRec', 'T2CaloHypo'], 'em20t2calo')
menu.addSequence('em20t2calo',['T2CaloIsol', 'T2CaloIsolHypo'], 'em20t2caloi')
menu.addSequence('em20t2caloi', ['IDScan', 'IDHypo'], 'em20t2track')
menu.addSequence('em20t2track', ['IDScan', 'IDHypo'], 'em20match')
#chains
chain = HLTChain('em10L2', '67', 'L1_1EM1', 'L2')
chain.addTriggerTypeBit(4)
chain.addStreamTag('electrons')
chain.addGroup('EM')