Commit 69ea5bdd authored by Francesca Pastore's avatar Francesca Pastore Committed by Graeme Stewart
Browse files

fill the l1_ROB_ids in the RTT test initialization (TrigROBDataProviderSvc-00-01-02)

parent 26c0e6dd
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ITrigROBDataProviderSvc_H
#define ITrigROBDataProviderSvc_H
#include "GaudiKernel/IInterface.h"
#include "ByteStreamData/RawEvent.h"
#include <inttypes.h>
#include <vector>
#include <map>
#include <string>
// Declaration of the interface ID ( interface id, major version, minor version)
static const InterfaceID IID_ITrigROBDataProviderSvc("ITrigROBDataProviderSvc", 2 , 0);
/** @class ITrigROBDataProviderSvc
@brief Interface class with additional methods to interface IROBDataProviderSvc for managing ROBs in online.
*/
class ITrigROBDataProviderSvc : virtual public IInterface {
public:
typedef OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF;
//---------------------------------------------------
// Methods to access the data in the online ROB cache
//---------------------------------------------------
/// Retrieve interface ID
static const InterfaceID& interfaceID() { return IID_ITrigROBDataProviderSvc; }
/// Return vector with all ROBFragments stored in the cache
virtual void getAllROBData(std::vector<const ROBF*>&) = 0;
/// Dump the internal ROB cache
virtual std::string dumpROBcache() const = 0;
/// Return size of ROBFragments cache
virtual int sizeROBCache() = 0;
/// iterators over cache entries
virtual std::map<uint32_t, ROBF>::iterator beginROBCache() = 0;
virtual std::map<uint32_t, ROBF>::iterator endROBCache() = 0;
//--------------------------------------------------------------------------------------------------
// Methods for the merged L2/EF system to initiate or check the retrieval of the complete event data
//--------------------------------------------------------------------------------------------------
/// Check if complete event data are already in cache
virtual bool isEventComplete() = 0;
/// Collect all data for an event from the ROS and put them into the cache
/// Return value: number of ROBs which were retrieved to complete the event
/// Optinonally the name of the caller of this method can be specified for cost monitoring
virtual int collectCompleteEventData(const std::string callerName="UNKNOWN") = 0;
//-------------------------------------
// Methods useful for (cost) monitoring
//-------------------------------------
/// set the name of the program which uses the ROBDataProviderSvc
virtual void setCallerName(const std::string) = 0;
/// get the name of the program which is presently registered in the ROBDataProviderSvc
virtual std::string getCallerName() = 0;
};
#endif
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef ITrigROBDataProviderSvc_RTT_H
#define ITrigROBDataProviderSvc_RTT_H
#include "GaudiKernel/IInterface.h"
#include <inttypes.h>
#include <vector>
#include <map>
// Declaration of the interface ID ( interface id, major version, minor version)
static const InterfaceID IID_ITrigROBDataProviderSvc_RTT("ITrigROBDataProviderSvc_RTT", 1 , 0);
/** @class ITrigROBDataProviderSvc_RTT
@brief Interface class with additional methods to interface ITrigROBDataProviderSvc for managing ROBs
*/
class ITrigROBDataProviderSvc_RTT : virtual public IInterface {
public:
/// Retrieve interface ID
static const InterfaceID& interfaceID() { return IID_ITrigROBDataProviderSvc_RTT; }
/// Return vector with all ROBFragments stored in the cache
virtual void addROBData(const std::vector<uint32_t>& robIds,
const std::string callerName="UNKNOWN") = 0;
//return status of prefecthing
virtual bool isMissingPrefetching() = 0;
// return setup of pre-fetching
virtual bool isPrefetchingAtAlgoLevel() = 0;
/// set the name of the program which uses the ROBDataProviderSvc
virtual void setCallerName(const std::string) = 0;
/// Check if complete event data are already in cache
virtual bool isEventComplete() = 0;
/// Collect all data for an event from the ROS and put them into the cache
/// Return value: number of ROBs which were retrieved to complete the event
/// Optinonally the name of the caller of this method can be specified for cost monitoring
virtual int collectCompleteEventData(const std::string callerName="UNKNOWN") = 0;
};
#endif
package TrigROBDataProviderSvc
author W. Wiedenmann <Werner.Wiedenmann@cern.ch>
use AtlasPolicy AtlasPolicy-*
use GaudiInterface GaudiInterface-* External
use ByteStreamData ByteStreamData-* Event
use DataCollection DataCollection-* External
private
use AtlasROOT AtlasROOT-* External
use CxxUtils CxxUtils-* Control
use StoreGate StoreGate-* Control
use TrigMonitorBase TrigMonitorBase-* Trigger/TrigMonitoring
use ByteStreamCnvSvcBase ByteStreamCnvSvcBase-* Event
use TrigDataAccessMonitoring TrigDataAccessMonitoring-* Trigger/TrigDataAccess
end_private
apply_pattern dual_use_library files="*.cxx"
apply_pattern declare_joboptions files="*.py"
apply_pattern declare_python_modules files="*.py"
apply_pattern declare_scripts files="../python/scripts/*.py"
#!/usr/bin/env python
# Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
#
# author: Werner Wiedenmann <Werner.Wiedenmann@cern.ch>
#
import sys
import os
import datetime
def random(hits, n):
"""Places all ROB hits randomly in 'n' ROSs.
This function will take the hits found in the list given as first parameter
and will randomly place all ROB identifiers over the 'n' available ROSs as
defined by the second parameter (which, btw, defaults to 1).
"""
from random import randint,seed
seed(0) # make it random, but no so random!
retval = {}
for h in hits: retval[h] = randint(1,n)
return retval
def my_conf(argv):
"""Runs the dumping routines"""
import logging
from EventApps import myopt
option = {}
option['ignore'] = {'short': 'v', 'arg': True,
'default': '0x007[3589abc].+|0x007[67]0001',
'description': 'A (python) regular expression of ROB hexadecimal numbers to ignore when making the robmap list. The comparision is done on a string basis, as a result of parsing each hit in a 0x%08x printf-like format'}
option['verbosity'] = {'short': 'V', 'arg': True,
'default': logging.INFO,
'description': 'From which level to print system messages [%d, %d]. For details please consult the documentation of python\'s "logging" module' % (logging.NOTSET, logging.CRITICAL)}
parser = myopt.Parser(extra_args=True)
for (k,v) in option.items():
parser.add_option(k, v['short'], v['description'], v['arg'], v['default'])
if len(sys.argv) == 1:
print parser.usage('global "%s" options:' % sys.argv[0])
sys.exit(1)
#process the global options
(kwargs, extra) = parser.parse(sys.argv[1:], prefix='global "%s" options:' % sys.argv[0])
#now the things which require global defaults
logging.getLogger('').setLevel(kwargs['verbosity'])
# os.environ['TDAQ_ERS_DEBUG_LEVEL'] = str(kwargs['debug'])
import eformat
stream = eformat.istream(extra)
rob_list = set()
sys.stderr.write('Processing %s events' % len(stream))
for event in stream:
sys.stderr.write('.')
sys.stderr.flush()
for rob in event: rob_list.add(rob.source_id().code())
sys.stderr.write('\n')
print "# This ROB-ROS map was generated by %s" % \
os.path.basename(sys.argv[0])
print "# Current date and time is", datetime.datetime(1,1,1).now()
print "#"
keys = list(rob_list)
keys.sort()
# checks if we need to apply filtering...
if len(kwargs['ignore'].strip()) != 0:
import re
ignore = re.compile(kwargs['ignore'].strip())
keys = [k for k in keys if not ignore.match('0x%08x' % k)]
print "# These unique identifiers were extracted from:"
for k in extra: print "# %s" % k
print "#"
print "svcMgr.ROBDataProviderSvc.RobRosMapping = {"
print "#"
print "# ROB id : ROS id = SubDetector Id "
print "#"
ros_count=0
old_sub_det=0
for k in keys:
if old_sub_det != eformat.helper.SourceIdentifier(k).subdetector_id().real:
old_sub_det = eformat.helper.SourceIdentifier(k).subdetector_id().real
ros_count = ros_count + 1
print "# %02i : Sub Detector = %s" % (ros_count, eformat.helper.SourceIdentifier(k).subdetector_id())
print " %s : %s ," % (hex(k), hex(eformat.helper.SourceIdentifier(k).subdetector_id().real))
print "}"
if __name__ == "__main__":
my_conf(sys.argv)
#**************************************************************
#
# TrigROBDataProviderSvc job options fragment
#
#==============================================================
from AthenaCommon.AppMgr import theApp
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from AthenaCommon import CfgMgr
# remove old ROBDataProviderSvc definition
if hasattr(svcMgr, 'ROBDataProviderSvc'):
if theApp.__dict__[ 'CreateSvc' ].count( svcMgr.ROBDataProviderSvc.getFullName() ):
theApp.__dict__[ 'CreateSvc' ].remove( svcMgr.ROBDataProviderSvc.getFullName() )
del svcMgr.allConfigurables['ROBDataProviderSvc']
del svcMgr.ROBDataProviderSvc
if dir().count('ROBDataProviderSvc'):
del ROBDataProviderSvc
# configure the offline monitoring ROBDataProviderSvc
svcMgr += CfgMgr.TrigROBDataProviderSvc("ROBDataProviderSvc")
theApp.CreateSvc += [ svcMgr.ROBDataProviderSvc.getFullName() ]
ROBDataProviderSvc = svcMgr.ROBDataProviderSvc
# switch on algorithm auditing in case it is not yet done
theApp.AuditAlgorithms = True
theApp.AuditServices = True
theApp.AuditTools = True
#
# TrigROBDataProviderSvc specific options
#
# provide histograms
svcMgr.ROBDataProviderSvc.doMonitoring = False
# provide cost monitoring information from ROBs
svcMgr.ROBDataProviderSvc.doDetailedROBMonitoring = True
# simulate online like data access,
# if = True: ROBs need to be registered before they can be retrieved as in online running
# if = False: Full event fragment is available as in offline running
svcMgr.ROBDataProviderSvc.SimulateOnlineDataAccess = True
# use a ROB-ROS mapping file to simulate ROS access
# (for the simulation of online running this should be True
# and a ROB-ROS mapping should be provided. A simple ROB-ROS mapping file
# can be generated with the tool generate-rob-ros-map-from-data.py in the
# directory python/scripts of this package)
svcMgr.ROBDataProviderSvc.UseROSmappingForROBRetrieval = True
#
# svcMgr.ROBDataProviderSvc.RobRosMapping = {}
#
# for finding modules which make a ROB request in getROBData to a
# not registered ROB it is possible to obtain a complete backtrace
# if this option is switched on. The output may be however big.
svcMgr.ROBDataProviderSvc.PrintStackTraceGetROBData = True
#
#==============================================================
#
# End of TrigROBDataProviderSvc job options fragment
#
#**************************************************************
#**************************************************************
#
# TrigROBDataProviderSvc_RTT job options fragment
#
#==============================================================
from AthenaCommon.AppMgr import theApp
from AthenaCommon.AppMgr import ServiceMgr as svcMgr
from AthenaCommon import CfgMgr
# remove old ROBDataProviderSvc definition
if hasattr(svcMgr, 'ROBDataProviderSvc'):
if theApp.__dict__[ 'CreateSvc' ].count( svcMgr.ROBDataProviderSvc.getFullName() ):
theApp.__dict__[ 'CreateSvc' ].remove( svcMgr.ROBDataProviderSvc.getFullName() )
del svcMgr.allConfigurables['ROBDataProviderSvc']
del svcMgr.ROBDataProviderSvc
if dir().count('ROBDataProviderSvc'):
del ROBDataProviderSvc
# configure the offline monitoring ROBDataProviderSvc
svcMgr += CfgMgr.TrigROBDataProviderSvc_RTT("ROBDataProviderSvc")
theApp.CreateSvc += [ svcMgr.ROBDataProviderSvc.getFullName() ]
ROBDataProviderSvc = svcMgr.ROBDataProviderSvc
# switch on algorithm auditing in case it is not yet done
theApp.AuditAlgorithms = True
theApp.AuditServices = True
theApp.AuditTools = True
#
# TrigROBDataProviderSvc_RTT specific options
#
# provide histograms
svcMgr.ROBDataProviderSvc.doMonitoring = True
#False
# provide cost monitoring information from ROBs
svcMgr.ROBDataProviderSvc.doDetailedROBMonitoring = True
# simulate online like data access,
# if = True: ROBs need to be registered before they can be retrieved as in online running
# if = False: Full event fragment is available as in offline running
svcMgr.ROBDataProviderSvc.SimulateOnlineDataAccess = True
# use a ROB-ROS mapping file to simulate ROS access
# (for the simulation of online running this should be True
# and a ROB-ROS mapping should be provided. A simple ROB-ROS mapping file
# can be generated with the tool generate-rob-ros-map-from-data.py in the
# directory python/scripts of this package)
svcMgr.ROBDataProviderSvc.UseROSmappingForROBRetrieval = True
#
# svcMgr.ROBDataProviderSvc.RobRosMapping = {}
#
# for finding modules which make a ROB request in getROBData to a
# not registered ROB it is possible to obtain a complete backtrace
# if this option is switched on. The output may be however big.
svcMgr.ROBDataProviderSvc.PrintStackTraceGetROBData = False
#True
#
# for enabling the pre-fetching at algorithm level, debugging prefetching
svcMgr.ROBDataProviderSvc.enablePrefetchingAtAlgoLevel = True
#
#svcMgr.ROBDataProviderSvc.OutputLevel=DEBUG
print svcMgr.ROBDataProviderSvc
#==============================================================
#
# End of TrigROBDataProviderSvc_RTT job options fragment
#
#**************************************************************
/*
Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
*/
#ifndef TRIGL2SERVICES_TRIGROBDATAPROVIDERSVC_H
#define TRIGL2SERVICES_TRIGROBDATAPROVIDERSVC_H
/** ===============================================================
* TrigROBDataProviderSvc.h
* ===============================================================
* Description: ROBDataProvider class for simulating the ROB data
* access offline in the merged L2/EF system after LS1.
*
* In contrast to the normal offline data access the
* the event data are retrieved incrementally online
* over the network and in general the complete event
* fragment is not available.
* All ROB data which are required for processing have
* to be pre-registered for retrieval with a call to
*
* addROBData(const std::vector<uint32_t>& robIds)
*
* before they can be used with
*
* getROBData(const std::vector<uint32_t>& robIds,
* std::vector<const ROBF*>& robFragments).
*
*
* Created: Mar 1, 2013
* By: Werner Wiedenmann
* Modified: Feb. 03, 2014 (implement complete hltinterface definitions)
* By: Werner Wiedenmann
*/
#include "GaudiKernel/Service.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/StatusCode.h"
#include "GaudiKernel/IIncidentListener.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/HistoProperty.h"
#include "GaudiKernel/Property.h"
#include "ByteStreamCnvSvcBase/ROBDataProviderSvc.h"
#include "ByteStreamData/RawEvent.h"
#include "TrigDataAccessMonitoring/ROBDataMonitor.h"
#include "eformat/Status.h"
#include <vector>
#include <map>
#include "TrigROBDataProviderSvc/ITrigROBDataProviderSvc.h"
// Forward declarations
class StoreGateSvc;
class IAlgContextSvc;
class TH1F; /// for monitoring purposes
class TH2F; /// for monitoring purposes
class TrigROBDataProviderSvc : public ROBDataProviderSvc,
virtual public ITrigROBDataProviderSvc,
virtual public IIncidentListener
{
public:
typedef OFFLINE_FRAGMENTS_NAMESPACE::ROBFragment ROBF ;
TrigROBDataProviderSvc(const std::string& name, ISvcLocator* svcloc);
virtual ~TrigROBDataProviderSvc(void);
virtual StatusCode initialize();
virtual StatusCode finalize();
virtual StatusCode queryInterface( const InterfaceID& riid, void** ppvInterface );
/// --- Implementation of IROBDataProviderSvc interface ---
/// Add ROBFragments to cache for given ROB ids, ROB fragments may be retrieved with DataCollector
virtual void addROBData(const std::vector<uint32_t>& robIds,
const std::string callerName="UNKNOWN");
/// Add a given LVL1 ROBFragment to cache
virtual void setNextEvent(const std::vector<ROBF>& result);
/// Add all ROBFragments of a RawEvent to cache
virtual void setNextEvent(const RawEvent* re);
/// Retrieve ROBFragments for given ROB ids from cache
virtual void getROBData(const std::vector<uint32_t>& robIds,
std::vector<const ROBF*>& robFragments,
const std::string callerName="UNKNOWN");
/// Retrieve the whole event.
virtual const RawEvent* getEvent() ;
/// --- Implementation of ITrigROBDataProviderSvc interface ---
/// Return vector with all ROBFragments stored in the cache
virtual void getAllROBData(std::vector<const ROBF*>& robFragments) ;
// Dump ROB cache
virtual std::string dumpROBcache() const ;
/// Return size of ROBFragments cache
virtual int sizeROBCache() { return m_online_robmap.size(); }
/// iterators over cache entries
virtual std::map<uint32_t, ROBF>::iterator beginROBCache() { return m_online_robmap.begin(); }
virtual std::map<uint32_t, ROBF>::iterator endROBCache() { return m_online_robmap.end(); }
/// Check if complete event data are already in cache
virtual bool isEventComplete() { return m_isEventComplete; }
/// Collect all data for an event from the ROS and put them into the cache
/// Return value: number of ROBs which were retrieved to complete the event
virtual int collectCompleteEventData(const std::string callerName="UNKNOWN");
/// set the name of the program which uses the ROBDataProviderSvc
virtual void setCallerName(const std::string);
/// get the name of the program which is presently registered in the ROBDataProviderSvc
virtual std::string getCallerName() { return m_callerName; };
/// --- Implementation of IIncidentListener interface ---
// handler for BeginRun actions
void handle(const Incident& incident);
protected:
/**
* @brief Accessor method for the MsgStream.
* @return handle to the MsgStream.
*/
inline MsgStream& logStream() const { return *m_msg; }
/**
* @brief Accessor method for the message level variable.
* @return value of the message level for this algorithm.
*/
inline MSG::Level logLevel() const { return (m_msg != 0) ? m_msg->level() : MSG::NIL; }
// name of the program which presently uses the ROBDataProviderSvc
std::string m_callerName;
BooleanProperty m_doDetailedROBMonitoring;
BooleanProperty m_doMonitoring;
/// Pointer to AlgContextSvc
IAlgContextSvc* m_algContextSvc;
private:
typedef ServiceHandle<StoreGateSvc> StoreGateSvc_t;
/// Reference to StoreGateSvc;
StoreGateSvc_t m_storeGateSvc;
typedef SimpleProperty< std::vector<uint32_t> > Uint32ArrayProperty;
typedef SimpleProperty< std::map<int,int> > IntegerMapProperty;
// flag indicates if running in online/offline
bool m_onlineRunning ;
// read enabled ROBs from OKS when possible
BooleanProperty m_readROBfromOKS;
// list of all enabled ROBs which can be retrieved
Uint32ArrayProperty m_enabledROBs;
// list of ROBs which should be ignored for retrieval
Uint32ArrayProperty m_ignoreROB;
// list of all LAr MET ROBs which can be retrieved
Uint32ArrayProperty m_enabledLArMetROBs ;
UnsignedIntegerProperty m_genericLArMetModuleID ;
// list of all Tile MET ROBs which can be retrieved
Uint32ArrayProperty m_enabledTileMetROBs;
UnsignedIntegerProperty m_genericTileMetModuleID ;
// Separate data collector calls to ROS for normal ROBs and MET ROBs
BooleanProperty m_separateMETandDetROBRetrieval ;
// Filter out empty ROB fragments which are send by the ROS
bool m_removeEmptyROB;
// flag which tells if module IDs from the L2 and EF result should be masked off
bool m_maskL2EFModuleID;
// ROS-ROB mapping
IntegerMapProperty m_rob_ros_map ;
BooleanProperty m_useROSmappingForROBRetrieval ;
std::map< uint32_t, int > m_Det_Robs_for_retrieval ; // internal map of ROB->ROS for retrieval
// map for all the ROB fragments (cache for ROB data so that they are
// not deleted when local containers go out of scope)
typedef std::map<uint32_t, ROBF> ONLINE_ROBMAP;
ONLINE_ROBMAP m_online_robmap;
// helper function to retrieve ROB fragments over the network and to add them to the cache
void addROBDataToCache(std::vector<uint32_t>& robIdsForRetrieval, // vector of ROBs to retrieve
std::vector<uint32_t>& retrievedRobIds, // vector of received ROB ids
robmonitor::ROBDataMonitorStruct* p_robMonStruct); // pointer to ROB monitoring structure for retrieval