diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx index 26e0d84203624ed855529bf71f5c3e61e89ec13c..73bcb78f9632e6c3485a27ef207ddcb552a9043e 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.cxx @@ -141,9 +141,8 @@ StatusCode CpByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CPMTower>* const ttCollection) { - m_ttCollection = ttCollection; - m_ttMap.clear(); - return convertBs(robFrags, CPM_TOWERS); + CpmTowerData data (ttCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CPM hits @@ -152,9 +151,8 @@ StatusCode CpByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CPMHits>* const hitCollection) { - m_hitCollection = hitCollection; - m_hitsMap.clear(); - return convertBs(robFrags, CPM_HITS); + CpmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM-CP hits @@ -163,9 +161,8 @@ StatusCode CpByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMCPHits>* const hitCollection) { - m_cmmHitCollection = hitCollection; - m_cmmHitsMap.clear(); - return convertBs(robFrags, CMM_CP_HITS); + CmmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion of CP container to bytestream @@ -471,7 +468,7 @@ const std::vector<uint32_t>& CpByteStreamTool::sourceIDs( StatusCode CpByteStreamTool::convertBs( const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -599,8 +596,8 @@ StatusCode CpByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_CP_HITS) { - decodeCmmCp(m_cmmCpSubBlock, trigCmm); + if (data.m_collection == CMM_CP_HITS) { + decodeCmmCp(m_cmmCpSubBlock, trigCmm, static_cast<CmmHitsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmCp failed" << endmsg; break; @@ -622,8 +619,8 @@ StatusCode CpByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CPM_TOWERS || collection == CPM_HITS) { - decodeCpm(m_cpmSubBlock, trigCpm, collection); + if (data.m_collection == CPM_TOWERS || data.m_collection == CPM_HITS) { + decodeCpm(m_cpmSubBlock, trigCpm, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCpm failed" << endmsg; break; @@ -640,7 +637,8 @@ StatusCode CpByteStreamTool::convertBs( // Unpack CMM-CP sub-block -void CpByteStreamTool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) +void CpByteStreamTool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm, + CmmHitsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -727,7 +725,7 @@ void CpByteStreamTool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) errorBits.set(LVL1::DataError::SubStatusWord, subStatus); err = errorBits.error(); if (hits || err) { - LVL1::CMMCPHits* ch = findCmmCpHits(crate, dataID); + LVL1::CMMCPHits* ch = findCmmCpHits(data, crate, dataID); if ( ! ch ) { // create new CMM hits m_hitsVec0.assign(timeslices, 0); m_hitsVec1.assign(timeslices, 0); @@ -740,11 +738,12 @@ void CpByteStreamTool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) m_hitsVec1[slice] = hits; m_errVec1[slice] = err; } - ch = new LVL1::CMMCPHits(swCrate, dataID, m_hitsVec0, m_hitsVec1, - m_errVec0, m_errVec1, trigCmm); + auto chp = + std::make_unique<LVL1::CMMCPHits>(swCrate, dataID, m_hitsVec0, m_hitsVec1, + m_errVec0, m_errVec1, trigCmm); const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, ch)); - m_cmmHitCollection->push_back(ch); + data.m_cmmHitsMap.insert(std::make_pair(key, chp.get())); + data.m_cmmHitCollection->push_back(std::move(chp)); } else { m_hitsVec0 = ch->HitsVec0(); m_hitsVec1 = ch->HitsVec1(); @@ -783,7 +782,7 @@ void CpByteStreamTool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) // Unpack CPM sub-block void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, - int trigCpm, const CollectionType collection) + int trigCpm, CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -839,7 +838,8 @@ void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1; for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == CPM_TOWERS) { + if (data.m_collection == CPM_TOWERS) { + CpmTowerData& tdata = static_cast<CpmTowerData&> (data); // Loop over tower channels and fill CPM towers @@ -870,7 +870,7 @@ void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) { if (layer == m_coreOverlap) { const unsigned int key = m_towerKey->ttKey(phi, eta); - LVL1::CPMTower* tt = findCpmTower(key); + LVL1::CPMTower* tt = findCpmTower(tdata, key); if ( ! tt ) { // create new CPM tower m_emVec.assign(timeslices, 0); m_hadVec.assign(timeslices, 0); @@ -880,10 +880,11 @@ void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, m_hadVec[slice] = had; m_emErrVec[slice] = emErr1; m_hadErrVec[slice] = hadErr1; - tt = new LVL1::CPMTower(phi, eta, m_emVec, m_emErrVec, - m_hadVec, m_hadErrVec, trigCpm); - m_ttMap.insert(std::make_pair(key, tt)); - m_ttCollection->push_back(tt); + auto ttp = + std::make_unique<LVL1::CPMTower>(phi, eta, m_emVec, m_emErrVec, + m_hadVec, m_hadErrVec, trigCpm); + tdata.m_ttMap.insert(std::make_pair(key, ttp.get())); + tdata.m_ttCollection->push_back(std::move(ttp)); } else { m_emVec = tt->emEnergyVec(); m_hadVec = tt->hadEnergyVec(); @@ -923,22 +924,24 @@ void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, msg(MSG::DEBUG); } } - } else if (collection == CPM_HITS) { + } else if (data.m_collection == CPM_HITS) { + CpmHitsData& hdata = static_cast<CpmHitsData&> (data); // Get CPM hits const unsigned int hits0 = subBlock->hits0(slice); const unsigned int hits1 = subBlock->hits1(slice); if (hits0 || hits1) { - LVL1::CPMHits* ch = findCpmHits(crate, module); + LVL1::CPMHits* ch = findCpmHits(hdata, crate, module); if ( ! ch ) { // create new CPM hits m_hitsVec0.assign(timeslices, 0); m_hitsVec1.assign(timeslices, 0); m_hitsVec0[slice] = hits0; m_hitsVec1[slice] = hits1; - ch = new LVL1::CPMHits(swCrate, module, m_hitsVec0, m_hitsVec1, trigCpm); - m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, ch)); - m_hitCollection->push_back(ch); + auto chp = + std::make_unique<LVL1::CPMHits>(swCrate, module, m_hitsVec0, m_hitsVec1, trigCpm); + hdata.m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, chp.get())); + hdata.m_hitCollection->push_back(std::move(chp)); } else { m_hitsVec0 = ch->HitsVec0(); m_hitsVec1 = ch->HitsVec1(); @@ -971,36 +974,60 @@ void CpByteStreamTool::decodeCpm(CpmSubBlock* subBlock, // Find a CPM tower for given key -LVL1::CPMTower* CpByteStreamTool::findCpmTower(const unsigned int key) +const +LVL1::CPMTower* CpByteStreamTool::findCpmTower(const unsigned int key) const +{ + ConstCpmTowerMap::const_iterator mapIter = m_ttMap.find(key); + if (mapIter != m_ttMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CPMTower* CpByteStreamTool::findCpmTower(const CpmTowerData& data, + const unsigned int key) const { - LVL1::CPMTower* tt = 0; - CpmTowerMap::const_iterator mapIter; - mapIter = m_ttMap.find(key); - if (mapIter != m_ttMap.end()) tt = mapIter->second; - return tt; + CpmTowerMap::const_iterator mapIter = data.m_ttMap.find(key); + if (mapIter != data.m_ttMap.end()) return mapIter->second; + return nullptr; } // Find CPM hits for given crate, module -LVL1::CPMHits* CpByteStreamTool::findCpmHits(const int crate, const int module) +const +LVL1::CPMHits* CpByteStreamTool::findCpmHits(const int crate, const int module) const { - LVL1::CPMHits* hits = 0; - CpmHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate*m_modules + module - 1); - if (mapIter != m_hitsMap.end()) hits = mapIter->second; - return hits; + ConstCpmHitsMap::const_iterator mapIter = + m_hitsMap.find(crate*m_modules + module - 1); + if (mapIter != m_hitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CPMHits* CpByteStreamTool::findCpmHits(const CpmHitsData& data, + const int crate, const int module) const +{ + CpmHitsMap::const_iterator mapIter = + data.m_hitsMap.find(crate*m_modules + module - 1); + if (mapIter != data.m_hitsMap.end()) return mapIter->second; + return nullptr; } // Find CMM-CP hits for given crate, dataID +const LVL1::CMMCPHits* CpByteStreamTool::findCmmCpHits(const int crate, - const int dataID) + const int dataID) const +{ + ConstCmmCpHitsMap::const_iterator mapIter = m_cmmHitsMap.find(crate*100 + dataID); + if (mapIter != m_cmmHitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMCPHits* CpByteStreamTool::findCmmCpHits(const CmmHitsData& data, + const int crate, + const int dataID) const { - LVL1::CMMCPHits* hits = 0; - CmmCpHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); - if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; - return hits; + CmmCpHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate*100 + dataID); + if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second; + return nullptr; } // Set up CPM tower map @@ -1013,7 +1040,7 @@ void CpByteStreamTool::setupCpmTowerMap(const CpmTowerCollection* CpmTowerCollection::const_iterator pos = ttCollection->begin(); CpmTowerCollection::const_iterator pose = ttCollection->end(); for (; pos != pose; ++pos) { - LVL1::CPMTower* const tt = *pos; + const LVL1::CPMTower* const tt = *pos; const unsigned int key = m_towerKey->ttKey(tt->phi(), tt->eta()); m_ttMap.insert(std::make_pair(key, tt)); } @@ -1030,7 +1057,7 @@ void CpByteStreamTool::setupCpmHitsMap(const CpmHitsCollection* CpmHitsCollection::const_iterator pos = hitCollection->begin(); CpmHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CPMHits* const hits = *pos; + const LVL1::CPMHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = m_modules * crate + hits->module() - 1; m_hitsMap.insert(std::make_pair(key, hits)); @@ -1048,7 +1075,7 @@ void CpByteStreamTool::setupCmmCpHitsMap(const CmmCpHitsCollection* CmmCpHitsCollection::const_iterator pos = hitCollection->begin(); CmmCpHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMCPHits* const hits = *pos; + const LVL1::CMMCPHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = crate*100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.h index 11ce0ad1b9d4e94b181f7ff0d2767b0463990e51..7d1d1b9a5ab520d2ba3e508be40ac022b7ac3f64 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamTool.h @@ -85,26 +85,61 @@ class CpByteStreamTool : public AthAlgTool { typedef DataVector<LVL1::CPMHits> CpmHitsCollection; typedef DataVector<LVL1::CMMCPHits> CmmCpHitsCollection; typedef std::map<unsigned int, LVL1::CPMTower*> CpmTowerMap; + typedef std::map<unsigned int, const LVL1::CPMTower*> ConstCpmTowerMap; typedef std::map<int, LVL1::CPMHits*> CpmHitsMap; + typedef std::map<int, const LVL1::CPMHits*> ConstCpmHitsMap; typedef std::map<int, LVL1::CMMCPHits*> CmmCpHitsMap; + typedef std::map<int, const LVL1::CMMCPHits*> ConstCmmCpHitsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct CpByteStreamToolData + { + CpByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct CpmTowerData : public CpByteStreamToolData + { + CpmTowerData (CpmTowerCollection* const ttCollection) + : CpByteStreamToolData (CPM_TOWERS), m_ttCollection (ttCollection) {} + CpmTowerCollection* const m_ttCollection; + CpmTowerMap m_ttMap; + }; + struct CpmHitsData : public CpByteStreamToolData + { + CpmHitsData (CpmHitsCollection* const hitCollection) + : CpByteStreamToolData (CPM_HITS), m_hitCollection (hitCollection) {} + CpmHitsCollection* const m_hitCollection; + CpmHitsMap m_hitsMap; + }; + struct CmmHitsData : public CpByteStreamToolData + { + CmmHitsData (CmmCpHitsCollection* const hitCollection) + : CpByteStreamToolData (CMM_CP_HITS), m_cmmHitCollection (hitCollection) {} + CmmCpHitsCollection* const m_cmmHitCollection; + CmmCpHitsMap m_cmmHitsMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + CpByteStreamToolData& data); /// Unpack CMM-CP sub-block - void decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm); + void decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm, CmmHitsData& data); /// Unpack CPM sub-block - void decodeCpm(CpmSubBlock* subBlock, int trigCpm, CollectionType collection); + void decodeCpm(CpmSubBlock* subBlock, int trigCpm, CpByteStreamToolData& data); /// Find a CPM tower for given key - LVL1::CPMTower* findCpmTower(unsigned int key); + const LVL1::CPMTower* findCpmTower(unsigned int key) const; + LVL1::CPMTower* findCpmTower(const CpmTowerData& data, unsigned int key) const; /// Find CPM hits for given crate, module - LVL1::CPMHits* findCpmHits(int crate, int module); + const LVL1::CPMHits* findCpmHits(int crate, int module) const; + LVL1::CPMHits* findCpmHits(const CpmHitsData& data, int crate, int module) const; /// Find CMM-CP hits for given crate, data ID - LVL1::CMMCPHits* findCmmCpHits(int crate, int dataID); + const LVL1::CMMCPHits* findCmmCpHits(int crate, int dataID) const; + LVL1::CMMCPHits* findCmmCpHits(const CmmHitsData& data, + int crate, int dataID) const; /// Set up CPM tower map void setupCpmTowerMap(const CpmTowerCollection* ttCollection); @@ -180,18 +215,12 @@ class CpByteStreamTool : public AthAlgTool { DataVector<CmmCpSubBlock> m_cmmHit0Blocks; /// Vector for current CMM-CP hit1 sub-blocks DataVector<CmmCpSubBlock> m_cmmHit1Blocks; - /// Current CPM tower collection - CpmTowerCollection* m_ttCollection; - /// Current CPM hits collection - CpmHitsCollection* m_hitCollection; - /// Current CMM-CP hits collection - CmmCpHitsCollection* m_cmmHitCollection; /// CPM tower map - CpmTowerMap m_ttMap; + ConstCpmTowerMap m_ttMap; /// CPM hits map - CpmHitsMap m_hitsMap; + ConstCpmHitsMap m_hitsMap; /// CMM-CP hits map - CmmCpHitsMap m_cmmHitsMap; + ConstCmmCpHitsMap m_cmmHitsMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx index fba80862490c6c1797c9319f08a7f7719f137578..12284575cb32476c6c94a350c2a4af72fbe1cd1e 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.cxx @@ -147,9 +147,8 @@ StatusCode CpByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CPMTower>* const ttCollection) { - m_ttCollection = ttCollection; - m_ttMap.clear(); - return convertBs(robFrags, CPM_TOWERS); + CpmTowerData data (ttCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CPM hits @@ -158,9 +157,8 @@ StatusCode CpByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CPMHits>* const hitCollection) { - m_hitCollection = hitCollection; - m_hitsMap.clear(); - return convertBs(robFrags, CPM_HITS); + CpmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM-CP hits @@ -169,9 +167,8 @@ StatusCode CpByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMCPHits>* const hitCollection) { - m_cmmHitCollection = hitCollection; - m_cmmHitsMap.clear(); - return convertBs(robFrags, CMM_CP_HITS); + CmmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion of CP container to bytestream @@ -477,7 +474,7 @@ const std::vector<uint32_t>& CpByteStreamV1Tool::sourceIDs( StatusCode CpByteStreamV1Tool::convertBs( const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -615,8 +612,8 @@ StatusCode CpByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_CP_HITS) { - decodeCmmCp(m_cmmCpSubBlock, trigCmm); + if (data.m_collection == CMM_CP_HITS) { + decodeCmmCp(m_cmmCpSubBlock, trigCmm, static_cast<CmmHitsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmCp failed" << endmsg; break; @@ -637,8 +634,8 @@ StatusCode CpByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CPM_TOWERS || collection == CPM_HITS) { - decodeCpm(m_cpmSubBlock, trigCpm, collection); + if (data.m_collection == CPM_TOWERS || data.m_collection == CPM_HITS) { + decodeCpm(m_cpmSubBlock, trigCpm, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCpm failed" << endmsg; break; @@ -655,7 +652,8 @@ StatusCode CpByteStreamV1Tool::convertBs( // Unpack CMM-CP sub-block -void CpByteStreamV1Tool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) +void CpByteStreamV1Tool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm, + CmmHitsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -742,7 +740,7 @@ void CpByteStreamV1Tool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) errorBits.set(LVL1::DataError::SubStatusWord, subStatus); err = errorBits.error(); if (hits || err) { - LVL1::CMMCPHits* ch = findCmmCpHits(crate, dataID); + LVL1::CMMCPHits* ch = findCmmCpHits(data, crate, dataID); if ( ! ch ) { // create new CMM hits m_hitsVec0.assign(timeslices, 0); m_hitsVec1.assign(timeslices, 0); @@ -755,11 +753,12 @@ void CpByteStreamV1Tool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) m_hitsVec1[slice] = hits; m_errVec1[slice] = err; } - ch = new LVL1::CMMCPHits(swCrate, dataID, m_hitsVec0, m_hitsVec1, - m_errVec0, m_errVec1, trigCmm); + auto chp = + std::make_unique<LVL1::CMMCPHits>(swCrate, dataID, m_hitsVec0, m_hitsVec1, + m_errVec0, m_errVec1, trigCmm); const int key = crate*100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, ch)); - m_cmmHitCollection->push_back(ch); + data.m_cmmHitsMap.insert(std::make_pair(key, chp.get())); + data.m_cmmHitCollection->push_back(std::move(ch)); } else { m_hitsVec0 = ch->HitsVec0(); m_hitsVec1 = ch->HitsVec1(); @@ -798,7 +797,7 @@ void CpByteStreamV1Tool::decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm) // Unpack CPM sub-block void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, - int trigCpm, const CollectionType collection) + int trigCpm, CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -854,7 +853,8 @@ void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1; for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == CPM_TOWERS) { + if (data.m_collection == CPM_TOWERS) { + CpmTowerData& tdata = static_cast<CpmTowerData&> (data); // Loop over tower channels and fill CPM towers @@ -885,7 +885,7 @@ void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, if (m_cpmMaps->mapping(crate, module, chan, eta, phi, layer)) { if (layer == m_coreOverlap) { const unsigned int key = m_towerKey->ttKey(phi, eta); - LVL1::CPMTower* tt = findCpmTower(key); + LVL1::CPMTower* tt = findCpmTower(tdata, key); if ( ! tt ) { // create new CPM tower m_emVec.assign(timeslices, 0); m_hadVec.assign(timeslices, 0); @@ -895,10 +895,11 @@ void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, m_hadVec[slice] = had; m_emErrVec[slice] = emErr1; m_hadErrVec[slice] = hadErr1; - tt = new LVL1::CPMTower(phi, eta, m_emVec, m_emErrVec, - m_hadVec, m_hadErrVec, trigCpm); - m_ttMap.insert(std::make_pair(key, tt)); - m_ttCollection->push_back(tt); + auto ttp = + std::make_unique<LVL1::CPMTower>(phi, eta, m_emVec, m_emErrVec, + m_hadVec, m_hadErrVec, trigCpm); + tdata.m_ttMap.insert(std::make_pair(key, ttp.get())); + tdata.m_ttCollection->push_back(std::move(tt)); } else { m_emVec = tt->emEnergyVec(); m_hadVec = tt->hadEnergyVec(); @@ -938,22 +939,24 @@ void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, msg(MSG::DEBUG); } } - } else if (collection == CPM_HITS) { + } else if (data.m_collection == CPM_HITS) { + CpmHitsData& hdata = static_cast<CpmHitsData&> (data); // Get CPM hits const unsigned int hits0 = subBlock->hits0(slice); const unsigned int hits1 = subBlock->hits1(slice); if (hits0 || hits1) { - LVL1::CPMHits* ch = findCpmHits(crate, module); + LVL1::CPMHits* ch = findCpmHits(hdata, crate, module); if ( ! ch ) { // create new CPM hits m_hitsVec0.assign(timeslices, 0); m_hitsVec1.assign(timeslices, 0); m_hitsVec0[slice] = hits0; m_hitsVec1[slice] = hits1; - ch = new LVL1::CPMHits(swCrate, module, m_hitsVec0, m_hitsVec1, trigCpm); - m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, ch)); - m_hitCollection->push_back(ch); + auto chp = + std::make_unique<LVL1::CPMHits>(swCrate, module, m_hitsVec0, m_hitsVec1, trigCpm); + hdata.m_hitsMap.insert(std::make_pair(crate*m_modules+module-1, chp.get())); + hdata.m_hitCollection->push_back(std::move(chp)); } else { m_hitsVec0 = ch->HitsVec0(); m_hitsVec1 = ch->HitsVec1(); @@ -986,36 +989,60 @@ void CpByteStreamV1Tool::decodeCpm(CpmSubBlockV1* subBlock, // Find a CPM tower for given key -LVL1::CPMTower* CpByteStreamV1Tool::findCpmTower(const unsigned int key) +const +LVL1::CPMTower* CpByteStreamV1Tool::findCpmTower(const unsigned int key) const +{ + ConstCpmTowerMap::const_iterator mapIter = m_ttMap.find(key); + if (mapIter != m_ttMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CPMTower* CpByteStreamV1Tool::findCpmTower(const CpmTowerData& data, + const unsigned int key) const { - LVL1::CPMTower* tt = 0; - CpmTowerMap::const_iterator mapIter; - mapIter = m_ttMap.find(key); - if (mapIter != m_ttMap.end()) tt = mapIter->second; - return tt; + CpmTowerMap::const_iterator mapIter = data.m_ttMap.find(key); + if (mapIter != data.m_ttMap.end()) return mapIter->second; + return nullptr; } // Find CPM hits for given crate, module -LVL1::CPMHits* CpByteStreamV1Tool::findCpmHits(const int crate, const int module) +const +LVL1::CPMHits* CpByteStreamV1Tool::findCpmHits(const int crate, const int module) const { - LVL1::CPMHits* hits = 0; - CpmHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate*m_modules + module - 1); - if (mapIter != m_hitsMap.end()) hits = mapIter->second; - return hits; + ConstCpmHitsMap::const_iterator mapIter = + m_hitsMap.find(crate*m_modules + module - 1); + if (mapIter != m_hitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CPMHits* CpByteStreamV1Tool::findCpmHits(const CpmHitsData& data, + const int crate, const int module) const +{ + CpmHitsMap::const_iterator mapIter = + data.m_hitsMap.find(crate*m_modules + module - 1); + if (mapIter != data.m_hitsMap.end()) return mapIter->second; + return nullptr; } // Find CMM-CP hits for given crate, dataID +const LVL1::CMMCPHits* CpByteStreamV1Tool::findCmmCpHits(const int crate, - const int dataID) + const int dataID) const +{ + ConstCmmCpHitsMap::const_iterator mapIter = m_cmmHitsMap.find(crate*100 + dataID); + if (mapIter != m_cmmHitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMCPHits* CpByteStreamV1Tool::findCmmCpHits(const CmmHitsData& data, + const int crate, + const int dataID) const { - LVL1::CMMCPHits* hits = 0; - CmmCpHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate*100 + dataID); - if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; - return hits; + CmmCpHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate*100 + dataID); + if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second; + return nullptr; } // Set up CPM tower map @@ -1028,7 +1055,7 @@ void CpByteStreamV1Tool::setupCpmTowerMap(const CpmTowerCollection* CpmTowerCollection::const_iterator pos = ttCollection->begin(); CpmTowerCollection::const_iterator pose = ttCollection->end(); for (; pos != pose; ++pos) { - LVL1::CPMTower* const tt = *pos; + const LVL1::CPMTower* const tt = *pos; const unsigned int key = m_towerKey->ttKey(tt->phi(), tt->eta()); m_ttMap.insert(std::make_pair(key, tt)); } @@ -1045,7 +1072,7 @@ void CpByteStreamV1Tool::setupCpmHitsMap(const CpmHitsCollection* CpmHitsCollection::const_iterator pos = hitCollection->begin(); CpmHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CPMHits* const hits = *pos; + const LVL1::CPMHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = m_modules * crate + hits->module() - 1; m_hitsMap.insert(std::make_pair(key, hits)); @@ -1063,7 +1090,7 @@ void CpByteStreamV1Tool::setupCmmCpHitsMap(const CmmCpHitsCollection* CmmCpHitsCollection::const_iterator pos = hitCollection->begin(); CmmCpHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMCPHits* const hits = *pos; + const LVL1::CMMCPHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = crate*100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.h index f1653634171e9808c66f199dcccfb2ce552232b6..905be01d1afbb1c345ab9938d98e34662ef0c58b 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV1Tool.h @@ -84,27 +84,62 @@ class CpByteStreamV1Tool : public AthAlgTool { typedef DataVector<LVL1::CPMTower> CpmTowerCollection; typedef DataVector<LVL1::CPMHits> CpmHitsCollection; typedef DataVector<LVL1::CMMCPHits> CmmCpHitsCollection; + typedef std::map<unsigned int, const LVL1::CPMTower*> ConstCpmTowerMap; typedef std::map<unsigned int, LVL1::CPMTower*> CpmTowerMap; + typedef std::map<int, const LVL1::CPMHits*> ConstCpmHitsMap; typedef std::map<int, LVL1::CPMHits*> CpmHitsMap; + typedef std::map<int, const LVL1::CMMCPHits*> ConstCmmCpHitsMap; typedef std::map<int, LVL1::CMMCPHits*> CmmCpHitsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct CpByteStreamToolData + { + CpByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct CpmTowerData : public CpByteStreamToolData + { + CpmTowerData (CpmTowerCollection* const ttCollection) + : CpByteStreamToolData (CPM_TOWERS), m_ttCollection (ttCollection) {} + CpmTowerCollection* const m_ttCollection; + CpmTowerMap m_ttMap; + }; + struct CpmHitsData : public CpByteStreamToolData + { + CpmHitsData (CpmHitsCollection* const hitCollection) + : CpByteStreamToolData (CPM_HITS), m_hitCollection (hitCollection) {} + CpmHitsCollection* const m_hitCollection; + CpmHitsMap m_hitsMap; + }; + struct CmmHitsData : public CpByteStreamToolData + { + CmmHitsData (CmmCpHitsCollection* const hitCollection) + : CpByteStreamToolData (CMM_CP_HITS), m_cmmHitCollection (hitCollection) {} + CmmCpHitsCollection* const m_cmmHitCollection; + CmmCpHitsMap m_cmmHitsMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + CpByteStreamToolData& data); /// Unpack CMM-CP sub-block - void decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm); + void decodeCmmCp(CmmCpSubBlock* subBlock, int trigCmm, CmmHitsData& data); /// Unpack CPM sub-block - void decodeCpm(CpmSubBlockV1* subBlock, int trigCpm, CollectionType collection); + void decodeCpm(CpmSubBlockV1* subBlock, int trigCpm, CpByteStreamToolData& data); /// Find a CPM tower for given key - LVL1::CPMTower* findCpmTower(unsigned int key); + const LVL1::CPMTower* findCpmTower(unsigned int key) const; + LVL1::CPMTower* findCpmTower(const CpmTowerData& data, unsigned int key) const; /// Find CPM hits for given crate, module - LVL1::CPMHits* findCpmHits(int crate, int module); + const LVL1::CPMHits* findCpmHits(int crate, int module) const; + LVL1::CPMHits* findCpmHits(const CpmHitsData& data, int crate, int module) const; /// Find CMM-CP hits for given crate, data ID - LVL1::CMMCPHits* findCmmCpHits(int crate, int dataID); + const LVL1::CMMCPHits* findCmmCpHits(int crate, int dataID) const; + LVL1::CMMCPHits* findCmmCpHits(const CmmHitsData& data, + int crate, int dataID) const; /// Set up CPM tower map void setupCpmTowerMap(const CpmTowerCollection* ttCollection); @@ -184,18 +219,12 @@ class CpByteStreamV1Tool : public AthAlgTool { DataVector<CmmCpSubBlock> m_cmmHit0Blocks; /// Vector for current CMM-CP hit1 sub-blocks DataVector<CmmCpSubBlock> m_cmmHit1Blocks; - /// Current CPM tower collection - CpmTowerCollection* m_ttCollection; - /// Current CPM hits collection - CpmHitsCollection* m_hitCollection; - /// Current CMM-CP hits collection - CmmCpHitsCollection* m_cmmHitCollection; /// CPM tower map - CpmTowerMap m_ttMap; + ConstCpmTowerMap m_ttMap; /// CPM hits map - CpmHitsMap m_hitsMap; + ConstCpmHitsMap m_hitsMap; /// CMM-CP hits map - CmmCpHitsMap m_cmmHitsMap; + ConstCmmCpHitsMap m_cmmHitsMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx index 637202d9ca80ad1b4d0c457975a91b6b2ae68285..aa146ebe7e0fa4649bbae00a8cc6ef0a7703ed73 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.cxx @@ -154,9 +154,8 @@ StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector<LVL1::CPMTower> *const ttCollection) { - m_ttCollection = ttCollection; - m_ttMap.clear(); - return convertBs(robFrags, CPM_TOWERS); + CpmTowerData data (ttCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMX-CP TOBs @@ -176,9 +175,8 @@ StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector<LVL1::CMXCPTob> *const tobCollection) { - m_tobCollection = tobCollection; - m_tobMap.clear(); - return convertBs(robFrags, CMX_CP_TOBS); + CmxCpTobData data (tobCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMX-CP hits @@ -198,9 +196,8 @@ StatusCode CpByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG &robFrags, DataVector<LVL1::CMXCPHits> *const hitCollection) { - m_hitCollection = hitCollection; - m_hitsMap.clear(); - return convertBs(robFrags, CMX_CP_HITS); + CmxCpHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion of CP container to bytestream @@ -532,7 +529,7 @@ const std::vector<uint32_t> &CpByteStreamV2Tool::sourceIDs( StatusCode CpByteStreamV2Tool::convertBs( const IROBDataProviderSvc::VROBFRAG &robFrags, - const CollectionType collection) + CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -681,9 +678,9 @@ StatusCode CpByteStreamV2Tool::convertBs( break; } - if (collection == CMX_CP_TOBS || collection == CMX_CP_HITS) + if (data.m_collection == CMX_CP_TOBS || data.m_collection == CMX_CP_HITS) { - decodeCmxCp(m_cmxCpSubBlock, trigCpm, collection); + decodeCmxCp(m_cmxCpSubBlock, trigCpm, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmxCp failed" << endmsg; @@ -710,9 +707,9 @@ StatusCode CpByteStreamV2Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CPM_TOWERS) + if (data.m_collection == CPM_TOWERS) { - decodeCpm(m_cpmSubBlock, trigCpm); + decodeCpm(m_cpmSubBlock, trigCpm, static_cast<CpmTowerData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCpm failed" << endmsg; @@ -732,7 +729,7 @@ StatusCode CpByteStreamV2Tool::convertBs( // Unpack CMX-CP sub-block void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, - CollectionType collection) + CpByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -794,8 +791,9 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == CMX_CP_TOBS) + if (data.m_collection == CMX_CP_TOBS) { + CmxCpTobData& tdata = static_cast<CmxCpTobData&> (data); // TOBs @@ -823,7 +821,7 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, } error = errBits.error(); const int key = tobKey(crate, cmx, cpm, chip, loc); - LVL1::CMXCPTob *tb = findCmxCpTob(key); + LVL1::CMXCPTob *tb = findCmxCpTob(tdata, key); if ( ! tb ) // create new CMX TOB { m_energyVec.assign(timeslices, 0); @@ -834,11 +832,12 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, m_isolVec[slice] = isolation; m_errorVec[slice] = error; m_presenceMapVec[slice] = presenceMap; - tb = new LVL1::CMXCPTob(swCrate, cmx, cpm, chip, loc, - m_energyVec, m_isolVec, m_errorVec, - m_presenceMapVec, trigCpm); - m_tobMap.insert(std::make_pair(key, tb)); - m_tobCollection->push_back(tb); + auto tbp = + std::make_unique<LVL1::CMXCPTob>(swCrate, cmx, cpm, chip, loc, + m_energyVec, m_isolVec, m_errorVec, + m_presenceMapVec, trigCpm); + tdata.m_tobMap.insert(std::make_pair(key, tbp.get())); + tdata.m_tobCollection->push_back(std::move(tbp)); } else { @@ -871,8 +870,9 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, } } - else if (collection == CMX_CP_HITS) + else if (data.m_collection == CMX_CP_HITS) { + CmxCpHitsData& hdata = static_cast<CmxCpHitsData&> (data); // Hit/Topo counts @@ -899,7 +899,7 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, if (hits0 || hits1 || err0 || err1) { const int key = hitsKey(crate, cmx, source); - LVL1::CMXCPHits *ch = findCmxCpHits(key); + LVL1::CMXCPHits *ch = findCmxCpHits(hdata, key); if ( ! ch ) // create new CMX hits { m_hitsVec0.assign(timeslices, 0); @@ -910,11 +910,12 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, m_hitsVec1[slice] = hits1; m_errVec0[slice] = err0; m_errVec1[slice] = err1; - ch = new LVL1::CMXCPHits(swCrate, cmx, source, - m_hitsVec0, m_hitsVec1, - m_errVec0, m_errVec1, trigCpm); - m_hitsMap.insert(std::make_pair(key, ch)); - m_hitCollection->push_back(ch); + auto chp = + std::make_unique<LVL1::CMXCPHits>(swCrate, cmx, source, + m_hitsVec0, m_hitsVec1, + m_errVec0, m_errVec1, trigCpm); + hdata.m_hitsMap.insert(std::make_pair(key, chp.get())); + hdata.m_hitCollection->push_back(std::move(chp)); } else { @@ -953,7 +954,8 @@ void CpByteStreamV2Tool::decodeCmxCp(CmxCpSubBlock *subBlock, int trigCpm, // Unpack CPM sub-block -void CpByteStreamV2Tool::decodeCpm(CpmSubBlockV2 *subBlock, int trigCpm) +void CpByteStreamV2Tool::decodeCpm(CpmSubBlockV2 *subBlock, int trigCpm, + CpmTowerData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1049,7 +1051,7 @@ void CpByteStreamV2Tool::decodeCpm(CpmSubBlockV2 *subBlock, int trigCpm) if (layer == m_coreOverlap) { const unsigned int key = m_towerKey->ttKey(phi, eta); - LVL1::CPMTower *tt = findCpmTower(key); + LVL1::CPMTower *tt = findCpmTower(data, key); if ( ! tt ) // create new CPM tower { m_emVec.assign(timeslices, 0); @@ -1060,10 +1062,11 @@ void CpByteStreamV2Tool::decodeCpm(CpmSubBlockV2 *subBlock, int trigCpm) m_hadVec[slice] = had; m_emErrVec[slice] = emErr1; m_hadErrVec[slice] = hadErr1; - tt = new LVL1::CPMTower(phi, eta, m_emVec, m_emErrVec, - m_hadVec, m_hadErrVec, trigCpm); - m_ttMap.insert(std::make_pair(key, tt)); - m_ttCollection->push_back(tt); + auto ttp = + std::make_unique<LVL1::CPMTower>(phi, eta, m_emVec, m_emErrVec, + m_hadVec, m_hadErrVec, trigCpm); + data.m_ttMap.insert(std::make_pair(key, ttp.get())); + data.m_ttCollection->push_back(std::move(ttp)); } else { @@ -1118,35 +1121,56 @@ void CpByteStreamV2Tool::decodeCpm(CpmSubBlockV2 *subBlock, int trigCpm) // Find a CPM tower for given key -LVL1::CPMTower *CpByteStreamV2Tool::findCpmTower(const unsigned int key) +const +LVL1::CPMTower *CpByteStreamV2Tool::findCpmTower(const unsigned int key) const +{ + ConstCpmTowerMap::const_iterator mapIter = m_ttMap.find(key); + if (mapIter != m_ttMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CPMTower *CpByteStreamV2Tool::findCpmTower(const CpmTowerData& data, + const unsigned int key) const { - LVL1::CPMTower *tt = 0; - CpmTowerMap::const_iterator mapIter; - mapIter = m_ttMap.find(key); - if (mapIter != m_ttMap.end()) tt = mapIter->second; - return tt; + CpmTowerMap::const_iterator mapIter = data.m_ttMap.find(key); + if (mapIter != data.m_ttMap.end()) return mapIter->second; + return nullptr; } // Find CMX-CP TOB for given key -LVL1::CMXCPTob *CpByteStreamV2Tool::findCmxCpTob(const int key) +const +LVL1::CMXCPTob *CpByteStreamV2Tool::findCmxCpTob(const int key) const { - LVL1::CMXCPTob *tob = 0; - CmxCpTobMap::const_iterator mapIter; - mapIter = m_tobMap.find(key); - if (mapIter != m_tobMap.end()) tob = mapIter->second; - return tob; + ConstCmxCpTobMap::const_iterator mapIter = m_tobMap.find(key); + if (mapIter != m_tobMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMXCPTob *CpByteStreamV2Tool::findCmxCpTob(const CmxCpTobData& data, + const int key) const +{ + CmxCpTobMap::const_iterator mapIter = data.m_tobMap.find(key); + if (mapIter != data.m_tobMap.end()) return mapIter->second; + return nullptr; } // Find CMX-CP hits for given key -LVL1::CMXCPHits *CpByteStreamV2Tool::findCmxCpHits(const int key) +const +LVL1::CMXCPHits *CpByteStreamV2Tool::findCmxCpHits(const int key) const +{ + ConstCmxCpHitsMap::const_iterator mapIter = m_hitsMap.find(key); + if (mapIter != m_hitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMXCPHits *CpByteStreamV2Tool::findCmxCpHits(const CmxCpHitsData& data, + const int key) const { - LVL1::CMXCPHits *hits = 0; - CmxCpHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(key); - if (mapIter != m_hitsMap.end()) hits = mapIter->second; - return hits; + CmxCpHitsMap::const_iterator mapIter = data.m_hitsMap.find(key); + if (mapIter != data.m_hitsMap.end()) return mapIter->second; + return nullptr; } // Set up CPM tower map @@ -1161,7 +1185,7 @@ void CpByteStreamV2Tool::setupCpmTowerMap(const CpmTowerCollection * CpmTowerCollection::const_iterator pose = ttCollection->end(); for (; pos != pose; ++pos) { - LVL1::CPMTower *const tt = *pos; + const LVL1::CPMTower *const tt = *pos; const unsigned int key = m_towerKey->ttKey(tt->phi(), tt->eta()); m_ttMap.insert(std::make_pair(key, tt)); } @@ -1180,7 +1204,7 @@ void CpByteStreamV2Tool::setupCmxCpTobMap(const CmxCpTobCollection * CmxCpTobCollection::const_iterator pose = tobCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMXCPTob *const tob = *pos; + const LVL1::CMXCPTob *const tob = *pos; const int crate = tob->crate() - m_crateOffsetSw; const int cmx = tob->cmx(); const int cpm = tob->cpm(); @@ -1204,7 +1228,7 @@ void CpByteStreamV2Tool::setupCmxCpHitsMap(const CmxCpHitsCollection * CmxCpHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMXCPHits *const hits = *pos; + const LVL1::CMXCPHits *const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int cmx = hits->cmx(); const int source = hits->source(); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h index 30ece2c6aca9fb1af915bc65a219df2318663ad6..2843ffa580e9a3814d5bcab01475a682b5880902 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/CpByteStreamV2Tool.h @@ -90,27 +90,60 @@ class CpByteStreamV2Tool : public AthAlgTool { typedef DataVector<LVL1::CMXCPTob> CmxCpTobCollection; typedef DataVector<LVL1::CMXCPHits> CmxCpHitsCollection; typedef std::map<unsigned int, LVL1::CPMTower*> CpmTowerMap; + typedef std::map<unsigned int, const LVL1::CPMTower*> ConstCpmTowerMap; typedef std::map<int, LVL1::CMXCPTob*> CmxCpTobMap; + typedef std::map<int, const LVL1::CMXCPTob*> ConstCmxCpTobMap; typedef std::map<int, LVL1::CMXCPHits*> CmxCpHitsMap; + typedef std::map<int, const LVL1::CMXCPHits*> ConstCmxCpHitsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct CpByteStreamToolData + { + CpByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct CpmTowerData : public CpByteStreamToolData + { + CpmTowerData (CpmTowerCollection* const ttCollection) + : CpByteStreamToolData (CPM_TOWERS), m_ttCollection (ttCollection) {} + CpmTowerCollection* const m_ttCollection; + CpmTowerMap m_ttMap; + }; + struct CmxCpTobData : public CpByteStreamToolData + { + CmxCpTobData (CmxCpTobCollection* const tobCollection) + : CpByteStreamToolData (CMX_CP_TOBS), m_tobCollection (tobCollection) {} + CmxCpTobCollection* const m_tobCollection; + CmxCpTobMap m_tobMap; + }; + struct CmxCpHitsData : public CpByteStreamToolData + { + CmxCpHitsData (CmxCpHitsCollection* const hitCollection) + : CpByteStreamToolData (CMX_CP_HITS), m_hitCollection (hitCollection) {} + CmxCpHitsCollection* const m_hitCollection; + CmxCpHitsMap m_hitsMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + CpByteStreamToolData& data); /// Unpack CMX-CP sub-block - void decodeCmxCp(CmxCpSubBlock* subBlock, int trigCpm, - CollectionType collection); + void decodeCmxCp(CmxCpSubBlock* subBlock, int trigCpm, CpByteStreamToolData& data); /// Unpack CPM sub-block - void decodeCpm(CpmSubBlockV2* subBlock, int trigCpm); + void decodeCpm(CpmSubBlockV2* subBlock, int trigCpm, CpmTowerData& data); /// Find a CPM tower for given key - LVL1::CPMTower* findCpmTower(unsigned int key); + const LVL1::CPMTower* findCpmTower(unsigned int key) const; + LVL1::CPMTower* findCpmTower(const CpmTowerData& data, unsigned int key) const; /// Find CMX-CP TOB for given key - LVL1::CMXCPTob* findCmxCpTob(int key); + const LVL1::CMXCPTob* findCmxCpTob(int key) const; + LVL1::CMXCPTob* findCmxCpTob(const CmxCpTobData& data, int key) const; /// Find CMX-CP hits for given key - LVL1::CMXCPHits* findCmxCpHits(int key); + const LVL1::CMXCPHits* findCmxCpHits(int key) const; + LVL1::CMXCPHits* findCmxCpHits(const CmxCpHitsData& data, int key) const; /// Set up CPM tower map void setupCpmTowerMap(const CpmTowerCollection* ttCollection); @@ -209,18 +242,12 @@ class CpByteStreamV2Tool : public AthAlgTool { DataVector<CpmSubBlockV2> m_cpmBlocks; /// Vector for current CMX-CP sub-blocks DataVector<CmxCpSubBlock> m_cmxBlocks; - /// Current CPM tower collection - CpmTowerCollection* m_ttCollection; - /// Current CMX-CP TOB collection - CmxCpTobCollection* m_tobCollection; - /// Current CMX-CP hits collection - CmxCpHitsCollection* m_hitCollection; /// CPM tower map - CpmTowerMap m_ttMap; + ConstCpmTowerMap m_ttMap; /// CMX-CP TOB map - CmxCpTobMap m_tobMap; + ConstCmxCpTobMap m_tobMap; /// CMX-CP hits map - CmxCpHitsMap m_hitsMap; + ConstCmxCpHitsMap m_hitsMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx index 71eb74a82a00b04b7bd010433044afdc47c32639..5d2a3274cee2879b32f0c8c94016dd31290cf9fb 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.cxx @@ -148,9 +148,8 @@ StatusCode JepByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JetElement>* const jeCollection) { - m_jeCollection = jeCollection; - m_jeMap.clear(); - return convertBs(robFrags, JET_ELEMENTS); + JetElementData data (jeCollection); + return convertBs(robFrags, data); } // Conversion bytestream to jet hits @@ -159,9 +158,8 @@ StatusCode JepByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JEMHits>* const hitCollection) { - m_hitCollection = hitCollection; - m_hitsMap.clear(); - return convertBs(robFrags, JET_HITS); + JetHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to energy sums @@ -170,9 +168,8 @@ StatusCode JepByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JEMEtSums>* const etCollection) { - m_etCollection = etCollection; - m_etMap.clear(); - return convertBs(robFrags, ENERGY_SUMS); + EnergySumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM hits @@ -181,9 +178,8 @@ StatusCode JepByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMJetHits>* const hitCollection) { - m_cmmHitCollection = hitCollection; - m_cmmHitsMap.clear(); - return convertBs(robFrags, CMM_HITS); + CmmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM energy sums @@ -192,9 +188,8 @@ StatusCode JepByteStreamTool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMEtSums>* const etCollection) { - m_cmmEtCollection = etCollection; - m_cmmEtMap.clear(); - return convertBs(robFrags, CMM_SUMS); + CmmSumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion of JEP container to bytestream @@ -588,7 +583,7 @@ const std::vector<uint32_t>& JepByteStreamTool::sourceIDs( StatusCode JepByteStreamTool::convertBs( const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -716,8 +711,8 @@ StatusCode JepByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_HITS) { - decodeCmmJet(m_cmmJetSubBlock, trigCmm); + if (data.m_collection == CMM_HITS) { + decodeCmmJet(m_cmmJetSubBlock, trigCmm, static_cast<CmmHitsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmJet failed" << endmsg; break; @@ -732,8 +727,8 @@ StatusCode JepByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_SUMS) { - decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); + if (data.m_collection == CMM_SUMS) { + decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm, static_cast<CmmSumsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmEnergy failed" << endmsg; break; @@ -754,9 +749,9 @@ StatusCode JepByteStreamTool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == JET_ELEMENTS || collection == JET_HITS || - collection == ENERGY_SUMS) { - decodeJem(m_jemSubBlock, trigJem, collection); + if (data.m_collection == JET_ELEMENTS || data.m_collection == JET_HITS || + data.m_collection == ENERGY_SUMS) { + decodeJem(m_jemSubBlock, trigJem, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeJem failed" << endmsg; break; @@ -774,7 +769,8 @@ StatusCode JepByteStreamTool::convertBs( // Unpack CMM-Energy sub-block void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, - int trigCmm) + int trigCmm, + CmmSumsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -883,7 +879,7 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, eyErr = eyErrBits.error(); etErr = etErrBits.error(); if (ex || ey || et || exErr || eyErr || etErr) { - LVL1::CMMEtSums* sums = findCmmSums(crate, dataID); + LVL1::CMMEtSums* sums = findCmmSums(data, crate, dataID); if ( ! sums ) { // create new CMM energy sums m_exVec.assign(timeslices, 0); m_eyVec.assign(timeslices, 0); @@ -897,11 +893,12 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, m_exErrVec[slice] = exErr; m_eyErrVec[slice] = eyErr; m_etErrVec[slice] = etErr; - sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, - m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); + auto sumsp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, m_etVec, m_exVec, m_eyVec, + m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, sums)); - m_cmmEtCollection->push_back(sums); + data.m_cmmEtMap.insert(std::make_pair(key, sumsp.get())); + data.m_cmmEtCollection->push_back(std::move(sumsp)); } else { m_exVec = sums->ExVec(); m_eyVec = sums->EyVec(); @@ -942,18 +939,19 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int missEt = subBlock->missingEtHits(slice); if ( missEt || ssError ) { const int dataID = LVL1::CMMEtSums::MISSING_ET_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = missEt; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -979,18 +977,19 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int sumEt = subBlock->sumEtHits(slice); if ( sumEt || ssError ) { const int dataID = LVL1::CMMEtSums::SUM_ET_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = sumEt; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -1017,18 +1016,19 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int missEtSig = subBlock->missingEtSigHits(slice); if ( missEtSig || ssError ) { const int dataID = LVL1::CMMEtSums::MISSING_ET_SIG_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = missEtSig; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -1061,7 +1061,8 @@ void JepByteStreamTool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, // Unpack CMM-Jet sub-block -void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) +void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm, + CmmHitsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -1153,16 +1154,17 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) subBlock->jetHitsError(slice, source)); const int err = errBits.error(); if (hits || err) { - LVL1::CMMJetHits* jh = findCmmHits(crate, dataID); + LVL1::CMMJetHits* jh = findCmmHits(data, crate, dataID); if ( ! jh ) { // create new CMM hits m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); m_hitsVec[slice] = hits; m_errVec[slice] = err; - jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + auto jhp = + std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, jh)); - m_cmmHitCollection->push_back(jh); + data.m_cmmHitsMap.insert(std::make_pair(key, jhp.get())); + data.m_cmmHitCollection->push_back(std::move(jhp)); } else { m_hitsVec = jh->HitsVec(); m_errVec = jh->ErrorVec(); @@ -1180,7 +1182,7 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) } m_hitsVec[slice] = hits; m_errVec[slice] = err; - jh->addHits(m_hitsVec, m_errVec); + jh->addHits(m_hitsVec, m_errVec); } } } @@ -1191,16 +1193,17 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) const unsigned int etMap = subBlock->jetEtMap(slice); if ( etMap || ssError ) { const int dataID = LVL1::CMMJetHits::ET_MAP; - LVL1::CMMJetHits* map = findCmmHits(crate, dataID); + LVL1::CMMJetHits* map = findCmmHits(data, crate, dataID); if ( ! map ) { m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); m_hitsVec[slice] = etMap; m_errVec[slice] = ssError; - map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, map)); - m_cmmHitCollection->push_back(map); + data.m_cmmHitsMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmHitCollection->push_back(std::move(mapp)); } else { m_hitsVec = map->HitsVec(); m_errVec = map->ErrorVec(); @@ -1218,7 +1221,7 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) } m_hitsVec[slice] = etMap; m_errVec[slice] = ssError; - map->addHits(m_hitsVec, m_errVec); + map->addHits(m_hitsVec, m_errVec); } } } @@ -1230,7 +1233,7 @@ void JepByteStreamTool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) // Unpack JEM sub-block void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1282,7 +1285,8 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1; for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == JET_ELEMENTS) { + if (data.m_collection == JET_ELEMENTS) { + JetElementData& jedata = static_cast<JetElementData&>(data); // Loop over jet element channels and fill jet elements @@ -1294,13 +1298,15 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, int layer = 0; if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { if (layer == m_coreOverlap) { - LVL1::JetElement* je = findJetElement(eta, phi); + LVL1::JetElement* je = findJetElement(jedata, eta, phi); if ( ! je ) { // create new jet element const unsigned int key = m_elementKey->jeKey(phi, eta); - je = new LVL1::JetElement(phi, eta, dummy, dummy, key, - dummy, dummy, dummy, trigJem); - m_jeMap.insert(std::make_pair(key, je)); - m_jeCollection->push_back(je); + auto jep = + std::make_unique<LVL1::JetElement>(phi, eta, dummy, dummy, key, + dummy, dummy, dummy, trigJem); + je = jep.get(); + jedata.m_jeMap.insert(std::make_pair(key, jep.get())); + jedata.m_jeCollection->push_back(std::move(jep)); } else { const std::vector<int>& emEnergy(je->emEnergyVec()); const std::vector<int>& hadEnergy(je->hadEnergyVec()); @@ -1330,7 +1336,7 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, emErrBits.set(LVL1::DataError::LinkDown, linkError); hadErrBits.set(LVL1::DataError::Parity, jetEle.hadParity()); hadErrBits.set(LVL1::DataError::LinkDown, linkError >> 1); - je->addSlice(slice, jetEle.emData(), jetEle.hadData(), + je->addSlice(slice, jetEle.emData(), jetEle.hadData(), emErrBits.error(), hadErrBits.error(), linkError); } @@ -1345,19 +1351,21 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, msg(MSG::DEBUG); } } - } else if (collection == JET_HITS) { + } else if (data.m_collection == JET_HITS) { + JetHitsData& jhdata = static_cast<JetHitsData&>(data); // Get jet hits const unsigned int hits = subBlock->jetHits(slice); if (hits) { - LVL1::JEMHits* jh = findJetHits(crate, module); + LVL1::JEMHits* jh = findJetHits(jhdata, crate, module); if ( ! jh ) { // create new jet hits m_hitsVec.assign(timeslices, 0); m_hitsVec[slice] = hits; - jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); - m_hitsMap.insert(std::make_pair(crate * m_modules + module, jh)); - m_hitCollection->push_back(jh); + auto jhp = + std::make_unique<LVL1::JEMHits>(swCrate, module, m_hitsVec, trigJem); + jhdata.m_hitsMap.insert(std::make_pair(crate * m_modules + module, jhp.get())); + jhdata.m_hitCollection->push_back(std::move(jhp)); } else { m_hitsVec = jh->JetHitsVec(); const int nsl = m_hitsVec.size(); @@ -1376,7 +1384,7 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, return; } m_hitsVec[slice] = hits; - jh->addJetHits(m_hitsVec); + jh->addJetHits(m_hitsVec); } } else if (verbose) { msg(MSG::VERBOSE) << "No jet hits data for crate/module/slice " @@ -1384,7 +1392,8 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, << endmsg; msg(MSG::DEBUG); } - } else if (collection == ENERGY_SUMS) { + } else if (data.m_collection == ENERGY_SUMS) { + EnergySumsData& sumdata = static_cast<EnergySumsData&>(data); // Get energy subsums @@ -1392,7 +1401,7 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, const unsigned int ey = subBlock->ey(slice); const unsigned int et = subBlock->et(slice); if (ex | ey | et) { - LVL1::JEMEtSums* sums = findEnergySums(crate, module); + LVL1::JEMEtSums* sums = findEnergySums(sumdata, crate, module); if ( ! sums ) { // create new energy sums m_exVec.assign(timeslices, 0); m_eyVec.assign(timeslices, 0); @@ -1400,10 +1409,11 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, m_exVec[slice] = ex; m_eyVec[slice] = ey; m_etVec[slice] = et; - sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, - trigJem); - m_etMap.insert(std::make_pair(crate * m_modules + module, sums)); - m_etCollection->push_back(sums); + auto sumsp = + std::make_unique<LVL1::JEMEtSums>(swCrate, module, m_etVec, m_exVec, m_eyVec, + trigJem); + sumdata.m_etMap.insert(std::make_pair(crate * m_modules + module, sumsp.get())); + sumdata.m_etCollection->push_back(std::move(sumsp)); } else { m_exVec = sums->ExVec(); m_eyVec = sums->EyVec(); @@ -1443,63 +1453,104 @@ void JepByteStreamTool::decodeJem(JemSubBlock* subBlock, int trigJem, // Find a jet element given eta, phi +const LVL1::JetElement* JepByteStreamTool::findJetElement(const double eta, - const double phi) + const double phi) const { - LVL1::JetElement* tt = 0; const unsigned int key = m_elementKey->jeKey(phi, eta); - JetElementMap::const_iterator mapIter; - mapIter = m_jeMap.find(key); - if (mapIter != m_jeMap.end()) tt = mapIter->second; - return tt; + ConstJetElementMap::const_iterator mapIter = m_jeMap.find(key); + if (mapIter != m_jeMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JetElement* JepByteStreamTool::findJetElement(const JetElementData& data, + const double eta, + const double phi) const +{ + const unsigned int key = m_elementKey->jeKey(phi, eta); + JetElementMap::const_iterator mapIter = data.m_jeMap.find(key); + if (mapIter != data.m_jeMap.end()) return mapIter->second; + return nullptr; } // Find jet hits for given crate, module +const LVL1::JEMHits* JepByteStreamTool::findJetHits(const int crate, - const int module) + const int module) const { - LVL1::JEMHits* hits = 0; - JetHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate * m_modules + module); - if (mapIter != m_hitsMap.end()) hits = mapIter->second; - return hits; + ConstJetHitsMap::const_iterator mapIter = m_hitsMap.find(crate * m_modules + module); + if (mapIter != m_hitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JEMHits* JepByteStreamTool::findJetHits(const JetHitsData& data, + const int crate, + const int module) const +{ + JetHitsMap::const_iterator mapIter = data.m_hitsMap.find(crate * m_modules + module); + if (mapIter != data.m_hitsMap.end()) return mapIter->second; + return nullptr; } // Find energy sums for given crate, module +const LVL1::JEMEtSums* JepByteStreamTool::findEnergySums(const int crate, - const int module) + const int module) const { - LVL1::JEMEtSums* sums = 0; - EnergySumsMap::const_iterator mapIter; - mapIter = m_etMap.find(crate * m_modules + module); - if (mapIter != m_etMap.end()) sums = mapIter->second; - return sums; + ConstEnergySumsMap::const_iterator mapIter = m_etMap.find(crate * m_modules + module); + if (mapIter != m_etMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JEMEtSums* JepByteStreamTool::findEnergySums(const EnergySumsData& data, + const int crate, + const int module) const +{ + EnergySumsMap::const_iterator mapIter = data.m_etMap.find(crate * m_modules + module); + if (mapIter != data.m_etMap.end()) return mapIter->second; + return nullptr; } // Find CMM hits for given crate, dataID +const LVL1::CMMJetHits* JepByteStreamTool::findCmmHits(const int crate, - const int dataID) + const int dataID) const +{ + ConstCmmHitsMap::const_iterator mapIter = m_cmmHitsMap.find(crate * 100 + dataID); + if (mapIter != m_cmmHitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMJetHits* JepByteStreamTool::findCmmHits(const CmmHitsData& data, + const int crate, + const int dataID) const { - LVL1::CMMJetHits* hits = 0; - CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate * 100 + dataID); - if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; - return hits; + CmmHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate * 100 + dataID); + if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second; + return nullptr; } // Find CMM energy sums for given crate, module, dataID +const LVL1::CMMEtSums* JepByteStreamTool::findCmmSums(const int crate, - const int dataID) + const int dataID) const +{ + ConstCmmSumsMap::const_iterator mapIter = m_cmmEtMap.find(crate * 100 + dataID); + if (mapIter != m_cmmEtMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMEtSums* JepByteStreamTool::findCmmSums(const CmmSumsData& data, + const int crate, + const int dataID) const { - LVL1::CMMEtSums* sums = 0; - CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate * 100 + dataID); - if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; - return sums; + CmmSumsMap::const_iterator mapIter = data.m_cmmEtMap.find(crate * 100 + dataID); + if (mapIter != data.m_cmmEtMap.end()) return mapIter->second; + return nullptr; } // Set up jet element map @@ -1512,7 +1563,7 @@ void JepByteStreamTool::setupJeMap(const JetElementCollection* JetElementCollection::const_iterator pos = jeCollection->begin(); JetElementCollection::const_iterator pose = jeCollection->end(); for (; pos != pose; ++pos) { - LVL1::JetElement* const je = *pos; + const LVL1::JetElement* const je = *pos; const unsigned int key = m_elementKey->jeKey(je->phi(), je->eta()); m_jeMap.insert(std::make_pair(key, je)); } @@ -1529,7 +1580,7 @@ void JepByteStreamTool::setupHitsMap(const JetHitsCollection* JetHitsCollection::const_iterator pos = hitCollection->begin(); JetHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::JEMHits* const hits = *pos; + const LVL1::JEMHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = m_modules * crate + hits->module(); m_hitsMap.insert(std::make_pair(key, hits)); @@ -1547,7 +1598,7 @@ void JepByteStreamTool::setupEtMap(const EnergySumsCollection* EnergySumsCollection::const_iterator pos = etCollection->begin(); EnergySumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::JEMEtSums* const sums = *pos; + const LVL1::JEMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = m_modules * crate + sums->module(); m_etMap.insert(std::make_pair(key, sums)); @@ -1565,7 +1616,7 @@ void JepByteStreamTool::setupCmmHitsMap(const CmmHitsCollection* CmmHitsCollection::const_iterator pos = hitCollection->begin(); CmmHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMJetHits* const hits = *pos; + const LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); @@ -1583,7 +1634,7 @@ void JepByteStreamTool::setupCmmEtMap(const CmmSumsCollection* CmmSumsCollection::const_iterator pos = etCollection->begin(); CmmSumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMEtSums* const sums = *pos; + const LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.h index 8e307e6ec5e60f3f23278fb880a24989a7d804ab..7e253dcdf7cbc66f3a0c30e9789aceb89ce0e352 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamTool.h @@ -96,35 +96,87 @@ class JepByteStreamTool : public AthAlgTool { typedef DataVector<LVL1::CMMJetHits> CmmHitsCollection; typedef DataVector<LVL1::CMMEtSums> CmmSumsCollection; typedef std::map<unsigned int, LVL1::JetElement*> JetElementMap; + typedef std::map<unsigned int, const LVL1::JetElement*> ConstJetElementMap; typedef std::map<int, LVL1::JEMHits*> JetHitsMap; + typedef std::map<int, const LVL1::JEMHits*> ConstJetHitsMap; typedef std::map<int, LVL1::JEMEtSums*> EnergySumsMap; + typedef std::map<int, const LVL1::JEMEtSums*> ConstEnergySumsMap; typedef std::map<int, LVL1::CMMJetHits*> CmmHitsMap; + typedef std::map<int, const LVL1::CMMJetHits*> ConstCmmHitsMap; typedef std::map<int, LVL1::CMMEtSums*> CmmSumsMap; + typedef std::map<int, const LVL1::CMMEtSums*> ConstCmmSumsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct JepByteStreamToolData + { + JepByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct JetElementData : public JepByteStreamToolData + { + JetElementData (JetElementCollection* const jeCollection) + : JepByteStreamToolData (JET_ELEMENTS), m_jeCollection (jeCollection) {} + JetElementCollection* const m_jeCollection; + JetElementMap m_jeMap; + }; + struct JetHitsData : public JepByteStreamToolData + { + JetHitsData (JetHitsCollection* const hitCollection) + : JepByteStreamToolData (JET_HITS), m_hitCollection (hitCollection) {} + JetHitsCollection* const m_hitCollection; + JetHitsMap m_hitsMap; + }; + struct EnergySumsData : public JepByteStreamToolData + { + EnergySumsData (EnergySumsCollection* const etCollection) + : JepByteStreamToolData (ENERGY_SUMS), m_etCollection (etCollection) {} + EnergySumsCollection* const m_etCollection; + EnergySumsMap m_etMap; + }; + struct CmmHitsData : public JepByteStreamToolData + { + CmmHitsData (CmmHitsCollection* const cmmHitCollection) + : JepByteStreamToolData (CMM_HITS), m_cmmHitCollection (cmmHitCollection) {} + CmmHitsCollection* const m_cmmHitCollection; + CmmHitsMap m_cmmHitsMap; + }; + struct CmmSumsData : public JepByteStreamToolData + { + CmmSumsData (CmmSumsCollection* const cmmEtCollection) + : JepByteStreamToolData (CMM_SUMS), m_cmmEtCollection (cmmEtCollection) {} + CmmSumsCollection* const m_cmmEtCollection; + CmmSumsMap m_cmmEtMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + JepByteStreamToolData& data); /// Unpack CMM-Energy sub-block - void decodeCmmEnergy(CmmEnergySubBlock* subBlock, int trigCmm); + void decodeCmmEnergy(CmmEnergySubBlock* subBlock, int trigCmm, CmmSumsData& data); /// Unpack CMM-Jet sub-block - void decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm); + void decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm, CmmHitsData& data); /// Unpack JEM sub-block void decodeJem(JemSubBlock* subBlock, int trigJem, - CollectionType collection); + JepByteStreamToolData& data); /// Find a jet element given eta, phi - LVL1::JetElement* findJetElement(double eta, double phi); + const LVL1::JetElement* findJetElement(double eta, double phi) const; + LVL1::JetElement* findJetElement(const JetElementData& data, double eta, double phi) const; /// Find jet hits for given crate, module - LVL1::JEMHits* findJetHits(int crate, int module); + const LVL1::JEMHits* findJetHits(int crate, int module) const; + LVL1::JEMHits* findJetHits(const JetHitsData& data, int crate, int module) const; /// Find energy sums for given crate, module - LVL1::JEMEtSums* findEnergySums(int crate, int module); + const LVL1::JEMEtSums* findEnergySums(int crate, int module) const; + LVL1::JEMEtSums* findEnergySums(const EnergySumsData& data, int crate, int module) const; /// Find CMM hits for given crate, data ID - LVL1::CMMJetHits* findCmmHits(int crate, int dataID); + const LVL1::CMMJetHits* findCmmHits(int crate, int dataID) const; + LVL1::CMMJetHits* findCmmHits(const CmmHitsData& data, int crate, int dataID) const; /// Find CMM energy sums for given crate, data ID - LVL1::CMMEtSums* findCmmSums(int crate, int dataID); + const LVL1::CMMEtSums* findCmmSums(int crate, int dataID) const; + LVL1::CMMEtSums* findCmmSums(const CmmSumsData& data, int crate, int dataID) const; /// Set up jet element map void setupJeMap(const JetElementCollection* jeCollection); @@ -206,26 +258,16 @@ class JepByteStreamTool : public AthAlgTool { DataVector<CmmEnergySubBlock> m_cmmEnergyBlocks; /// Vector for current CMM-Jet sub-blocks DataVector<CmmJetSubBlock> m_cmmJetBlocks; - /// Current jet elements collection - JetElementCollection* m_jeCollection; - /// Current jet hits collection - JetHitsCollection* m_hitCollection; - /// Current energy sums collection - EnergySumsCollection* m_etCollection; - /// Current CMM hits collection - CmmHitsCollection* m_cmmHitCollection; - /// Current CMM energy sums collection - CmmSumsCollection* m_cmmEtCollection; /// Jet element map - JetElementMap m_jeMap; + ConstJetElementMap m_jeMap; /// Jet hits map - JetHitsMap m_hitsMap; + ConstJetHitsMap m_hitsMap; /// Energy sums map - EnergySumsMap m_etMap; + ConstEnergySumsMap m_etMap; /// CMM hits map - CmmHitsMap m_cmmHitsMap; + ConstCmmHitsMap m_cmmHitsMap; /// CMM energy sums map - CmmSumsMap m_cmmEtMap; + ConstCmmSumsMap m_cmmEtMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx index 80f60a2fd29fab5ddfabe404d18eb15dcc757a1a..4ebb89cb44a498db8313fe463e39747622420467 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.cxx @@ -154,9 +154,8 @@ StatusCode JepByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JetElement>* const jeCollection) { - m_jeCollection = jeCollection; - m_jeMap.clear(); - return convertBs(robFrags, JET_ELEMENTS); + JetElementData data (jeCollection); + return convertBs(robFrags, data); } // Conversion bytestream to jet hits @@ -165,9 +164,8 @@ StatusCode JepByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JEMHits>* const hitCollection) { - m_hitCollection = hitCollection; - m_hitsMap.clear(); - return convertBs(robFrags, JET_HITS); + JetHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to energy sums @@ -176,9 +174,8 @@ StatusCode JepByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JEMEtSums>* const etCollection) { - m_etCollection = etCollection; - m_etMap.clear(); - return convertBs(robFrags, ENERGY_SUMS); + EnergySumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM hits @@ -187,9 +184,8 @@ StatusCode JepByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMJetHits>* const hitCollection) { - m_cmmHitCollection = hitCollection; - m_cmmHitsMap.clear(); - return convertBs(robFrags, CMM_HITS); + CmmHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMM energy sums @@ -198,9 +194,8 @@ StatusCode JepByteStreamV1Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMMEtSums>* const etCollection) { - m_cmmEtCollection = etCollection; - m_cmmEtMap.clear(); - return convertBs(robFrags, CMM_SUMS); + CmmSumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion of JEP container to bytestream @@ -597,7 +592,7 @@ const std::vector<uint32_t>& JepByteStreamV1Tool::sourceIDs( StatusCode JepByteStreamV1Tool::convertBs( const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -731,8 +726,8 @@ StatusCode JepByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_HITS) { - decodeCmmJet(m_cmmJetSubBlock, trigCmm); + if (data.m_collection == CMM_HITS) { + decodeCmmJet(m_cmmJetSubBlock, trigCmm, static_cast<CmmHitsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmJet failed" << endmsg; break; @@ -747,8 +742,8 @@ StatusCode JepByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMM_SUMS) { - decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm); + if (data.m_collection == CMM_SUMS) { + decodeCmmEnergy(m_cmmEnergySubBlock, trigCmm, static_cast<CmmSumsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmmEnergy failed" << endmsg; break; @@ -769,9 +764,9 @@ StatusCode JepByteStreamV1Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == JET_ELEMENTS || collection == JET_HITS || - collection == ENERGY_SUMS) { - decodeJem(m_jemSubBlock, trigJem, collection); + if (data.m_collection == JET_ELEMENTS || data.m_collection == JET_HITS || + data.m_collection == ENERGY_SUMS) { + decodeJem(m_jemSubBlock, trigJem, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeJem failed" << endmsg; break; @@ -789,7 +784,8 @@ StatusCode JepByteStreamV1Tool::convertBs( // Unpack CMM-Energy sub-block void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, - int trigCmm) + int trigCmm, + CmmSumsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -892,7 +888,7 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, eyErr = eyErrBits.error(); etErr = etErrBits.error(); if (ex || ey || et || exErr || eyErr || etErr) { - LVL1::CMMEtSums* sums = findCmmSums(crate, dataID); + LVL1::CMMEtSums* sums = findCmmSums(data, crate, dataID); if ( ! sums ) { // create new CMM energy sums m_exVec.assign(timeslices, 0); m_eyVec.assign(timeslices, 0); @@ -906,11 +902,12 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, m_exErrVec[slice] = exErr; m_eyErrVec[slice] = eyErr; m_etErrVec[slice] = etErr; - sums = new LVL1::CMMEtSums(swCrate, dataID, m_etVec, m_exVec, m_eyVec, - m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); + auto sumsp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, m_etVec, m_exVec, m_eyVec, + m_etErrVec, m_exErrVec, m_eyErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, sums)); - m_cmmEtCollection->push_back(sums); + data.m_cmmEtMap.insert(std::make_pair(key, sumsp.get())); + data.m_cmmEtCollection->push_back(std::move(sumsp)); } else { m_exVec = sums->ExVec(); m_eyVec = sums->EyVec(); @@ -951,18 +948,19 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int missEt = subBlock->missingEtHits(slice); if ( missEt || ssError ) { const int dataID = LVL1::CMMEtSums::MISSING_ET_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = missEt; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -988,18 +986,19 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int sumEt = subBlock->sumEtHits(slice); if ( sumEt || ssError ) { const int dataID = LVL1::CMMEtSums::SUM_ET_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = sumEt; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -1026,18 +1025,19 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, const unsigned int missEtSig = subBlock->missingEtSigHits(slice); if ( missEtSig || ssError ) { const int dataID = LVL1::CMMEtSums::MISSING_ET_SIG_MAP; - LVL1::CMMEtSums* map = findCmmSums(crate, dataID); + LVL1::CMMEtSums* map = findCmmSums(data, crate, dataID); if ( ! map ) { m_etVec.assign(timeslices, 0); m_etErrVec.assign(timeslices, 0); m_etVec[slice] = missEtSig; m_etErrVec[slice] = ssError; - map = new LVL1::CMMEtSums(swCrate, dataID, - m_etVec, m_etVec, m_etVec, - m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMEtSums>(swCrate, dataID, + m_etVec, m_etVec, m_etVec, + m_etErrVec, m_etErrVec, m_etErrVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmEtMap.insert(std::make_pair(key, map)); - m_cmmEtCollection->push_back(map); + data.m_cmmEtMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmEtCollection->push_back(std::move(mapp)); } else { m_etVec = map->EtVec(); m_etErrVec = map->EtErrorVec(); @@ -1070,7 +1070,8 @@ void JepByteStreamV1Tool::decodeCmmEnergy(CmmEnergySubBlock* subBlock, // Unpack CMM-Jet sub-block -void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) +void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm, + CmmHitsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -1165,16 +1166,17 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) subBlock->jetHitsError(slice, source)); const int err = errBits.error(); if (hits || err) { - LVL1::CMMJetHits* jh = findCmmHits(crate, dataID); + LVL1::CMMJetHits* jh = findCmmHits(data, crate, dataID); if ( ! jh ) { // create new CMM hits m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); m_hitsVec[slice] = hits; m_errVec[slice] = err; - jh = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + auto jhp = + std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, jh)); - m_cmmHitCollection->push_back(jh); + data.m_cmmHitsMap.insert(std::make_pair(key, jhp.get())); + data.m_cmmHitCollection->push_back(std::move(jhp)); } else { m_hitsVec = jh->HitsVec(); m_errVec = jh->ErrorVec(); @@ -1203,16 +1205,17 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) const unsigned int etMap = subBlock->jetEtMap(slice); if ( etMap || ssError ) { const int dataID = LVL1::CMMJetHits::ET_MAP; - LVL1::CMMJetHits* map = findCmmHits(crate, dataID); + LVL1::CMMJetHits* map = findCmmHits(data, crate, dataID); if ( ! map ) { m_hitsVec.assign(timeslices, 0); m_errVec.assign(timeslices, 0); m_hitsVec[slice] = etMap; m_errVec[slice] = ssError; - map = new LVL1::CMMJetHits(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); + auto mapp = + std::make_unique<LVL1::CMMJetHits>(swCrate, dataID, m_hitsVec, m_errVec, trigCmm); const int key = crate * 100 + dataID; - m_cmmHitsMap.insert(std::make_pair(key, map)); - m_cmmHitCollection->push_back(map); + data.m_cmmHitsMap.insert(std::make_pair(key, mapp.get())); + data.m_cmmHitCollection->push_back(std::move(mapp)); } else { m_hitsVec = map->HitsVec(); m_errVec = map->ErrorVec(); @@ -1242,7 +1245,7 @@ void JepByteStreamV1Tool::decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm) // Unpack JEM sub-block void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1294,7 +1297,8 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1; for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == JET_ELEMENTS) { + if (data.m_collection == JET_ELEMENTS) { + JetElementData& jedata = static_cast<JetElementData&>(data); // Loop over jet element channels and fill jet elements @@ -1306,13 +1310,15 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, int layer = 0; if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { if (layer == m_coreOverlap) { - LVL1::JetElement* je = findJetElement(eta, phi); + LVL1::JetElement* je = findJetElement(jedata, eta, phi); if ( ! je ) { // create new jet element const unsigned int key = m_elementKey->jeKey(phi, eta); - je = new LVL1::JetElement(phi, eta, dummy, dummy, key, - dummy, dummy, dummy, trigJem); - m_jeMap.insert(std::make_pair(key, je)); - m_jeCollection->push_back(je); + auto jep = + std::make_unique<LVL1::JetElement>(phi, eta, dummy, dummy, key, + dummy, dummy, dummy, trigJem); + je = jep.get(); + jedata.m_jeMap.insert(std::make_pair(key, jep.get())); + jedata.m_jeCollection->push_back(std::move(jep)); } else { const std::vector<int>& emEnergy(je->emEnergyVec()); const std::vector<int>& hadEnergy(je->hadEnergyVec()); @@ -1357,19 +1363,21 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, msg(MSG::DEBUG); } } - } else if (collection == JET_HITS) { + } else if (data.m_collection == JET_HITS) { + JetHitsData& jhdata = static_cast<JetHitsData&>(data); // Get jet hits const unsigned int hits = subBlock->jetHits(slice); if (hits) { - LVL1::JEMHits* jh = findJetHits(crate, module); + LVL1::JEMHits* jh = findJetHits(jhdata, crate, module); if ( ! jh ) { // create new jet hits m_hitsVec.assign(timeslices, 0); m_hitsVec[slice] = hits; - jh = new LVL1::JEMHits(swCrate, module, m_hitsVec, trigJem); - m_hitsMap.insert(std::make_pair(crate * m_modules + module, jh)); - m_hitCollection->push_back(jh); + auto jhp = + std::make_unique<LVL1::JEMHits>(swCrate, module, m_hitsVec, trigJem); + jhdata.m_hitsMap.insert(std::make_pair(crate * m_modules + module, jhp.get())); + jhdata.m_hitCollection->push_back(std::move(jhp)); } else { m_hitsVec = jh->JetHitsVec(); const int nsl = m_hitsVec.size(); @@ -1396,7 +1404,8 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, << endmsg; msg(MSG::DEBUG); } - } else if (collection == ENERGY_SUMS) { + } else if (data.m_collection == ENERGY_SUMS) { + EnergySumsData& sumdata = static_cast<EnergySumsData&>(data); // Get energy subsums @@ -1404,7 +1413,7 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, const unsigned int ey = subBlock->ey(slice); const unsigned int et = subBlock->et(slice); if (ex | ey | et) { - LVL1::JEMEtSums* sums = findEnergySums(crate, module); + LVL1::JEMEtSums* sums = findEnergySums(sumdata, crate, module); if ( ! sums ) { // create new energy sums m_exVec.assign(timeslices, 0); m_eyVec.assign(timeslices, 0); @@ -1412,10 +1421,11 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, m_exVec[slice] = ex; m_eyVec[slice] = ey; m_etVec[slice] = et; - sums = new LVL1::JEMEtSums(swCrate, module, m_etVec, m_exVec, m_eyVec, - trigJem); - m_etMap.insert(std::make_pair(crate * m_modules + module, sums)); - m_etCollection->push_back(sums); + auto sumsp = + std::make_unique<LVL1::JEMEtSums>(swCrate, module, m_etVec, m_exVec, m_eyVec, + trigJem); + sumdata.m_etMap.insert(std::make_pair(crate * m_modules + module, sumsp.get())); + sumdata.m_etCollection->push_back(std::move(sumsp)); } else { m_exVec = sums->ExVec(); m_eyVec = sums->EyVec(); @@ -1455,63 +1465,104 @@ void JepByteStreamV1Tool::decodeJem(JemSubBlockV1* subBlock, int trigJem, // Find a jet element given eta, phi +const LVL1::JetElement* JepByteStreamV1Tool::findJetElement(const double eta, - const double phi) + const double phi) const { - LVL1::JetElement* tt = 0; const unsigned int key = m_elementKey->jeKey(phi, eta); - JetElementMap::const_iterator mapIter; - mapIter = m_jeMap.find(key); - if (mapIter != m_jeMap.end()) tt = mapIter->second; - return tt; + ConstJetElementMap::const_iterator mapIter = m_jeMap.find(key); + if (mapIter != m_jeMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JetElement* JepByteStreamV1Tool::findJetElement(const JetElementData& data, + const double eta, + const double phi) const +{ + const unsigned int key = m_elementKey->jeKey(phi, eta); + JetElementMap::const_iterator mapIter = data.m_jeMap.find(key); + if (mapIter != data.m_jeMap.end()) return mapIter->second; + return nullptr; } // Find jet hits for given crate, module +const LVL1::JEMHits* JepByteStreamV1Tool::findJetHits(const int crate, - const int module) + const int module) const +{ + ConstJetHitsMap::const_iterator mapIter = m_hitsMap.find(crate * m_modules + module); + if (mapIter != m_hitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JEMHits* JepByteStreamV1Tool::findJetHits(const JetHitsData& data, + const int crate, + const int module) const { - LVL1::JEMHits* hits = 0; - JetHitsMap::const_iterator mapIter; - mapIter = m_hitsMap.find(crate * m_modules + module); - if (mapIter != m_hitsMap.end()) hits = mapIter->second; - return hits; + JetHitsMap::const_iterator mapIter = data.m_hitsMap.find(crate * m_modules + module); + if (mapIter != data.m_hitsMap.end()) return mapIter->second; + return nullptr; } // Find energy sums for given crate, module +const LVL1::JEMEtSums* JepByteStreamV1Tool::findEnergySums(const int crate, - const int module) + const int module) const +{ + ConstEnergySumsMap::const_iterator mapIter = m_etMap.find(crate * m_modules + module); + if (mapIter != m_etMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JEMEtSums* JepByteStreamV1Tool::findEnergySums(const EnergySumsData& data, + const int crate, + const int module) const { - LVL1::JEMEtSums* sums = 0; - EnergySumsMap::const_iterator mapIter; - mapIter = m_etMap.find(crate * m_modules + module); - if (mapIter != m_etMap.end()) sums = mapIter->second; - return sums; + EnergySumsMap::const_iterator mapIter = data.m_etMap.find(crate * m_modules + module); + if (mapIter != data.m_etMap.end()) return mapIter->second; + return nullptr; } // Find CMM hits for given crate, dataID +const LVL1::CMMJetHits* JepByteStreamV1Tool::findCmmHits(const int crate, - const int dataID) + const int dataID) const { - LVL1::CMMJetHits* hits = 0; - CmmHitsMap::const_iterator mapIter; - mapIter = m_cmmHitsMap.find(crate * 100 + dataID); - if (mapIter != m_cmmHitsMap.end()) hits = mapIter->second; - return hits; + ConstCmmHitsMap::const_iterator mapIter = m_cmmHitsMap.find(crate * 100 + dataID); + if (mapIter != m_cmmHitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMJetHits* JepByteStreamV1Tool::findCmmHits(const CmmHitsData& data, + const int crate, + const int dataID) const +{ + CmmHitsMap::const_iterator mapIter = data.m_cmmHitsMap.find(crate * 100 + dataID); + if (mapIter != data.m_cmmHitsMap.end()) return mapIter->second; + return nullptr; } // Find CMM energy sums for given crate, module, dataID +const LVL1::CMMEtSums* JepByteStreamV1Tool::findCmmSums(const int crate, - const int dataID) + const int dataID) const { - LVL1::CMMEtSums* sums = 0; - CmmSumsMap::const_iterator mapIter; - mapIter = m_cmmEtMap.find(crate * 100 + dataID); - if (mapIter != m_cmmEtMap.end()) sums = mapIter->second; - return sums; + ConstCmmSumsMap::const_iterator mapIter = m_cmmEtMap.find(crate * 100 + dataID); + if (mapIter != m_cmmEtMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMMEtSums* JepByteStreamV1Tool::findCmmSums(const CmmSumsData& data, + const int crate, + const int dataID) const +{ + CmmSumsMap::const_iterator mapIter = data.m_cmmEtMap.find(crate * 100 + dataID); + if (mapIter != data.m_cmmEtMap.end()) return mapIter->second; + return nullptr; } // Set up jet element map @@ -1531,6 +1582,7 @@ void JepByteStreamV1Tool::setupJeMap(const JetElementCollection* } } + // Set up jet hits map void JepByteStreamV1Tool::setupHitsMap(const JetHitsCollection* @@ -1541,7 +1593,7 @@ void JepByteStreamV1Tool::setupHitsMap(const JetHitsCollection* JetHitsCollection::const_iterator pos = hitCollection->begin(); JetHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::JEMHits* const hits = *pos; + const LVL1::JEMHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = m_modules * crate + hits->module(); m_hitsMap.insert(std::make_pair(key, hits)); @@ -1559,7 +1611,7 @@ void JepByteStreamV1Tool::setupEtMap(const EnergySumsCollection* EnergySumsCollection::const_iterator pos = etCollection->begin(); EnergySumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::JEMEtSums* const sums = *pos; + const LVL1::JEMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = m_modules * crate + sums->module(); m_etMap.insert(std::make_pair(key, sums)); @@ -1577,7 +1629,7 @@ void JepByteStreamV1Tool::setupCmmHitsMap(const CmmHitsCollection* CmmHitsCollection::const_iterator pos = hitCollection->begin(); CmmHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMJetHits* const hits = *pos; + const LVL1::CMMJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = crate * 100 + hits->dataID(); m_cmmHitsMap.insert(std::make_pair(key, hits)); @@ -1595,7 +1647,7 @@ void JepByteStreamV1Tool::setupCmmEtMap(const CmmSumsCollection* CmmSumsCollection::const_iterator pos = etCollection->begin(); CmmSumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMMEtSums* const sums = *pos; + const LVL1::CMMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = crate * 100 + sums->dataID(); m_cmmEtMap.insert(std::make_pair(key, sums)); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.h index 85e61f68d1eba84d6fcaad58f27076768511f1e7..7eda9a1ff53b2a59cf4f767317764cbea1b36d2f 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV1Tool.h @@ -96,35 +96,87 @@ class JepByteStreamV1Tool : public AthAlgTool { typedef DataVector<LVL1::CMMJetHits> CmmHitsCollection; typedef DataVector<LVL1::CMMEtSums> CmmSumsCollection; typedef std::map<unsigned int, LVL1::JetElement*> JetElementMap; + typedef std::map<unsigned int, const LVL1::JetElement*> ConstJetElementMap; typedef std::map<int, LVL1::JEMHits*> JetHitsMap; + typedef std::map<int, const LVL1::JEMHits*> ConstJetHitsMap; typedef std::map<int, LVL1::JEMEtSums*> EnergySumsMap; + typedef std::map<int, const LVL1::JEMEtSums*> ConstEnergySumsMap; typedef std::map<int, LVL1::CMMJetHits*> CmmHitsMap; + typedef std::map<int, const LVL1::CMMJetHits*> ConstCmmHitsMap; typedef std::map<int, LVL1::CMMEtSums*> CmmSumsMap; + typedef std::map<int, const LVL1::CMMEtSums*> ConstCmmSumsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct JepByteStreamToolData + { + JepByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct JetElementData : public JepByteStreamToolData + { + JetElementData (JetElementCollection* const jeCollection) + : JepByteStreamToolData (JET_ELEMENTS), m_jeCollection (jeCollection) {} + JetElementCollection* const m_jeCollection; + JetElementMap m_jeMap; + }; + struct JetHitsData : public JepByteStreamToolData + { + JetHitsData (JetHitsCollection* const hitCollection) + : JepByteStreamToolData (JET_HITS), m_hitCollection (hitCollection) {} + JetHitsCollection* const m_hitCollection; + JetHitsMap m_hitsMap; + }; + struct EnergySumsData : public JepByteStreamToolData + { + EnergySumsData (EnergySumsCollection* const etCollection) + : JepByteStreamToolData (ENERGY_SUMS), m_etCollection (etCollection) {} + EnergySumsCollection* const m_etCollection; + EnergySumsMap m_etMap; + }; + struct CmmHitsData : public JepByteStreamToolData + { + CmmHitsData (CmmHitsCollection* const cmmHitCollection) + : JepByteStreamToolData (CMM_HITS), m_cmmHitCollection (cmmHitCollection) {} + CmmHitsCollection* const m_cmmHitCollection; + CmmHitsMap m_cmmHitsMap; + }; + struct CmmSumsData : public JepByteStreamToolData + { + CmmSumsData (CmmSumsCollection* const cmmEtCollection) + : JepByteStreamToolData (CMM_SUMS), m_cmmEtCollection (cmmEtCollection) {} + CmmSumsCollection* const m_cmmEtCollection; + CmmSumsMap m_cmmEtMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + JepByteStreamToolData& data); /// Unpack CMM-Energy sub-block - void decodeCmmEnergy(CmmEnergySubBlock* subBlock, int trigCmm); + void decodeCmmEnergy(CmmEnergySubBlock* subBlock, int trigCmm, CmmSumsData& data); /// Unpack CMM-Jet sub-block - void decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm); + void decodeCmmJet(CmmJetSubBlock* subBlock, int trigCmm, CmmHitsData& data); /// Unpack JEM sub-block void decodeJem(JemSubBlockV1* subBlock, int trigJem, - CollectionType collection); + JepByteStreamToolData& data); /// Find a jet element given eta, phi - LVL1::JetElement* findJetElement(double eta, double phi); + const LVL1::JetElement* findJetElement(double eta, double phi) const; + LVL1::JetElement* findJetElement(const JetElementData& data, double eta, double phi) const; /// Find jet hits for given crate, module - LVL1::JEMHits* findJetHits(int crate, int module); + const LVL1::JEMHits* findJetHits(int crate, int module) const; + LVL1::JEMHits* findJetHits(const JetHitsData& data, int crate, int module) const; /// Find energy sums for given crate, module - LVL1::JEMEtSums* findEnergySums(int crate, int module); + const LVL1::JEMEtSums* findEnergySums(int crate, int module) const; + LVL1::JEMEtSums* findEnergySums(const EnergySumsData& data, int crate, int module) const; /// Find CMM hits for given crate, data ID - LVL1::CMMJetHits* findCmmHits(int crate, int dataID); + const LVL1::CMMJetHits* findCmmHits(int crate, int dataID) const; + LVL1::CMMJetHits* findCmmHits(const CmmHitsData& data, int crate, int dataID) const; /// Find CMM energy sums for given crate, data ID - LVL1::CMMEtSums* findCmmSums(int crate, int dataID); + const LVL1::CMMEtSums* findCmmSums(int crate, int dataID) const; + LVL1::CMMEtSums* findCmmSums(const CmmSumsData& data, int crate, int dataID) const; /// Set up jet element map void setupJeMap(const JetElementCollection* jeCollection); @@ -210,26 +262,16 @@ class JepByteStreamV1Tool : public AthAlgTool { DataVector<CmmEnergySubBlock> m_cmmEnergyBlocks; /// Vector for current CMM-Jet sub-blocks DataVector<CmmJetSubBlock> m_cmmJetBlocks; - /// Current jet elements collection - JetElementCollection* m_jeCollection; - /// Current jet hits collection - JetHitsCollection* m_hitCollection; - /// Current energy sums collection - EnergySumsCollection* m_etCollection; - /// Current CMM hits collection - CmmHitsCollection* m_cmmHitCollection; - /// Current CMM energy sums collection - CmmSumsCollection* m_cmmEtCollection; /// Jet element map - JetElementMap m_jeMap; + ConstJetElementMap m_jeMap; /// Jet hits map - JetHitsMap m_hitsMap; + ConstJetHitsMap m_hitsMap; /// Energy sums map - EnergySumsMap m_etMap; + ConstEnergySumsMap m_etMap; /// CMM hits map - CmmHitsMap m_cmmHitsMap; + ConstCmmHitsMap m_cmmHitsMap; /// CMM energy sums map - CmmSumsMap m_cmmEtMap; + ConstCmmSumsMap m_cmmEtMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx index 32a045b365109f54704efbea075ea75589b754fe..5c29b9cfbcde64ca686671063aad32011ed47ff3 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.cxx @@ -168,9 +168,8 @@ StatusCode JepByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JetElement>* jeCollection) { - m_jeCollection = jeCollection; - m_jeMap.clear(); - return convertBs(robFrags, JET_ELEMENTS); + JetElementData data (jeCollection); + return convertBs(robFrags, data); } // Conversion bytestream to energy sums @@ -190,9 +189,8 @@ StatusCode JepByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::JEMEtSums>* etCollection) { - m_etCollection = etCollection; - m_etMap.clear(); - return convertBs(robFrags, ENERGY_SUMS); + EnergySumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMX TOBs @@ -212,9 +210,8 @@ StatusCode JepByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMXJetTob>* tobCollection) { - m_cmxTobCollection = tobCollection; - m_cmxTobMap.clear(); - return convertBs(robFrags, CMX_TOBS); + CmxTobData data (tobCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMX hits @@ -234,9 +231,8 @@ StatusCode JepByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMXJetHits>* hitCollection) { - m_cmxHitCollection = hitCollection; - m_cmxHitsMap.clear(); - return convertBs(robFrags, CMX_HITS); + CmxHitsData data (hitCollection); + return convertBs(robFrags, data); } // Conversion bytestream to CMX energy sums @@ -257,9 +253,8 @@ StatusCode JepByteStreamV2Tool::convert( const IROBDataProviderSvc::VROBFRAG& robFrags, DataVector<LVL1::CMXEtSums>* etCollection) { - m_cmxEtCollection = etCollection; - m_cmxEtMap.clear(); - return convertBs(robFrags, CMX_SUMS); + CmxSumsData data (etCollection); + return convertBs(robFrags, data); } // Conversion of JEP container to bytestream @@ -668,7 +663,7 @@ const std::vector<uint32_t>& JepByteStreamV2Tool::sourceIDs( StatusCode JepByteStreamV2Tool::convertBs( const IROBDataProviderSvc::VROBFRAG& robFrags, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -794,8 +789,8 @@ StatusCode JepByteStreamV2Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMX_HITS || collection == CMX_TOBS) { - decodeCmxJet(m_cmxJetSubBlock, trigJem, collection); + if (data.m_collection == CMX_HITS || data.m_collection == CMX_TOBS) { + decodeCmxJet(m_cmxJetSubBlock, trigJem, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmxJet failed" << endmsg; break; @@ -810,8 +805,8 @@ StatusCode JepByteStreamV2Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == CMX_SUMS) { - decodeCmxEnergy(m_cmxEnergySubBlock, trigJem); + if (data.m_collection == CMX_SUMS) { + decodeCmxEnergy(m_cmxEnergySubBlock, trigJem, static_cast<CmxSumsData&>(data)); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeCmxEnergy failed" << endmsg; break; @@ -832,8 +827,8 @@ StatusCode JepByteStreamV2Tool::convertBs( m_rodErr = L1CaloSubBlock::ERROR_CRATE_NUMBER; break; } - if (collection == JET_ELEMENTS || collection == ENERGY_SUMS) { - decodeJem(m_jemSubBlock, trigJem, collection); + if (data.m_collection == JET_ELEMENTS || data.m_collection == ENERGY_SUMS) { + decodeJem(m_jemSubBlock, trigJem, data); if (m_rodErr != L1CaloSubBlock::ERROR_NONE) { if (debug) msg() << "decodeJem failed" << endmsg; break; @@ -851,7 +846,8 @@ StatusCode JepByteStreamV2Tool::convertBs( // Unpack CMX-Energy sub-block void JepByteStreamV2Tool::decodeCmxEnergy(CmxEnergySubBlock* subBlock, - int trigJem) + int trigJem, + CmxSumsData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -970,7 +966,7 @@ void JepByteStreamV2Tool::decodeCmxEnergy(CmxEnergySubBlock* subBlock, eyErr = eyErrBits.error(); etErr = etErrBits.error(); if (ex || ey || et || exErr || eyErr || etErr) { - LVL1::CMXEtSums* sums = findCmxSums(crate, source); + LVL1::CMXEtSums* sums = findCmxSums(data, crate, source); if ( ! sums ) { // create new CMX energy sums exVec.assign(timeslices, 0); eyVec.assign(timeslices, 0); @@ -984,11 +980,12 @@ void JepByteStreamV2Tool::decodeCmxEnergy(CmxEnergySubBlock* subBlock, exErrVec[slice] = exErr; eyErrVec[slice] = eyErr; etErrVec[slice] = etErr; - sums = new LVL1::CMXEtSums(swCrate, source, etVec, exVec, eyVec, - etErrVec, exErrVec, eyErrVec, trigJem); + auto sumsp = + std::make_unique<LVL1::CMXEtSums>(swCrate, source, etVec, exVec, eyVec, + etErrVec, exErrVec, eyErrVec, trigJem); const int key = crate*100 + source; - m_cmxEtMap.insert(std::make_pair(key, sums)); - m_cmxEtCollection->push_back(sums); + data.m_cmxEtMap.insert(std::make_pair(key, sumsp.get())); + data.m_cmxEtCollection->push_back(std::move(sumsp)); } else { exVec = sums->ExVec(); eyVec = sums->EyVec(); @@ -1030,7 +1027,7 @@ void JepByteStreamV2Tool::decodeCmxEnergy(CmxEnergySubBlock* subBlock, // Unpack CMX-Jet sub-block void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); if (debug) msg(MSG::DEBUG); @@ -1095,7 +1092,8 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, // Jet TOBs - if (collection == CMX_TOBS) { + if (data.m_collection == CMX_TOBS) { + CmxTobData& tdata = static_cast<CmxTobData&> (data); for (int jem = 0; jem < m_modules; ++jem) { const unsigned int presenceMap = subBlock->presenceMap(slice, jem); @@ -1119,7 +1117,7 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, } error = errBits.error(); const int key = tobKey(crate, jem, frame, loc); - LVL1::CMXJetTob* tb = findCmxTob(key); + LVL1::CMXJetTob* tb = findCmxTob(tdata, key); if ( ! tb ) { // create new CMX TOB energyLgVec.assign(timeslices, 0); energySmVec.assign(timeslices, 0); @@ -1129,11 +1127,12 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, energySmVec[slice] = energySmall; errorVec[slice] = error; presenceMapVec[slice] = presenceMap; - tb = new LVL1::CMXJetTob(swCrate, jem, frame, loc, - energyLgVec, energySmVec, errorVec, - presenceMapVec, trigJem); - m_cmxTobMap.insert(std::make_pair(key, tb)); - m_cmxTobCollection->push_back(tb); + auto tbp = + std::make_unique<LVL1::CMXJetTob>(swCrate, jem, frame, loc, + energyLgVec, energySmVec, errorVec, + presenceMapVec, trigJem); + tdata.m_cmxTobMap.insert(std::make_pair(key, tbp.get())); + tdata.m_cmxTobCollection->push_back(std::move(tbp)); } else { energyLgVec = tb->energyLgVec(); energySmVec = tb->energySmVec(); @@ -1164,7 +1163,8 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, // Jet hit counts and topo info - else if (collection == CMX_HITS) { + else if (data.m_collection == CMX_HITS) { + CmxHitsData& hdata = static_cast<CmxHitsData&> (data); for (int source = 0; source < maxSource; ++source) { if (summing == CmxSubBlock::CRATE && @@ -1187,7 +1187,7 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, err0 = err0Bits.error(); err1 = err1Bits.error(); if (hit0 || hit1 || err0 || err1) { - LVL1::CMXJetHits* jh = findCmxHits(crate, source); + LVL1::CMXJetHits* jh = findCmxHits(hdata, crate, source); if ( ! jh ) { // create new CMX hits hit0Vec.assign(timeslices, 0); hit1Vec.assign(timeslices, 0); @@ -1197,11 +1197,12 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, hit1Vec[slice] = hit1; err0Vec[slice] = err0; err1Vec[slice] = err1; - jh = new LVL1::CMXJetHits(swCrate, source, hit0Vec, hit1Vec, - err0Vec, err1Vec, trigJem); + auto jhp = + std::make_unique<LVL1::CMXJetHits>(swCrate, source, hit0Vec, hit1Vec, + err0Vec, err1Vec, trigJem); const int key = crate*100 + source; - m_cmxHitsMap.insert(std::make_pair(key, jh)); - m_cmxHitCollection->push_back(jh); + hdata.m_cmxHitsMap.insert(std::make_pair(key, jhp.get())); + hdata.m_cmxHitCollection->push_back(std::move(jhp)); } else { hit0Vec = jh->hitsVec0(); hit1Vec = jh->hitsVec1(); @@ -1237,7 +1238,7 @@ void JepByteStreamV2Tool::decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, // Unpack JEM sub-block void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, - const CollectionType collection) + JepByteStreamToolData& data) { const bool debug = msgLvl(MSG::DEBUG); const bool verbose = msgLvl(MSG::VERBOSE); @@ -1292,7 +1293,8 @@ void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, const int sliceEnd = ( neutralFormat ) ? timeslices : sliceNum + 1; for (int slice = sliceBeg; slice < sliceEnd; ++slice) { - if (collection == JET_ELEMENTS) { + if (data.m_collection == JET_ELEMENTS) { + JetElementData& jedata = static_cast<JetElementData&> (data); // Loop over jet element channels and fill jet elements @@ -1304,13 +1306,15 @@ void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, int layer = 0; if (m_jemMaps->mapping(crate, module, chan, eta, phi, layer)) { if (layer == m_coreOverlap) { - LVL1::JetElement* je = findJetElement(eta, phi); + LVL1::JetElement* je = findJetElement(jedata, eta, phi); if ( ! je ) { // create new jet element const unsigned int key = m_elementKey->jeKey(phi, eta); - je = new LVL1::JetElement(phi, eta, dummy, dummy, key, - dummy, dummy, dummy, trigJem); - m_jeMap.insert(std::make_pair(key, je)); - m_jeCollection->push_back(je); + auto jep = + std::make_unique<LVL1::JetElement>(phi, eta, dummy, dummy, key, + dummy, dummy, dummy, trigJem); + je = jep.get(); + jedata.m_jeMap.insert(std::make_pair(key, jep.get())); + jedata.m_jeCollection->push_back(std::move(jep)); } else { const std::vector<int>& emEnergy(je->emEnergyVec()); const std::vector<int>& hadEnergy(je->hadEnergyVec()); @@ -1355,7 +1359,8 @@ void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, msg(MSG::DEBUG); } } - } else if (collection == ENERGY_SUMS) { + } else if (data.m_collection == ENERGY_SUMS) { + EnergySumsData& sumdata = static_cast<EnergySumsData&> (data); // Get energy subsums @@ -1363,7 +1368,7 @@ void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, const unsigned int ey = subBlock->ey(slice); const unsigned int et = subBlock->et(slice); if (ex | ey | et) { - LVL1::JEMEtSums* sums = findEnergySums(crate, module); + LVL1::JEMEtSums* sums = findEnergySums(sumdata, crate, module); if ( ! sums ) { // create new energy sums exVec.assign(timeslices, 0); eyVec.assign(timeslices, 0); @@ -1371,10 +1376,11 @@ void JepByteStreamV2Tool::decodeJem(JemSubBlockV2* subBlock, int trigJem, exVec[slice] = ex; eyVec[slice] = ey; etVec[slice] = et; - sums = new LVL1::JEMEtSums(swCrate, module, etVec, exVec, eyVec, - trigJem); - m_etMap.insert(std::make_pair(crate*m_modules+module, sums)); - m_etCollection->push_back(sums); + auto sumsp = + std::make_unique<LVL1::JEMEtSums>(swCrate, module, etVec, exVec, eyVec, + trigJem); + sumdata.m_etMap.insert(std::make_pair(crate*m_modules+module, sumsp.get())); + sumdata.m_etCollection->push_back(std::move(sumsp)); } else { exVec = sums->ExVec(); eyVec = sums->EyVec(); @@ -1422,62 +1428,102 @@ int JepByteStreamV2Tool::tobKey(const int crate, const int jem, // Find a jet element given eta, phi +const LVL1::JetElement* JepByteStreamV2Tool::findJetElement(const double eta, - const double phi) + const double phi) const { - LVL1::JetElement* tt = 0; const unsigned int key = m_elementKey->jeKey(phi, eta); - JetElementMap::const_iterator mapIter; - mapIter = m_jeMap.find(key); - if (mapIter != m_jeMap.end()) tt = mapIter->second; - return tt; + ConstJetElementMap::const_iterator mapIter = m_jeMap.find(key); + if (mapIter != m_jeMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JetElement* JepByteStreamV2Tool::findJetElement(const JetElementData& data, + const double eta, + const double phi) const +{ + const unsigned int key = m_elementKey->jeKey(phi, eta); + JetElementMap::const_iterator mapIter = data.m_jeMap.find(key); + if (mapIter != data.m_jeMap.end()) return mapIter->second; + return nullptr; } // Find energy sums for given crate, module +const LVL1::JEMEtSums* JepByteStreamV2Tool::findEnergySums(const int crate, - const int module) + const int module) const { - LVL1::JEMEtSums* sums = 0; - EnergySumsMap::const_iterator mapIter; - mapIter = m_etMap.find(crate*m_modules + module); - if (mapIter != m_etMap.end()) sums = mapIter->second; - return sums; + ConstEnergySumsMap::const_iterator mapIter = m_etMap.find(crate*m_modules + module); + if (mapIter != m_etMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::JEMEtSums* JepByteStreamV2Tool::findEnergySums(const EnergySumsData& data, + const int crate, + const int module) const +{ + EnergySumsMap::const_iterator mapIter = data.m_etMap.find(crate*m_modules + module); + if (mapIter != data.m_etMap.end()) return mapIter->second; + return nullptr; } // Find CMX TOB for given crate, jem, frame, loc -LVL1::CMXJetTob* JepByteStreamV2Tool::findCmxTob(const int key) +const +LVL1::CMXJetTob* JepByteStreamV2Tool::findCmxTob(const int key) const { - LVL1::CMXJetTob* tob = 0; - CmxTobMap::const_iterator mapIter; - mapIter = m_cmxTobMap.find(key); - if (mapIter != m_cmxTobMap.end()) tob = mapIter->second; - return tob; + ConstCmxTobMap::const_iterator mapIter = m_cmxTobMap.find(key); + if (mapIter != m_cmxTobMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMXJetTob* JepByteStreamV2Tool::findCmxTob(const CmxTobData& data, + const int key) const +{ + CmxTobMap::const_iterator mapIter = data.m_cmxTobMap.find(key); + if (mapIter != data.m_cmxTobMap.end()) return mapIter->second; + return nullptr; } // Find CMX hits for given crate, source +const LVL1::CMXJetHits* JepByteStreamV2Tool::findCmxHits(const int crate, - const int source) + const int source) const +{ + ConstCmxHitsMap::const_iterator mapIter = m_cmxHitsMap.find(crate*100 + source); + if (mapIter != m_cmxHitsMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMXJetHits* JepByteStreamV2Tool::findCmxHits(const CmxHitsData& data, + const int crate, + const int source) const { - LVL1::CMXJetHits* hits = 0; - CmxHitsMap::const_iterator mapIter; - mapIter = m_cmxHitsMap.find(crate*100 + source); - if (mapIter != m_cmxHitsMap.end()) hits = mapIter->second; - return hits; + CmxHitsMap::const_iterator mapIter = data.m_cmxHitsMap.find(crate*100 + source); + if (mapIter != data.m_cmxHitsMap.end()) return mapIter->second; + return nullptr; } // Find CMX energy sums for given crate, module, source +const LVL1::CMXEtSums* JepByteStreamV2Tool::findCmxSums(const int crate, - const int source) + const int source) const +{ + ConstCmxSumsMap::const_iterator mapIter = m_cmxEtMap.find(crate*100 + source); + if (mapIter != m_cmxEtMap.end()) return mapIter->second; + return nullptr; +} + +LVL1::CMXEtSums* JepByteStreamV2Tool::findCmxSums(const CmxSumsData& data, + const int crate, + const int source) const { - LVL1::CMXEtSums* sums = 0; - CmxSumsMap::const_iterator mapIter; - mapIter = m_cmxEtMap.find(crate*100 + source); - if (mapIter != m_cmxEtMap.end()) sums = mapIter->second; - return sums; + CmxSumsMap::const_iterator mapIter = data.m_cmxEtMap.find(crate*100 + source); + if (mapIter != data.m_cmxEtMap.end()) return mapIter->second; + return nullptr; } // Set up jet element map @@ -1490,7 +1536,7 @@ void JepByteStreamV2Tool::setupJeMap(const JetElementCollection* JetElementCollection::const_iterator pos = jeCollection->begin(); JetElementCollection::const_iterator pose = jeCollection->end(); for (; pos != pose; ++pos) { - LVL1::JetElement* const je = *pos; + const LVL1::JetElement* const je = *pos; const unsigned int key = m_elementKey->jeKey(je->phi(), je->eta()); m_jeMap.insert(std::make_pair(key, je)); } @@ -1507,7 +1553,7 @@ void JepByteStreamV2Tool::setupEtMap(const EnergySumsCollection* EnergySumsCollection::const_iterator pos = etCollection->begin(); EnergySumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::JEMEtSums* const sums = *pos; + const LVL1::JEMEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = m_modules * crate + sums->module(); m_etMap.insert(std::make_pair(key, sums)); @@ -1525,7 +1571,7 @@ void JepByteStreamV2Tool::setupCmxTobMap(const CmxTobCollection* CmxTobCollection::const_iterator pos = tobCollection->begin(); CmxTobCollection::const_iterator pose = tobCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMXJetTob* const tob = *pos; + const LVL1::CMXJetTob* const tob = *pos; const int crate = tob->crate() - m_crateOffsetSw; const int jem = tob->jem(); const int frame = tob->frame(); @@ -1546,7 +1592,7 @@ void JepByteStreamV2Tool::setupCmxHitsMap(const CmxHitsCollection* CmxHitsCollection::const_iterator pos = hitCollection->begin(); CmxHitsCollection::const_iterator pose = hitCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMXJetHits* const hits = *pos; + const LVL1::CMXJetHits* const hits = *pos; const int crate = hits->crate() - m_crateOffsetSw; const int key = crate*100 + hits->source(); m_cmxHitsMap.insert(std::make_pair(key, hits)); @@ -1564,7 +1610,7 @@ void JepByteStreamV2Tool::setupCmxEtMap(const CmxSumsCollection* CmxSumsCollection::const_iterator pos = etCollection->begin(); CmxSumsCollection::const_iterator pose = etCollection->end(); for (; pos != pose; ++pos) { - LVL1::CMXEtSums* const sums = *pos; + const LVL1::CMXEtSums* const sums = *pos; const int crate = sums->crate() - m_crateOffsetSw; const int key = crate*100 + sums->source(); m_cmxEtMap.insert(std::make_pair(key, sums)); diff --git a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.h b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.h index 571f34cd17bd73193438cc6fe1583154a6d0730b..e5a65dddb851bcafa4b5dfc6390b354c284cfdbd 100755 --- a/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.h +++ b/Trigger/TrigT1/TrigT1CaloByteStream/src/JepByteStreamV2Tool.h @@ -107,39 +107,91 @@ class JepByteStreamV2Tool : public AthAlgTool { typedef DataVector<LVL1::CMXJetHits> CmxHitsCollection; typedef DataVector<LVL1::CMXEtSums> CmxSumsCollection; typedef std::map<unsigned int, LVL1::JetElement*> JetElementMap; + typedef std::map<unsigned int, const LVL1::JetElement*> ConstJetElementMap; typedef std::map<int, LVL1::JEMEtSums*> EnergySumsMap; + typedef std::map<int, const LVL1::JEMEtSums*> ConstEnergySumsMap; typedef std::map<int, LVL1::CMXJetTob*> CmxTobMap; + typedef std::map<int, const LVL1::CMXJetTob*> ConstCmxTobMap; typedef std::map<int, LVL1::CMXJetHits*> CmxHitsMap; + typedef std::map<int, const LVL1::CMXJetHits*> ConstCmxHitsMap; typedef std::map<int, LVL1::CMXEtSums*> CmxSumsMap; + typedef std::map<int, const LVL1::CMXEtSums*> ConstCmxSumsMap; typedef IROBDataProviderSvc::VROBFRAG::const_iterator ROBIterator; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType ROBPointer; typedef OFFLINE_FRAGMENTS_NAMESPACE::PointerType RODPointer; + struct JepByteStreamToolData + { + JepByteStreamToolData (const CollectionType collection) + : m_collection(collection){} + const CollectionType m_collection; + }; + struct JetElementData : public JepByteStreamToolData + { + JetElementData (JetElementCollection* const jeCollection) + : JepByteStreamToolData (JET_ELEMENTS), m_jeCollection (jeCollection) {} + JetElementCollection* const m_jeCollection; + JetElementMap m_jeMap; + }; + struct EnergySumsData : public JepByteStreamToolData + { + EnergySumsData (EnergySumsCollection* const etCollection) + : JepByteStreamToolData (ENERGY_SUMS), m_etCollection (etCollection) {} + EnergySumsCollection* const m_etCollection; + EnergySumsMap m_etMap; + }; + struct CmxTobData : public JepByteStreamToolData + { + CmxTobData (CmxTobCollection* const tobCollection) + : JepByteStreamToolData (CMX_TOBS), m_cmxTobCollection (tobCollection) {} + CmxTobCollection* const m_cmxTobCollection; + CmxTobMap m_cmxTobMap; + }; + struct CmxHitsData : public JepByteStreamToolData + { + CmxHitsData (CmxHitsCollection* const hitCollection) + : JepByteStreamToolData (CMX_HITS), m_cmxHitCollection (hitCollection) {} + CmxHitsCollection* const m_cmxHitCollection; + CmxHitsMap m_cmxHitsMap; + }; + struct CmxSumsData : public JepByteStreamToolData + { + CmxSumsData (CmxSumsCollection* const etCollection) + : JepByteStreamToolData (CMX_SUMS), m_cmxEtCollection (etCollection) {} + CmxSumsCollection* const m_cmxEtCollection; + CmxSumsMap m_cmxEtMap; + }; + /// Convert bytestream to given container type StatusCode convertBs(const IROBDataProviderSvc::VROBFRAG& robFrags, - CollectionType collection); + JepByteStreamToolData& data); /// Unpack CMX-Energy sub-block - void decodeCmxEnergy(CmxEnergySubBlock* subBlock, int trigJem); + void decodeCmxEnergy(CmxEnergySubBlock* subBlock, int trigJem, CmxSumsData& data); /// Unpack CMX-Jet sub-block void decodeCmxJet(CmxJetSubBlock* subBlock, int trigJem, - CollectionType collection); + JepByteStreamToolData& data); /// Unpack JEM sub-block void decodeJem(JemSubBlockV2* subBlock, int trigJem, - CollectionType collection); + JepByteStreamToolData& data); /// Find TOB map key for given crate, jem, frame, loc int tobKey(int crate, int jem, int frame, int loc); /// Find a jet element given eta, phi - LVL1::JetElement* findJetElement(double eta, double phi); + const LVL1::JetElement* findJetElement(double eta, double phi) const; + LVL1::JetElement* findJetElement(const JetElementData& data, double eta, double phi) const; /// Find energy sums for given crate, module - LVL1::JEMEtSums* findEnergySums(int crate, int module); + const LVL1::JEMEtSums* findEnergySums(int crate, int module) const; + LVL1::JEMEtSums* findEnergySums(const EnergySumsData& data, int crate, int module) const; /// Find CMX TOB for given key - LVL1::CMXJetTob* findCmxTob(int key); + const LVL1::CMXJetTob* findCmxTob(int key) const; + LVL1::CMXJetTob* findCmxTob(const CmxTobData& data, int key) const; /// Find CMX hits for given crate, source - LVL1::CMXJetHits* findCmxHits(int crate, int source); + const LVL1::CMXJetHits* findCmxHits(int crate, int source) const; + LVL1::CMXJetHits* findCmxHits(const CmxHitsData& data, int crate, int source) const; /// Find CMX energy sums for given crate, source - LVL1::CMXEtSums* findCmxSums(int crate, int source); + const LVL1::CMXEtSums* findCmxSums(int crate, int source) const; + LVL1::CMXEtSums* findCmxSums(const CmxSumsData& data, int crate, int source) const; /// Set up jet element map void setupJeMap(const JetElementCollection* jeCollection); @@ -235,26 +287,16 @@ class JepByteStreamV2Tool : public AthAlgTool { DataVector<CmxEnergySubBlock> m_cmxEnergyBlocks; /// Vector for current CMX-Jet sub-blocks DataVector<CmxJetSubBlock> m_cmxJetBlocks; - /// Current jet elements collection - JetElementCollection* m_jeCollection; - /// Current energy sums collection - EnergySumsCollection* m_etCollection; - /// Current CMX TOB collection - CmxTobCollection* m_cmxTobCollection; - /// Current CMX hits collection - CmxHitsCollection* m_cmxHitCollection; - /// Current CMX energy sums collection - CmxSumsCollection* m_cmxEtCollection; /// Jet element map - JetElementMap m_jeMap; + ConstJetElementMap m_jeMap; /// Energy sums map - EnergySumsMap m_etMap; + ConstEnergySumsMap m_etMap; /// CMX TOB map - CmxTobMap m_cmxTobMap; + ConstCmxTobMap m_cmxTobMap; /// CMX hits map - CmxHitsMap m_cmxHitsMap; + ConstCmxHitsMap m_cmxHitsMap; /// CMX energy sums map - CmxSumsMap m_cmxEtMap; + ConstCmxSumsMap m_cmxEtMap; /// ROD Status words std::vector<uint32_t>* m_rodStatus; /// ROD status map