Skip to content
Snippets Groups Projects
Commit bd084b93 authored by Vakhtang Tsulaia's avatar Vakhtang Tsulaia
Browse files

Merge branch 'iac_master_rpcrdo' into 'master'

RPC BS to RDO converter cache updated

See merge request atlas/athena!21502
parents d3febdc3 5a5b5e4d
No related branches found
No related tags found
No related merge requests found
Showing
with 1214 additions and 1016 deletions
......@@ -63,6 +63,7 @@ StatusCode MuonCacheCreator::execute (const EventContext& ctx) const {
// Create the CSC cache container
ATH_CHECK(createContainer(m_CscCacheKey, m_cscIdHelper->module_hash_max(), ctx));
// Create the RPC cache container
// Max should match 600 (hardcoded in RPC_RawDataProviderTool)
ATH_CHECK(createContainer(m_RpcCacheKey, m_rpcIdHelper->module_hash_max(), ctx));
// Create the TGC cache container
ATH_CHECK(createContainer(m_TgcCacheKey, m_tgcIdHelper->module_hash_max(), ctx));
......
......@@ -33,10 +33,13 @@ Muon::RPC_RawDataProviderTool::RPC_RawDataProviderTool(
AthAlgTool(t, n, p),
m_decoder("Muon::RpcROD_Decoder/RpcROD_Decoder", this),
m_AllowCreation(false),
m_robDataProvider ("ROBDataProviderSvc",n)
m_robDataProvider ("ROBDataProviderSvc",n),
m_WriteOutRpcSectorLogic(true)
{
declareInterface<IMuonRawDataProviderTool>(this);
declareProperty("Decoder", m_decoder);
declareProperty("RpcContainerCacheKey", m_rdoContainerCacheKey, "Optional external cache for the RPC container");
declareProperty("WriteOutRpcSectorLogic", m_WriteOutRpcSectorLogic, "Turn on/off RpcSectorLogic writing");
}
......@@ -50,11 +53,20 @@ StatusCode Muon::RPC_RawDataProviderTool::initialize()
StatusCode sc = AlgTool::initialize();
if (sc.isFailure()) return sc;
sc = service("ActiveStoreSvc", m_activeStore);
if ( !sc.isSuccess() ) {
ATH_MSG_FATAL( "Could not get active store service" );
return sc;
}
sc = service("ActiveStoreSvc", m_activeStore);
if ( !sc.isSuccess() ) {
ATH_MSG_FATAL( "Could not get active store service" );
return sc;
}
ATH_CHECK( m_rdoContainerCacheKey.initialize( !m_rdoContainerCacheKey.key().empty() ) );
// We should only turn off the sector logic when running with cached data a la trigger mode
if(!m_rdoContainerCacheKey.key().empty() && m_WriteOutRpcSectorLogic){
ATH_MSG_FATAL("Cannot write out RpcSectorLogic while running with cached RpcPad containers"
" as the RpcSectorLogic is not cached at the same time and the written containers will desync."
" Please turn off RpcSectorLogic writing when running with cached bytestream container");
}
if (m_decoder.retrieve().isFailure())
{
......@@ -64,7 +76,6 @@ StatusCode Muon::RPC_RawDataProviderTool::initialize()
else
ATH_MSG_INFO( "Retrieved tool " << m_decoder );
//m_hashfunc = new RpcPadIdHash();
// get cabling svc
......@@ -152,15 +163,10 @@ StatusCode Muon::RPC_RawDataProviderTool::initialize()
}
}
else has_bytestream = true;
//{
// msg(MSG::FATAL) << "Cannot get the job configuration" << endmsg;
//return StatusCode::FAILURE;
//}
// register the container only when the imput from ByteStream is set up
m_activeStore->setStore( &*evtStore() );
if( has_bytestream || m_RpcPadC.key() != "RPCPAD" )
if( has_bytestream || m_containerKey.key() != "RPCPAD" )
{
m_AllowCreation= true;
}
......@@ -171,7 +177,7 @@ StatusCode Muon::RPC_RawDataProviderTool::initialize()
ATH_MSG_INFO( "initialize() successful in " << name());
ATH_CHECK( m_RpcPadC.initialize() );
ATH_CHECK( m_containerKey.initialize() );
ATH_CHECK( m_sec.initialize() );
return StatusCode::SUCCESS;
......@@ -230,62 +236,86 @@ StatusCode Muon::RPC_RawDataProviderTool::convert(const std::vector<IdentifierHa
}
// the old one
StatusCode Muon::RPC_RawDataProviderTool::convert(const ROBFragmentList& vecRobs,
const std::vector<IdentifierHash>& collections)
const std::vector<IdentifierHash>& collections)
{
//CALLGRIND_START_INSTRUMENTATION
// retrieve the container through the MuonRdoContainerManager becasue
// if the MuonByteStream CNV has to be used, the container must have been
// registered there!
m_activeStore->setStore( &*evtStore() );
if(m_AllowCreation == false)
{
ATH_MSG_WARNING( "Container create disabled due to byte stream");
m_activeStore->setStore( &*evtStore() );
if(m_AllowCreation == false)
{
ATH_MSG_WARNING( "Container create disabled due to byte stream");
return StatusCode::SUCCESS; // Maybe it should be false to stop the job
// because the convert method should not
// have been called .... but this depends
// on the user experience
}
}
SG::WriteHandle<RpcPadContainer> padHandle(m_RpcPadC);
if (padHandle.isPresent())
return StatusCode::SUCCESS;
auto pad = std::make_unique<RpcPadContainer> (padMaxIndex);
SG::WriteHandle<RpcSectorLogicContainer> logicHandle(m_sec);
auto logic = std::make_unique<RpcSectorLogicContainer>();
for (ROBFragmentList::const_iterator itFrag = vecRobs.begin(); itFrag != vecRobs.end(); itFrag++)
SG::WriteHandle<RpcPadContainer> rdoContainerHandle(m_containerKey);
if (rdoContainerHandle.isPresent())
return StatusCode::SUCCESS;
// Split the methods to have one where we use the cache and one where we just setup the container
const bool externalCacheRDO = !m_rdoContainerCacheKey.key().empty();
if(!externalCacheRDO){
ATH_CHECK( rdoContainerHandle.record(std::make_unique<RpcPadContainer> (padMaxIndex) ) );
ATH_MSG_DEBUG( "Created RpcPadContainer" );
}
else{
SG::UpdateHandle<RpcPad_Cache> update(m_rdoContainerCacheKey);
ATH_CHECK(update.isValid());
ATH_CHECK(rdoContainerHandle.record (std::make_unique<RpcPadContainer>( update.ptr() )));
ATH_MSG_DEBUG("Created container using cache for " << m_rdoContainerCacheKey.key());
}
RpcPadContainer* pad = rdoContainerHandle.ptr();
SG::WriteHandle<RpcSectorLogicContainer> logicHandle(m_sec);
auto logic = std::make_unique<RpcSectorLogicContainer>();
// Reset to a nullptr (logic.get() will pass this through to decoder)
if(!m_WriteOutRpcSectorLogic) logic.reset();
for (ROBFragmentList::const_iterator itFrag = vecRobs.begin(); itFrag != vecRobs.end(); itFrag++)
{
//convert only if data payload is delivered
if ( (**itFrag).rod_ndata()!=0 )
{
//convert only if data payload is delivered
if ( (**itFrag).rod_ndata()!=0 )
{
std::vector<IdentifierHash> coll =
to_be_converted(**itFrag,collections);
if (m_decoder->fillCollections(**itFrag, *pad, coll, logic.get()).isFailure())
{
// store the error conditions into the StatusCode and continue
}
}
else
{
if(msgLvl(MSG::DEBUG))
{
uint32_t sourceId= (**itFrag).source_id();
msg(MSG::DEBUG) << " ROB " << MSG::hex << sourceId
std::vector<IdentifierHash> coll = to_be_converted(**itFrag,collections);
if (m_decoder->fillCollections(**itFrag, *pad, coll, logic.get()).isFailure())
{
// store the error conditions into the StatusCode and continue
}
}
else
{
if(msgLvl(MSG::DEBUG))
{
uint32_t sourceId= (**itFrag).source_id();
msg(MSG::DEBUG) << " ROB " << MSG::hex << sourceId
<< " is delivered with an empty payload" << MSG::dec
<< endmsg;
}
// store the error condition into the StatusCode and continue
}
}
// store the error condition into the StatusCode and continue
}
ATH_CHECK( padHandle.record (std::move (pad)) );
}
ATH_MSG_DEBUG("After processing, number of collections in container : " << pad-> numberOfCollections() );
// Only write out the RpcSectorLogigContainer if we activate the flag
if(m_WriteOutRpcSectorLogic){
ATH_MSG_DEBUG("Writing out RpcSectorLogicContainer");
ATH_CHECK( logicHandle.record (std::move (logic)) );
//in presence of errors return FAILURE
//CALLGRIND_STOP_INSTRUMENTATION
return StatusCode::SUCCESS;
}
//in presence of errors return FAILURE
//CALLGRIND_STOP_INSTRUMENTATION
return StatusCode::SUCCESS;
}
......
......@@ -9,6 +9,7 @@
#include "GaudiKernel/ToolHandle.h"
#include "MuonCnvToolInterfaces/IMuonRawDataProviderTool.h"
#include "MuonRDO/RpcPadContainer.h"
#include "MuonRDO/RpcPad_Cache.h"
#include "MuonRDO/RpcSectorLogicContainer.h"
class StoreGateSvc;
......@@ -54,7 +55,7 @@ private:
// ServiceHandle<StoreGateSvc> m_eventStore;
ToolHandle<IRpcROD_Decoder> m_decoder;
// std::string m_rdoContainerKey;
SG::WriteHandleKey<RpcPadContainer> m_RpcPadC {
SG::WriteHandleKey<RpcPadContainer> m_containerKey {
this, "RdoLocation", "RPCPAD", "Name of the RPCPAD produced by RawDataProvider"};
SG::WriteHandleKey<RpcSectorLogicContainer> m_sec{
this, "RPCSec", "RPC_SECTORLOGIC", "Name of the RPC_SECTORLOGIC produced by RawDataProvider"};
......@@ -68,6 +69,12 @@ private:
const IRPCcablingSvc *m_rpcCabling;
// Rob Data Provider handle
ServiceHandle<IROBDataProviderSvc> m_robDataProvider;
/// RPC container cache key
SG::UpdateHandleKey<RpcPad_Cache> m_rdoContainerCacheKey ;
/// Turn on/off RpcSectorConfig writing
bool m_WriteOutRpcSectorLogic;
};
......
......@@ -38,7 +38,7 @@ Muon::RpcROD_Decoder::RpcROD_Decoder ( const std::string& type, const std::strin
m_decodeSL(false),
//m_byteStreamErrSvc("RPC_ByteStreamErrorSvc",name),
m_cabling(0),
m_pRpcIdHelper(0) //,m_bench("RpcROD_Decoder")
m_pRpcIdHelper(0) //,m_bench("RpcROD_Decoder"),
{
declareInterface< IRpcROD_Decoder >( this );
declareProperty("SpecialROBNumber",m_specialROBNumber=-1);
......@@ -54,58 +54,49 @@ Muon::RpcROD_Decoder::~RpcROD_Decoder() {
}
StatusCode Muon::RpcROD_Decoder::initialize() {
ServiceHandle<IRPCcablingServerSvc> rpc_server("RPCcablingServerSvc", name());
if (rpc_server.retrieve().isFailure()) {
msg(MSG::FATAL) << " Can't get RPCcablingServerSvc " << endmsg;
return StatusCode::FAILURE;
}
ATH_MSG_FATAL("Can't get RPCcablingServerSvc" );
return StatusCode::FAILURE;
}
if (StatusCode::SUCCESS != rpc_server->giveCabling(m_cabling)) {
msg(MSG::FATAL) << " Can't get RPCcablingSvc from Server" << endmsg;
return StatusCode::FAILURE;
}
if (StatusCode::SUCCESS != rpc_server->giveCabling(m_cabling)) {
ATH_MSG_FATAL("Can't get RPCcablingSvc from Server");
return StatusCode::FAILURE;
}
StatusCode status=StatusCode::SUCCESS;
StatusCode status=StatusCode::SUCCESS;
// Get the RPC id helper from the detector store
status = detStore()->retrieve(m_pRpcIdHelper, "RPCIDHELPER");
if (status.isFailure()) {
msg(MSG::FATAL) << "Could not get RpcIdHelper !" << endmsg;
return StatusCode::FAILURE;
}
else {
msg(MSG::VERBOSE) << " Found the RpcIdHelper. " << endmsg;
}
//m_hashfunc = new RpcPadIdHash();
if (m_specialROBNumber>0) {
msg(MSG::DEBUG) << "Setting the special ROB Number to: 0x" << MSG::hex << m_specialROBNumber
<< MSG::dec <<endmsg;
}
//==LBTAG initialize vector and variables for format failure check
for(int i=0; i<13; i++) m_RPCcheckfail[i]=0;
m_previous=0;
m_printerror=0;
return StatusCode::SUCCESS;
status = detStore()->retrieve(m_pRpcIdHelper, "RPCIDHELPER");
if (status.isFailure()) {
ATH_MSG_FATAL("Could not get RpcIdHelper !");
return StatusCode::FAILURE;
}
else {
ATH_MSG_VERBOSE("Found the RpcIdHelper.");
}
if (m_specialROBNumber>0) {
ATH_MSG_DEBUG("Setting the special ROB Number to: 0x" << MSG::hex << m_specialROBNumber << MSG::dec );
}
//==LBTAG initialize vector and variables for format failure check
for(int i=0; i<13; i++) m_RPCcheckfail[i]=0;
m_previous=0;
m_printerror=0;
return StatusCode::SUCCESS;
}
StatusCode Muon::RpcROD_Decoder::finalize() {
//if(m_hashfunc) delete m_hashfunc;
//==LBTAG print format failure final statistics
printcheckformat();
return StatusCode::SUCCESS;
return StatusCode::SUCCESS;
}
......
......@@ -23,6 +23,10 @@ StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302(BS data, const uint
RpcSectorLogicContainer* sectorLogicContainer ) const
{
bool skipSectorLogicDecoding = (sectorLogicContainer == nullptr);
if(skipSectorLogicDecoding)
ATH_MSG_DEBUG("Skip SectorLogic decoding, so SLROC.decodeFragment is not being processed");
/* for (unsigned int i = 0; i<1000; ++i) { */
/* //std::cout<<" aaa "<<std::endl; */
/* msg(MSG::VERBOSE) << "try to increase cpu time "<<log(pow(((double)i+1.)/999.,3))<<endmsg; */
......@@ -229,7 +233,9 @@ StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302(BS data, const uint
RXROS.decodeFragment(currentWord,recFieldROS);
PDROS.decodeFragment(currentWord,recFieldPAD);
SLROS.decodeFragment(currentWord,recFieldSL);
if(!skipSectorLogicDecoding){
SLROS.decodeFragment(currentWord,recFieldSL);
}
if (RXROS.isHeader()) {
isRXHeader=true;
......@@ -256,7 +262,26 @@ StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302(BS data, const uint
} else if (SLROS.isSubHeader() && isSLFragment) {
isSLSubHeader=true;
}
// The SLROS functions still return values (based on default values)
if(skipSectorLogicDecoding){
isSLHeader = false;
isSLSubHeader = false;
isSLFragment = false;
isSLFooter = false;
}
ATH_MSG_VERBOSE("\n isRXHeader " << isRXHeader <<
"\n isRXFooter " << isRXFooter <<
"\n isPadHeader " << isPadHeader <<
"\n isPadSubHeader " << isPadSubHeader <<
"\n isPADFragment " << isPADFragment <<
"\n isPadPreFooter " << isPadPreFooter <<
"\n isPadFooter " << isPadFooter <<
"\n isSLHeader " << isSLHeader <<
"\n isSLSubHeader " << isSLSubHeader <<
"\n isSLFragment " << isSLFragment <<
"\n isSLFooter " << isSLFooter );
......@@ -297,27 +322,26 @@ StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302(BS data, const uint
//we must start with an RX Header:
if (i==0 && (!isRXHeader))
{
ATH_MSG_WARNING("Bad data from RPC ROD 0x" << MSG::hex << rodId << MSG::dec
<< ". RX header not found at ROB fragment begin. Skipping this ROB fragment.");
return StatusCode::SUCCESS; //continue decoding data from other ROBs
//bsErrCheck_errorInRXHeader = true;
}
{
ATH_MSG_WARNING("Bad data from RPC ROD 0x" << MSG::hex << rodId << MSG::dec
<< ". RX header not found at ROB fragment begin. Skipping this ROB fragment.");
return StatusCode::SUCCESS; //continue decoding data from other ROBs
//bsErrCheck_errorInRXHeader = true;
}
if(isRXHeader) {
//bsErrCheck_errorInRXHeader = false;
//bsErrCheck_InRX = true;
// bsErrCheck_InSL = false;
// bsErrCheck_InPD = false;
// bsErrCheck_InCM = false;
//bsErrCheck_errorInRXHeader = false;
//bsErrCheck_InRX = true;
// bsErrCheck_InSL = false;
// bsErrCheck_InPD = false;
// bsErrCheck_InCM = false;
if (msgLvl(MSG::VERBOSE) )
{
msg(MSG::VERBOSE) << " this is a RX Header " << endmsg;
msg(MSG::VERBOSE) <<" Sector ID=" <<RXROS.RXid()<<endmsg;
}
if (msgLvl(MSG::VERBOSE) ){
msg(MSG::VERBOSE) << " this is a RX Header " << endmsg;
msg(MSG::VERBOSE) << " Sector ID=" <<RXROS.RXid()<<endmsg;
}
// get the sector id according to the new format
// not yet implemented in the readout classes
......@@ -327,7 +351,7 @@ StatusCode Muon::RpcROD_Decoder::fillCollectionsFromRob_v302(BS data, const uint
uint16_t rxid = RXROS.RXid(); // range (presumably) 0-1
sectorForCabling = 2*rodId+rxid; // range 0-31
sector = side*32+sectorForCabling; // range 0-63 //side = 1 for side A or 0 for side C // side 1 corresponds to subDetID=65 (side 0 for subDetID=66)
if (msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "RXid, sectorForCabling, sector = "<<rxid<<" "<<sectorForCabling<<" "<<sector<<std::endl;
if (msgLvl(MSG::VERBOSE) ) msg(MSG::VERBOSE) << "RXid, sectorForCabling, sector = "<<rxid<<" "<<sectorForCabling<<" "<<sector<<std::endl;
//fix for M3
if ((rodId==3 || rodId==1) && (m_specialROBNumber > 0) ) {
......
......@@ -55,6 +55,11 @@ def RpcBytestreamDecodeCfg(flags, forTrigger=False):
from MuonRPC_CnvTools.MuonRPC_CnvToolsConf import Muon__RPC_RawDataProviderTool
MuonRpcRawDataProviderTool = Muon__RPC_RawDataProviderTool(name = "RPC_RawDataProviderTool",
Decoder = RPCRodDecoder )
if forTrigger:
MuonRpcRawDataProviderTool.RpcContainerCacheKey = MuonCacheNames.RpcCache
MuonRpcRawDataProviderTool.WriteOutRpcSectorLogic = False
MuonRpcRawDataProviderTool.OutputLevel = DEBUG
acc.addPublicTool( MuonRpcRawDataProviderTool ) # This should be removed, but now defined as PublicTool at MuFastSteering
# Setup the RAW data provider algorithm
......@@ -67,6 +72,7 @@ def RpcBytestreamDecodeCfg(flags, forTrigger=False):
RpcRawDataProvider.DoSeededDecoding = True
RpcRawDataProvider.RoIs = "MURoIs" # Maybe we don't want to hard code this?
return acc, RpcRawDataProvider
def TgcBytestreamDecodeCfg(flags, forTrigger=False):
......@@ -118,7 +124,7 @@ def MdtBytestreamDecodeCfg(flags, forTrigger=False):
# Setup the MDT ROD decoder
from MuonMDT_CnvTools.MuonMDT_CnvToolsConf import MdtROD_Decoder
MDTRodDecoder = MdtROD_Decoder(name = "MdtROD_Decoder" )
MDTRodDecoder = MdtROD_Decoder(name = "MdtROD_Decoder")
# RAW data provider tool needs ROB data provider service (should be another Config function?)
from ByteStreamCnvSvcBase.ByteStreamCnvSvcBaseConf import ROBDataProviderSvc
......@@ -129,6 +135,7 @@ def MdtBytestreamDecodeCfg(flags, forTrigger=False):
from MuonMDT_CnvTools.MuonMDT_CnvToolsConf import Muon__MDT_RawDataProviderTool
MuonMdtRawDataProviderTool = Muon__MDT_RawDataProviderTool(name = "MDT_RawDataProviderTool",
Decoder = MDTRodDecoder)
if forTrigger:
# tell the raw data provider tool to use the cache
MuonMdtRawDataProviderTool.CsmContainerCacheKey = MuonCacheNames.MdtCsmCache
......@@ -197,7 +204,7 @@ if __name__=="__main__":
ConfigFlags.lock()
ConfigFlags.dump()
from AthenaCommon.Logging import log
from AthenaCommon.Logging import log
log.setLevel(DEBUG)
log.info('About to setup Rpc Raw data decoding')
......@@ -219,12 +226,12 @@ if __name__=="__main__":
cfg.addEventAlgo( tgcdecodingAlg )
# Schedule Mdt data decoding - once mergeAll is working can simplify these lines
mdtdecodingAcc, mdtdecodingAlg = MdtBytestreamDecodeCfg( ConfigFlags , True)
mdtdecodingAcc, mdtdecodingAlg = MdtBytestreamDecodeCfg( ConfigFlags )
cfg.merge( mdtdecodingAcc )
cfg.addEventAlgo( mdtdecodingAlg )
# Schedule Csc data decoding - once mergeAll is working can simplify these lines
cscdecodingAcc, cscdecodingAlg = CscBytestreamDecodeCfg( ConfigFlags , True)
cscdecodingAcc, cscdecodingAlg = CscBytestreamDecodeCfg( ConfigFlags )
cfg.merge( cscdecodingAcc )
cfg.addEventAlgo( cscdecodingAlg )
......
......@@ -167,10 +167,9 @@ def muonRdoDecodeTestData( forTrigger = False ):
log.setLevel(DEBUG)
log.info('About to setup Rpc Raw data decoding')
cfg=ComponentAccumulator()
# Seem to need this to read BS properly
from ByteStreamCnvSvc.ByteStreamConfig import TrigBSReadCfg
cfg.merge(TrigBSReadCfg(ConfigFlags ))
......@@ -182,7 +181,11 @@ def muonRdoDecodeTestData( forTrigger = False ):
# Schedule Rpc bytestream data decoding - once mergeAll is working can simplify these lines
from MuonConfig.MuonBytestreamDecodeConfig import RpcBytestreamDecodeCfg
rpcdecodingAcc, rpcdecodingAlg = RpcBytestreamDecodeCfg( ConfigFlags )
rpcdecodingAcc, rpcdecodingAlg = RpcBytestreamDecodeCfg( ConfigFlags, forTrigger )
# Put into a verbose logging mode to check the caching
if forTrigger:
rpcdecodingAlg.ProviderTool.OutputLevel = DEBUG
cfg.merge( rpcdecodingAcc )
cfg.addEventAlgo( rpcdecodingAlg )
......@@ -229,7 +232,6 @@ def muonRdoDecodeTestData( forTrigger = False ):
cfg.merge(cscbuildingAcc)
cfg.addEventAlgo(cscbuildingAlg)
# Need to add POOL converter - may be a better way of doing this?
from AthenaCommon import CfgMgr
cfg.addService( CfgMgr.AthenaPoolCnvSvc() )
......
This diff is collapsed.
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