Skip to content
Snippets Groups Projects
Commit a9174d20 authored by Stewart Martin-Haugh's avatar Stewart Martin-Haugh Committed by Graeme Stewart
Browse files

'Fix CMake linking' (ByteStreamEmonSvc-00-03-07)

parent e49b6112
No related merge requests found
Showing
with 2903 additions and 0 deletions
// this is -*- C++ -*-
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef BYTESTREAMCNVSVC_BYTESTREAMEVENTSTORAGEINPUTSVC_H
#define BYTESTREAMCNVSVC_BYTESTREAMEVENTSTORAGEINPUTSVC_H
/**
@class ByteStreamEmonInputSvc
@brief implements the interface ByteStreamInputSvc for reading events
from emon.
*/
// Include files.
#include "ByteStreamCnvSvc/ByteStreamInputSvc.h"
#include "ByteStreamData/RawEvent.h"
#include "GaudiKernel/IIncidentListener.h"
#include "GaudiKernel/ServiceHandle.h"
// To avoid compiler warning
#undef PACKAGE_VERSION
#include "emon/EventIterator.h"
#include <vector>
#include <stdint.h>
#include <memory>
#include <boost/regex.hpp>
class ITHistSvc;
class OHRootProvider;
class StoreGateSvc;
class ByteStreamEmonInputSvc: public ByteStreamInputSvc, public virtual IIncidentListener {
public:
/// Constructors:
ByteStreamEmonInputSvc(const std::string& name, ISvcLocator* svcloc);
/// Destructor.
virtual ~ByteStreamEmonInputSvc();
virtual StatusCode initialize();
virtual StatusCode finalize();
/// Implementation of the ByteStreamInputSvc interface methods.
virtual const RawEvent* previousEvent();
virtual const RawEvent* nextEvent();
/// Implementation of the ByteStreamInputSvc interface methods.
virtual const RawEvent* currentEvent() const;
public: // IIncidentListener
virtual void handle(const Incident&);
private:
bool getIterator();
void check_publish();
void get_runparams();
void updateHandler(Property& p);
int m_totalEventCounter; //!< event Counter
RawEvent* m_re; //!< current event
// Properties
std::string m_partition; //!< Partition name
std::string m_key; //!< Emon key, e.g. "SFI"
std::vector<std::string> m_value; //!< Emon values, e.g. "SFI-1", if empty, all SFIs
unsigned int m_key_count; //!< Emon key count, e.g. 5 to get five random SFIs
std::string m_publish; //!< Name to publish histograms under
bool m_exit; //!< Exit if partition shuts down (default: false)
std::string m_is_server; //!< Name of IS server to publish to
std::string m_include; //!< Regexpression of histograms to publish
std::string m_exclude; //!< Regexpression of histograms not to publish
int m_frequency; //!< After how many events to publish
int m_updatePeriod; //!< After how many seconds to publish
float m_updatePeriodRange; //!< Percentage of update window where allowed to publish.
bool m_clearHistograms; //!< Clear histograms for each new run (default: true)
std::vector<std::string> m_l1names; //!< Level 1 names
std::vector<unsigned int> m_l1items; //!< Level 1 items, as a numerical list
std::string m_l1logic; //!< One of: 'Or', 'And', 'Ignore' (default: Ignore)
std::string m_l1origin; //!< One of: 'TBP', 'TAP', 'TAV'
std::string m_stream_type; //!< HLT stream type (physics or calibration)
std::vector<std::string> m_stream_names; //!< HLT stream names
std::string m_stream_logic; //!< One of 'Or', 'And', 'Ignore' (default: Ignore)
unsigned int m_trigger_type; //!< LVL1 8 bit trigger type
bool m_dispersion; //!< Dispersion
unsigned int m_buffer_size; //!< Number of events buffered internally.
bool m_readDetectorMask; //!< Read detector mask and run params from IS
int m_timeout; //!< Timeout in seconds, -1 == infinite
bool m_corrupted_events; //!< process corrupted events ?
std::string m_state;
// internal
bool m_connect;
std::auto_ptr<emon::EventIterator> m_eventIt; //!< Event iterator
ITHistSvc *m_histSvc;
OHRootProvider *m_provider;
boost::regex m_include_rex;
boost::regex m_exclude_rex;
int m_frequency_counter;
int m_publish_target;
/// Reference to StoreGateSvc;
ServiceHandle<StoreGateSvc> m_inputMetaDataStore;
ServiceHandle<StoreGateSvc> m_sgSvc; //!< StoreGateSvc
};
#endif
################################################################################
# Package: ByteStreamEmonSvc
################################################################################
# Declare the package name:
atlas_subdir( ByteStreamEmonSvc )
# Declare the package's dependencies:
atlas_depends_on_subdirs( PUBLIC
Event/ByteStreamCnvSvc
Event/ByteStreamData
GaudiKernel
PRIVATE
Control/StoreGate
Database/PersistentDataModel
Event/ByteStreamCnvSvcBase
Event/EventInfo )
# External dependencies:
find_package( Boost COMPONENTS filesystem thread system )
find_package( tdaq COMPONENTS emon ohroot owl is omniORB4 omnithread )
# Component(s) in the package:
atlas_add_library( ByteStreamEmonSvcLib
src/ByteStreamEmonInputSvc.cxx
PUBLIC_HEADERS ByteStreamEmonSvc
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${TDAQ-COMMON_INCLUDE_DIRS} ${TDAQ_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${TDAQ-COMMON_LIBRARIES} ${TDAQ_LIBRARIES} ByteStreamData GaudiKernel ByteStreamCnvSvcLib ByteStreamData_test StoreGateLib SGtests ByteStreamCnvSvcBaseLib
PRIVATE_LINK_LIBRARIES PersistentDataModel EventInfo )
atlas_add_component( ByteStreamEmonSvc
src/components/*.cxx
INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${TDAQ-COMMON_INCLUDE_DIRS} ${TDAQ_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${TDAQ-COMMON_LIBRARIES} ${TDAQ_LIBRARIES} ByteStreamCnvSvcLib ByteStreamData ByteStreamData_test GaudiKernel StoreGateLib SGtests PersistentDataModel ByteStreamCnvSvcBaseLib EventInfo ByteStreamEmonSvcLib )
# Install files from the package:
atlas_install_joboptions( share/*.py )
package ByteStreamEmonSvc
author Reiner Hauser <Reiner.Hauser@cern.ch>
use AtlasPolicy AtlasPolicy-*
use ByteStreamData ByteStreamData-* Event
use DataCollection DataCollection-* External
use GaudiInterface GaudiInterface-* External
use ByteStreamCnvSvc ByteStreamCnvSvc-* Event
use AtlasBoost AtlasBoost-* External
use HLTtdaq HLTtdaq-* HLT/HLTExternal
private
use EventInfo EventInfo-* Event
use StoreGate StoreGate-* Control
use ByteStreamCnvSvcBase ByteStreamCnvSvcBase-* Event
use PersistentDataModel PersistentDataModel-* Database
end_private
macro_append ByteStreamEmonSvc_shlibflags "-lemon -lohroot"
apply_pattern dual_use_library files="ByteStreamEmonInputSvc.cxx"
apply_pattern declare_joboptions files="*.py"
###############################################################
#
# Job options file for reading bytestream events from emon
#==============================================================
# get a handle on the ServiceManager
svcMgr = theApp.serviceMgr()
# Services
from ByteStreamEmonSvc.ByteStreamEmonSvcConf import ByteStreamEmonInputSvc
svcMgr += ByteStreamEmonInputSvc("ByteStreamInputSvc")
from ByteStreamCnvSvcBase.ByteStreamCnvSvcBaseConf import ROBDataProviderSvc
svcMgr += ROBDataProviderSvc()
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import EventSelectorByteStream
svcMgr += EventSelectorByteStream("EventSelector")
theApp.EvtSel = "EventSelector"
# for EventType
from ByteStreamCnvSvc.ByteStreamCnvSvcConf import ByteStreamCnvSvc
svcMgr += ByteStreamCnvSvc()
# Properties
EventSelector = svcMgr.EventSelector
EventSelector.ByteStreamInputSvc = "ByteStreamInputSvc";
EventSelector.FileBased = False
EventPersistencySvc = svcMgr.EventPersistencySvc
EventPersistencySvc.CnvServices += [ "ByteStreamCnvSvc" ]
# ByteStreamAddressProviderSvc
from ByteStreamCnvSvcBase. ByteStreamCnvSvcBaseConf import ByteStreamAddressProviderSvc
svcMgr += ByteStreamAddressProviderSvc()
ByteStreamAddressProviderSvc = svcMgr.ByteStreamAddressProviderSvc
# proxy provider
from SGComps.SGCompsConf import ProxyProviderSvc
svcMgr += ProxyProviderSvc()
ProxyProviderSvc = svcMgr.ProxyProviderSvc
ProxyProviderSvc.ProviderNames += [ "ByteStreamAddressProviderSvc" ]
#########################################
#
# Example setup for ByteStreamEmonSvc
#
#########################################
# Common part, copy from here
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from AthenaCommon.Constants import *
include("ByteStreamEmonSvc/ByteStreamEmonInputSvc_jobOptions.py")
# #####################################################
# If using the ERSBootstrap.py file, enable the output
# via ERS
# ####################################################
#MessageSvc.useErs = True
# Define the input
ByteStreamEmonInputSvc = svcMgr.ByteStreamInputSvc
# ############################################################
# The name of the partition you want to connect to is taken
# from 'TDAQ_PARTITION' if it this parameter is empty, otherwise from here.
# ############################################################
ByteStreamEmonInputSvc.Partition = "rhauser_hlt"
# #########################################
# The source of events, SFI for full events
# #########################################
ByteStreamEmonInputSvc.Key = "SFI"
# ############################################################
# A list of of key values, e.g. a list of SFIs to contact.
# If not defined, all event providers of this type (e.g. all SFIs)
# ############################################################
# ByteStreamEmonInputSvc.KeyValue = ["SFI-1", "SFI-2" ]
# ###########################################################
# Preferred way: just indicate the number of SFIs you
# want to connect to.
# ###########################################################
ByteStreamEmonInputSvc.KeyCount = 3
# ############################################################
# Dispersion: if false all processes with the same selection
# criteria see the same events.
# ############################################################
# ByteStreamEmonInputSvc.Dispersion = False
# ############################################################
# Number of internally buffered events. Keep small for
# full events.
# ############################################################
# ByteStreamEmonInputSvc.BufferSize = 2
# #######################################
# Set this to the IS server where you want
# to publish histograms, too. If unset, no
# histograms are published.
# #######################################
#ByteStreamEmonInputSvc.ISServer = 'Histogramming'
# ########################################
# The provider name under which your histograms
# appear in OH.
# ########################################
#ByteStreamEmonInputSvc.PublishName = 'HelloWorld'
# ###################################################
# Should histograms be cleared at new run ? default: yes
# ###################################################
# ByteStreamEmonInputSvc.ClearHistograms = True
# ####################################################
# A regular expression to restrict which histograms are published.
# ####################################################
# ByteStreamEmonInputSvc.Include = '.*'
# ByteStreamEmonInputSvc.Exclude = ''
# ###############################################
# Frequency of updates (in number of events, not secs...)
# ###############################################
# ByteStreamEmonInputSvc.Frequency = 5
# ##############################
# one of 'Ignore', 'Or', 'And'
# ##############################
ByteStreamEmonInputSvc.LVL1Logic = "Ignore"
# ###########################################################
# A LVL1 bit pattern to select events on.
#
# From 1 to 4 64bit values, first entry = Bit 0..63 in CTP
# ###########################################################
#ByteStreamEmonInputSvc.LVL1Bits = [ 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff]
# ###########################################################
# A list of L1 bit names to select on. This requires the
# L1CT.TrigConfL1Items to be published in IS.
#
# This can be used instead of or in addition to LVL1Bits.
# ###########################################################
#ByteStreamEmonInputSvc.LVL1Names = ['L1_MU2', 'L1_MU3', 'L1_EM10' ]
# #################################################
# Shall athena exit if the partition is shutdown ?
# For offline athena tasks mainly.
# #################################################
#ByteStreamEmonInputSvc.ExitOnPartitionShutdown = False
ByteStreamCnvSvc = Service( "ByteStreamCnvSvc" )
theApp.ExtSvc += [ "ByteStreamCnvSvc"]
# It looks as if one needs this now online ?
if False:
from EventSelectorAthenaPool.EventSelectorAthenaPoolConf import MetaDataSvc
svcMgr += MetaDataSvc( "MetaDataSvc" )
# Add in MetaData Stores
from StoreGate.StoreGateConf import StoreGateSvc
svcMgr += StoreGateSvc( "MetaDataStore" )
svcMgr += StoreGateSvc( "InputMetaDataStore" )
# Make MetaDataSvc an AddressProvider
svcMgr.ProxyProviderSvc.ProviderNames += [ "MetaDataSvc" ]
# enable IOVDbSvc to read metadata
#svcMgr.MetaDataSvc.MetaDataContainer = "MetaDataHdr"
#svcMgr.MetaDataSvc.MetaDataTools += [ "IOVDbMetaDataTool" ]
MetaDataStore=svcMgr.MetaDataStore
#--------------------------------------------------------------
# Private Application Configuration options, replace with
# your configuration.
#--------------------------------------------------------------
from TrigExMTHelloWorld.TrigExMTHelloWorldConf import MTHelloWorld
HelloWorld = MTHelloWorld("HelloWorld")
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
topSequence += HelloWorld
#--------------------------------------------------------------
# Algorithms Private Options
#--------------------------------------------------------------
# For the genuine HelloWorld algorithm
HelloWorld.MyInt = 42
HelloWorld.MyBool = TRUE
HelloWorld.MyDouble = 3.14159
HelloWorld.MyStringVec = [ "Welcome", "to", "Athena", "Framework", "Tutorial" ]
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
theApp.MessageSvcType='TrigMessageSvc'
svcMgr += CfgMgr.TrigMessageSvc('MessageSvc')
#########################################
#
# Example setup for ByteStreamEmonSvc
#
#########################################
# Common part, copy from here
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from AthenaCommon.Constants import *
include("ByteStreamEmonSvc/ByteStreamEmonInputSvc_jobOptions.py")
# #####################################################
# If using the ERSBootstrap.py file, enable the output
# via ERS
# ####################################################
#MessageSvc.useErs = True
# Define the input
ByteStreamEmonInputSvc = svcMgr.ByteStreamInputSvc
# ############################################################
# The name of the partition you want to connect to is taken
# from 'TDAQ_PARTITION' if it exists, otherwise from here.
# ############################################################
ByteStreamEmonInputSvc.Partition = "rhauser_hlt"
# #########################################
# The source of events, SFI for full events
# #########################################
ByteStreamEmonInputSvc.Key = "SFI"
# ############################################################
# A list of of key values, e.g. a list of SFIs to contact.
# If not defined, one event providers of this type.
# ############################################################
ByteStreamEmonInputSvc.KeyCount = 2
# ##############################
# one of 'Ignore', 'Or', 'And'
# ##############################
ByteStreamEmonInputSvc.LVL1Logic = "Ignore"
# ###########################################################
# A LVL1 bit pattern to select events on.
#
# From 1 to 4 64bit values, first entry = Bit 0..63 in CTP
# ###########################################################
#ByteStreamEmonInputSvc.LVL1Bits = [ 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff, 0xffffffffffffffff]
# ###########################################################
# A list of L1 bit names to select on. This requires the
# L1CT.TrigConfL1Items to be published in IS.
#
# This can be used instead of or in addition to LVL1Bits
# and LVL1Items.
# ###########################################################
#ByteStreamEmonInputSvc.LVL1Names = ['L1_MU2', 'L1_MU3', 'L1_EM10' ]
# ###########################################################
# A list of numerical L1 items to select on.
#
# This can be used instead of or in addition to LVL1Bits and
# LVL1Names
# ###########################################################
#ByteStreamEmonInputSvc.LVL1Items = [ 1, 20, 45 ] + range(22,28)
# #################################################
# Shall athena exit if the partition is shutdown ?
# For offline athena tasks mainly.
# #################################################
#ByteStreamEmonInputSvc.ExitOnPartitionShutdown = False
ByteStreamCnvSvc = Service( "ByteStreamCnvSvc" )
theApp.ExtSvc += [ "ByteStreamCnvSvc"]
# -----------------------------------------------------
# An example algorithm in Python
# -----------------------------------------------------
import AthenaPython.PyAthena as PyAthena
from GaudiPython.Bindings import gbl,InterfaceCast
class ShowLVL1(PyAthena.Alg):
"""
An athena algorithm written in python.
"""
def __init__(self, name="ShowLVL1", **kw):
kw['name'] = name
super(ShowLVL1,self).__init__(name=name)
# How to access properties
self.SomeProperty = kw.get('SomeProperty', 'DefaultValue')
def initialize(self):
self.msg.info("initializing [%s]", self.name())
self.sg = PyAthena.py_svc("StoreGateSvc")
if not self.sg:
self.msg.error("Could not get StoreGateSvc")
return PyAthena.StatusCode.Failure
return PyAthena.StatusCode.Success
def execute(self):
self.msg.debug("executing [%s]", self.name())
# Get EventInfo
ev = self.sg.retrieve('EventInfo')
# Print some LVL1 information
print "Run:",ev.event_ID().run_number(),"Event:",ev.event_ID().event_number()
for x in ev.trigger_info().level1TriggerInfo():
print "0x%08x" % x
return PyAthena.StatusCode.Success
def finalize(self):
self.msg.debug("finalizing [%s]", self.name())
return PyAthena.StatusCode.Success
ShowLVL1Algo = ShowLVL1("ShowMyLVL1")
#--------------------------------------------------------------
# Private Application Configuration options, replace with
# your configuration.
#--------------------------------------------------------------
from AthenaCommon.AlgSequence import AlgSequence
topSequence = AlgSequence()
topSequence += ShowLVL1Algo
#--------------------------------------------------------------
# Algorithms Private Options
#--------------------------------------------------------------
ShowLVL1Algo.SomeProperty = 'Some Value'
#!/usr/bin/env python
import sys
def l1bits(bits):
result = 0L
for i in bits:
result |= 1L << i
print "Full: 0x%x" % result
mask = (2**64-1)
print '[',"0x%x" % (result & mask),',',
print "0x%x" % ((result >> 64) & mask),',',
print "0x%x" % ((result >> 128) & mask),',',
print "0x%x" % ((result >> 192) & mask),']'
if __name__ == '__main__':
l1bits(map(int,sys.argv[1:]))
This diff is collapsed.
This diff is collapsed.
//====================================================================
#include "GaudiKernel/DeclareFactoryEntries.h"
#include "ByteStreamEmonSvc/ByteStreamEmonInputSvc.h"
DECLARE_SERVICE_FACTORY( ByteStreamEmonInputSvc )
DECLARE_FACTORY_ENTRIES( ByteStreamEmonSvc ) {
DECLARE_SERVICE ( ByteStreamEmonInputSvc )
}
#include "GaudiKernel/LoadFactoryEntries.h"
LOAD_FACTORY_ENTRIES( ByteStreamEmonSvc )
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